From 90c0a9bfdf632a4290803fbee335cb8018e8ad58 Mon Sep 17 00:00:00 2001 From: dimengzhe <251008545@qq.com> Date: Wed, 15 Mar 2023 18:13:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B93-15=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BuildWuyeCompanyController.java | 7 ++++++- .../PmsProductAttributeCategoryController.java | 2 +- .../PmsProductCategoryController.java | 15 +++++++++++++++ .../service/IPmsProductCategoryService.java | 4 ++++ .../impl/PmsProductCategoryServiceImpl.java | 10 ++++++++++ .../build/entity/BuildWuyeCompany.java | 5 +++++ .../pms/mapper/PmsProductCategoryMapper.java | 5 +++++ .../mapper/pms/PmsProductCategoryMapper.xml | 8 ++++++++ .../service/impl/PmsProductServiceImpl.java | 18 +++++++++++++----- .../mallplus/single/SingePmsController.java | 6 +++++- 10 files changed, 72 insertions(+), 8 deletions(-) diff --git a/mallplus-admin/src/main/java/com/zscat/mallplus/build/controller/BuildWuyeCompanyController.java b/mallplus-admin/src/main/java/com/zscat/mallplus/build/controller/BuildWuyeCompanyController.java index d0ce09d..6e37026 100644 --- a/mallplus-admin/src/main/java/com/zscat/mallplus/build/controller/BuildWuyeCompanyController.java +++ b/mallplus-admin/src/main/java/com/zscat/mallplus/build/controller/BuildWuyeCompanyController.java @@ -7,6 +7,7 @@ import com.zscat.mallplus.annotation.SysLog; import com.zscat.mallplus.build.entity.BuildWuyeCompany; import com.zscat.mallplus.enums.StatusEnum; import com.zscat.mallplus.util.EasyPoiUtils; +import com.zscat.mallplus.util.StringUtils; import com.zscat.mallplus.utils.CommonResult; import com.zscat.mallplus.utils.ValidatorUtils; import io.swagger.annotations.ApiOperation; @@ -45,7 +46,11 @@ public class BuildWuyeCompanyController { @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize ) { try { - return new CommonResult().success(IBuildWuyeCompanyService.page(new Page(pageNum, pageSize), new QueryWrapper<>(entity))); + QueryWrapper qw = new QueryWrapper<>(); + if(StringUtils.isNotBlank(entity.getKeyword())){ + qw.like("name",entity.getKeyword()); + } + return new CommonResult().success(IBuildWuyeCompanyService.page(new Page(pageNum, pageSize), qw)); } catch (Exception e) { log.error("根据条件查询所有物业公司表列表:%s", e.getMessage(), e); } diff --git a/mallplus-admin/src/main/java/com/zscat/mallplus/pms/controller/PmsProductAttributeCategoryController.java b/mallplus-admin/src/main/java/com/zscat/mallplus/pms/controller/PmsProductAttributeCategoryController.java index 3d2a4aa..3f3664d 100644 --- a/mallplus-admin/src/main/java/com/zscat/mallplus/pms/controller/PmsProductAttributeCategoryController.java +++ b/mallplus-admin/src/main/java/com/zscat/mallplus/pms/controller/PmsProductAttributeCategoryController.java @@ -62,7 +62,7 @@ public class PmsProductAttributeCategoryController { @SysLog(MODULE = "pms", REMARK = "保存产品属性分类表") @ApiOperation("保存产品属性分类表") @PostMapping(value = "/create") - @PreAuthorize("hasAuthority('pms:PmsProductAttributeCategory:create')") +// @PreAuthorize("hasAuthority('pms:PmsProductAttributeCategory:create')") public Object create(@RequestParam String name, @RequestParam(value = "pic", required = false) String pic, @RequestParam(value = "showIndex", required = false) Integer showIndex, diff --git a/mallplus-admin/src/main/java/com/zscat/mallplus/pms/controller/PmsProductCategoryController.java b/mallplus-admin/src/main/java/com/zscat/mallplus/pms/controller/PmsProductCategoryController.java index dc40018..eeeead7 100644 --- a/mallplus-admin/src/main/java/com/zscat/mallplus/pms/controller/PmsProductCategoryController.java +++ b/mallplus-admin/src/main/java/com/zscat/mallplus/pms/controller/PmsProductCategoryController.java @@ -66,6 +66,13 @@ public class PmsProductCategoryController { @PreAuthorize("hasAuthority('pms:PmsProductCategory:create')") public Object savePmsProductCategory(@RequestBody PmsProductCategory entity) { try { + //查询是否存在相同级别的相同名称的分类 + Long parentId = entity.getParentId(); + String name = entity.getName(); + int count = IPmsProductCategoryService.selectCountByNameAndLevel(parentId,name); + if(count>0){ + return new CommonResult().failed("该分类已存在"); + } if (IPmsProductCategoryService.saveAnd(entity)) { return new CommonResult().success(); } @@ -82,6 +89,14 @@ public class PmsProductCategoryController { @PreAuthorize("hasAuthority('pms:PmsProductCategory:update')") public Object updatePmsProductCategory(@RequestBody PmsProductCategory entity) { try { + //查询是否存在相同级别的相同名称的分类 + Long parentId = entity.getParentId(); + String name = entity.getName(); + Long id = entity.getId(); + int count = IPmsProductCategoryService.selectCountByNameAndLevelId(parentId,name,id); + if(count>0){ + return new CommonResult().failed("该分类已存在"); + } if (IPmsProductCategoryService.updateAnd(entity)) { return new CommonResult().success(); } diff --git a/mallplus-admin/src/main/java/com/zscat/mallplus/pms/service/IPmsProductCategoryService.java b/mallplus-admin/src/main/java/com/zscat/mallplus/pms/service/IPmsProductCategoryService.java index b8f7158..543e41c 100644 --- a/mallplus-admin/src/main/java/com/zscat/mallplus/pms/service/IPmsProductCategoryService.java +++ b/mallplus-admin/src/main/java/com/zscat/mallplus/pms/service/IPmsProductCategoryService.java @@ -27,4 +27,8 @@ public interface IPmsProductCategoryService extends IService boolean updateAnd(PmsProductCategory entity); boolean saveAnd(PmsProductCategory entity); + + int selectCountByNameAndLevel(Long parentId, String name); + + int selectCountByNameAndLevelId(Long parentId, String name, Long id); } diff --git a/mallplus-admin/src/main/java/com/zscat/mallplus/pms/service/impl/PmsProductCategoryServiceImpl.java b/mallplus-admin/src/main/java/com/zscat/mallplus/pms/service/impl/PmsProductCategoryServiceImpl.java index 753934e..3c97fb9 100644 --- a/mallplus-admin/src/main/java/com/zscat/mallplus/pms/service/impl/PmsProductCategoryServiceImpl.java +++ b/mallplus-admin/src/main/java/com/zscat/mallplus/pms/service/impl/PmsProductCategoryServiceImpl.java @@ -103,6 +103,16 @@ public class PmsProductCategoryServiceImpl extends ServiceImpl { List listWithChildren(); + + int selectCountByNameAndLevel(@Param("parentId") Long parentId, @Param("name") String name); + + int selectCountByNameAndLevelId(@Param("parentId") Long parentId, @Param("name") String name, @Param("id") Long id); } diff --git a/mallplus-mbg/src/main/resources/mapper/pms/PmsProductCategoryMapper.xml b/mallplus-mbg/src/main/resources/mapper/pms/PmsProductCategoryMapper.xml index 70c065c..8d4192a 100644 --- a/mallplus-mbg/src/main/resources/mapper/pms/PmsProductCategoryMapper.xml +++ b/mallplus-mbg/src/main/resources/mapper/pms/PmsProductCategoryMapper.xml @@ -39,4 +39,12 @@ from pms_product_category c1 left join pms_product_category c2 on c1.id = c2.parent_id where c1.parent_id = 0 + + + + diff --git a/mallplus-portal/src/main/java/com/zscat/mallplus/pms/service/impl/PmsProductServiceImpl.java b/mallplus-portal/src/main/java/com/zscat/mallplus/pms/service/impl/PmsProductServiceImpl.java index 70b6efd..c95ad1f 100644 --- a/mallplus-portal/src/main/java/com/zscat/mallplus/pms/service/impl/PmsProductServiceImpl.java +++ b/mallplus-portal/src/main/java/com/zscat/mallplus/pms/service/impl/PmsProductServiceImpl.java @@ -171,13 +171,21 @@ public class PmsProductServiceImpl extends ServiceImpl valueList = productAttributeValueMapper.selectList(new QueryWrapper().eq("product_id", goods.getId())); List productAttributeValueList = new ArrayList<>(); List attributeValueList = new ArrayList<>(); - for (PmsProductAttributeValue attributeValue : valueList) { - if (attributeValue.getType() == 1) { - productAttributeValueList.add(attributeValue); - } else { - attributeValueList.add(attributeValue); + valueList.removeAll(Collections.singleton(null)); + if(!valueList.isEmpty()){ + for (PmsProductAttributeValue attributeValue : valueList) { + if(attributeValue.getType() != null){ + if (attributeValue.getType() == 1) { + productAttributeValueList.add(attributeValue); + } else { + attributeValueList.add(attributeValue); + } + }else{ + attributeValueList.add(attributeValue); + } } } + param.setProductAttributeValueList(productAttributeValueList); param.setProductCanShuValueList(attributeValueList); diff --git a/mallplus-portal/src/main/java/com/zscat/mallplus/single/SingePmsController.java b/mallplus-portal/src/main/java/com/zscat/mallplus/single/SingePmsController.java index 62e01b2..3c46ec2 100644 --- a/mallplus-portal/src/main/java/com/zscat/mallplus/single/SingePmsController.java +++ b/mallplus-portal/src/main/java/com/zscat/mallplus/single/SingePmsController.java @@ -909,7 +909,11 @@ public class SingePmsController extends ApiBaseAction { List ids = new ArrayList<>(); ids.add(1L); ids.add(0L); - List categories = categoryMapper.selectList(new QueryWrapper().in("level", ids)); + QueryWrapper qw = new QueryWrapper<>(); + qw.in("level", ids); + qw.orderByAsc("sort"); + qw.eq("show_status",1); + List categories = categoryMapper.selectList(qw); for (PmsProductCategory v : categories) { if (v.getLevel() == 0) { ProductTypeVo vo = new ProductTypeVo();