第三次提交
parent
5895475559
commit
fba615cec8
|
@ -22,7 +22,7 @@ import java.util.List;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class RuleInfoAddModel extends BaseEntity {
|
public class RuleInfoAddModel extends BaseEntity {
|
||||||
|
private Long id;
|
||||||
/** 规格名称 */
|
/** 规格名称 */
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.muyu.product.domain.req;
|
package com.muyu.product.domain.req;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
@ -33,5 +35,10 @@ public class AttributeGroupEditReq extends BaseEntity {
|
||||||
@ApiModelProperty(name = "状态", value = "状态", required = true)
|
@ApiModelProperty(name = "状态", value = "状态", required = true)
|
||||||
private String states;
|
private String states;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性ID集合
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(name = "属性ID集合", value = "属性ID集合", required = true)
|
||||||
|
|
||||||
|
private List<Long> attributeIdList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.muyu.product.domain.req;
|
||||||
|
|
||||||
|
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:尚志豪
|
||||||
|
* @Package:com.muyu.product.domain.req
|
||||||
|
* @Project:cloud-server
|
||||||
|
* @name:RuleAttrInfoReq
|
||||||
|
* @Date:2024/11/14 0:32
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class RuleAttrInfoReq {
|
||||||
|
/** 规格名称 */
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 规格状态 */
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规格属性集合
|
||||||
|
*/
|
||||||
|
private List<RuleAttrAddModel> ruleAttrList;
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.muyu.product.domain.resp;
|
||||||
|
|
||||||
|
import com.muyu.product.domain.AttributeInfo;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:尚志豪
|
||||||
|
* @Package:com.muyu.product.domain.resp
|
||||||
|
* @Project:cloud-server
|
||||||
|
* @name:AttributeGroupUpdResp
|
||||||
|
* @Date:2024/11/13 16:33
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class AttributeGroupUpdResp {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 属性组编号 */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 组名称 */
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 状态 */
|
||||||
|
private String states;
|
||||||
|
|
||||||
|
/** 属性Id集合 */
|
||||||
|
private List<AttributeInfo> attributeList;
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
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.RuleAttrInfo;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:尚志豪
|
||||||
|
* @Package:com.muyu.product.domain.resp
|
||||||
|
* @Project:cloud-server
|
||||||
|
* @name:RuleAttrInfoResp
|
||||||
|
* @Date:2024/11/14 0:37
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class RuleAttrInfoResp {
|
||||||
|
/** 主键 */
|
||||||
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
@ApiModelProperty(name = "主键", value = "主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 规格名称 */
|
||||||
|
@Excel(name = "规格名称")
|
||||||
|
@ApiModelProperty(name = "规格名称", value = "规格名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 规格状态 */
|
||||||
|
@Excel(name = "规格状态")
|
||||||
|
@ApiModelProperty(name = "规格状态", value = "规格状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
private List<RuleAttrInfo> ruleInfoResps;
|
||||||
|
|
||||||
|
private List<String> attrValue;
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ import com.muyu.product.domain.model.AttributeGroupSaveModel;
|
||||||
import com.muyu.product.domain.model.Ids;
|
import com.muyu.product.domain.model.Ids;
|
||||||
import com.muyu.product.domain.req.AttributeInfoEditReq;
|
import com.muyu.product.domain.req.AttributeInfoEditReq;
|
||||||
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||||
|
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -76,8 +77,8 @@ public class AttributeGroupController extends BaseController {
|
||||||
@RequiresPermissions("product:attributeGroup:query")
|
@RequiresPermissions("product:attributeGroup:query")
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||||
public Result<AttributeGroup> getInfo(@PathVariable("id") Long id) {
|
public Result<AttributeGroupUpdResp> getInfo(@PathVariable("id") Long id) {
|
||||||
return Result.success(attributeGroupService.getById(id));
|
return Result.success(attributeGroupService.getUpdById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,7 +104,6 @@ public class AttributeGroupController extends BaseController {
|
||||||
public Result<String> edit(@PathVariable Long id, @RequestBody AttributeGroupSaveReq attributeGroupSaveReq) {
|
public Result<String> edit(@PathVariable Long id, @RequestBody AttributeGroupSaveReq attributeGroupSaveReq) {
|
||||||
// return toAjax(attributeGroupService.updateById(AttributeGroup.editBuild(id,attributeGroupEditReq)));
|
// return toAjax(attributeGroupService.updateById(AttributeGroup.editBuild(id,attributeGroupEditReq)));
|
||||||
return toAjax(attributeGroupService.updateByIdss(id,attributeGroupSaveReq));
|
return toAjax(attributeGroupService.updateByIdss(id,attributeGroupSaveReq));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -73,6 +73,7 @@ public class RuleAttrInfoController extends BaseController {
|
||||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||||
public Result<RuleAttrInfo> getInfo(@PathVariable("id") Long id) {
|
public Result<RuleAttrInfo> getInfo(@PathVariable("id") Long id) {
|
||||||
return Result.success(ruleAttrInfoService.getById(id));
|
return Result.success(ruleAttrInfoService.getById(id));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.muyu.common.core.text.Convert;
|
import com.muyu.common.core.text.Convert;
|
||||||
import com.muyu.product.domain.model.RuleInfoAddModel;
|
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||||
|
import com.muyu.product.domain.req.RuleAttrInfoReq;
|
||||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -77,8 +78,9 @@ public class RuleInfoController extends BaseController {
|
||||||
@RequiresPermissions("product:rule:query")
|
@RequiresPermissions("product:rule:query")
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||||
public Result<RuleInfo> getInfo(@PathVariable("id") Long id) {
|
public Result<RuleInfoAddModel> getInfo(@PathVariable("id") Long id) {
|
||||||
return Result.success(ruleInfoService.getById(id));
|
RuleInfoAddModel resp=ruleInfoService.getRuleAttrInfoResp(id);
|
||||||
|
return Result.success(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,9 +101,9 @@ public class RuleInfoController extends BaseController {
|
||||||
@Log(title = "商品规格", businessType = BusinessType.UPDATE)
|
@Log(title = "商品规格", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
@ApiOperation("修改商品规格")
|
@ApiOperation("修改商品规格")
|
||||||
public Result<String> edit(@PathVariable Long id, @RequestBody RuleInfoEditReq ruleInfoEditReq) {
|
public Result<String> edit(@PathVariable Long id, @RequestBody RuleAttrInfoReq req) {
|
||||||
return toAjax(ruleInfoService.updateById(RuleInfo.editBuild(id,ruleInfoEditReq)));
|
ruleInfoService.updateRuleById(id,req);
|
||||||
}
|
return Result.success(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除商品规格
|
* 删除商品规格
|
||||||
|
|
|
@ -24,4 +24,8 @@ public interface AttributeGroupMapper extends BaseMapper<AttributeGroup> {
|
||||||
*/
|
*/
|
||||||
int updateByIdss(@Param("id") Long id);
|
int updateByIdss(@Param("id") Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改主表
|
||||||
|
*/
|
||||||
|
void updateGroup(AttributeGroupSaveReq attributeGroupSaveReq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package com.muyu.product.mapper;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.product.domain.RuleAttrInfo;
|
import com.muyu.product.domain.RuleAttrInfo;
|
||||||
|
import com.muyu.product.domain.req.RuleAttrInfoReq;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规格详情Mapper接口
|
* 规格详情Mapper接口
|
||||||
|
@ -11,5 +13,26 @@ import com.muyu.product.domain.RuleAttrInfo;
|
||||||
* @date 2024-02-27
|
* @date 2024-02-27
|
||||||
*/
|
*/
|
||||||
public interface RuleAttrInfoMapper extends BaseMapper<RuleAttrInfo> {
|
public interface RuleAttrInfoMapper extends BaseMapper<RuleAttrInfo> {
|
||||||
|
/**
|
||||||
|
* 查询规格详情表
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<RuleAttrInfo> getRuleAttrInfo(@Param("id") Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除规格详情表
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
void deleteRule(@Param("id") Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改商品规格表
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
void updRule(@Param("id") Long id, @Param("req") RuleAttrInfoReq req);
|
||||||
|
|
||||||
|
void addRuleAttrModel(@Param("id") Long id, @Param("name") String name, @Param("valueData") String valueData);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.muyu.product.domain.model.Ids;
|
||||||
import com.muyu.product.domain.req.AttributeGroupSaveReq;
|
import com.muyu.product.domain.req.AttributeGroupSaveReq;
|
||||||
import com.muyu.product.domain.req.AttributeInfoEditReq;
|
import com.muyu.product.domain.req.AttributeInfoEditReq;
|
||||||
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||||
|
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -47,4 +48,8 @@ public interface AttributeGroupService extends IService<AttributeGroup> {
|
||||||
int updateByIds(Ids id);
|
int updateByIds(Ids id);
|
||||||
|
|
||||||
int updateByIdss(Long id, AttributeGroupSaveReq attributeGroupSaveReq);
|
int updateByIdss(Long id, AttributeGroupSaveReq attributeGroupSaveReq);
|
||||||
|
/**
|
||||||
|
* 获取属性组详细信息
|
||||||
|
*/
|
||||||
|
AttributeGroupUpdResp getUpdById(Long id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,4 +25,10 @@ public interface RuleAttrInfoService extends IService<RuleAttrInfo> {
|
||||||
* @return 规格详情集合
|
* @return 规格详情集合
|
||||||
*/
|
*/
|
||||||
List<RuleAttrInfo> getInfoByRuleId (Long ruleId);
|
List<RuleAttrInfo> getInfoByRuleId (Long ruleId);
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* 获取商品规格详细信息
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<RuleAttrInfo> getRuleAttrInfo(Long id);}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
import com.muyu.product.domain.RuleInfo;
|
import com.muyu.product.domain.RuleInfo;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.product.domain.model.RuleInfoAddModel;
|
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||||
|
import com.muyu.product.domain.req.RuleAttrInfoReq;
|
||||||
import com.muyu.product.domain.req.RuleInfoQueryReq;
|
import com.muyu.product.domain.req.RuleInfoQueryReq;
|
||||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||||
|
|
||||||
|
@ -32,4 +33,12 @@ public interface RuleInfoService extends IService<RuleInfo> {
|
||||||
public boolean save(RuleInfoAddModel ruleInfoAddModel);
|
public boolean save(RuleInfoAddModel ruleInfoAddModel);
|
||||||
|
|
||||||
TableDataInfo<RuleInfoResp> queryList (RuleInfoQueryReq ruleInfoQueryReq);
|
TableDataInfo<RuleInfoResp> queryList (RuleInfoQueryReq ruleInfoQueryReq);
|
||||||
|
/**
|
||||||
|
* 获取商品规格详细信息
|
||||||
|
*/
|
||||||
|
RuleInfoAddModel getRuleAttrInfoResp(Long id);
|
||||||
|
/**
|
||||||
|
* 修改商品规格
|
||||||
|
*/
|
||||||
|
void updateRuleById(Long id, RuleAttrInfoReq req);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import com.muyu.product.domain.model.Ids;
|
||||||
import com.muyu.product.domain.req.AttributeGroupSaveReq;
|
import com.muyu.product.domain.req.AttributeGroupSaveReq;
|
||||||
import com.muyu.product.domain.req.AttributeInfoEditReq;
|
import com.muyu.product.domain.req.AttributeInfoEditReq;
|
||||||
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||||
|
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
|
||||||
import com.muyu.product.mapper.AttributeGroupMapper;
|
import com.muyu.product.mapper.AttributeGroupMapper;
|
||||||
import com.muyu.product.service.AsAttributeGroupService;
|
import com.muyu.product.service.AsAttributeGroupService;
|
||||||
import com.muyu.product.service.AttributeGroupService;
|
import com.muyu.product.service.AttributeGroupService;
|
||||||
|
@ -39,6 +40,8 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AsAttributeGroupService attributeGroupService;
|
private AsAttributeGroupService attributeGroupService;
|
||||||
|
@Autowired
|
||||||
|
private AsAttributeGroupService asAttributeGroupService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AttributeInfoService attributeInfoService;
|
private AttributeInfoService attributeInfoService;
|
||||||
|
@ -122,16 +125,41 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public int updateByIdss(Long id, AttributeGroupSaveReq attributeGroupSaveReq) {
|
public int updateByIdss(Long id, AttributeGroupSaveReq attributeGroupSaveReq) {
|
||||||
|
// 删除中间表
|
||||||
attributeGroupMapper.updateByIdss(id);
|
attributeGroupMapper.updateByIdss(id);
|
||||||
|
// 修改主表
|
||||||
|
attributeGroupMapper.updateGroup(attributeGroupSaveReq);
|
||||||
List<Long> attributeIdList = attributeGroupSaveReq.getAttributeIdList();
|
List<Long> attributeIdList = attributeGroupSaveReq.getAttributeIdList();
|
||||||
attributeGroupService.saveBatch(
|
attributeGroupService.saveBatch(
|
||||||
attributeIdList.stream()
|
attributeIdList.stream()
|
||||||
.map(attributeId -> AsAttributeGroup.buildGroup(id, attributeId))
|
.map(attributeId -> AsAttributeGroup.buildGroup(id, attributeId))
|
||||||
.toList()
|
.toList()
|
||||||
);
|
);
|
||||||
return 0;
|
return 1;
|
||||||
// return attributeGroupMapper.updateByIdss(id,attributeGroupSaveReq);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 获取属性组详细信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AttributeGroupUpdResp getUpdById(Long id) {
|
||||||
|
AttributeGroup attributeGroup = this.getById(id);
|
||||||
|
|
||||||
|
LambdaQueryWrapper<AsAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(AsAttributeGroup::getGroupId,id);
|
||||||
|
List<AsAttributeGroup> asAttributeGroupList = asAttributeGroupService.list(queryWrapper);
|
||||||
|
List<Long> attributeIdList = asAttributeGroupList.stream()
|
||||||
|
.map(AsAttributeGroup::getAttributeId)
|
||||||
|
.toList();
|
||||||
|
List<AttributeInfo> attributeInfoList = attributeInfoService.listByIds(attributeIdList);
|
||||||
|
|
||||||
|
return AttributeGroupUpdResp.builder()
|
||||||
|
.id(attributeGroup.getId())
|
||||||
|
.name(attributeGroup.getName())
|
||||||
|
.states(attributeGroup.getStates())
|
||||||
|
.attributeList(attributeInfoList)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||||
|
|
||||||
import com.muyu.common.core.utils.ObjUtils;
|
import com.muyu.common.core.utils.ObjUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.muyu.product.mapper.RuleAttrInfoMapper;
|
import com.muyu.product.mapper.RuleAttrInfoMapper;
|
||||||
import com.muyu.product.domain.RuleAttrInfo;
|
import com.muyu.product.domain.RuleAttrInfo;
|
||||||
|
@ -20,7 +21,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class RuleAttrInfoServiceImpl extends ServiceImpl<RuleAttrInfoMapper, RuleAttrInfo> implements RuleAttrInfoService {
|
public class RuleAttrInfoServiceImpl extends ServiceImpl<RuleAttrInfoMapper, RuleAttrInfo> implements RuleAttrInfoService {
|
||||||
|
@Autowired
|
||||||
|
private RuleAttrInfoMapper ruleAttrInfoMapper;
|
||||||
/**
|
/**
|
||||||
* 查询规格详情列表
|
* 查询规格详情列表
|
||||||
*
|
*
|
||||||
|
@ -64,4 +66,15 @@ public class RuleAttrInfoServiceImpl extends ServiceImpl<RuleAttrInfoMapper, Rul
|
||||||
queryWrapper.eq(RuleAttrInfo::getRuleId, ruleId);
|
queryWrapper.eq(RuleAttrInfo::getRuleId, ruleId);
|
||||||
return this.list(queryWrapper);
|
return this.list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 获取商品规格详细信息
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<RuleAttrInfo> getRuleAttrInfo(Long id) {
|
||||||
|
List<RuleAttrInfo> ruleAttrInfos= ruleAttrInfoMapper.getRuleAttrInfo(id);
|
||||||
|
return ruleAttrInfos;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,10 @@ import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.product.domain.RuleAttrInfo;
|
import com.muyu.product.domain.RuleAttrInfo;
|
||||||
import com.muyu.product.domain.model.RuleAttrAddModel;
|
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||||
import com.muyu.product.domain.model.RuleInfoAddModel;
|
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||||
|
import com.muyu.product.domain.req.RuleAttrInfoReq;
|
||||||
import com.muyu.product.domain.req.RuleInfoQueryReq;
|
import com.muyu.product.domain.req.RuleInfoQueryReq;
|
||||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||||
|
import com.muyu.product.mapper.RuleAttrInfoMapper;
|
||||||
import com.muyu.product.service.RuleAttrInfoService;
|
import com.muyu.product.service.RuleAttrInfoService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -39,6 +41,8 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RuleAttrInfoService ruleAttrInfoService;
|
private RuleAttrInfoService ruleAttrInfoService;
|
||||||
|
@Autowired
|
||||||
|
private RuleAttrInfoMapper ruleAttrInfoMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询商品规格列表
|
* 查询商品规格列表
|
||||||
|
@ -107,4 +111,55 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
||||||
.total(isPage ? new PageInfo<>(list).getTotal() : 0)
|
.total(isPage ? new PageInfo<>(list).getTotal() : 0)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 获取商品规格详细信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public RuleInfoAddModel getRuleAttrInfoResp(Long id) {
|
||||||
|
//获取商品规格
|
||||||
|
RuleInfo byId = this.getById(id);
|
||||||
|
if (byId==null){
|
||||||
|
throw new RuntimeException("没有这个商品规格");
|
||||||
|
}
|
||||||
|
List<RuleAttrInfo> ruleAttrInfos=ruleAttrInfoService.getRuleAttrInfo(byId.getId());
|
||||||
|
ArrayList<RuleAttrAddModel> arrayList = new ArrayList<>();
|
||||||
|
RuleAttrAddModel ruleAttrAddModel = new RuleAttrAddModel();
|
||||||
|
for (RuleAttrInfo ruleAttrInfo : ruleAttrInfos) {
|
||||||
|
ruleAttrAddModel.setName(ruleAttrInfo.getName());
|
||||||
|
}
|
||||||
|
List<String> list = ruleAttrInfos.stream().map(RuleAttrInfo::getAttrValue).toList();
|
||||||
|
ruleAttrAddModel.setValueList(list);
|
||||||
|
arrayList.add(ruleAttrAddModel);
|
||||||
|
RuleInfoAddModel resp = new RuleInfoAddModel();
|
||||||
|
resp.setId(byId.getId());
|
||||||
|
resp.setName(byId.getName());
|
||||||
|
resp.setStatus(byId.getStatus());
|
||||||
|
resp.setRuleAttrList(arrayList);
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 修改商品规格
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateRuleById(Long id, RuleAttrInfoReq req) {
|
||||||
|
//修改商品规格表
|
||||||
|
ruleAttrInfoMapper.updRule(id,req);
|
||||||
|
//删除规格详情表
|
||||||
|
ruleAttrInfoMapper.deleteRule(id);
|
||||||
|
//添加规格详情表
|
||||||
|
List<RuleAttrAddModel> ruleAttrList = req.getRuleAttrList();
|
||||||
|
for (RuleAttrAddModel ruleAttrAddModel : ruleAttrList) {
|
||||||
|
List<String> valueList = ruleAttrAddModel.getValueList();
|
||||||
|
String value="";
|
||||||
|
String valueData=null;
|
||||||
|
for (String s : valueList) {
|
||||||
|
valueData = value + "," + s;
|
||||||
|
}
|
||||||
|
String substring = valueData.substring(1);
|
||||||
|
System.out.println(substring);
|
||||||
|
ruleAttrInfoMapper.addRuleAttrModel(id,ruleAttrAddModel.getName(),substring);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,16 +27,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
( #{id}, #{e})
|
( #{id}, #{e})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
<!-- 修改主表-->
|
||||||
|
<update id="updateGroup" parameterType="com.muyu.product.domain.req.AttributeGroupSaveReq">
|
||||||
|
UPDATE `product`.`attribute_group`
|
||||||
|
SET
|
||||||
|
`name` = #{name},
|
||||||
|
`states` = #{states}
|
||||||
|
WHERE
|
||||||
|
`id` = #{id};
|
||||||
|
</update>
|
||||||
<delete id="updateByIdss">
|
<delete id="updateByIdss">
|
||||||
|
delete from as_attribute_group where group_id =#{id}
|
||||||
delete from as_attribute_group where
|
|
||||||
|
|
||||||
INSERT INTO `product`.`as_attribute_group`
|
|
||||||
( `group_id`, `attribute_id`) VALUES
|
|
||||||
|
|
||||||
<foreach collection="attributeGroupSaveReq" item="e" separator=",">
|
|
||||||
( #{id}, #{e.})
|
|
||||||
</foreach>
|
|
||||||
delete
|
|
||||||
</delete>
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -19,4 +19,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<sql id="selectRuleAttrInfoVo">
|
<sql id="selectRuleAttrInfoVo">
|
||||||
select id, rule_id, name, attr_value, remark, create_by, create_time, update_by, update_time from rule_attr_info
|
select id, rule_id, name, attr_value, remark, create_by, create_time, update_by, update_time from rule_attr_info
|
||||||
</sql>
|
</sql>
|
||||||
|
<insert id="addRuleAttrModel">
|
||||||
|
INSERT INTO rule_attr_info ( `rule_id`, `name`, `attr_value`,create_by, `create_time`)
|
||||||
|
VALUES ( #{id},#{name}, #{valueData},'admin',now());
|
||||||
|
</insert>
|
||||||
|
<!-- 修改商品规格表-->
|
||||||
|
<update id="updRule">
|
||||||
|
UPDATE rule_info
|
||||||
|
SET `name` = #{req.name},
|
||||||
|
`status` = #{req.status},
|
||||||
|
`update_time` = now()
|
||||||
|
WHERE
|
||||||
|
`id` = #{id}
|
||||||
|
</update>
|
||||||
|
<!-- 删除规格详情-->
|
||||||
|
<delete id="deleteRule" parameterType="java.lang.Long">
|
||||||
|
delete from rule_attr_info where rule_id=#{id}
|
||||||
|
</delete>
|
||||||
|
<select id="getRuleAttrInfo" resultType="com.muyu.product.domain.RuleAttrInfo"
|
||||||
|
parameterType="java.lang.Long">
|
||||||
|
select
|
||||||
|
rule_attr_info.id as id,
|
||||||
|
rule_attr_info.rule_id as rule_id,
|
||||||
|
rule_attr_info.name as name,
|
||||||
|
rule_attr_info.attr_value as attr_value,
|
||||||
|
rule_attr_info.remark as remark,
|
||||||
|
rule_attr_info.create_by as create_by,
|
||||||
|
rule_attr_info.create_time as create_time,
|
||||||
|
rule_attr_info.update_by as update_by,
|
||||||
|
rule_attr_info.update_time as update_time
|
||||||
|
from rule_attr_info where rule_id=#{id}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue