From db249fb121893fe74f42984d3636c163c3c0a486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3=E5=B9=B3?= <14767849+liuehping@user.noreply.gitee.com> Date: Wed, 13 Nov 2024 20:35:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=BB=84=E7=9A=84=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/req/AttributeGroupEditReq.java | 4 +++- .../controller/AttributeGroupController.java | 3 ++- .../mapper/AsAttributeGroupMapper.java | 5 ++++ .../service/AsAttributeGroupService.java | 6 +++++ .../service/AttributeGroupService.java | 10 ++++++++ .../impl/AsAttributeGroupServiceImpl.java | 16 +++++++++++++ .../impl/AttributeGroupServiceImpl.java | 23 +++++++++++++++++++ .../mapper/product/AsAttributeGroupMapper.xml | 6 +++++ 8 files changed, 71 insertions(+), 2 deletions(-) diff --git a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/AttributeGroupEditReq.java b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/AttributeGroupEditReq.java index 35a1b47..13b304e 100644 --- a/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/AttributeGroupEditReq.java +++ b/muyu-modules/muyu-product/muyu-product-common/src/main/java/com/muyu/product/domain/req/AttributeGroupEditReq.java @@ -1,6 +1,8 @@ package com.muyu.product.domain.req; import java.util.Date; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; @@ -32,6 +34,6 @@ public class AttributeGroupEditReq extends BaseEntity { /** 状态 */ @ApiModelProperty(name = "状态", value = "状态", required = true) private String states; - + private List attributeList; } 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 3a548c8..9678919 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 @@ -101,7 +101,8 @@ public class AttributeGroupController extends BaseController { @PutMapping("/{id}") @ApiOperation("修改属性组") public Result edit(@PathVariable Long id, @RequestBody AttributeGroupEditReq attributeGroupEditReq) { - return toAjax(attributeGroupService.updateById(AttributeGroup.editBuild(id,attributeGroupEditReq))); +// return toAjax(attributeGroupService.updateById(AttributeGroup.editBuild(id,attributeGroupEditReq))); + return attributeGroupService.edit(id, attributeGroupEditReq); } /** 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 1b420df..dd6a93f 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 @@ -3,6 +3,8 @@ package com.muyu.product.mapper; import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.muyu.product.domain.AsAttributeGroup; +import com.muyu.product.domain.req.AttributeInfoSaveReq; +import org.apache.ibatis.annotations.Param; /** * 属性与组中间Mapper接口 @@ -12,4 +14,7 @@ import com.muyu.product.domain.AsAttributeGroup; */ public interface AsAttributeGroupMapper extends BaseMapper { + void shanchu(Long id); + + void insertBatch(@Param("id") Long id, @Param("id1") Long id1); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsAttributeGroupService.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsAttributeGroupService.java index db672c4..d0169ad 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsAttributeGroupService.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/AsAttributeGroupService.java @@ -3,6 +3,8 @@ package com.muyu.product.service; import java.util.List; import com.muyu.product.domain.AsAttributeGroup; import com.baomidou.mybatisplus.extension.service.IService; +import com.muyu.product.domain.req.AttributeGroupEditReq; +import com.muyu.product.domain.req.AttributeInfoSaveReq; /** * 属性与组中间Service接口 @@ -19,4 +21,8 @@ public interface AsAttributeGroupService extends IService { */ public List list(AsAttributeGroup asAttributeGroup); + void delete(Long id); + + + void insertBatch(Long id, Long id1); } 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 00b7511..de33f22 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 @@ -2,11 +2,13 @@ package com.muyu.product.service; import java.util.List; +import com.muyu.common.core.domain.Result; import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.product.domain.AttributeGroup; import com.baomidou.mybatisplus.extension.service.IService; import com.muyu.product.domain.AttributeInfo; import com.muyu.product.domain.model.AttributeGroupSaveModel; +import com.muyu.product.domain.req.AttributeGroupEditReq; import com.muyu.product.domain.resp.AttributeGroupPageResp; import com.muyu.product.domain.resp.AttributeGroupUpdResp; @@ -49,4 +51,12 @@ public interface AttributeGroupService extends IService { */ AttributeGroupUpdResp getUpdById(Long id); + /** + * 修改 + * @param id + * @param attributeGroupEditReq + * @return + */ + Result edit(Long id, AttributeGroupEditReq attributeGroupEditReq); + } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AsAttributeGroupServiceImpl.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AsAttributeGroupServiceImpl.java index 7e2e186..944203c 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AsAttributeGroupServiceImpl.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/AsAttributeGroupServiceImpl.java @@ -3,7 +3,9 @@ package com.muyu.product.service.impl; import java.util.List; import com.muyu.common.core.utils.ObjUtils; +import com.muyu.product.domain.req.AttributeInfoSaveReq; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.muyu.product.mapper.AsAttributeGroupMapper; import com.muyu.product.domain.AsAttributeGroup; @@ -21,6 +23,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @Service public class AsAttributeGroupServiceImpl extends ServiceImpl implements AsAttributeGroupService { + @Autowired + private AsAttributeGroupMapper asAttributeGroupMapper; /** * 查询属性与组中间列表 * @@ -42,4 +46,16 @@ public class AsAttributeGroupServiceImpl extends ServiceImpl edit(Long id, AttributeGroupEditReq attributeGroupEditReq) { + //删除旧数据 + asAttributeGroupService.delete(id); + List attributeList = attributeGroupEditReq.getAttributeList(); + for (AttributeInfoSaveReq attributeInfoSaveReq : attributeList) { + //添加新数据 + asAttributeGroupService.insertBatch(attributeInfoSaveReq.getId(),id); + } + + return Result.success(); + } } 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 05c468d..5b9dc03 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 @@ -18,4 +18,10 @@ select id, group_id, attribute_id, remark, create_by, create_time, update_by, update_time from as_attribute_group + + insert into as_attribute_group(group_id,attribute_id) values (#{id1},#{id}) + + + delete from as_attribute_group where group_id=#{id} +