diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/MD5Utils.java b/eladmin-common/src/main/java/me/zhengjie/utils/MD5Utils.java new file mode 100644 index 00000000..6f8cb611 --- /dev/null +++ b/eladmin-common/src/main/java/me/zhengjie/utils/MD5Utils.java @@ -0,0 +1,124 @@ +package me.zhengjie.utils; + +import cn.hutool.core.util.ObjectUtil; + +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class MD5Utils { + private static String byteArrayToHexString(byte b[]) { + StringBuffer resultSb = new StringBuffer(); + for (int i = 0; i < b.length; i++) + resultSb.append(byteToHexString(b[i])); + + return resultSb.toString(); + } + + private static String byteToHexString(byte b) { + int n = b; + if (n < 0) + n += 256; + int d1 = n / 16; + int d2 = n % 16; + return hexDigits[d1] + hexDigits[d2]; + } + + public static String MD5Encode(String origin, String charsetname) { + String resultString = null; + try { + resultString = origin; + MessageDigest md = MessageDigest.getInstance("MD5"); + if (charsetname == null || "".equals(charsetname)) + resultString = byteArrayToHexString(md.digest(resultString + .getBytes())); + else + resultString = byteArrayToHexString(md.digest(resultString + .getBytes(charsetname))); + } catch (Exception exception) { + } + return resultString; + } + + private static final String hexDigits[] = { "0", "1", "2", "3", "4", "5", + "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" }; + + /** + * MD5指纹算法 + * + * @param str + * @return + */ + public static String md5(String str) { + if (str == null) { + return null; + } + + try { + MessageDigest messageDigest = MessageDigest.getInstance("MD5"); + messageDigest.update(str.getBytes()); + return bytesToHexString(messageDigest.digest()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + /** + * 将二进制转换成16进制 + * + * @param src + * @return + */ + public static String bytesToHexString(byte[] src) { + StringBuilder stringBuilder = new StringBuilder(""); + if (src == null || src.length <= 0) { + return null; + } + for (int i = 0; i < src.length; i++) { + int v = src[i] & 0xFF; + String hv = Integer.toHexString(v); + if (hv.length() < 2) { + stringBuilder.append(0); + } + stringBuilder.append(hv); + } + return stringBuilder.toString(); + } + + + + public static String encrypt(String plainText) { + try { + return encrypt(plainText,true); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + return null; + } + } + + /** + * @Title: encrypt + * @Description: TODO(16位或32位密码) + * @param @param + * plainText + * @param @param + * flag true为32位,false为16位 + * @throws UnsupportedEncodingException + */ + public static String encrypt(String plainText, boolean flag) throws UnsupportedEncodingException { + try { + if (ObjectUtil.isEmpty(plainText)) { + return null; + } + MessageDigest md = MessageDigest.getInstance("MD5"); + String encrStr = byteArrayToHexString(md.digest(plainText.getBytes("UTF-8"))); + if (flag) + return encrStr; + else + return encrStr.substring(8, 24); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + return null; + } + + } +} diff --git a/eladmin-system/src/main/java/me/zhengjie/config/JacksonConfig.java b/eladmin-system/src/main/java/me/zhengjie/config/JacksonConfig.java new file mode 100644 index 00000000..c42ea416 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/config/JacksonConfig.java @@ -0,0 +1,31 @@ +package me.zhengjie.config; + +import org.springframework.context.annotation.Configuration; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; + +import java.io.IOException; +@Configuration +public class JacksonConfig { + @Bean + @Primary + @ConditionalOnMissingBean(ObjectMapper.class) + public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) { + ObjectMapper objectMapper = builder.createXmlMapper(false).build(); + objectMapper.getSerializerProvider().setNullValueSerializer(new JsonSerializer() { + @Override + public void serialize(Object o, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { + jsonGenerator.writeString(""); + } + }); + return objectMapper; + } +} diff --git a/eladmin-system/src/main/java/me/zhengjie/config/fastJsonConfig.java b/eladmin-system/src/main/java/me/zhengjie/config/fastJsonConfig.java new file mode 100644 index 00000000..8dfc04f1 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/config/fastJsonConfig.java @@ -0,0 +1,48 @@ +package me.zhengjie.config; + +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.alibaba.fastjson.support.config.FastJsonConfig; +import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; + +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; + +@Configuration +public class fastJsonConfig extends WebMvcConfigurationSupport { + + /** + * 使用阿里 fastjson 作为JSON MessageConverter + * @param converters + */ + @Override + public void configureMessageConverters(List> converters) { + FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); + FastJsonConfig config = new FastJsonConfig(); + config.setSerializerFeatures( + // 保留map空的字段 + SerializerFeature.WriteMapNullValue, + // 将String类型的null转成"" + SerializerFeature.WriteNullStringAsEmpty, + // 将Number类型的null转成0 + SerializerFeature.WriteNullNumberAsZero, + // 将List类型的null转成[] + SerializerFeature.WriteNullListAsEmpty, + // 将Boolean类型的null转成false + SerializerFeature.WriteNullBooleanAsFalse, + // 避免循环引用 + SerializerFeature.DisableCircularReferenceDetect); + + converter.setFastJsonConfig(config); + converter.setDefaultCharset(Charset.forName("UTF-8")); + List mediaTypeList = new ArrayList<>(); + // 解决中文乱码问题,相当于在Controller上的@RequestMapping中加了个属性produces = "application/json" + mediaTypeList.add(MediaType.APPLICATION_JSON); + converter.setSupportedMediaTypes(mediaTypeList); + converters.add(converter); + } +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/rest/TbProductController.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/rest/TbProductController.java index a53c9337..85bc42f3 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/rest/TbProductController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/rest/TbProductController.java @@ -56,7 +56,6 @@ public class TbProductController { @GetMapping @Log("查询/product") @ApiOperation("查询/product") - @PreAuthorize("@el.check('tbProduct:list')") public ResponseEntity queryTbProduct(TbProductQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbProductService.queryAll(criteria,pageable),HttpStatus.OK); } @@ -64,14 +63,12 @@ public class TbProductController { @GetMapping("/{product}") @Log("查询/product") @ApiOperation("查询/product") - @PreAuthorize("@el.check('tbProduct:list')") public Object queryTbProductInfo(@PathVariable("product") Integer product)throws Exception{ return tbProductService.findByProductId(product); } @GetMapping ("/productList") @Log("查询/product") @ApiOperation("查询/product") - @PreAuthorize("@el.check('tbProduct:list')") public Object queryTbProductInfo(@RequestParam List productList){ return tbProductService.findByProductList(productList); } @@ -80,7 +77,6 @@ public class TbProductController { @PostMapping @Log("新增/product") @ApiOperation("新增/product") - @PreAuthorize("@el.check('tbProduct:add')") public ResponseEntity createTbProduct(@Validated @RequestBody TbProductVo resources){ return new ResponseEntity<>(tbProductService.create(resources),HttpStatus.CREATED); } @@ -88,7 +84,6 @@ public class TbProductController { @PutMapping @Log("修改/product") @ApiOperation("修改/product") - @PreAuthorize("@el.check('tbProduct:edit')") public ResponseEntity updateTbProduct(@Validated @RequestBody TbProductVo resources){ tbProductService.update(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); @@ -97,7 +92,6 @@ public class TbProductController { @DeleteMapping @Log("删除/product") @ApiOperation("删除/product") - @PreAuthorize("@el.check('tbProduct:del')") public ResponseEntity deleteTbProduct(@RequestBody Integer[] ids) { tbProductService.deleteAll(ids); return new ResponseEntity<>(HttpStatus.OK); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/service/impl/TbProductServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/service/impl/TbProductServiceImpl.java index 8b2bbd53..11581f87 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/service/impl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/service/impl/TbProductServiceImpl.java @@ -265,7 +265,7 @@ public class TbProductServiceImpl implements TbProductService { productSkuResult.setCreatedAt(Instant.now().toEpochMilli()); productSkuResult.setUpdatedAt(Instant.now().toEpochMilli()); productSkuResult.setTagSnap(resources.getSkuSnap()); - productSkuResult.setId(Integer.valueOf(save.getShopId())); + productSkuResult.setId(save.getId()); tbProductSkuResultRepository.save(productSkuResult); } return resources; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/rest/TbShopCategoryController.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/rest/TbShopCategoryController.java index acfad08c..576a4d39 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/rest/TbShopCategoryController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/rest/TbShopCategoryController.java @@ -54,7 +54,6 @@ public class TbShopCategoryController { @GetMapping @Log("查询product/category") @ApiOperation("查询product/category") - @PreAuthorize("@el.check('tbShopCategory:list')") public ResponseEntity queryTbShopCategory(TbShopCategoryQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbShopCategoryService.queryAll(criteria,pageable),HttpStatus.OK); } @@ -62,7 +61,6 @@ public class TbShopCategoryController { @PostMapping @Log("新增product/category") @ApiOperation("新增product/category") - @PreAuthorize("@el.check('tbShopCategory:add')") public ResponseEntity createTbShopCategory(@Validated @RequestBody TbShopCategory resources){ return new ResponseEntity<>(tbShopCategoryService.create(resources),HttpStatus.CREATED); } @@ -70,7 +68,6 @@ public class TbShopCategoryController { @PutMapping @Log("修改product/category") @ApiOperation("修改product/category") - @PreAuthorize("@el.check('tbShopCategory:edit')") public ResponseEntity updateTbShopCategory(@Validated @RequestBody TbShopCategory resources){ tbShopCategoryService.update(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); @@ -79,7 +76,6 @@ public class TbShopCategoryController { @DeleteMapping @Log("删除product/category") @ApiOperation("删除product/category") - @PreAuthorize("@el.check('tbShopCategory:del')") public ResponseEntity deleteTbShopCategory(@RequestBody Integer[] ids) { tbShopCategoryService.deleteAll(ids); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productGroup/rest/TbProductGroupController.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productGroup/rest/TbProductGroupController.java index 6b319deb..91e0958e 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productGroup/rest/TbProductGroupController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productGroup/rest/TbProductGroupController.java @@ -61,7 +61,6 @@ public class TbProductGroupController { @GetMapping @Log("查询product/group") @ApiOperation("查询product/group") - @PreAuthorize("@el.check('tbProductGroup:list')") public ResponseEntity queryTbProductGroup(TbProductGroupQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbProductGroupService.queryAll(criteria,pageable),HttpStatus.OK); } @@ -69,7 +68,6 @@ public class TbProductGroupController { @GetMapping("/{productGroup}") @Log("查询product/group") @ApiOperation("查询product/group") - @PreAuthorize("@el.check('tbProductGroup:list')") public ResponseEntity queryTbProductGroup(@PathVariable("productGroup") Integer productGroup){ return new ResponseEntity<>(tbProductGroupService.findByIdProduct(productGroup),HttpStatus.OK); } @@ -78,7 +76,6 @@ public class TbProductGroupController { @PostMapping @Log("新增product/group") @ApiOperation("新增product/group") - @PreAuthorize("@el.check('tbProductGroup:add')") public ResponseEntity createTbProductGroup(@Validated @RequestBody TbProductGroup resources){ return new ResponseEntity<>(tbProductGroupService.create(resources),HttpStatus.CREATED); } @@ -86,7 +83,6 @@ public class TbProductGroupController { @PutMapping @Log("修改product/group") @ApiOperation("修改product/group") - @PreAuthorize("@el.check('tbProductGroup:edit')") public ResponseEntity updateTbProductGroup(@Validated @RequestBody TbProductGroup resources){ tbProductGroupService.update(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); @@ -95,7 +91,6 @@ public class TbProductGroupController { @DeleteMapping @Log("删除product/group") @ApiOperation("删除product/group") - @PreAuthorize("@el.check('tbProductGroup:del')") public ResponseEntity deleteTbProductGroup(@RequestBody Integer[] ids) { tbProductGroupService.deleteAll(ids); return new ResponseEntity<>(HttpStatus.OK); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSpec/rest/TbProductSpecController.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSpec/rest/TbProductSpecController.java index 22bba252..8a953c4c 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSpec/rest/TbProductSpecController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSpec/rest/TbProductSpecController.java @@ -55,7 +55,6 @@ public class TbProductSpecController { @GetMapping @Log("查询product/spec") @ApiOperation("查询product/spec") - @PreAuthorize("@el.check('tbProductSpec:list')") public ResponseEntity queryTbProductSpec(TbProductSpecQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbProductSpecService.queryAll(criteria,pageable),HttpStatus.OK); } @@ -63,7 +62,6 @@ public class TbProductSpecController { @PostMapping @Log("新增product/spec") @ApiOperation("新增product/spec") - @PreAuthorize("@el.check('tbProductSpec:add')") public ResponseEntity createTbProductSpec(@Validated @RequestBody SpecDto resources){ return new ResponseEntity<>(tbProductSpecService.create(resources),HttpStatus.CREATED); } @@ -71,7 +69,6 @@ public class TbProductSpecController { @PutMapping @Log("修改product/spec") @ApiOperation("修改product/spec") - @PreAuthorize("@el.check('tbProductSpec:edit')") public ResponseEntity updateTbProductSpec(@Validated @RequestBody TbProductSpec resources){ tbProductSpecService.update(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); @@ -80,7 +77,6 @@ public class TbProductSpecController { @DeleteMapping @Log("删除product/spec") @ApiOperation("删除product/spec") - @PreAuthorize("@el.check('tbProductSpec:del')") public ResponseEntity deleteTbProductSpec(@RequestBody Integer[] ids) { tbProductSpecService.deleteAll(ids); return new ResponseEntity<>(HttpStatus.OK); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/domain/TbMerchantAccount.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/domain/TbMerchantAccount.java new file mode 100644 index 00000000..450ff3fd --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/domain/TbMerchantAccount.java @@ -0,0 +1,128 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.merchantAccount.domain; + +import lombok.Data; +import cn.hutool.core.bean.BeanUtil; +import io.swagger.annotations.ApiModelProperty; +import cn.hutool.core.bean.copier.CopyOptions; +import javax.persistence.*; +import javax.validation.constraints.*; +import java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description / +* @author lyf +* @date 2024-02-08 +**/ +@Entity +@Data +@Table(name="tb_merchant_account") +public class TbMerchantAccount implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "`id`") + @ApiModelProperty(value = "自增id") + private Integer id; + + @Column(name = "`account`",nullable = false) + @NotBlank + @ApiModelProperty(value = "登陆帐号") + private String account; + + @Column(name = "`password`") + @ApiModelProperty(value = "登陆密码") + private String password; + + @Column(name = "`merchant_id`") + @ApiModelProperty(value = "商家Id") + private String merchantId; + + @Column(name = "`shop_id`") + @ApiModelProperty(value = "门店Id") + private String shopId; + + @Column(name = "`shop_snap`") + @ApiModelProperty(value = "shopSnap") + private String shopSnap; + + @Column(name = "`is_admin`") + @ApiModelProperty(value = "是否管理员") + private Integer isAdmin; + + @Column(name = "`is_mercantile`") + @ApiModelProperty(value = "是否商户:1商户帐号0-店铺帐号") + private Integer isMercantile; + + @Column(name = "`name`") + @ApiModelProperty(value = "姓名") + private String name; + + @Column(name = "`sex`") + @ApiModelProperty(value = "性别:0女 1 男") + private Integer sex; + + @Column(name = "`email`") + @ApiModelProperty(value = "邮箱") + private String email; + + @Column(name = "`head_img`") + @ApiModelProperty(value = "头像") + private String headImg; + + @Column(name = "`telephone`") + @ApiModelProperty(value = "联系电话") + private String telephone; + + @Column(name = "`status`",nullable = false) + @NotNull + @ApiModelProperty(value = "状态") + private Integer status; + + @Column(name = "`sort`") + @ApiModelProperty(value = "排序") + private Integer sort; + + @Column(name = "`role_id`") + @ApiModelProperty(value = "roleId") + private Integer roleId; + + @Column(name = "`last_login_at`") + @ApiModelProperty(value = "最后登陆时间") + private Integer lastLoginAt; + + @Column(name = "`mp_open_id`") + @ApiModelProperty(value = "公众号openId") + private String mpOpenId; + + @Column(name = "`msg_able`") + @ApiModelProperty(value = "是否接收消息通知") + private Integer msgAble; + + @Column(name = "`created_at`") + @ApiModelProperty(value = "createdAt") + private Long createdAt; + + @Column(name = "`updated_at`") + @ApiModelProperty(value = "updatedAt") + private Long updatedAt; + + public void copy(TbMerchantAccount source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/repository/TbMerchantAccountRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/repository/TbMerchantAccountRepository.java new file mode 100644 index 00000000..6d6a8714 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/repository/TbMerchantAccountRepository.java @@ -0,0 +1,28 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.merchantAccount.repository; + +import me.zhengjie.modules.shopInfo.merchantAccount.domain.TbMerchantAccount; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-08 +**/ +public interface TbMerchantAccountRepository extends JpaRepository, JpaSpecificationExecutor { +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/rest/TbMerchantAccountController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/rest/TbMerchantAccountController.java new file mode 100644 index 00000000..d6f649f5 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/rest/TbMerchantAccountController.java @@ -0,0 +1,87 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.merchantAccount.rest; + +import me.zhengjie.annotation.Log; +import me.zhengjie.modules.shopInfo.merchantAccount.domain.TbMerchantAccount; +import me.zhengjie.modules.shopInfo.merchantAccount.service.TbMerchantAccountService; +import me.zhengjie.modules.shopInfo.merchantAccount.service.dto.TbMerchantAccountQueryCriteria; +import org.springframework.data.domain.Pageable; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-08 +**/ +@RestController +@RequiredArgsConstructor +@Api(tags = "/merchant/account管理") +@RequestMapping("/api/tbMerchantAccount") +public class TbMerchantAccountController { + + private final TbMerchantAccountService tbMerchantAccountService; + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@el.check('tbMerchantAccount:list')") + public void exportTbMerchantAccount(HttpServletResponse response, TbMerchantAccountQueryCriteria criteria) throws IOException { + tbMerchantAccountService.download(tbMerchantAccountService.queryAll(criteria), response); + } + + @GetMapping + @Log("查询/merchant/account") + @ApiOperation("查询/merchant/account") + @PreAuthorize("@el.check('tbMerchantAccount:list')") + public ResponseEntity queryTbMerchantAccount(TbMerchantAccountQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(tbMerchantAccountService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增/merchant/account") + @ApiOperation("新增/merchant/account") + @PreAuthorize("@el.check('tbMerchantAccount:add')") + public ResponseEntity createTbMerchantAccount(@Validated @RequestBody TbMerchantAccount resources){ + return new ResponseEntity<>(tbMerchantAccountService.create(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改/merchant/account") + @ApiOperation("修改/merchant/account") + @PreAuthorize("@el.check('tbMerchantAccount:edit')") + public ResponseEntity updateTbMerchantAccount(@Validated @RequestBody TbMerchantAccount resources){ + tbMerchantAccountService.update(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @DeleteMapping + @Log("删除/merchant/account") + @ApiOperation("删除/merchant/account") + @PreAuthorize("@el.check('tbMerchantAccount:del')") + public ResponseEntity deleteTbMerchantAccount(@RequestBody Integer[] ids) { + tbMerchantAccountService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/service/TbMerchantAccountService.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/service/TbMerchantAccountService.java new file mode 100644 index 00000000..9e2eecbb --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/service/TbMerchantAccountService.java @@ -0,0 +1,83 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.merchantAccount.service; + +import me.zhengjie.modules.shopInfo.merchantAccount.domain.TbMerchantAccount; +import me.zhengjie.modules.shopInfo.merchantAccount.service.dto.TbMerchantAccountDto; +import me.zhengjie.modules.shopInfo.merchantAccount.service.dto.TbMerchantAccountQueryCriteria; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://eladmin.vip +* @description 服务接口 +* @author lyf +* @date 2024-02-08 +**/ +public interface TbMerchantAccountService { + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(TbMerchantAccountQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(TbMerchantAccountQueryCriteria criteria); + + /** + * 根据ID查询 + * @param id ID + * @return TbMerchantAccountDto + */ + TbMerchantAccountDto findById(Integer id); + + /** + * 创建 + * @param resources / + * @return TbMerchantAccountDto + */ + TbMerchantAccountDto create(TbMerchantAccount resources); + + /** + * 编辑 + * @param resources / + */ + void update(TbMerchantAccount resources); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(Integer[] ids); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/service/dto/TbMerchantAccountDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/service/dto/TbMerchantAccountDto.java new file mode 100644 index 00000000..201cdd39 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/service/dto/TbMerchantAccountDto.java @@ -0,0 +1,88 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.merchantAccount.service.dto; + +import lombok.Data; +import java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description / +* @author lyf +* @date 2024-02-08 +**/ +@Data +public class TbMerchantAccountDto implements Serializable { + + /** 自增id */ + private Integer id; + + /** 登陆帐号 */ + private String account; + + /** 登陆密码 */ + private String password; + + /** 商家Id */ + private String merchantId; + + /** 门店Id */ + private String shopId; + + private String shopSnap; + + /** 是否管理员 */ + private Integer isAdmin; + + /** 是否商户:1商户帐号0-店铺帐号 */ + private Integer isMercantile; + + /** 姓名 */ + private String name; + + /** 性别:0女 1 男 */ + private Integer sex; + + /** 邮箱 */ + private String email; + + /** 头像 */ + private String headImg; + + /** 联系电话 */ + private String telephone; + + /** 状态 */ + private Integer status; + + /** 排序 */ + private Integer sort; + + private Integer roleId; + + /** 最后登陆时间 */ + private Integer lastLoginAt; + + /** 公众号openId */ + private String mpOpenId; + + /** 是否接收消息通知 */ + private Integer msgAble; + + private Long createdAt; + + private Long updatedAt; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/service/dto/TbMerchantAccountQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/service/dto/TbMerchantAccountQueryCriteria.java new file mode 100644 index 00000000..64889c31 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/service/dto/TbMerchantAccountQueryCriteria.java @@ -0,0 +1,41 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.merchantAccount.service.dto; + +import lombok.Data; +import java.util.List; +import me.zhengjie.annotation.Query; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-08 +**/ +@Data +public class TbMerchantAccountQueryCriteria{ + + /** 精确 */ + @Query + private Integer id; + + /** 精确 */ + @Query + private String account; + + /** 精确 */ + @Query + private String shopId; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/service/impl/TbMerchantAccountServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/service/impl/TbMerchantAccountServiceImpl.java new file mode 100644 index 00000000..a0b2624d --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/service/impl/TbMerchantAccountServiceImpl.java @@ -0,0 +1,123 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.merchantAccount.service.impl; + +import me.zhengjie.modules.shopInfo.merchantAccount.domain.TbMerchantAccount; +import me.zhengjie.utils.ValidationUtil; +import me.zhengjie.utils.FileUtil; +import lombok.RequiredArgsConstructor; +import me.zhengjie.modules.shopInfo.merchantAccount.repository.TbMerchantAccountRepository; +import me.zhengjie.modules.shopInfo.merchantAccount.service.TbMerchantAccountService; +import me.zhengjie.modules.shopInfo.merchantAccount.service.dto.TbMerchantAccountDto; +import me.zhengjie.modules.shopInfo.merchantAccount.service.dto.TbMerchantAccountQueryCriteria; +import me.zhengjie.modules.shopInfo.merchantAccount.service.mapstruct.TbMerchantAccountMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import me.zhengjie.utils.PageUtil; +import me.zhengjie.utils.QueryHelp; +import java.util.List; +import java.util.Map; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.LinkedHashMap; + +/** +* @website https://eladmin.vip +* @description 服务实现 +* @author lyf +* @date 2024-02-08 +**/ +@Service +@RequiredArgsConstructor +public class TbMerchantAccountServiceImpl implements TbMerchantAccountService { + + private final TbMerchantAccountRepository tbMerchantAccountRepository; + private final TbMerchantAccountMapper tbMerchantAccountMapper; + + @Override + public Map queryAll(TbMerchantAccountQueryCriteria criteria, Pageable pageable){ + Page page = tbMerchantAccountRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + return PageUtil.toPage(page.map(tbMerchantAccountMapper::toDto)); + } + + @Override + public List queryAll(TbMerchantAccountQueryCriteria criteria){ + return tbMerchantAccountMapper.toDto(tbMerchantAccountRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); + } + + @Override + @Transactional + public TbMerchantAccountDto findById(Integer id) { + TbMerchantAccount tbMerchantAccount = tbMerchantAccountRepository.findById(id).orElseGet(TbMerchantAccount::new); + ValidationUtil.isNull(tbMerchantAccount.getId(),"TbMerchantAccount","id",id); + return tbMerchantAccountMapper.toDto(tbMerchantAccount); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public TbMerchantAccountDto create(TbMerchantAccount resources) { + return tbMerchantAccountMapper.toDto(tbMerchantAccountRepository.save(resources)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(TbMerchantAccount resources) { + TbMerchantAccount tbMerchantAccount = tbMerchantAccountRepository.findById(resources.getId()).orElseGet(TbMerchantAccount::new); + ValidationUtil.isNull( tbMerchantAccount.getId(),"TbMerchantAccount","id",resources.getId()); + tbMerchantAccount.copy(resources); + tbMerchantAccountRepository.save(tbMerchantAccount); + } + + @Override + public void deleteAll(Integer[] ids) { + for (Integer id : ids) { + tbMerchantAccountRepository.deleteById(id); + } + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (TbMerchantAccountDto tbMerchantAccount : all) { + Map map = new LinkedHashMap<>(); + map.put("登陆帐号", tbMerchantAccount.getAccount()); + map.put("登陆密码", tbMerchantAccount.getPassword()); + map.put("商家Id", tbMerchantAccount.getMerchantId()); + map.put("门店Id", tbMerchantAccount.getShopId()); + map.put(" shopSnap", tbMerchantAccount.getShopSnap()); + map.put("是否管理员", tbMerchantAccount.getIsAdmin()); + map.put("是否商户:1商户帐号0-店铺帐号", tbMerchantAccount.getIsMercantile()); + map.put("姓名", tbMerchantAccount.getName()); + map.put("性别:0女 1 男", tbMerchantAccount.getSex()); + map.put("邮箱", tbMerchantAccount.getEmail()); + map.put("头像", tbMerchantAccount.getHeadImg()); + map.put("联系电话", tbMerchantAccount.getTelephone()); + map.put("状态", tbMerchantAccount.getStatus()); + map.put("排序", tbMerchantAccount.getSort()); + map.put(" roleId", tbMerchantAccount.getRoleId()); + map.put("最后登陆时间", tbMerchantAccount.getLastLoginAt()); + map.put("公众号openId", tbMerchantAccount.getMpOpenId()); + map.put("是否接收消息通知", tbMerchantAccount.getMsgAble()); + map.put(" createdAt", tbMerchantAccount.getCreatedAt()); + map.put(" updatedAt", tbMerchantAccount.getUpdatedAt()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/service/mapstruct/TbMerchantAccountMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/service/mapstruct/TbMerchantAccountMapper.java new file mode 100644 index 00000000..1c9a3b1a --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/merchantAccount/service/mapstruct/TbMerchantAccountMapper.java @@ -0,0 +1,32 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.merchantAccount.service.mapstruct; + +import me.zhengjie.base.BaseMapper; +import me.zhengjie.modules.shopInfo.merchantAccount.domain.TbMerchantAccount; +import me.zhengjie.modules.shopInfo.merchantAccount.service.dto.TbMerchantAccountDto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-08 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface TbMerchantAccountMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/domain/TbShopInfo.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/domain/TbShopInfo.java index c14d9d96..0f5047e0 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/domain/TbShopInfo.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/domain/TbShopInfo.java @@ -38,6 +38,7 @@ public class TbShopInfo implements Serializable { @Id @Column(name = "`id`") @ApiModelProperty(value = "自增id") + @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; @Column(name = "`account`") @@ -213,6 +214,9 @@ public class TbShopInfo implements Serializable { @Column(name = "`proxy_id`") @ApiModelProperty(value = "proxyId") private String proxyId; + @Column(name = "profiles") + @ApiModelProperty(value = "未激活 no 试用probation 正式release") + private String profiles=""; public void copy(TbShopInfo source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(false)); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/repository/TbShopInfoRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/repository/TbShopInfoRepository.java index 1f598e74..f0c775c2 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/repository/TbShopInfoRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/repository/TbShopInfoRepository.java @@ -16,6 +16,7 @@ package me.zhengjie.modules.shopInfo.shop.repository; import me.zhengjie.modules.shopInfo.shop.domain.TbShopInfo; +import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Param; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; @@ -30,4 +31,6 @@ public interface TbShopInfoRepository extends JpaRepository @Query("select info from TbShopInfo info where info.account = :account") TbShopInfo findByAccount(@Param("account") String account); + + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/rest/TbShopInfoController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/rest/TbShopInfoController.java index fdf9fe62..cd8a3e4d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/rest/TbShopInfoController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/rest/TbShopInfoController.java @@ -18,6 +18,7 @@ package me.zhengjie.modules.shopInfo.shop.rest; import me.zhengjie.annotation.Log; import me.zhengjie.modules.shopInfo.shop.domain.TbShopInfo; import me.zhengjie.modules.shopInfo.shop.service.TbShopInfoService; +import me.zhengjie.modules.shopInfo.shop.service.dto.TbShopInfoDto; import me.zhengjie.modules.shopInfo.shop.service.dto.TbShopInfoQueryCriteria; import org.springframework.data.domain.Pageable; import lombok.RequiredArgsConstructor; @@ -71,7 +72,7 @@ public class TbShopInfoController { @Log("新增/shop/list") @ApiOperation("新增/shop/list") @PreAuthorize("@el.check('tbShopInfo:add')") - public ResponseEntity createTbShopInfo(@Validated @RequestBody TbShopInfo resources){ + public ResponseEntity createTbShopInfo(@Validated @RequestBody TbShopInfoDto resources){ return new ResponseEntity<>(tbShopInfoService.create(resources),HttpStatus.CREATED); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/TbShopInfoService.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/TbShopInfoService.java index 8ca19b5b..48123cfa 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/TbShopInfoService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/TbShopInfoService.java @@ -61,7 +61,7 @@ public interface TbShopInfoService { * @param resources / * @return TbShopInfoDto */ - TbShopInfoDto create(TbShopInfo resources); + TbShopInfoDto create(TbShopInfoDto resources); /** * 编辑 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/dto/TbShopInfoDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/dto/TbShopInfoDto.java index 76c3b0fc..28b54681 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/dto/TbShopInfoDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/dto/TbShopInfoDto.java @@ -17,6 +17,8 @@ package me.zhengjie.modules.shopInfo.shop.service.dto; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; + +import javax.validation.constraints.NotBlank; import java.math.BigDecimal; import java.io.Serializable; @@ -34,6 +36,7 @@ public class TbShopInfoDto implements Serializable { private Integer id; /** 店铺帐号 */ + @NotBlank(message = "店铺账号不能为空") private String account; /** 店铺代号,策略方式为city +店铺号(8位) */ @@ -46,6 +49,7 @@ public class TbShopInfoDto implements Serializable { private String merchantId; /** 店铺名称 */ + @NotBlank(message = "店铺账号不能为空") private String shopName; /** 连锁店扩展店名 */ @@ -64,6 +68,7 @@ public class TbShopInfoDto implements Serializable { private String phone; /** 店铺log */ + @NotBlank(message = "店铺logo不能为空") private String logo; /** 是否参与代收 0--不参与 1参与 */ @@ -156,4 +161,12 @@ public class TbShopInfoDto implements Serializable { private Long updatedAt; private String proxyId; + /** + * 激活码 + */ + private String registerCode; + @NotBlank(message = "密码不能为空") + private String password; + + private String profiles; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/dto/TbShopInfoQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/dto/TbShopInfoQueryCriteria.java index 180328c7..efafb0ae 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/dto/TbShopInfoQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/dto/TbShopInfoQueryCriteria.java @@ -36,7 +36,7 @@ public class TbShopInfoQueryCriteria{ private String account; /** 精确 */ - @Query + @Query(type = Query.Type.LEFT_LIKE) private String shopName; /** 精确 */ diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/impl/TbShopInfoServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/impl/TbShopInfoServiceImpl.java index 946fe10c..8f450704 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/impl/TbShopInfoServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/impl/TbShopInfoServiceImpl.java @@ -15,29 +15,39 @@ */ package me.zhengjie.modules.shopInfo.shop.service.impl; +import cn.hutool.core.bean.BeanUtil; +import lombok.Data; import me.zhengjie.exception.BadRequestException; +import me.zhengjie.modules.shopInfo.merchantAccount.domain.TbMerchantAccount; +import me.zhengjie.modules.shopInfo.merchantAccount.repository.TbMerchantAccountRepository; import me.zhengjie.modules.shopInfo.shop.domain.TbShopInfo; -import me.zhengjie.utils.ValidationUtil; -import me.zhengjie.utils.FileUtil; +import me.zhengjie.modules.shopInfo.shopRegister.domain.TbMerchantRegister; +import me.zhengjie.modules.shopInfo.shopRegister.repository.TbMerchantRegisterRepository; +import me.zhengjie.modules.system.domain.Dept; +import me.zhengjie.modules.system.domain.Job; +import me.zhengjie.modules.system.domain.Role; +import me.zhengjie.modules.system.domain.User; +import me.zhengjie.modules.system.repository.UserRepository; +import me.zhengjie.utils.*; import lombok.RequiredArgsConstructor; import me.zhengjie.modules.shopInfo.shop.repository.TbShopInfoRepository; import me.zhengjie.modules.shopInfo.shop.service.TbShopInfoService; import me.zhengjie.modules.shopInfo.shop.service.dto.TbShopInfoDto; import me.zhengjie.modules.shopInfo.shop.service.dto.TbShopInfoQueryCriteria; import me.zhengjie.modules.shopInfo.shop.service.mapstruct.TbShopInfoMapper; +import org.springframework.beans.BeanUtils; +import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import me.zhengjie.utils.PageUtil; -import me.zhengjie.utils.QueryHelp; -import java.util.List; -import java.util.Map; + +import java.sql.Timestamp; +import java.time.Instant; +import java.util.*; import java.io.IOException; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.LinkedHashMap; /** * @website https://eladmin.vip @@ -53,13 +63,27 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { @Resource private TbShopInfoMapper tbShopInfoMapper; + private final TbMerchantAccountRepository merchantAccountRepository; + + private final UserRepository userRepository; + + private final TbMerchantRegisterRepository merchantRegisterRepository; + + private final PasswordEncoder passwordEncoder; + @Override public Map queryAll(TbShopInfoQueryCriteria criteria, Pageable pageable){ // if (!"admin".equals(criteria.getAccount())){ // throw new BadRequestException("登录账号有误"); // } Page page = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - return PageUtil.toPage(page.map(tbShopInfoMapper::toDto)); + List content = page.getContent(); + for (TbShopInfo data: content){ + if (data.getProfiles() == null){ + data.setProfiles(""); + } + } + return PageUtil.toPage(page); } @Override @@ -88,8 +112,74 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { @Override @Transactional(rollbackFor = Exception.class) - public TbShopInfoDto create(TbShopInfo resources) { - return tbShopInfoMapper.toDto(tbShopInfoRepository.save(resources)); + public TbShopInfoDto create(TbShopInfoDto resources) { + if ("release".equals(resources.getProfiles())){ + if (resources.getRegisterCode() == null){ + throw new BadRequestException("未绑定激活码"); + } + } + TbShopInfo byAccount = tbShopInfoRepository.findByAccount(resources.getAccount()); + if (byAccount != null){ + throw new BadRequestException("登录名重复"); + } + + TbShopInfo tbShopInfo = new TbShopInfo(); + BeanUtils.copyProperties(resources,tbShopInfo); + tbShopInfo.setCreatedAt(Instant.now().toEpochMilli()); + tbShopInfo.setUpdatedAt(Instant.now().toEpochMilli()); + //增加商户详情 + TbShopInfo save = tbShopInfoRepository.save(tbShopInfo); + //增加商户登录账号 + TbMerchantAccount tbMerchantAccount = new TbMerchantAccount(); + tbMerchantAccount.setAccount(resources.getAccount()); + tbMerchantAccount.setPassword(MD5Utils.encrypt(resources.getPassword())); + tbMerchantAccount.setShopId(String.valueOf(save.getId())); + tbMerchantAccount.setIsAdmin(0); + tbMerchantAccount.setIsMercantile(0); + tbMerchantAccount.setStatus(1); + tbMerchantAccount.setMsgAble(0); + merchantAccountRepository.save(tbMerchantAccount); + //添加收银系统后台账号 + User user = new User(); + user.setPassword(passwordEncoder.encode(resources.getPassword())); + user.setUsername(resources.getAccount()); + user.setPhone(resources.getPhone()); + user.setCreateBy("admin"); + user.setEnabled(true); + + Dept dept = new Dept(); + dept.setId(18L); + user.setDept(dept); + + Set roles = new HashSet<>(); + Role role = new Role(); + role.setId(2L); + roles.add(role); + user.setRoles(roles); + + Set jobs = new HashSet<>(); + Job job = new Job(); + job.setId(10L); + jobs.add(job); + user.setJobs(jobs); + userRepository.save(user); + + if (resources.getRegisterCode() != null){ + //激活码绑定 + TbMerchantRegister tbMerchantRegister = merchantRegisterRepository.findByRegisterCode(resources.getRegisterCode()); + if(tbMerchantRegister == null){ + throw new BadRequestException("激活码有误"); + } + if (tbMerchantRegister.getStatus() == 1){ + throw new BadRequestException("激活码已激活,不能重复绑定"); + } + tbMerchantRegister.setStatus(1); + tbMerchantAccount.setShopId(String.valueOf(save.getId())); + tbMerchantAccount.setName(save.getShopName()); + merchantRegisterRepository.save(tbMerchantRegister); + } + + return tbShopInfoMapper.toDto(new TbShopInfo()); } @Override diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/rest/TbShopAreaController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/rest/TbShopAreaController.java index e77c7917..62294fb0 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/rest/TbShopAreaController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/rest/TbShopAreaController.java @@ -54,7 +54,6 @@ public class TbShopAreaController { @GetMapping @Log("查询/shop/area") @ApiOperation("查询/shop/area") - @PreAuthorize("@el.check('tbShopArea:list')") public ResponseEntity queryTbShopArea(TbShopAreaQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbShopAreaService.queryAll(criteria,pageable),HttpStatus.OK); } @@ -62,7 +61,6 @@ public class TbShopAreaController { @PostMapping @Log("新增/shop/area") @ApiOperation("新增/shop/area") - @PreAuthorize("@el.check('tbShopArea:add')") public ResponseEntity createTbShopArea(@Validated @RequestBody TbShopArea resources){ return new ResponseEntity<>(tbShopAreaService.create(resources),HttpStatus.CREATED); } @@ -70,7 +68,6 @@ public class TbShopAreaController { @PutMapping @Log("修改/shop/area") @ApiOperation("修改/shop/area") - @PreAuthorize("@el.check('tbShopArea:edit')") public ResponseEntity updateTbShopArea(@Validated @RequestBody TbShopArea resources){ tbShopAreaService.update(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); @@ -79,7 +76,6 @@ public class TbShopAreaController { @DeleteMapping @Log("删除/shop/area") @ApiOperation("删除/shop/area") - @PreAuthorize("@el.check('tbShopArea:del')") public ResponseEntity deleteTbShopArea(@RequestBody Integer[] ids) { tbShopAreaService.deleteAll(ids); return new ResponseEntity<>(HttpStatus.OK); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/rest/TbShopPurveyorController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/rest/TbShopPurveyorController.java index 6838d8cc..c138eac0 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/rest/TbShopPurveyorController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/rest/TbShopPurveyorController.java @@ -54,7 +54,6 @@ public class TbShopPurveyorController { @GetMapping @Log("查询/shop/purveyor") @ApiOperation("查询/shop/purveyor") - @PreAuthorize("@el.check('tbShopPurveyor:list')") public ResponseEntity queryTbShopPurveyor(TbShopPurveyorQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbShopPurveyorService.queryAll(criteria,pageable),HttpStatus.OK); } @@ -62,7 +61,6 @@ public class TbShopPurveyorController { @PostMapping @Log("新增/shop/purveyor") @ApiOperation("新增/shop/purveyor") - @PreAuthorize("@el.check('tbShopPurveyor:add')") public ResponseEntity createTbShopPurveyor(@Validated @RequestBody TbShopPurveyor resources){ return new ResponseEntity<>(tbShopPurveyorService.create(resources),HttpStatus.CREATED); } @@ -70,7 +68,6 @@ public class TbShopPurveyorController { @PutMapping @Log("修改/shop/purveyor") @ApiOperation("修改/shop/purveyor") - @PreAuthorize("@el.check('tbShopPurveyor:edit')") public ResponseEntity updateTbShopPurveyor(@Validated @RequestBody TbShopPurveyor resources){ tbShopPurveyorService.update(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); @@ -79,7 +76,6 @@ public class TbShopPurveyorController { @DeleteMapping @Log("删除/shop/purveyor") @ApiOperation("删除/shop/purveyor") - @PreAuthorize("@el.check('tbShopPurveyor:del')") public ResponseEntity deleteTbShopPurveyor(@RequestBody Integer[] ids) { tbShopPurveyorService.deleteAll(ids); return new ResponseEntity<>(HttpStatus.OK); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyorTransact/rest/TbShopPurveyorTransactController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyorTransact/rest/TbShopPurveyorTransactController.java index 645b192e..e21d8230 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyorTransact/rest/TbShopPurveyorTransactController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyorTransact/rest/TbShopPurveyorTransactController.java @@ -60,7 +60,6 @@ public class TbShopPurveyorTransactController { @GetMapping @Log("查询/shop/purveyorTransact") @ApiOperation("查询/shop/purveyorTransact") - @PreAuthorize("@el.check('tbShopPurveyorTransact:list')") public ResponseEntity queryTbShopPurveyorTransactSum(TbShopPurveyorTransactQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbShopPurveyorTransactService.queryTransactDate(criteria,pageable),HttpStatus.OK); } @@ -89,7 +88,6 @@ public class TbShopPurveyorTransactController { @PostMapping @Log("新增/shop/purveyorTransact") @ApiOperation("新增/shop/purveyorTransact") - @PreAuthorize("@el.check('tbShopPurveyorTransact:add')") public ResponseEntity createTbShopPurveyorTransact(@Validated @RequestBody TbShopPurveyorTransact resources){ return new ResponseEntity<>(tbShopPurveyorTransactService.create(resources),HttpStatus.CREATED); } @@ -97,7 +95,6 @@ public class TbShopPurveyorTransactController { @PutMapping @Log("修改/shop/purveyorTransact") @ApiOperation("修改/shop/purveyorTransact") - @PreAuthorize("@el.check('tbShopPurveyorTransact:edit')") public ResponseEntity updateTbShopPurveyorTransact(@Validated @RequestBody TbShopPurveyorTransact resources){ tbShopPurveyorTransactService.update(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); @@ -106,7 +103,6 @@ public class TbShopPurveyorTransactController { @DeleteMapping @Log("删除/shop/purveyorTransact") @ApiOperation("删除/shop/purveyorTransact") - @PreAuthorize("@el.check('tbShopPurveyorTransact:del')") public ResponseEntity deleteTbShopPurveyorTransact(@RequestBody Integer[] ids) { tbShopPurveyorTransactService.deleteAll(ids); return new ResponseEntity<>(HttpStatus.OK); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/domain/TbReceiptSales.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/domain/TbReceiptSales.java index a01e39bf..ebccecfb 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/domain/TbReceiptSales.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/domain/TbReceiptSales.java @@ -15,6 +15,7 @@ */ package me.zhengjie.modules.shopInfo.shopReceiptSales.domain; +import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; import cn.hutool.core.bean.BeanUtil; import io.swagger.annotations.ApiModelProperty; @@ -40,43 +41,43 @@ public class TbReceiptSales implements Serializable { @Column(name = "`title`") @ApiModelProperty(value = "标题") - private String title; + private String title=""; @Column(name = "`logo`") @ApiModelProperty(value = "是否显示公司Logo") - private String logo; + private String logo=""; @Column(name = "`show_contact_info`") @ApiModelProperty(value = "打印联系电话等信息") - private Integer showContactInfo; + private Integer showContactInfo=0; @Column(name = "`show_member`") @ApiModelProperty(value = "打印会员开关 0?1") - private Integer showMember; + private Integer showMember=0; @Column(name = "`show_member_code`") @ApiModelProperty(value = "打印会员编号开关") - private Integer showMemberCode; + private Integer showMemberCode=0; @Column(name = "`show_member_score`") @ApiModelProperty(value = "打印会员积分") - private Integer showMemberScore; + private Integer showMemberScore=0; @Column(name = "`show_member_wallet`") @ApiModelProperty(value = "打印会员余额开关 0?1") - private Integer showMemberWallet; + private Integer showMemberWallet=0; @Column(name = "`footer_remark`") @ApiModelProperty(value = "店铺Id") - private String footerRemark; + private String footerRemark=""; @Column(name = "`show_cash_charge`") @ApiModelProperty(value = "打印找零") - private Integer showCashCharge; + private Integer showCashCharge=0; @Column(name = "`show_serial_no`") @ApiModelProperty(value = "流水号") - private Integer showSerialNo; + private Integer showSerialNo=0; @Column(name = "`big_serial_no`") @ApiModelProperty(value = "用大号字打印流水号 在showSerialNo可用前提下") @@ -92,7 +93,7 @@ public class TbReceiptSales implements Serializable { @Column(name = "`footer_text`") @ApiModelProperty(value = "尾部文字") - private String footerText; + private String footerText=""; @Column(name = "`footer_text_align`") @ApiModelProperty(value = "文字 对齐方式") @@ -100,7 +101,7 @@ public class TbReceiptSales implements Serializable { @Column(name = "`footer_image`") @ApiModelProperty(value = "尾部图像") - private String footerImage; + private String footerImage=""; @Column(name = "`pre_print`") @ApiModelProperty(value = "预打印,YES开启 NO不开启") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/rest/TbReceiptSalesController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/rest/TbReceiptSalesController.java index 446a8908..51cc5a8c 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/rest/TbReceiptSalesController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/rest/TbReceiptSalesController.java @@ -64,6 +64,7 @@ public class TbReceiptSalesController { @ApiOperation("查询/shop/receiptSales") @PreAuthorize("@el.check('tbReceiptSales:info')") public Object queryTbReceiptSalesInfo(@PathVariable("shopId")Integer shopId){ + return tbReceiptSalesService.findById(shopId); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/service/impl/TbReceiptSalesServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/service/impl/TbReceiptSalesServiceImpl.java index 042f0304..9c5147df 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/service/impl/TbReceiptSalesServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/service/impl/TbReceiptSalesServiceImpl.java @@ -65,7 +65,7 @@ public class TbReceiptSalesServiceImpl implements TbReceiptSalesService { @Transactional public TbReceiptSalesDto findById(Integer id) { TbReceiptSales tbReceiptSales = tbReceiptSalesRepository.findById(id).orElseGet(TbReceiptSales::new); - ValidationUtil.isNull(tbReceiptSales.getId(),"TbReceiptSales","id",id); + return tbReceiptSalesMapper.toDto(tbReceiptSales); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/domain/TbMerchantRegister.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/domain/TbMerchantRegister.java new file mode 100644 index 00000000..7f3290c8 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/domain/TbMerchantRegister.java @@ -0,0 +1,125 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.shopRegister.domain; + +import com.baomidou.mybatisplus.annotation.TableField; +import lombok.Data; +import cn.hutool.core.bean.BeanUtil; +import io.swagger.annotations.ApiModelProperty; +import cn.hutool.core.bean.copier.CopyOptions; +import javax.persistence.*; +import javax.validation.constraints.*; +import java.math.BigDecimal; +import java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description / +* @author lyf +* @date 2024-02-23 +**/ +@Entity +@Data +@Table(name="tb_merchant_register") +public class TbMerchantRegister implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "`id`") + @ApiModelProperty(value = "id") + private Integer id; + + @Column(name = "`register_code`") + @ApiModelProperty(value = "激活码") + private String registerCode; + + @Column(name = "`app_code`") + @ApiModelProperty(value = "授权token") + private String appCode; + + @Column(name = "`telephone`") + @ApiModelProperty(value = "telephone") + private String telephone; + + @Column(name = "`merchant_id`") + @ApiModelProperty(value = "merchantId") + private String merchantId; + + @Column(name = "`shop_id`") + @ApiModelProperty(value = "店铺id") + private String shopId; + + @Column(name = "`type`") + @ApiModelProperty(value = "版本类型") + private String type; + + @Column(name = "`amount`") + @ApiModelProperty(value = "激活码金额") + private BigDecimal amount; + + @Column(name = "`period_year`") + @ApiModelProperty(value = "激活时长(月)") + private Integer periodYear; + + @Column(name = "`name`") + @ApiModelProperty(value = "name") + private String name = ""; + + @Column(name = "`address`") + @ApiModelProperty(value = "address") + private String address; + + @Column(name = "`logo`") + @ApiModelProperty(value = "logo") + private String logo; + + @Column(name = "`industry`") + @ApiModelProperty(value = "industry") + private String industry; + + @Column(name = "`industry_name`") + @ApiModelProperty(value = "industryName") + private String industryName; + + @Column(name = "`status`") + @ApiModelProperty(value = "状态0未使用1已使用") + private Integer status; + + @Column(name = "`limit_shop_number`") + @ApiModelProperty(value = "limitShopNumber") + private Integer limitShopNumber; + + @Column(name = "`source_path`") + @ApiModelProperty(value = "sourcePath") + private String sourcePath; + + @Column(name = "`created_at`") + @ApiModelProperty(value = "创建时间") + private Long createdAt; + + @Column(name = "`updated_at`") + @ApiModelProperty(value = "updatedAt") + private Long updatedAt; + + @Column(name = "proxy_id") + @ApiModelProperty(value = "代理id") + private String proxyId; + + + public void copy(TbMerchantRegister source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/repository/TbMerchantRegisterRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/repository/TbMerchantRegisterRepository.java new file mode 100644 index 00000000..fabcf34b --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/repository/TbMerchantRegisterRepository.java @@ -0,0 +1,33 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.shopRegister.repository; + +import me.zhengjie.modules.shopInfo.shopRegister.domain.TbMerchantRegister; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Query; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-23 +**/ +public interface TbMerchantRegisterRepository extends JpaRepository, JpaSpecificationExecutor { + + @Query("select register from TbMerchantRegister register where register.registerCode =:registerCode") + TbMerchantRegister findByRegisterCode(@Param("registerCode") String registerCode); +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/rest/TbMerchantRegisterController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/rest/TbMerchantRegisterController.java new file mode 100644 index 00000000..a7ba3400 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/rest/TbMerchantRegisterController.java @@ -0,0 +1,88 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.shopRegister.rest; + +import me.zhengjie.annotation.Log; +import me.zhengjie.modules.shopInfo.shopRegister.domain.TbMerchantRegister; +import me.zhengjie.modules.shopInfo.shopRegister.service.TbMerchantRegisterService; +import me.zhengjie.modules.shopInfo.shopRegister.service.dto.TbMerchantRegisterDto; +import me.zhengjie.modules.shopInfo.shopRegister.service.dto.TbMerchantRegisterQueryCriteria; +import org.springframework.data.domain.Pageable; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-23 +**/ +@RestController +@RequiredArgsConstructor +@Api(tags = "/shop/register管理") +@RequestMapping("/api/tbMerchantRegister") +public class TbMerchantRegisterController { + + private final TbMerchantRegisterService tbMerchantRegisterService; + +// @Log("导出数据") +// @ApiOperation("导出数据") +// @GetMapping(value = "/download") +// @PreAuthorize("@el.check('tbMerchantRegister:list')") +// public void exportTbMerchantRegister(HttpServletResponse response, TbMerchantRegisterQueryCriteria criteria) throws IOException { +// tbMerchantRegisterService.download(tbMerchantRegisterService.queryAll(criteria), response); +// } + + @PostMapping("/list") + @Log("查询/shop/register") + @ApiOperation("查询/shop/register") + @PreAuthorize("@el.check('tbMerchantRegister:list')") + public ResponseEntity queryTbMerchantRegister(@RequestBody TbMerchantRegisterQueryCriteria criteria){ + return new ResponseEntity<>(tbMerchantRegisterService.queryAll(criteria),HttpStatus.OK); + } + + @PostMapping + @Log("新增/shop/register") + @ApiOperation("新增/shop/register") + @PreAuthorize("@el.check('tbMerchantRegister:add')") + public ResponseEntity createTbMerchantRegister(@Validated @RequestBody TbMerchantRegisterDto resources){ + return new ResponseEntity<>(tbMerchantRegisterService.create(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改/shop/register") + @ApiOperation("修改/shop/register") + @PreAuthorize("@el.check('tbMerchantRegister:edit')") + public ResponseEntity updateTbMerchantRegister(@Validated @RequestBody TbMerchantRegister resources){ + tbMerchantRegisterService.update(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @DeleteMapping + @Log("删除/shop/register") + @ApiOperation("删除/shop/register") + @PreAuthorize("@el.check('tbMerchantRegister:del')") + public ResponseEntity deleteTbMerchantRegister(@RequestBody Integer[] ids) { + tbMerchantRegisterService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/service/TbMerchantRegisterService.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/service/TbMerchantRegisterService.java new file mode 100644 index 00000000..162d45fc --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/service/TbMerchantRegisterService.java @@ -0,0 +1,83 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.shopRegister.service; + +import me.zhengjie.modules.shopInfo.shopRegister.domain.TbMerchantRegister; +import me.zhengjie.modules.shopInfo.shopRegister.service.dto.TbMerchantRegisterDto; +import me.zhengjie.modules.shopInfo.shopRegister.service.dto.TbMerchantRegisterQueryCriteria; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://eladmin.vip +* @description 服务接口 +* @author lyf +* @date 2024-02-23 +**/ +public interface TbMerchantRegisterService { + + /** + * 查询数据分页 + * @param criteria 条件 + + * @return Map + */ + Map queryAll(TbMerchantRegisterQueryCriteria criteria); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ +// List queryAll(TbMerchantRegisterQueryCriteria criteria); + + /** + * 根据ID查询 + * @param id ID + * @return TbMerchantRegisterDto + */ + TbMerchantRegisterDto findById(Integer id); + + /** + * 创建 + * @param resources / + * @return TbMerchantRegisterDto + */ + TbMerchantRegisterDto create(TbMerchantRegisterDto resources); + + /** + * 编辑 + * @param resources / + */ + void update(TbMerchantRegister resources); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(Integer[] ids); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/service/dto/TbMerchantRegisterDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/service/dto/TbMerchantRegisterDto.java new file mode 100644 index 00000000..fdd797d4 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/service/dto/TbMerchantRegisterDto.java @@ -0,0 +1,78 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.shopRegister.service.dto; + +import lombok.Data; +import java.math.BigDecimal; +import java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description / +* @author lyf +* @date 2024-02-23 +**/ +@Data +public class TbMerchantRegisterDto implements Serializable { + + private Integer id; + + /** 激活码 */ + private String registerCode; + + /** 授权token */ + private String appCode; + + private String telephone; + + private String merchantId; + + /** 店铺id */ + private String shopId; + + /** 版本类型 */ + private String type; + + /** 激活码金额 */ + private BigDecimal amount; + + /** 激活时长(月) */ + private Integer periodYear; + + private String name; + + private String address; + + private String logo; + + private String industry; + + private String industryName; + + /** 状态0未使用1已使用 */ + private Integer status; + + private Integer limitShopNumber; + + private String sourcePath; + + /** 创建时间 */ + private Long createdAt; + + private Long updatedAt; + + private Integer number; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/service/dto/TbMerchantRegisterQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/service/dto/TbMerchantRegisterQueryCriteria.java new file mode 100644 index 00000000..62223ab7 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/service/dto/TbMerchantRegisterQueryCriteria.java @@ -0,0 +1,47 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.shopRegister.service.dto; + +import lombok.Data; +import java.util.List; +import me.zhengjie.annotation.Query; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-23 +**/ +@Data +public class TbMerchantRegisterQueryCriteria{ + + /** 精确 */ + @Query + private String type; + + /** 精确 */ + @Query + private Integer status; + /** BETWEEN */ + @Query(type = Query.Type.BETWEEN) + private List createdAt; + + @Query(type = Query.Type.LEFT_LIKE) + private String proxyName; + + private Integer page; + + private Integer size; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/service/impl/TbMerchantRegisterServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/service/impl/TbMerchantRegisterServiceImpl.java new file mode 100644 index 00000000..4564d273 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/service/impl/TbMerchantRegisterServiceImpl.java @@ -0,0 +1,152 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.shopRegister.service.impl; + +import com.baomidou.mybatisplus.extension.api.R; +import me.zhengjie.exception.BadRequestException; +import me.zhengjie.modules.shopInfo.shopRegister.domain.TbMerchantRegister; +import me.zhengjie.utils.ValidationUtil; +import me.zhengjie.utils.FileUtil; +import lombok.RequiredArgsConstructor; +import me.zhengjie.modules.shopInfo.shopRegister.repository.TbMerchantRegisterRepository; +import me.zhengjie.modules.shopInfo.shopRegister.service.TbMerchantRegisterService; +import me.zhengjie.modules.shopInfo.shopRegister.service.dto.TbMerchantRegisterDto; +import me.zhengjie.modules.shopInfo.shopRegister.service.dto.TbMerchantRegisterQueryCriteria; +import me.zhengjie.modules.shopInfo.shopRegister.service.mapstruct.TbMerchantRegisterMapper; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import me.zhengjie.utils.PageUtil; +import me.zhengjie.utils.QueryHelp; + +import java.time.Instant; +import java.util.*; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://eladmin.vip +* @description 服务实现 +* @author lyf +* @date 2024-02-23 +**/ +@Service +@RequiredArgsConstructor +public class TbMerchantRegisterServiceImpl implements TbMerchantRegisterService { + + private final TbMerchantRegisterRepository tbMerchantRegisterRepository; + private final TbMerchantRegisterMapper tbMerchantRegisterMapper; + + @Override + public Map queryAll(TbMerchantRegisterQueryCriteria criteria){ + Sort sort = Sort.by(Sort.Direction.DESC, "id"); + Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort); + + + Page page = tbMerchantRegisterRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + for (TbMerchantRegister data : page.getContent()) { + data.setName(data.getName() == null?"":data.getName()); + data.setTelephone(data.getTelephone() == null?"": data.getTelephone()); + data.setType(data.getType() == null?"": data.getType()); + data.setProxyId(data.getProxyId() == null?"":data.getProxyId()); + } + + return PageUtil.toPage(page.getContent(),page.getTotalElements()); + } + +// @Override +// public List queryAll(TbMerchantRegisterQueryCriteria criteria){ +// return tbMerchantRegisterMapper.toDto(tbMerchantRegisterRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); +// } + + @Override + @Transactional + public TbMerchantRegisterDto findById(Integer id) { + TbMerchantRegister tbMerchantRegister = tbMerchantRegisterRepository.findById(id).orElseGet(TbMerchantRegister::new); + ValidationUtil.isNull(tbMerchantRegister.getId(),"TbMerchantRegister","id",id); + return tbMerchantRegisterMapper.toDto(tbMerchantRegister); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public TbMerchantRegisterDto create(TbMerchantRegisterDto resources) { + if (resources.getNumber()>10){ + throw new BadRequestException("每次最多生成10条激活码"); + } + for (int i = 0; i < resources.getNumber(); i++) { + TbMerchantRegister tbMerchantRegister = new TbMerchantRegister(); + tbMerchantRegister.setRegisterCode(UUID.randomUUID().toString().replaceAll("-", "")); + tbMerchantRegister.setStatus(0); + tbMerchantRegister.setCreatedAt(Instant.now().toEpochMilli()); + tbMerchantRegister.setUpdatedAt(Instant.now().toEpochMilli()); + tbMerchantRegister.setPeriodYear(resources.getPeriodYear()); + tbMerchantRegisterRepository.save(tbMerchantRegister); + } + + return tbMerchantRegisterMapper.toDto(new TbMerchantRegister()); + } + + public static void main(String[] args) { + String uuid = UUID.randomUUID().toString().replaceAll("-", ""); + System.out.println(uuid); + } + @Override + @Transactional(rollbackFor = Exception.class) + public void update(TbMerchantRegister resources) { + TbMerchantRegister tbMerchantRegister = tbMerchantRegisterRepository.findById(resources.getId()).orElseGet(TbMerchantRegister::new); + ValidationUtil.isNull( tbMerchantRegister.getId(),"TbMerchantRegister","id",resources.getId()); + tbMerchantRegister.copy(resources); + tbMerchantRegisterRepository.save(tbMerchantRegister); + } + + @Override + public void deleteAll(Integer[] ids) { + for (Integer id : ids) { + tbMerchantRegisterRepository.deleteById(id); + } + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (TbMerchantRegisterDto tbMerchantRegister : all) { + Map map = new LinkedHashMap<>(); + map.put("激活码", tbMerchantRegister.getRegisterCode()); + map.put("授权token", tbMerchantRegister.getAppCode()); + map.put(" telephone", tbMerchantRegister.getTelephone()); + map.put(" merchantId", tbMerchantRegister.getMerchantId()); + map.put("店铺id", tbMerchantRegister.getShopId()); + map.put("版本类型", tbMerchantRegister.getType()); + map.put("激活码金额", tbMerchantRegister.getAmount()); + map.put("激活时长(月)", tbMerchantRegister.getPeriodYear()); + map.put(" name", tbMerchantRegister.getName()); + map.put(" address", tbMerchantRegister.getAddress()); + map.put(" logo", tbMerchantRegister.getLogo()); + map.put(" industry", tbMerchantRegister.getIndustry()); + map.put(" industryName", tbMerchantRegister.getIndustryName()); + map.put("状态0未使用1已使用", tbMerchantRegister.getStatus()); + map.put(" limitShopNumber", tbMerchantRegister.getLimitShopNumber()); + map.put(" sourcePath", tbMerchantRegister.getSourcePath()); + map.put("创建时间", tbMerchantRegister.getCreatedAt()); + map.put(" updatedAt", tbMerchantRegister.getUpdatedAt()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/service/mapstruct/TbMerchantRegisterMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/service/mapstruct/TbMerchantRegisterMapper.java new file mode 100644 index 00000000..67d6ab3c --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopRegister/service/mapstruct/TbMerchantRegisterMapper.java @@ -0,0 +1,32 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.shopRegister.service.mapstruct; + +import me.zhengjie.base.BaseMapper; +import me.zhengjie.modules.shopInfo.shopRegister.domain.TbMerchantRegister; +import me.zhengjie.modules.shopInfo.shopRegister.service.dto.TbMerchantRegisterDto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-23 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface TbMerchantRegisterMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/rest/TbShopUnitController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/rest/TbShopUnitController.java index f3d8482d..e9d8bfb2 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/rest/TbShopUnitController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/rest/TbShopUnitController.java @@ -54,7 +54,6 @@ public class TbShopUnitController { @GetMapping @Log("查询/shop/unit") @ApiOperation("查询/shop/unit") - @PreAuthorize("@el.check('tbShopUnit:list')") public ResponseEntity queryTbShopUnit(TbShopUnitQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbShopUnitService.queryAll(criteria,pageable),HttpStatus.OK); } @@ -62,7 +61,6 @@ public class TbShopUnitController { @PostMapping @Log("新增/shop/unit") @ApiOperation("新增/shop/unit") - @PreAuthorize("@el.check('tbShopUnit:add')") public ResponseEntity createTbShopUnit(@Validated @RequestBody TbShopUnit resources)throws Exception{ return new ResponseEntity<>(tbShopUnitService.create(resources),HttpStatus.CREATED); } @@ -70,7 +68,6 @@ public class TbShopUnitController { @PutMapping @Log("修改/shop/unit") @ApiOperation("修改/shop/unit") - @PreAuthorize("@el.check('tbShopUnit:edit')") public ResponseEntity updateTbShopUnit(@Validated @RequestBody TbShopUnit resources){ tbShopUnitService.update(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); @@ -79,7 +76,6 @@ public class TbShopUnitController { @DeleteMapping @Log("删除/shop/unit") @ApiOperation("删除/shop/unit") - @PreAuthorize("@el.check('tbShopUnit:del')") public ResponseEntity deleteTbShopUnit(@RequestBody Integer[] ids) { tbShopUnitService.deleteAll(ids); return new ResponseEntity<>(HttpStatus.OK); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/rest/TbShopTableController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/rest/TbShopTableController.java index acaa2208..4d23bc57 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/rest/TbShopTableController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/rest/TbShopTableController.java @@ -54,7 +54,6 @@ public class TbShopTableController { @GetMapping @Log("查询/shop/table") @ApiOperation("查询/shop/table") - @PreAuthorize("@el.check('tbShopTable:list')") public ResponseEntity queryTbShopTable(TbShopTableQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbShopTableService.queryAll(criteria,pageable),HttpStatus.OK); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java index b4d11bda..fe28773b 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java @@ -74,11 +74,9 @@ public class User extends BaseEntity implements Serializable { private String nickName; @Email - @NotBlank @ApiModelProperty(value = "邮箱") private String email; - @NotBlank @ApiModelProperty(value = "电话号码") private String phone; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java index 867509d3..17e891c3 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java @@ -20,6 +20,10 @@ import me.zhengjie.config.FileProperties; import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.security.service.OnlineUserService; import me.zhengjie.modules.security.service.UserCacheManager; +import me.zhengjie.modules.shopInfo.merchantAccount.domain.TbMerchantAccount; +import me.zhengjie.modules.shopInfo.merchantAccount.repository.TbMerchantAccountRepository; +import me.zhengjie.modules.shopInfo.shop.domain.TbShopInfo; +import me.zhengjie.modules.shopInfo.shop.repository.TbShopInfoRepository; import me.zhengjie.modules.system.domain.User; import me.zhengjie.exception.EntityExistException; import me.zhengjie.exception.EntityNotFoundException; @@ -59,6 +63,10 @@ public class UserServiceImpl implements UserService { private final UserCacheManager userCacheManager; private final OnlineUserService onlineUserService; private final UserLoginMapper userLoginMapper; + private final TbMerchantAccountRepository merchantAccountRepository; + private final TbShopInfoRepository shopInfoRepository; + + @Override public Object queryAll(UserQueryCriteria criteria, Pageable pageable) { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/userInfo/rest/TbUserInfoController.java b/eladmin-system/src/main/java/me/zhengjie/modules/userInfo/rest/TbUserInfoController.java index df594493..45d15dde 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/userInfo/rest/TbUserInfoController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/userInfo/rest/TbUserInfoController.java @@ -54,7 +54,6 @@ public class TbUserInfoController { @GetMapping @Log("查询/userInfo/list") @ApiOperation("查询/userInfo/list") - @PreAuthorize("@el.check('tbUserInfo:list')") public ResponseEntity queryTbUserInfo(TbUserInfoQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbUserInfoService.queryAll(criteria,pageable),HttpStatus.OK); } @@ -62,7 +61,6 @@ public class TbUserInfoController { @PostMapping @Log("新增/userInfo/list") @ApiOperation("新增/userInfo/list") - @PreAuthorize("@el.check('tbUserInfo:add')") public ResponseEntity createTbUserInfo(@Validated @RequestBody TbUserInfo resources){ return new ResponseEntity<>(tbUserInfoService.create(resources),HttpStatus.CREATED); } @@ -70,7 +68,6 @@ public class TbUserInfoController { @PutMapping @Log("修改/userInfo/list") @ApiOperation("修改/userInfo/list") - @PreAuthorize("@el.check('tbUserInfo:edit')") public ResponseEntity updateTbUserInfo(@Validated @RequestBody TbUserInfo resources){ tbUserInfoService.update(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); @@ -79,7 +76,6 @@ public class TbUserInfoController { @DeleteMapping @Log("删除/userInfo/list") @ApiOperation("删除/userInfo/list") - @PreAuthorize("@el.check('tbUserInfo:del')") public ResponseEntity deleteTbUserInfo(@RequestBody Integer[] ids) { tbUserInfoService.deleteAll(ids); return new ResponseEntity<>(HttpStatus.OK); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/userInfo/service/dto/TbUserInfoQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/userInfo/service/dto/TbUserInfoQueryCriteria.java index 8defdd08..f1ea9a82 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/userInfo/service/dto/TbUserInfoQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/userInfo/service/dto/TbUserInfoQueryCriteria.java @@ -55,4 +55,7 @@ public class TbUserInfoQueryCriteria{ /** 精确 */ @Query private Long lastLogInAt; + + @Query + private String shopId; } \ No newline at end of file