diff --git a/eladmin-common/src/main/java/cn/ysk/cashier/utils/ListUtil.java b/eladmin-common/src/main/java/cn/ysk/cashier/utils/ListUtil.java index bf98c814..be6fd86d 100644 --- a/eladmin-common/src/main/java/cn/ysk/cashier/utils/ListUtil.java +++ b/eladmin-common/src/main/java/cn/ysk/cashier/utils/ListUtil.java @@ -73,6 +73,17 @@ public class ListUtil { return stringList; } + public static List stringChangeIntegerList(String listString){ + // 使用Fastjson将JSON字符串转换为JSONArray对象 + + listString = listString.replaceAll("\"", "").replaceAll("\\[", "").replaceAll("\\]", ""); + List integerList = Stream.of(listString.split(",")) + .map(Integer::valueOf) + .collect(Collectors.toList()); + return integerList; + } + + public static List stringChangeIntegerList(List listString){ // method1 创建一个Integer类型的集合,循环遍历String类型的数组并把数据添加进集合 diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbProductController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbProductController.java index 2987e2f7..fe39d203 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbProductController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbProductController.java @@ -44,19 +44,11 @@ public class TbProductController { private final TbProductService tbProductService; - @Log("导出数据") - @ApiOperation("导出数据") - @GetMapping(value = "/download") - @PreAuthorize("@el.check('tbProduct:list')") - public void exportTbProduct(HttpServletResponse response, TbProductQueryCriteria criteria) throws IOException { - tbProductService.download(tbProductService.queryAll(criteria), response); - } - @GetMapping @Log("查询/product") @ApiOperation("查询/product") - public ResponseEntity queryTbProduct(TbProductQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(tbProductService.queryAll(criteria,pageable),HttpStatus.OK); + public ResponseEntity queryTbProduct(TbProductQueryCriteria criteria){ + return new ResponseEntity<>(tbProductService.queryAll(criteria),HttpStatus.OK); } @GetMapping("/{product}") diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbProductGroupController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbProductGroupController.java index 8614149f..69543865 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbProductGroupController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbProductGroupController.java @@ -102,7 +102,7 @@ public class TbProductGroupController { */ @GetMapping("/addProduct") public ResponseEntity ProductList(TbProductQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(tbProductService.queryAll(criteria,pageable),HttpStatus.OK); + return new ResponseEntity<>(tbProductService.queryAll(criteria),HttpStatus.OK); } /** diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java index e8d8f40f..2b8d819b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopInfoController.java @@ -44,20 +44,20 @@ public class TbShopInfoController { private final TbShopInfoService tbShopInfoService; - @Log("导出数据") - @ApiOperation("导出数据") - @GetMapping(value = "/download") - @PreAuthorize("@el.check('tbShopInfo:list')") - public void exportTbShopInfo(HttpServletResponse response, TbShopInfoQueryCriteria criteria) throws IOException { - tbShopInfoService.download(tbShopInfoService.queryAll(criteria), response); - } +// @Log("导出数据") +// @ApiOperation("导出数据") +// @GetMapping(value = "/download") +// @PreAuthorize("@el.check('tbShopInfo:list')") +// public void exportTbShopInfo(HttpServletResponse response, TbShopInfoQueryCriteria criteria) throws IOException { +// tbShopInfoService.download(tbShopInfoService.queryAll(criteria), response); +// } @GetMapping @Log("查询/shop/list") @ApiOperation("查询/shop/list") @PreAuthorize("@el.check('tbShopInfo:list')") public ResponseEntity queryTbShopInfo(TbShopInfoQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(tbShopInfoService.queryAll(criteria,pageable),HttpStatus.OK); + return new ResponseEntity<>(tbShopInfoService.queryAll(criteria),HttpStatus.OK); } @GetMapping("/{shopId}") diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductGroupDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductGroupDto.java index 993da955..66ed15a4 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductGroupDto.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductGroupDto.java @@ -55,7 +55,7 @@ public class TbProductGroupDto implements Serializable { private Integer sort; /** 商品列表 */ - private List productIds; + private List productIds; private Long createdAt; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductQueryCriteria.java index c3b9dd5b..e4b106e2 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductQueryCriteria.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductQueryCriteria.java @@ -121,4 +121,10 @@ public class TbProductQueryCriteria{ @Query private String typeEnum; + + private Integer page; + + private Integer size; + + private String sort; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java index 1f5003a7..700b127c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopInfoQueryCriteria.java @@ -65,4 +65,10 @@ public class TbShopInfoQueryCriteria{ /** 精确 */ @Query private Integer status; + + private Integer page; + + private Integer size; + + private String sort; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/product/TbProductGroupMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mapper/product/TbProductGroupMapper.java index 7cd648eb..df3c70c1 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mapper/product/TbProductGroupMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mapper/product/TbProductGroupMapper.java @@ -19,6 +19,7 @@ import cn.ysk.cashier.base.BaseMapper; import cn.ysk.cashier.pojo.product.TbProductGroup; import cn.ysk.cashier.dto.product.TbProductGroupDto; +import cn.ysk.cashier.utils.ListUtil; import org.mapstruct.Mapper; import org.mapstruct.Mapping; @@ -38,13 +39,7 @@ import java.util.stream.Collectors; public interface TbProductGroupMapper extends BaseMapper { // 自定义的字符串到整数列表的转换方法 default List map(String value) { - if (value == null || value.isEmpty()) { - return Collections.emptyList(); - } - // 分割字符串,然后将每个数字字符串转换为Integer,收集到List中 - return Arrays.stream(value.split(",")) - .map(Integer::valueOf) - .collect(Collectors.toList()); + return ListUtil.stringChangeIntegerList(value); } // 如果需要从DTO转回实体,也可能需要实现反向的映射方法 diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductGroupServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductGroupServiceImpl.java index 032ec886..d3baa204 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductGroupServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductGroupServiceImpl.java @@ -80,7 +80,7 @@ public class TbProductGroupServiceImpl implements TbProductGroupService { TbProductGroup tbProductGroup = tbProductGroupRepository.findById(productGroup).orElseGet(TbProductGroup::new); TbProductGroupDto dto = tbProductGroupMapper.toDto(tbProductGroup); if (!CollectionUtils.isEmpty(dto.getProductIds())){ - return tbProductRepository.findByIds(ListUtil.stringChangeIntegerList(dto.getProductIds())); + return tbProductRepository.findByIds(dto.getProductIds()); } return new ArrayList<>(); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index 6b8d520f..7706b47c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -37,10 +37,13 @@ import cn.ysk.cashier.pojo.shop.TbShopUnit; import cn.ysk.cashier.repository.shop.TbShopUnitRepository; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; +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 org.springframework.util.StringUtils; import java.time.Instant; import java.util.*; @@ -68,7 +71,9 @@ public class TbProductServiceImpl implements TbProductService { @Override - public Map queryAll(TbProductQueryCriteria criteria, Pageable pageable){ + public Map queryAll(TbProductQueryCriteria criteria){ + Sort sort = Sort.by(Sort.Direction.DESC, "id"); + Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort); //查询商品数据 Page page = tbProductRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); List productId = new ArrayList<>(); @@ -147,7 +152,7 @@ public class TbProductServiceImpl implements TbProductService { //单位 CompletableFuture tbShopUnits = CompletableFuture.supplyAsync(() -> - tbShopUnitRepository.searchUnit(Integer.valueOf(tbProduct.getUnitId()))); + tbShopUnitRepository.searchUnit(Integer.valueOf(StringUtils.isEmpty(tbProduct.getUnitId())? null:tbProduct.getUnitId() ))); //sku CompletableFuture> tbProductSkus = CompletableFuture.supplyAsync(() -> tbProductSkuRepository.searchSku(tbProduct.getId().toString())); @@ -163,8 +168,6 @@ public class TbProductServiceImpl implements TbProductService { if (tbProduct.getUnitId() == null){ tbProductVo.setUnitId(null); tbProductVo.setUnitName(null); - }else { - tbProductVo.setUnitName(tbShopUnits.get().getName()); } //套餐 if (tbProduct.getGroupSnap() == null){ @@ -203,7 +206,7 @@ public class TbProductServiceImpl implements TbProductService { } @Override - public List queryAll(TbProductQueryCriteria criteria){ + public List queryAlls(TbProductQueryCriteria criteria){ return tbProductMapper.toDto(tbProductRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); } @@ -225,6 +228,7 @@ public class TbProductServiceImpl implements TbProductService { if (resources.getCategoryId() == null){ throw new BadRequestException("必填内容未填写"); } + product.setImages(resources.getImages().toString()); product.setCategoryId(String.valueOf(resources.getCategoryId())); product.setIsDel(0); product.setIsDelete(0); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbShopCategoryServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbShopCategoryServiceImpl.java index 097700dc..43e85196 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbShopCategoryServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbShopCategoryServiceImpl.java @@ -60,7 +60,7 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService { public Map queryAll(TbShopCategoryQueryCriteria criteria, Pageable pageable){ // Page page = tbShopCategoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - PageRequest.of(0, 10, Sort.by("sort")); + PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("sort")); Page page = tbShopCategoryRepository.findAllBy(criteria.getShopId(), pageable); tbShopCategoryRepository.findAllBy(criteria.getShopId(),pageable); @@ -112,14 +112,16 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService { resources.setUpdatedAt(Instant.now().toEpochMilli()); TbShopCategoryDto dto = tbShopCategoryMapper.toDto(tbShopCategoryRepository.save(resources)); - + if (resources.getName() != null){ + throw new BadRequestException("分类名称重复"); + } if (resources.getPid() == null || "".equals(resources.getPid())){ resources.setTree(resources.getId()); }else { resources.setTree(Integer.valueOf(resources.getPid().trim())); } - ValidationUtil.isNull( dto.getId(),"TbShopCategory","id",resources.getId()); + ValidationUtil.isNull(dto.getId(),"TbShopCategory","id",resources.getId()); tbShopCategoryRepository.save(resources); return tbShopCategoryRepository.save(resources); } @@ -132,9 +134,7 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService { throw new BadRequestException("必要参数为空"); } TbShopCategory byName = tbShopCategoryRepository.findByName(resources.getName(), resources.getShopId()); - if (byName != null){ - throw new BadRequestException("分类名称重复"); - } + resources.setUpdatedAt(Instant.now().toEpochMilli()); ValidationUtil.isNull( tbShopCategory.getId(),"TbShopCategory","id",resources.getId()); tbShopCategory.copy(resources); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java index 8bdbe692..941057e3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java @@ -16,6 +16,7 @@ package cn.ysk.cashier.service.impl.shopimpl; import cn.ysk.cashier.exception.BadRequestException; +import cn.ysk.cashier.pojo.product.TbShopCategory; import cn.ysk.cashier.pojo.shop.TbMerchantAccount; import cn.ysk.cashier.pojo.shop.TbPlussShopStaff; import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository; @@ -36,6 +37,8 @@ import cn.ysk.cashier.dto.shop.TbShopInfoDto; import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria; import cn.ysk.cashier.mapper.shop.TbShopInfoMapper; import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -73,11 +76,10 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { private final TbPlussShopStaffRepository shopStaffRepository; @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); + public Map queryAll(TbShopInfoQueryCriteria criteria){ + Sort sort = Sort.by(Sort.Direction.DESC, "id"); + Pageable pageables = PageRequest.of(criteria.getPage(), criteria.getSize(), sort); + Page page = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageables); List content = page.getContent(); for (TbShopInfo data: content){ if (data.getProfiles() == null){ @@ -87,10 +89,10 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { return PageUtil.toPage(page); } - @Override - public List queryAll(TbShopInfoQueryCriteria criteria){ - return tbShopInfoMapper.toDto(tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); - } +// @Override +// public List queryAll(TbShopInfoQueryCriteria criteria){ +// return tbShopInfoMapper.toDto(tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); +// } @Override @Transactional @@ -178,6 +180,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { tbPlussShopStaff.setStatus(1); tbPlussShopStaff.setCreatedAt(Instant.now().toEpochMilli()); tbPlussShopStaff.setUpdatedAt(Instant.now().toEpochMilli()); + tbPlussShopStaff.setCode(save.getPhone()); shopStaffRepository.save(tbPlussShopStaff); if (resources.getRegisterCode() != null){ diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 8133ee26..433e1ad0 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -106,6 +106,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { resources.setCreatedAt(Instant.now().toEpochMilli()); resources.setUpdatedAt(Instant.now().toEpochMilli()); resources.setQrcode(""); + resources.setStatus("closed"); return tbShopTableRepository.save(resources); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/product/TbProductService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/product/TbProductService.java index da71364e..906c7bbd 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/product/TbProductService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/product/TbProductService.java @@ -36,17 +36,16 @@ public interface TbProductService { /** * 查询数据分页 * @param criteria 条件 - * @param pageable 分页参数 * @return Map */ - Map queryAll(TbProductQueryCriteria criteria, Pageable pageable); + Map queryAll(TbProductQueryCriteria criteria); /** * 查询所有数据不分页 * @param criteria 条件参数 * @return List */ - List queryAll(TbProductQueryCriteria criteria); + List queryAlls(TbProductQueryCriteria criteria); /** * 根据ID查询 diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopInfoService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopInfoService.java index 42fb066f..20c2b410 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopInfoService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopInfoService.java @@ -35,17 +35,16 @@ public interface TbShopInfoService { /** * 查询数据分页 * @param criteria 条件 - * @param pageable 分页参数 * @return Map */ - Map queryAll(TbShopInfoQueryCriteria criteria, Pageable pageable); + Map queryAll(TbShopInfoQueryCriteria criteria); /** * 查询所有数据不分页 * @param criteria 条件参数 * @return List */ - List queryAll(TbShopInfoQueryCriteria criteria); +// List queryAll(TbShopInfoQueryCriteria criteria); /** * 根据ID查询 diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductVo.java index 6b67ff6d..a75a2a64 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductVo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductVo.java @@ -66,7 +66,7 @@ public class TbProductVo { private String shareImg; - private String images; + private List images; private String video; diff --git a/eladmin-system/src/main/resources/config/application.yml b/eladmin-system/src/main/resources/config/application.yml index afe3ee47..f5e14942 100644 --- a/eladmin-system/src/main/resources/config/application.yml +++ b/eladmin-system/src/main/resources/config/application.yml @@ -5,7 +5,7 @@ spring: freemarker: check-template-location: false profiles: - active: @env@ + active: dev jackson: time-zone: GMT+8