第一次优化
parent
b8ec6ad07d
commit
987cc25fc8
|
@ -49,6 +49,9 @@ public class AttributeGroup extends BaseEntity {
|
|||
@ApiModelProperty(name = "状态", value = "状态", required = true)
|
||||
private String states;
|
||||
|
||||
@Excel(name = "备注")
|
||||
@ApiModelProperty(name = "备注", value = "备注", required = true)
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
|
|
|
@ -30,6 +30,8 @@ public class RuleAttrAddModel extends BaseEntity {
|
|||
*/
|
||||
private String name;
|
||||
|
||||
private String attrValue;
|
||||
|
||||
/**
|
||||
* 规格属性值集合
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package com.muyu.product.domain.req;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.product.domain.AttributeGroup;
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -33,5 +38,7 @@ public class AttributeGroupEditReq extends BaseEntity {
|
|||
@ApiModelProperty(name = "状态", value = "状态", required = true)
|
||||
private String states;
|
||||
|
||||
private List<AttributeInfo> attributeList;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.product.domain.req;
|
||||
|
||||
import com.muyu.product.domain.RuleInfo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -8,6 +9,8 @@ import lombok.experimental.SuperBuilder;
|
|||
import io.swagger.annotations.*;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品规格对象 rule_info
|
||||
*
|
||||
|
@ -31,4 +34,6 @@ public class RuleInfoEditReq extends BaseEntity {
|
|||
@ApiModelProperty(name = "规格状态", value = "规格状态")
|
||||
private String status;
|
||||
|
||||
private List<RuleInfo> ruleInfoList;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.muyu.product.domain.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AddAttributeGroupResp {
|
||||
private Long groupId;
|
||||
private Integer attributeId;
|
||||
|
||||
private List<AddAttributeGroupResp> list;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.muyu.product.domain.resp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AttributeGroupUpdResp {
|
||||
/** 属性组编号 */
|
||||
private Long id;
|
||||
|
||||
/** 组名称 */
|
||||
private String name;
|
||||
|
||||
/** 状态 */
|
||||
private String states;
|
||||
|
||||
private List<AttributeInfo> attributeList;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.muyu.product.domain.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class FindByIdResp {
|
||||
private Integer id;//属性组编号
|
||||
private String name;//组名称
|
||||
private String states;//状态
|
||||
private String createBy;//创建人
|
||||
private Date createTime;//创建时间
|
||||
private String updateBy;//更新人
|
||||
private Date updateTime;//更新时间
|
||||
private String remark;//备注
|
||||
|
||||
private String attrId;//属性ID
|
||||
private String attrName;//属性名称
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.muyu.product.domain.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class RuleAttrUpdResp {
|
||||
|
||||
private Long id;
|
||||
/**
|
||||
* 规格属性名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 规格属性值集合
|
||||
*/
|
||||
private List<String> valueList;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -4,7 +4,10 @@ import java.util.List;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.product.domain.model.AttributeGroupSaveModel;
|
||||
import com.muyu.product.domain.resp.AddAttributeGroupResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
|
||||
import com.muyu.product.domain.resp.FindByIdResp;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -74,10 +77,32 @@ public class AttributeGroupController extends BaseController {
|
|||
@RequiresPermissions("product:attributeGroup:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<AttributeGroup> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(attributeGroupService.getById(id));
|
||||
public Result<AttributeGroupUpdResp> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(attributeGroupService.getUpdById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 回显
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/findById/{id}")
|
||||
public Result<FindByIdResp> findById(@PathVariable Integer id){
|
||||
return Result.success(attributeGroupService.findById(id));
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * 修改属性
|
||||
// * @param
|
||||
// * @return
|
||||
// */
|
||||
// @PostMapping("upd")
|
||||
// public Result upd(@RequestBody AddAttributeGroupResp addAttributeGroupResp){
|
||||
// Result upd = attributeGroupService.upd(addAttributeGroupResp);
|
||||
// return upd;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 新增属性组
|
||||
*/
|
||||
|
@ -99,6 +124,7 @@ public class AttributeGroupController extends BaseController {
|
|||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改属性组")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody AttributeGroupEditReq attributeGroupEditReq) {
|
||||
attributeGroupService.updateAttibuteGroup(id, attributeGroupEditReq);
|
||||
return toAjax(attributeGroupService.updateById(AttributeGroup.editBuild(id,attributeGroupEditReq)));
|
||||
}
|
||||
|
||||
|
|
|
@ -77,10 +77,12 @@ public class RuleInfoController extends BaseController {
|
|||
@RequiresPermissions("product:rule:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<RuleInfo> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(ruleInfoService.getById(id));
|
||||
public Result<RuleInfoResp> getInfo(@PathVariable("id") Long id) {
|
||||
Result<RuleInfoResp> ruleById = ruleInfoService.getRuleById(id);
|
||||
return ruleById;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增商品规格
|
||||
*/
|
||||
|
@ -100,6 +102,7 @@ public class RuleInfoController extends BaseController {
|
|||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改商品规格")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody RuleInfoEditReq ruleInfoEditReq) {
|
||||
ruleInfoService.upd(id,ruleInfoEditReq);
|
||||
return toAjax(ruleInfoService.updateById(RuleInfo.editBuild(id,ruleInfoEditReq)));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,13 @@ package com.muyu.product.mapper;
|
|||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.product.domain.AsAttributeGroup;
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import com.muyu.product.domain.resp.AddAttributeGroupResp;
|
||||
import com.muyu.product.domain.resp.FindByIdResp;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 属性与组中间Mapper接口
|
||||
|
@ -10,6 +16,29 @@ import com.muyu.product.domain.AsAttributeGroup;
|
|||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface AsAttributeGroupMapper extends BaseMapper<AsAttributeGroup> {
|
||||
|
||||
/**
|
||||
* 回显已有属性
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
FindByIdResp findById(Integer id);
|
||||
|
||||
/**
|
||||
* 删除中间表已有属性
|
||||
* @param groupId
|
||||
* @return
|
||||
*/
|
||||
void del(Long groupId);
|
||||
|
||||
/**
|
||||
* 添加中间表已有属性
|
||||
* @param groupId
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
void add(@Param("groupId") Long groupId , @Param("list") List<AttributeInfo> list);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@ 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.resp.RuleInfoResp;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 规格详情Mapper接口
|
||||
|
@ -10,6 +14,13 @@ import com.muyu.product.domain.RuleAttrInfo;
|
|||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface RuleAttrInfoMapper extends BaseMapper<RuleAttrInfo> {
|
||||
|
||||
RuleInfoResp getRuleById(Long id);
|
||||
|
||||
void del(Long id);
|
||||
|
||||
void add(@Param("id") Long id, @Param("ruleInfoList") List<RuleInfo> ruleInfoList);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,12 +2,17 @@ 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.AddAttributeGroupResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
|
||||
import com.muyu.product.domain.resp.FindByIdResp;
|
||||
|
||||
/**
|
||||
* 属性组Service接口
|
||||
|
@ -39,4 +44,27 @@ public interface AttributeGroupService extends IService<AttributeGroup> {
|
|||
*/
|
||||
public Boolean save(AttributeGroupSaveModel attributeGroupSaveModel);
|
||||
|
||||
/**
|
||||
* 回显规格属性
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
FindByIdResp findById(Integer id);
|
||||
|
||||
|
||||
/**
|
||||
* 修改规格属性
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
// Result upd(AddAttributeGroupResp addAttributeGroupResp);
|
||||
|
||||
/**
|
||||
* 商品规格回显
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
AttributeGroupUpdResp getUpdById(Long id);
|
||||
|
||||
Result updateAttibuteGroup(Long id, AttributeGroupEditReq attributeGroupEditReq);
|
||||
}
|
||||
|
|
|
@ -2,10 +2,12 @@ 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.RuleInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||
import com.muyu.product.domain.req.RuleInfoEditReq;
|
||||
import com.muyu.product.domain.req.RuleInfoQueryReq;
|
||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||
|
||||
|
@ -32,4 +34,14 @@ public interface RuleInfoService extends IService<RuleInfo> {
|
|||
public boolean save(RuleInfoAddModel ruleInfoAddModel);
|
||||
|
||||
TableDataInfo<RuleInfoResp> queryList (RuleInfoQueryReq ruleInfoQueryReq);
|
||||
|
||||
/**
|
||||
* 回显
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Result<RuleInfoResp> getRuleById(Long id);
|
||||
|
||||
Result upd(Long id, RuleInfoEditReq ruleInfoEditReq);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,13 +3,19 @@ package com.muyu.product.service.impl;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.product.domain.AsAttributeGroup;
|
||||
import com.muyu.product.domain.AttributeGroup;
|
||||
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.AddAttributeGroupResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
|
||||
import com.muyu.product.domain.resp.FindByIdResp;
|
||||
import com.muyu.product.mapper.AsAttributeGroupMapper;
|
||||
import com.muyu.product.mapper.AttributeGroupMapper;
|
||||
import com.muyu.product.service.AsAttributeGroupService;
|
||||
import com.muyu.product.service.AttributeGroupService;
|
||||
|
@ -34,11 +40,14 @@ import java.util.stream.Stream;
|
|||
public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper, AttributeGroup> implements AttributeGroupService {
|
||||
|
||||
@Autowired
|
||||
private AsAttributeGroupService attributeGroupService;
|
||||
private AsAttributeGroupService asAttributeGroupService;
|
||||
|
||||
@Autowired
|
||||
private AttributeInfoService attributeInfoService;
|
||||
|
||||
@Autowired
|
||||
private AsAttributeGroupMapper asAttributeGroupMapper;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
|
@ -100,11 +109,64 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
|
|||
Long attributeGroupId = attributeGroup.getId();
|
||||
List<Long> attributeIdList = attributeGroupSaveModel.getAttributeIdList();
|
||||
|
||||
attributeGroupService.saveBatch(
|
||||
asAttributeGroupService.saveBatch(
|
||||
attributeIdList.stream()
|
||||
.map(attributeId -> AsAttributeGroup.buildGroup(attributeGroupId, attributeId))
|
||||
.toList()
|
||||
);
|
||||
return save;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FindByIdResp findById(Integer id) {
|
||||
return asAttributeGroupMapper.findById(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改规格属性
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
// @Transactional
|
||||
// @Override
|
||||
// public Result upd(AddAttributeGroupResp addAttributeGroupResp) {
|
||||
//// asAttributeGroupMapper.del(addAttributeGroupResp.getGroupId());
|
||||
//// asAttributeGroupMapper.add(addAttributeGroupResp.getGroupId(),addAttributeGroupResp.getList());
|
||||
// return Result.success(0,"修改成功");
|
||||
// }
|
||||
|
||||
/**
|
||||
* 商品规格属性回显
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AttributeGroupUpdResp getUpdById(Long id) {
|
||||
//查询编号
|
||||
AttributeGroup attributeGroup = this.getById(id);
|
||||
LambdaQueryWrapper<AsAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AsAttributeGroup::getGroupId, id);
|
||||
List<AsAttributeGroup> asAttributeGroups = asAttributeGroupService.list(queryWrapper);
|
||||
List<Long> attributeList = asAttributeGroups.stream()
|
||||
.map(AsAttributeGroup::getAttributeId)
|
||||
.toList();
|
||||
List<AttributeInfo> attributeInfoList = attributeInfoService.listByIds(attributeList);
|
||||
|
||||
return AttributeGroupUpdResp.builder()
|
||||
.id(attributeGroup.getId())
|
||||
.name(attributeGroup.getName())
|
||||
.states(attributeGroup.getStates())
|
||||
.attributeList(attributeInfoList).build();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public Result updateAttibuteGroup(Long id, AttributeGroupEditReq attributeGroupEditReq) {
|
||||
asAttributeGroupMapper.del(id);
|
||||
asAttributeGroupMapper.add(id,attributeGroupEditReq.getAttributeList());
|
||||
return Result.success(0,"修改成功");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,27 +5,32 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.text.Convert;
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.product.domain.RuleAttrInfo;
|
||||
import com.muyu.product.domain.*;
|
||||
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||
import com.muyu.product.domain.req.RuleInfoEditReq;
|
||||
import com.muyu.product.domain.req.RuleInfoQueryReq;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
|
||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||
import com.muyu.product.mapper.RuleAttrInfoMapper;
|
||||
import com.muyu.product.service.RuleAttrInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.product.mapper.RuleInfoMapper;
|
||||
import com.muyu.product.domain.RuleInfo;
|
||||
import com.muyu.product.service.RuleInfoService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 商品规格Service业务层处理
|
||||
|
@ -40,6 +45,9 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
|||
@Autowired
|
||||
private RuleAttrInfoService ruleAttrInfoService;
|
||||
|
||||
@Autowired
|
||||
private RuleAttrInfoMapper ruleAttrInfoMapper;
|
||||
|
||||
/**
|
||||
* 查询商品规格列表
|
||||
*
|
||||
|
@ -107,4 +115,24 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
|||
.total(isPage ? new PageInfo<>(list).getTotal() : 0)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<RuleInfoResp> getRuleById(Long id) {
|
||||
RuleInfoResp getRuleById = ruleAttrInfoMapper.getRuleById(id);
|
||||
List<RuleAttrAddModel> ruleAttrList = getRuleById.getRuleAttrList();
|
||||
for (RuleAttrAddModel ruleAttrAddModel : ruleAttrList) {
|
||||
String attrValue = ruleAttrAddModel.getAttrValue();
|
||||
String[] split = attrValue.split(",");
|
||||
ruleAttrAddModel.setValueList(List.of(split));
|
||||
}
|
||||
return Result.success(getRuleById);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public Result upd(Long id, RuleInfoEditReq ruleInfoEditReq) {
|
||||
ruleAttrInfoMapper.del(id);
|
||||
ruleAttrInfoMapper.add(id,ruleInfoEditReq.getRuleInfoList());
|
||||
return Result.success(0,"修改成功");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,4 +18,17 @@
|
|||
<sql id="selectAsAttributeGroupVo">
|
||||
select id, group_id, attribute_id, remark, create_by, create_time, update_by, update_time from as_attribute_group
|
||||
</sql>
|
||||
<insert id="add">
|
||||
INSERT INTO `as_attribute_group` ( `group_id`, `attribute_id`) VALUES
|
||||
<foreach collection="list" item="list" separator=",">
|
||||
(#{groupId},#{list.id})
|
||||
</foreach>
|
||||
|
||||
</insert>
|
||||
<delete id="del">
|
||||
delete from as_attribute_group where group_id =#{groupId}
|
||||
</delete>
|
||||
<select id="findById" resultType="com.muyu.product.domain.resp.FindByIdResp">
|
||||
SELECT attribute_group.id, attribute_group.`name`, attribute_group.states, GROUP_CONCAT(attribute_info.`name`) as attrName, GROUP_CONCAT(attribute_info.id) as attrId FROM attribute_group LEFT JOIN as_attribute_group ON attribute_group.id = as_attribute_group.group_id LEFT JOIN attribute_info ON attribute_info.id = as_attribute_group.attribute_id where attribute_group.id = #{id} GROUP BY attribute_group.id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -16,7 +16,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.muyu.product.domain.resp.RuleInfoResp" id="RuleAttrInfo">
|
||||
<result property="id" column="rid" />
|
||||
<result property="name" column="name" />
|
||||
<collection property="ruleAttrList" ofType="com.muyu.product.domain.model.RuleAttrAddModel">
|
||||
<result property="name" column="rname" />
|
||||
<result property="attrValue" column="attr_value"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="getRuleById" resultMap="RuleAttrInfo">
|
||||
SELECT
|
||||
rule_info.`id` AS rid,
|
||||
rule_info.`name`,
|
||||
rule_attr_info.`name` AS rname,
|
||||
attr_value
|
||||
FROM
|
||||
rule_info
|
||||
INNER JOIN rule_attr_info ON rule_info.id = rule_attr_info.rule_id
|
||||
WHERE rule_info.`id`=#{id}
|
||||
</select>
|
||||
|
||||
<sql id="selectRuleAttrInfoVo">
|
||||
select id, rule_id, name, attr_value, remark, create_by, create_time, update_by, update_time from rule_attr_info
|
||||
</sql>
|
||||
<insert id="add">
|
||||
|
||||
</insert>
|
||||
<delete id="del">
|
||||
delete from rule_attr_info where rule_id = #{id}
|
||||
</delete>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue