品类添加
parent
a640ca19d2
commit
0d68b51739
|
@ -50,7 +50,7 @@ public class VelocityUtils {
|
||||||
VelocityContext velocityContext = new VelocityContext();
|
VelocityContext velocityContext = new VelocityContext();
|
||||||
velocityContext.put("tplCategory", genTable.getTplCategory());
|
velocityContext.put("tplCategory", genTable.getTplCategory());
|
||||||
velocityContext.put("tableName", genTable.getTableName());
|
velocityContext.put("tableName", genTable.getTableName());
|
||||||
velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】");
|
velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "");
|
||||||
velocityContext.put("ClassName", genTable.getClassName());
|
velocityContext.put("ClassName", genTable.getClassName());
|
||||||
velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName()));
|
velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName()));
|
||||||
velocityContext.put("moduleName", genTable.getModuleName());
|
velocityContext.put("moduleName", genTable.getModuleName());
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package ${packageName}.service;
|
package ${packageName}.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import
|
import ${packageName}.domain.${ClassName};
|
||||||
import com.baomidou.mybatisplus.extension.service.IService; ${packageName}.domain.${ClassName};
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}Service接口
|
* ${functionName}Service接口
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.product.domain.req.RuleAttrReq;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
@ -11,6 +12,9 @@ import lombok.experimental.SuperBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规格对象 rule
|
* 规格对象 rule
|
||||||
*
|
*
|
||||||
|
@ -33,35 +37,23 @@ public class Rule extends BaseEntity
|
||||||
@Excel(name = "规格名称")
|
@Excel(name = "规格名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public void setId(Long id)
|
private String states;
|
||||||
{
|
|
||||||
this.id = id;
|
public static Rule saveBuilder(RuleAttrReq req, Supplier<String> username){
|
||||||
|
return Rule.builder()
|
||||||
|
.name(req.getName())
|
||||||
|
.states(req.getStates())
|
||||||
|
.createBy(username.get())
|
||||||
|
.createTime(new Date())
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setName(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
public static Rule updateBuilder(RuleAttrReq ruleAttrReq) {
|
||||||
{
|
return Rule.builder()
|
||||||
return name;
|
.id(ruleAttrReq.getId())
|
||||||
}
|
.states(ruleAttrReq.getStates())
|
||||||
|
.name(ruleAttrReq.getName())
|
||||||
@Override
|
.build();
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("id", getId())
|
|
||||||
.append("name", getName())
|
|
||||||
.append("remark", getRemark())
|
|
||||||
.append("createBy", SecurityUtils.getUsername())
|
|
||||||
.append("createTime", getCreateTime())
|
|
||||||
.append("updateBy", SecurityUtils.getUsername())
|
|
||||||
.append("updateTime", getUpdateTime())
|
|
||||||
.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.muyu.product.domain;
|
||||||
|
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||||
|
import com.muyu.product.domain.req.RuleAttrReq;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规格对象 rule
|
||||||
|
*
|
||||||
|
* @author saisai
|
||||||
|
* @date 2024-02-29
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class RuleAttr extends BaseEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 规格主键
|
||||||
|
*/
|
||||||
|
private Long ruleId;
|
||||||
|
/**
|
||||||
|
* 规格属性名称
|
||||||
|
*/
|
||||||
|
@Excel(name = "规格属性")
|
||||||
|
private String attrName;
|
||||||
|
private String attrValue;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规格属性构建体
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<RuleAttr> saveBuilder(RuleAttrReq req,Supplier<String> username) {
|
||||||
|
ArrayList<RuleAttr> ruleAttrs = new ArrayList<>();
|
||||||
|
List<RuleAttrAddModel> ruleAttrAddModels = req.getRuleAttrList();
|
||||||
|
ruleAttrAddModels.stream().map(
|
||||||
|
ruleAttrAddModel -> ruleAttrs.addAll(RuleAttr.constructBuilder(ruleAttrAddModel,username,req.getRuleId())
|
||||||
|
)).toList();
|
||||||
|
return ruleAttrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<RuleAttr> constructBuilder(RuleAttrAddModel ruleAttrAddModel, Supplier<String> username, Long ruleId) {
|
||||||
|
return (List<RuleAttr>) ruleAttrAddModel.getValueList().stream().map(
|
||||||
|
value -> RuleAttr.builder().attrName(ruleAttrAddModel.getAttrName())
|
||||||
|
.id(null)
|
||||||
|
.ruleId(ruleId)
|
||||||
|
.createBy(username.get())
|
||||||
|
.createTime(new Date())
|
||||||
|
.attrValue(value)
|
||||||
|
.build()
|
||||||
|
).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -41,55 +41,5 @@ public class RuleProduct extends BaseEntity
|
||||||
@Excel(name = "规格值")
|
@Excel(name = "规格值")
|
||||||
private String ruleValue;
|
private String ruleValue;
|
||||||
|
|
||||||
public void setId(Long id)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setProductId(Long productId)
|
|
||||||
{
|
|
||||||
this.productId = productId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getProductId()
|
|
||||||
{
|
|
||||||
return productId;
|
|
||||||
}
|
|
||||||
public void setRuleId(Long ruleId)
|
|
||||||
{
|
|
||||||
this.ruleId = ruleId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getRuleId()
|
|
||||||
{
|
|
||||||
return ruleId;
|
|
||||||
}
|
|
||||||
public void setRuleValue(String ruleValue)
|
|
||||||
{
|
|
||||||
this.ruleValue = ruleValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRuleValue()
|
|
||||||
{
|
|
||||||
return ruleValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("id", getId())
|
|
||||||
.append("productId", getProductId())
|
|
||||||
.append("ruleId", getRuleId())
|
|
||||||
.append("ruleValue", getRuleValue())
|
|
||||||
.append("remark", getRemark())
|
|
||||||
.append("createBy", SecurityUtils.getUsername())
|
|
||||||
.append("createTime", getCreateTime())
|
|
||||||
.append("updateBy", SecurityUtils.getUsername())
|
|
||||||
.append("updateTime", getUpdateTime())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.muyu.product.domain.demo;
|
||||||
|
|
||||||
|
import com.muyu.product.domain.Attribute;
|
||||||
|
import com.muyu.product.domain.AttributeGroup;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName Product
|
||||||
|
* @Description 描述
|
||||||
|
* @Author SaiSai.Liu
|
||||||
|
* @Date 2024/3/6/0006 14:12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Product {
|
||||||
|
/**
|
||||||
|
* 属性组
|
||||||
|
*/
|
||||||
|
private List<AttributeGroup> attributeGroupList;
|
||||||
|
/**
|
||||||
|
* 属性
|
||||||
|
*/
|
||||||
|
private List<Attribute> attributeList;
|
||||||
|
/**
|
||||||
|
* 自有属性
|
||||||
|
*/
|
||||||
|
private List<Attribute> selfAttributeList;
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.muyu.product.domain.model;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.product.domain.Rule;
|
||||||
|
import com.muyu.product.domain.RuleAttr;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName RuleAttrAddModel
|
||||||
|
* @Description 描述
|
||||||
|
* @Author SaiSai.Liu
|
||||||
|
* @Date 2024/3/7/0007 11:53
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class RuleAttrAddModel extends BaseEntity {
|
||||||
|
private String attrName;
|
||||||
|
private List<String> valueList;
|
||||||
|
|
||||||
|
public static RuleAttrAddModel saveBuilder(RuleAttr ruleAttr) {
|
||||||
|
return RuleAttrAddModel.builder()
|
||||||
|
.attrName(ruleAttr.getAttrName())
|
||||||
|
.valueList(Arrays.stream(ruleAttr.getAttrValue().split(",")).toList())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,7 +25,8 @@ import java.lang.annotation.Annotation;
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class BrandReq {
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class BrandReq extends BaseEntity{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.muyu.product.domain.req;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName RuleAttrReq
|
||||||
|
* @Description 描述
|
||||||
|
* @Author SaiSai.Liu
|
||||||
|
* @Date 2024/3/7/0007 9:02
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class RuleAttrReq extends BaseEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 主键 */
|
||||||
|
private Long id;
|
||||||
|
/** 规格id */
|
||||||
|
private Long ruleId;
|
||||||
|
/**规格名称*/
|
||||||
|
private String name;
|
||||||
|
/** 属性组 */
|
||||||
|
private List<RuleAttrAddModel> ruleAttrList;
|
||||||
|
/** 是否启用 */
|
||||||
|
private String states;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.muyu.product.domain.resp;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.product.domain.Rule;
|
||||||
|
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName RuleAttrResp
|
||||||
|
* @Description 描述
|
||||||
|
* @Author SaiSai.Liu
|
||||||
|
* @Date 2024/3/7/0007 15:56
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class RuleAttrResp extends BaseEntity {
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
private String states;
|
||||||
|
private List<RuleAttrAddModel> ruleAttrAddModels;
|
||||||
|
|
||||||
|
public static RuleAttrResp saveBuilder(Rule rule, Function<Long,List<RuleAttrAddModel>> ruleAttrs){
|
||||||
|
return RuleAttrResp.builder()
|
||||||
|
.id(rule.getId())
|
||||||
|
.name(rule.getName())
|
||||||
|
.ruleAttrAddModels(ruleAttrs.apply(rule.getId()))
|
||||||
|
.states(rule.getStates())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -40,3 +40,64 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
"product": {
|
||||||
|
"name": null,
|
||||||
|
"brandId": 1,
|
||||||
|
"remark": null,
|
||||||
|
"image": null,
|
||||||
|
"images": [],
|
||||||
|
"description": null
|
||||||
|
},
|
||||||
|
"attribute": {
|
||||||
|
"attributeGroup": {
|
||||||
|
"attributeGroupId": 1,
|
||||||
|
},
|
||||||
|
"attributeList": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"attributeValue": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rule": {
|
||||||
|
"ruleId": 1,
|
||||||
|
"ruleValueList": [
|
||||||
|
{
|
||||||
|
"ruleName1": null,
|
||||||
|
"ruleName2":null,
|
||||||
|
...
|
||||||
|
"image": null,
|
||||||
|
"stork": 1,
|
||||||
|
"price": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
package com.muyu.product.controller;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
import com.muyu.common.log.annotation.Log;
|
||||||
|
import com.muyu.common.log.enums.BusinessType;
|
||||||
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.product.domain.RuleAttr;
|
||||||
|
import com.muyu.product.domain.req.RuleAttrReq;
|
||||||
|
import com.muyu.product.service.RuleAttrService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-03-07
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/attr")
|
||||||
|
public class RuleAttrController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private RuleAttrService ruleAttrService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("system:attr:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<TableDataInfo<RuleAttr>> list(RuleAttr ruleAttr) {
|
||||||
|
startPage();
|
||||||
|
List<RuleAttr> list = ruleAttrService.selectRuleAttrList(ruleAttr);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("system:attr:export")
|
||||||
|
@Log(title = "", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, RuleAttr ruleAttr) {
|
||||||
|
List<RuleAttr> list = ruleAttrService.selectRuleAttrList(ruleAttr);
|
||||||
|
ExcelUtil<RuleAttr> util = new ExcelUtil<RuleAttr>(RuleAttr.class);
|
||||||
|
util.exportExcel(response, list, "数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取详细信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("system:attr:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public Result getInfo(@PathVariable("id") Long id) {
|
||||||
|
return success(ruleAttrService.selectRuleAttrById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*/
|
||||||
|
// @RequiresPermissions("system:attr:add")
|
||||||
|
// @Log(title = "", businessType = BusinessType.INSERT)
|
||||||
|
// @PostMapping
|
||||||
|
// public Result add(@RequestBody RuleAttr ruleAttr) {
|
||||||
|
// return toAjax(ruleAttrService.insertRuleAttr(ruleAttr));
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("system:attr:add")
|
||||||
|
@Log(title = "", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public Result add(@RequestBody RuleAttrReq ruleAttrReq) {
|
||||||
|
return ruleAttrService.saveBatch(RuleAttr.saveBuilder(ruleAttrReq,SecurityUtils::getUsername))
|
||||||
|
? Result.success("","批量添加成功") : Result.error("添加失败") ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("system:attr:edit")
|
||||||
|
@Log(title = "", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public Result edit(@RequestBody RuleAttr ruleAttr) {
|
||||||
|
return toAjax(ruleAttrService.updateRuleAttr(ruleAttr));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("system:attr:remove")
|
||||||
|
@Log(title = "", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public Result remove(@PathVariable Long[] ids) {
|
||||||
|
return toAjax(ruleAttrService.deleteRuleAttrByIds(ids));
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,10 @@ package com.muyu.product.controller;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.muyu.product.domain.req.RuleAttrReq;
|
||||||
|
import com.muyu.product.domain.resp.RuleAttrResp;
|
||||||
|
import com.muyu.product.service.RuleAttrService;
|
||||||
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;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
@ -35,18 +39,36 @@ public class RuleController extends BaseController
|
||||||
@Autowired
|
@Autowired
|
||||||
private IRuleService ruleService;
|
private IRuleService ruleService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RuleAttrService ruleAttrService;
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 查询规格列表
|
||||||
|
// */
|
||||||
|
// @RequiresPermissions("product:rule:list")
|
||||||
|
// @GetMapping("/list")
|
||||||
|
// public Result<TableDataInfo<Rule>> list(Rule rule)
|
||||||
|
// {
|
||||||
|
// startPage();
|
||||||
|
// List<Rule> list = ruleService.selectRuleList(rule);
|
||||||
|
// return getDataTable(list);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询规格列表
|
* 查询规格列表
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("product:rule:list")
|
@RequiresPermissions("product:rule:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result<TableDataInfo<Rule>> list(Rule rule)
|
public Result<TableDataInfo<RuleAttrResp>> ruleAttrList(RuleAttrReq ruleAttrReq)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<Rule> list = ruleService.selectRuleList(rule);
|
List<RuleAttrResp> list = ruleService.selectRuleAttrList(ruleAttrReq);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出规格列表
|
* 导出规格列表
|
||||||
*/
|
*/
|
||||||
|
@ -76,9 +98,9 @@ public class RuleController extends BaseController
|
||||||
@RequiresPermissions("product:rule:add")
|
@RequiresPermissions("product:rule:add")
|
||||||
@Log(title = "规格", businessType = BusinessType.INSERT)
|
@Log(title = "规格", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public Result add(@RequestBody Rule rule)
|
public Result add(@RequestBody RuleAttrReq ruleAttrReq)
|
||||||
{
|
{
|
||||||
return toAjax(ruleService.insertRule(rule));
|
return toAjax(ruleService.insertRule(ruleAttrReq));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,9 +109,9 @@ public class RuleController extends BaseController
|
||||||
@RequiresPermissions("product:rule:edit")
|
@RequiresPermissions("product:rule:edit")
|
||||||
@Log(title = "规格", businessType = BusinessType.UPDATE)
|
@Log(title = "规格", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public Result edit(@RequestBody Rule rule)
|
public Result edit(@RequestBody RuleAttrReq ruleAttrReq)
|
||||||
{
|
{
|
||||||
return toAjax(ruleService.updateRule(rule));
|
return toAjax(ruleService.updateRule(ruleAttrReq));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.muyu.product.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.product.domain.RuleAttr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapper接口
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-03-07
|
||||||
|
*/
|
||||||
|
public interface RuleAttrMapper extends BaseMapper<RuleAttr>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
RuleAttr selectRuleAttrById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询列表
|
||||||
|
*
|
||||||
|
* @param ruleAttr
|
||||||
|
* @return 集合
|
||||||
|
*/
|
||||||
|
List<RuleAttr> selectRuleAttrList(RuleAttr ruleAttr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*
|
||||||
|
* @param ruleAttr
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int insertRuleAttr(RuleAttr ruleAttr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*
|
||||||
|
* @param ruleAttr
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int updateRuleAttr(RuleAttr ruleAttr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteRuleAttrById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteRuleAttrByIds(Long[] ids);
|
||||||
|
}
|
|
@ -5,6 +5,8 @@ import java.util.List;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.product.domain.Address;
|
import com.muyu.product.domain.Address;
|
||||||
import com.muyu.product.domain.Rule;
|
import com.muyu.product.domain.Rule;
|
||||||
|
import com.muyu.product.domain.req.RuleAttrReq;
|
||||||
|
import com.muyu.product.domain.resp.RuleAttrResp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规格Service接口
|
* 规格Service接口
|
||||||
|
@ -33,18 +35,18 @@ public interface IRuleService extends IService<Rule>
|
||||||
/**
|
/**
|
||||||
* 新增规格
|
* 新增规格
|
||||||
*
|
*
|
||||||
* @param rule 规格
|
* @param ruleAttrReq 规格
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int insertRule(Rule rule);
|
int insertRule(RuleAttrReq ruleAttrReq);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改规格
|
* 修改规格
|
||||||
*
|
*
|
||||||
* @param rule 规格
|
* @param ruleAttrReq 规格
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int updateRule(Rule rule);
|
int updateRule(RuleAttrReq ruleAttrReq);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除规格
|
* 批量删除规格
|
||||||
|
@ -61,4 +63,6 @@ public interface IRuleService extends IService<Rule>
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int deleteRuleById(Long id);
|
int deleteRuleById(Long id);
|
||||||
|
|
||||||
|
List<RuleAttrResp> selectRuleAttrList(RuleAttrReq ruleAttrReq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.muyu.product.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.muyu.product.domain.RuleAttr;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service接口
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-03-07
|
||||||
|
*/
|
||||||
|
public interface RuleAttrService extends IService<RuleAttr>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
RuleAttr selectRuleAttrById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询列表
|
||||||
|
*
|
||||||
|
* @param ruleAttr
|
||||||
|
* @return 集合
|
||||||
|
*/
|
||||||
|
List<RuleAttr> selectRuleAttrList(RuleAttr ruleAttr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*
|
||||||
|
* @param ruleAttr
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int insertRuleAttr(RuleAttr ruleAttr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*
|
||||||
|
* @param ruleAttr
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int updateRuleAttr(RuleAttr ruleAttr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteRuleAttrByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除信息
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteRuleAttrById(Long id);
|
||||||
|
}
|
|
@ -0,0 +1,99 @@
|
||||||
|
package com.muyu.product.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.common.core.utils.DateUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.muyu.product.mapper.RuleAttrMapper;
|
||||||
|
import com.muyu.product.domain.RuleAttr;
|
||||||
|
import com.muyu.product.service.RuleAttrService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service业务层处理
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-03-07
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class RuleAttrServiceImpl extends ServiceImpl<RuleAttrMapper,RuleAttr> implements RuleAttrService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private RuleAttrMapper ruleAttrMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public RuleAttr selectRuleAttrById(Long id)
|
||||||
|
{
|
||||||
|
|
||||||
|
return ruleAttrMapper.selectRuleAttrById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询列表
|
||||||
|
* @param ruleAttr
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<RuleAttr> selectRuleAttrList(RuleAttr ruleAttr)
|
||||||
|
{
|
||||||
|
|
||||||
|
return ruleAttrMapper.selectRuleAttrList(ruleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*
|
||||||
|
* @param ruleAttr
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertRuleAttr(RuleAttr ruleAttr)
|
||||||
|
{
|
||||||
|
ruleAttr.setCreateTime(DateUtils.getNowDate());
|
||||||
|
return ruleAttrMapper.insertRuleAttr(ruleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*
|
||||||
|
* @param ruleAttr
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateRuleAttr(RuleAttr ruleAttr)
|
||||||
|
{
|
||||||
|
ruleAttr.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
return ruleAttrMapper.updateRuleAttr(ruleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteRuleAttrByIds(Long[] ids)
|
||||||
|
{
|
||||||
|
return ruleAttrMapper.deleteRuleAttrByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除信息
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteRuleAttrById(Long id)
|
||||||
|
{
|
||||||
|
return ruleAttrMapper.deleteRuleAttrById(id);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,13 +2,13 @@ package com.muyu.product.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.muyu.product.domain.RuleProduct;
|
||||||
import com.muyu.common.core.utils.DateUtils;
|
import com.muyu.common.core.utils.DateUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.muyu.product.mapper.RuleProductMapper;
|
import com.muyu.product.mapper.RuleProductMapper;
|
||||||
import com.muyu.product.domain.RuleProduct;
|
|
||||||
import com.muyu.product.service.IRuleProductService;
|
import com.muyu.product.service.IRuleProductService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规格商品中间Service业务层处理
|
* 规格商品中间Service业务层处理
|
||||||
|
|
|
@ -1,14 +1,23 @@
|
||||||
package com.muyu.product.service.impl;
|
package com.muyu.product.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.common.core.utils.DateUtils;
|
import com.muyu.common.core.utils.DateUtils;
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.product.domain.Rule;
|
||||||
|
import com.muyu.product.domain.RuleAttr;
|
||||||
|
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||||
|
import com.muyu.product.domain.req.RuleAttrReq;
|
||||||
|
import com.muyu.product.domain.resp.RuleAttrResp;
|
||||||
|
import com.muyu.product.mapper.RuleMapper;
|
||||||
|
import com.muyu.product.service.IRuleService;
|
||||||
|
import com.muyu.product.service.RuleAttrService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.muyu.product.mapper.RuleMapper;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import com.muyu.product.domain.Rule;
|
|
||||||
import com.muyu.product.service.IRuleService;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规格Service业务层处理
|
* 规格Service业务层处理
|
||||||
|
@ -17,10 +26,15 @@ import com.muyu.product.service.IRuleService;
|
||||||
* @date 2024-02-29
|
* @date 2024-02-29
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class RuleServiceImpl extends ServiceImpl<RuleMapper,Rule> implements IRuleService
|
public class RuleServiceImpl extends ServiceImpl<RuleMapper, Rule> implements IRuleService {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RuleMapper ruleMapper;
|
private RuleMapper ruleMapper;
|
||||||
|
private RuleAttrService ruleAttrService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public RuleServiceImpl(RuleAttrService ruleAttrService) {
|
||||||
|
this.ruleAttrService = ruleAttrService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询规格
|
* 查询规格
|
||||||
|
@ -29,8 +43,7 @@ public class RuleServiceImpl extends ServiceImpl<RuleMapper,Rule> implements IRu
|
||||||
* @return 规格
|
* @return 规格
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Rule selectRuleById(Long id)
|
public Rule selectRuleById(Long id) {
|
||||||
{
|
|
||||||
return ruleMapper.selectRuleById(id);
|
return ruleMapper.selectRuleById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,34 +54,46 @@ public class RuleServiceImpl extends ServiceImpl<RuleMapper,Rule> implements IRu
|
||||||
* @return 规格
|
* @return 规格
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Rule> selectRuleList(Rule rule)
|
public List<Rule> selectRuleList(Rule rule) {
|
||||||
{
|
|
||||||
return ruleMapper.selectRuleList(rule);
|
return ruleMapper.selectRuleList(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增规格
|
* 新增规格
|
||||||
*
|
*
|
||||||
* @param rule 规格
|
* @param ruleAttrReq 规格
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertRule(Rule rule)
|
@Transactional
|
||||||
{
|
public int insertRule(RuleAttrReq ruleAttrReq) {
|
||||||
rule.setCreateTime(DateUtils.getNowDate());
|
Rule rule = Rule.saveBuilder(ruleAttrReq, SecurityUtils::getUsername);
|
||||||
return ruleMapper.insertRule(rule);
|
int i = ruleMapper.insertRule(rule);
|
||||||
|
ruleAttrReq.setRuleId(rule.getId());
|
||||||
|
ruleAttrService.saveBatch(RuleAttr.saveBuilder(ruleAttrReq, SecurityUtils::getUsername));
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改规格
|
* 修改规格
|
||||||
*
|
*
|
||||||
* @param rule 规格
|
* @param ruleAttrReq 规格
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateRule(Rule rule)
|
@Transactional
|
||||||
{
|
public int updateRule(RuleAttrReq ruleAttrReq) {
|
||||||
rule.setUpdateTime(DateUtils.getNowDate());
|
|
||||||
|
//获取当前规格对象
|
||||||
|
Rule rule = Rule.updateBuilder(ruleAttrReq);
|
||||||
|
LambdaQueryWrapper<RuleAttr> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
//查找当前规格属性
|
||||||
|
List<Long> longs = ruleAttrService.list(wrapper.eq(RuleAttr::getRuleId, rule.getId())).stream().map(RuleAttr::getId).toList();
|
||||||
|
ruleAttrService.removeBatchByIds(longs);
|
||||||
|
RuleAttr.saveBuilder(ruleAttrReq,SecurityUtils::getUsername)
|
||||||
|
.stream().map(
|
||||||
|
ruleAttr -> ruleAttrService.insertRuleAttr(ruleAttr)
|
||||||
|
).count();
|
||||||
return ruleMapper.updateRule(rule);
|
return ruleMapper.updateRule(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,8 +104,7 @@ public class RuleServiceImpl extends ServiceImpl<RuleMapper,Rule> implements IRu
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteRuleByIds(Long[] ids)
|
public int deleteRuleByIds(Long[] ids) {
|
||||||
{
|
|
||||||
return ruleMapper.deleteRuleByIds(ids);
|
return ruleMapper.deleteRuleByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,8 +115,29 @@ public class RuleServiceImpl extends ServiceImpl<RuleMapper,Rule> implements IRu
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteRuleById(Long id)
|
public int deleteRuleById(Long id) {
|
||||||
{
|
|
||||||
return ruleMapper.deleteRuleById(id);
|
return ruleMapper.deleteRuleById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RuleAttrResp> selectRuleAttrList(RuleAttrReq ruleAttrReq) {
|
||||||
|
|
||||||
|
//规格集合
|
||||||
|
List<Rule> rules = this.selectRuleList(Rule.saveBuilder(ruleAttrReq, SecurityUtils::getUsername));
|
||||||
|
//规格主键集合
|
||||||
|
List<Long> ruleIdList = rules.stream().map(Rule::getId).toList();
|
||||||
|
|
||||||
|
//创建响应值容器
|
||||||
|
List<RuleAttrResp> ruleAttrResps = new ArrayList<>();
|
||||||
|
//根据编号转换响应对象
|
||||||
|
|
||||||
|
ruleAttrResps = rules.stream().map(rule ->
|
||||||
|
RuleAttrResp.saveBuilder(rule, id -> {
|
||||||
|
LambdaQueryWrapper<RuleAttr> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
List<RuleAttr> list = ruleAttrService.list(wrapper.eq(RuleAttr::getRuleId, rule.getId()));
|
||||||
|
return list.stream().map(RuleAttrAddModel::saveBuilder).toList();
|
||||||
|
})
|
||||||
|
).toList();
|
||||||
|
return ruleAttrResps;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.muyu.product.mapper.RuleAttrMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.muyu.product.domain.RuleAttr" id="RuleAttrResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="ruleId" column="rule_id" />
|
||||||
|
<result property="attrName" column="attr_name" />
|
||||||
|
<result property="attrValue" column="attr_value" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectRuleAttrVo">
|
||||||
|
select id, rule_id, attr_name, attr_value, create_by, create_time, update_by, update_time from rule_attr
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectRuleAttrList" parameterType="com.muyu.product.domain.RuleAttr" resultMap="RuleAttrResult">
|
||||||
|
<include refid="selectRuleAttrVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="ruleId != null "> and rule_id = #{ruleId}</if>
|
||||||
|
<if test="attrName != null and attrName != ''"> and attr_name like concat('%', #{attrName}, '%')</if>
|
||||||
|
<if test="attrValue != null and attrValue != ''"> and attr_value = #{attrValue}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectRuleAttrById" parameterType="Long" resultMap="RuleAttrResult">
|
||||||
|
<include refid="selectRuleAttrVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertRuleAttr" parameterType="com.muyu.product.domain.RuleAttr">
|
||||||
|
insert into rule_attr
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">id,</if>
|
||||||
|
<if test="ruleId != null">rule_id,</if>
|
||||||
|
<if test="attrName != null and attrName != ''">attr_name,</if>
|
||||||
|
<if test="attrValue != null">attr_value,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">#{id},</if>
|
||||||
|
<if test="ruleId != null">#{ruleId},</if>
|
||||||
|
<if test="attrName != null and attrName != ''">#{attrName},</if>
|
||||||
|
<if test="attrValue != null">#{attrValue},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateRuleAttr" parameterType="com.muyu.product.domain.RuleAttr">
|
||||||
|
update rule_attr
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="ruleId != null">rule_id = #{ruleId},</if>
|
||||||
|
<if test="attrName != null and attrName != ''">attr_name = #{attrName},</if>
|
||||||
|
<if test="attrValue != null">attr_value = #{attrValue},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteRuleAttrById" parameterType="Long">
|
||||||
|
delete from rule_attr where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteRuleAttrByIds" parameterType="String">
|
||||||
|
delete from rule_attr where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
|
@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<resultMap type="com.muyu.product.domain.Rule" id="RuleResult">
|
<resultMap type="com.muyu.product.domain.Rule" id="RuleResult">
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
<result property="name" column="name" />
|
<result property="name" column="name" />
|
||||||
|
<result property="states" column="states" />
|
||||||
<result property="remark" column="remark" />
|
<result property="remark" column="remark" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
|
@ -34,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
insert into rule
|
insert into rule
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="name != null and name != ''">name,</if>
|
<if test="name != null and name != ''">name,</if>
|
||||||
|
<if test="states != null and states != ''">states,</if>
|
||||||
<if test="remark != null">remark,</if>
|
<if test="remark != null">remark,</if>
|
||||||
<if test="createBy != null">create_by,</if>
|
<if test="createBy != null">create_by,</if>
|
||||||
<if test="createTime != null">create_time,</if>
|
<if test="createTime != null">create_time,</if>
|
||||||
|
@ -42,6 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="name != null and name != ''">#{name},</if>
|
<if test="name != null and name != ''">#{name},</if>
|
||||||
|
<if test="states != null and states != ''">#{states},</if>
|
||||||
<if test="remark != null">#{remark},</if>
|
<if test="remark != null">#{remark},</if>
|
||||||
<if test="createBy != null">#{createBy},</if>
|
<if test="createBy != null">#{createBy},</if>
|
||||||
<if test="createTime != null">#{createTime},</if>
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
@ -54,6 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
update rule
|
update rule
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<if test="name != null and name != ''">name = #{name},</if>
|
<if test="name != null and name != ''">name = #{name},</if>
|
||||||
|
<if test="states != null and states != ''">states = #{states},</if>
|
||||||
<if test="remark != null">remark = #{remark},</if>
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
|
Loading…
Reference in New Issue