From 414ab09bd855b757ae7d20c8115155e32f3fb1d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98mahaoran=E2=80=99?= <2570310046@qq.com> Date: Sat, 16 Nov 2024 09:33:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=AC=A1=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/muyu/product/domain/CategoryInfo.java | 3 ++ .../controller/AttributeGroupController.java | 11 +++++++ .../controller/CategoryInfoController.java | 1 + .../controller/RuleInfoController.java | 21 +++++++++++++ .../mapper/AsAttributeGroupMapper.java | 1 + .../product/mapper/CategoryInfoMapper.java | 11 ++++++- .../product/mapper/RuleAttrInfoMapper.java | 8 +++-- .../service/AttributeGroupService.java | 4 +++ .../muyu/product/service/RuleInfoService.java | 4 +++ .../impl/AttributeGroupServiceImpl.java | 11 +++++++ .../service/impl/CategoryInfoServiceImpl.java | 30 +++++++++++++++---- .../service/impl/RuleInfoServiceImpl.java | 29 ++++++++++++++++++ .../mapper/product/AsAttributeGroupMapper.xml | 3 ++ .../mapper/product/CategoryInfoMapper.xml | 30 +++++++++++++++---- .../mapper/product/RuleAttrInfoMapper.xml | 6 ++++ 15 files changed, 159 insertions(+), 14 deletions(-) diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/CategoryInfo.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/CategoryInfo.java index b2b2f01..4910fdd 100644 --- a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/CategoryInfo.java +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/CategoryInfo.java @@ -17,6 +17,7 @@ import com.muyu.product.domain.req.CategoryInfoEditReq; import com.muyu.common.core.web.domain.TreeEntity; import java.util.Date; +import java.util.List; import java.util.function.Function; import java.util.function.Supplier; @@ -62,6 +63,8 @@ public class CategoryInfo extends TreeEntity { @ApiModelProperty(name = "介绍", value = "介绍") private String introduction; + + /** * 查询构造器 */ diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/AttributeGroupController.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/AttributeGroupController.java index b63216e..e8b6e6a 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/AttributeGroupController.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/AttributeGroupController.java @@ -128,6 +128,17 @@ public class AttributeGroupController extends BaseController { return toAjax(attributeGroupService.updateById(AttributeGroup.editBuild(id,attributeGroupEditReq))); } + /** + * 修改状态 + */ + @Log(title = "属性组", businessType = BusinessType.UPDATE) + @PutMapping("updStatus") + @ApiOperation("修改状态") + public Result updStatus(String states,Long id) { + return attributeGroupService.updateStatus(states, id); + } + + /** * 删除属性组 */ diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/CategoryInfoController.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/CategoryInfoController.java index 006326e..d00afb8 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/CategoryInfoController.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/CategoryInfoController.java @@ -78,6 +78,7 @@ public class CategoryInfoController extends BaseController { @GetMapping(value = "/{id}") @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class) public Result getInfo(@PathVariable("id") Long id) { + return Result.success(categoryInfoService.getById(id)); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/RuleInfoController.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/RuleInfoController.java index 2966094..424498e 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/RuleInfoController.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/RuleInfoController.java @@ -106,6 +106,27 @@ public class RuleInfoController extends BaseController { return toAjax(ruleInfoService.updateById(RuleInfo.editBuild(id,ruleInfoEditReq))); } + /** + * 校验是否存在商品信息 + */ + + @GetMapping("have") + @ApiOperation("校验是否存在商品信息") + public Result have(Long id) { + Result have = ruleInfoService.have(id); + return have; + } + + /** + * 修改状态 + */ + @Log(title = "属性组", businessType = BusinessType.UPDATE) + @PutMapping("updStatus") + @ApiOperation("修改状态") + public Result updStatus(String status,Long id) { + return ruleInfoService.updateStatus(status, id); + } + /** * 删除商品规格 */ diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsAttributeGroupMapper.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsAttributeGroupMapper.java index 64da537..2634a58 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsAttributeGroupMapper.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/AsAttributeGroupMapper.java @@ -41,4 +41,5 @@ public interface AsAttributeGroupMapper extends BaseMapper { */ void add(@Param("groupId") Long groupId , @Param("list") List list); + void updStatus(@Param("states") String states, @Param("id") Long id); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/CategoryInfoMapper.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/CategoryInfoMapper.java index 397a209..0483fba 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/CategoryInfoMapper.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/CategoryInfoMapper.java @@ -21,11 +21,20 @@ public interface CategoryInfoMapper extends BaseMapper { void delArandIdList(Long id); - void addAttributeGroupId(@Param("id") Long id, @Param("attributeGroupId") Long attributeGroupId); +// void addAttributeGroupId(@Param("id") Long id, @Param("attributeGroupId") Long attributeGroupId); + void attributeGroupIdList(@Param("id") Long id, @Param("aLong") Long aLong); void addAttributeIdList(@Param("id") Long id, @Param("attributeId") Long attributeId); void addArandIdList(@Param("id") Long id, @Param("brandId") Long brandId); Integer selectByPid(String ids); + + Integer selectAsCategoryBrand(String ids); + + Integer selectAsCategoryAttribute(String ids); + + Integer selectAsCategoryAttributeGroup(String ids); + + } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/RuleAttrInfoMapper.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/RuleAttrInfoMapper.java index 25e31cc..4ea0973 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/RuleAttrInfoMapper.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/RuleAttrInfoMapper.java @@ -3,8 +3,7 @@ package com.muyu.product.mapper; import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.muyu.product.domain.RuleAttrInfo; -import com.muyu.product.domain.RuleInfo; -import com.muyu.product.domain.req.RuleInfoEditReq; + import com.muyu.product.domain.resp.RuleInfoResp; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -24,4 +23,9 @@ public interface RuleAttrInfoMapper extends BaseMapper { void add(@Param("id") Long id, @Param("name") String name, @Param("attrValue") String attrValue); + void updateStatus(@Param("status") String status, @Param("id") Long id); + + Integer selectByAttributeGroupCount(Long id); + + } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AttributeGroupService.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AttributeGroupService.java index eabf31b..f8bf983 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AttributeGroupService.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AttributeGroupService.java @@ -67,4 +67,8 @@ public interface AttributeGroupService extends IService { AttributeGroupUpdResp getUpdById(Long id); Result updateAttibuteGroup(Long id, AttributeGroupEditReq attributeGroupEditReq); + + Result updateStatus(String status,Long id); + + } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/RuleInfoService.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/RuleInfoService.java index f8b2a9e..e4c6912 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/RuleInfoService.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/RuleInfoService.java @@ -44,4 +44,8 @@ public interface RuleInfoService extends IService { Result upd(Long id, RuleInfoEditReq ruleInfoEditReq); + Result updateStatus(String status, Long id); + + Result have(Long id); + } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AttributeGroupServiceImpl.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AttributeGroupServiceImpl.java index 7331cbc..f2cd42c 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AttributeGroupServiceImpl.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AttributeGroupServiceImpl.java @@ -169,4 +169,15 @@ public class AttributeGroupServiceImpl extends ServiceImpl attributeGroupIdList = categoryInfoEditReq.getAttributeGroupIdList(); - for (Long aLong : attributeGroupIdList) { - categoryInfoMapper.addAttributeGroupId(id,aLong); - } + categoryInfoMapper.delAttributeIdList(id); List attributeIdList = categoryInfoEditReq.getAttributeIdList(); for (Long aLong : attributeIdList) { categoryInfoMapper.addAttributeIdList(id,aLong); } + + categoryInfoMapper.delArandIdList(id); List brandIdList = categoryInfoEditReq.getBrandIdList(); for (Long aLong : brandIdList) { categoryInfoMapper.addArandIdList(id,aLong); } + + categoryInfoMapper.delAttributeGroupId(id); + List attributeGroupIdList = categoryInfoEditReq.getAttributeGroupIdList(); + for (Long aLong : attributeGroupIdList) { + categoryInfoMapper.attributeGroupIdList(id,aLong); + } + return Result.success(0,"修改成功"); } @@ -303,6 +308,21 @@ public class CategoryInfoServiceImpl extends ServiceImpl0){ return Result.error(400,"该数据存在子集,禁止删除"); } + Integer countAsCategoryBrand = categoryInfoMapper.selectAsCategoryBrand(ids); + if(countAsCategoryBrand>0){ + return Result.error(400,"该数据存在关联关系,禁止删除"); + } + + Integer countAsCategoryAttribute = categoryInfoMapper.selectAsCategoryAttribute(ids); + if(countAsCategoryAttribute>0){ + return Result.error(400,"该数据存在关联关系,禁止删除"); + } + + Integer countAsCategoryAttributeGroup = categoryInfoMapper.selectAsCategoryAttributeGroup(ids); + if(countAsCategoryAttributeGroup>0){ + return Result.error(400,"该数据存在关联关系,禁止删除"); + } + categoryInfoMapper.deleteById(ids); return Result.success(200,"删除成功"); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/RuleInfoServiceImpl.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/RuleInfoServiceImpl.java index 5f62b81..e1d372f 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/RuleInfoServiceImpl.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/RuleInfoServiceImpl.java @@ -7,6 +7,7 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.muyu.common.core.domain.Result; @@ -48,6 +49,9 @@ public class RuleInfoServiceImpl extends ServiceImpl @Autowired private RuleAttrInfoMapper ruleAttrInfoMapper; + @Autowired + private RuleInfoMapper ruleInfoMapper; + /** * 查询商品规格列表 * @@ -100,6 +104,8 @@ public class RuleInfoServiceImpl extends ServiceImpl */ @Override public TableDataInfo queryList (RuleInfoQueryReq ruleInfoQueryReq) { + + List list = this.list(RuleInfo.queryBuild(ruleInfoQueryReq)); List ruleInfoRespList = list.stream() .map(ruleInfo -> RuleInfoResp.infoBuild(ruleInfo, ruleId -> { @@ -131,6 +137,9 @@ public class RuleInfoServiceImpl extends ServiceImpl @Transactional @Override public Result upd(Long id, RuleInfoEditReq ruleInfoEditReq) { + + + ruleAttrInfoMapper.del(id); List ruleAttrList = ruleInfoEditReq.getRuleAttrList(); for (RuleAttrAddModel ruleAttrAddModel : ruleAttrList) { @@ -144,4 +153,24 @@ public class RuleInfoServiceImpl extends ServiceImpl return Result.success(0,"修改成功"); } + + @Override + public Result updateStatus(String status, Long id) { + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(RuleInfo::getId,id); + updateWrapper.set(RuleInfo::getStatus,status); + ruleInfoMapper.update(null,updateWrapper); +// ruleAttrInfoMapper.updateStatus(status,id); + return Result.success(0,"修改成功"); + } + + @Override + public Result have(Long id) { + Integer count = ruleAttrInfoMapper.selectByAttributeGroupCount(id); + if(count>0){ + + return Result.error(400,"有商品关联禁止操作"); + } + return Result.success(count); + } } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsAttributeGroupMapper.xml b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsAttributeGroupMapper.xml index dc30ba4..3faace0 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsAttributeGroupMapper.xml +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/AsAttributeGroupMapper.xml @@ -25,6 +25,9 @@ + + update attribute_group set states = #{states} where id = #{id} + delete from as_attribute_group where group_id =#{groupId} diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/CategoryInfoMapper.xml b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/CategoryInfoMapper.xml index df9c7f9..880ad9b 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/CategoryInfoMapper.xml +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/CategoryInfoMapper.xml @@ -21,28 +21,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select id, name, image, parent_id, start, introduction, remark, create_by, create_time, update_by, update_time from category_info - - INSERT INTO `as_category_attribute_group` (`category_id`, `attribute_group_id`) values - (#{id},#{attributeGroupId}) - + - INSERT INTO `as_category_attribute` (`category_id`, `attribute_id`) values - (#{id},#{attributeId}) + INSERT INTO `as_category_attribute` ( `category_id`, `attribute_id`) + VALUES (#{id},#{attributeId}); + INSERT INTO `as_category_brand` (`category_id`, `brand_id`) values (#{id},#{brandId}) + + INSERT INTO `as_category_attribute_group` ( `category_id`, `attribute_group_id`) + VALUES (#{id},#{aLong}); + + delete from as_category_attribute where category_id = #{id} + delete from as_category_brand where category_id = #{id} + delete from as_category_attribute_group where category_id = #{id} + + + + + + + diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/RuleAttrInfoMapper.xml b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/RuleAttrInfoMapper.xml index 6d1e3d9..26d0b2b 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/RuleAttrInfoMapper.xml +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/RuleAttrInfoMapper.xml @@ -24,6 +24,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + update rule_info set status = #{status} where id = #{id} + + select id, rule_id, name, attr_value, remark, create_by, create_time, update_by, update_time from rule_attr_info