master
parent
99485ae5a4
commit
90ec9846a3
|
@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.product.domain.model.TemplateAttributeModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -50,6 +51,14 @@ public class AttributeInfo extends BaseEntity {
|
|||
private String name;
|
||||
|
||||
|
||||
public TemplateAttributeModel buildTemplateModel(){
|
||||
return TemplateAttributeModel.builder()
|
||||
.id(this.getId())
|
||||
.code(this.getCode())
|
||||
.name(this.getName())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -15,6 +16,9 @@ import com.muyu.product.domain.req.RuleAttrInfoSaveReq;
|
|||
import com.muyu.product.domain.req.RuleAttrInfoEditReq;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 规格详情对象 rule_attr_info
|
||||
*
|
||||
|
@ -86,4 +90,13 @@ public class RuleAttrInfo extends BaseEntity {
|
|||
.build();
|
||||
}
|
||||
|
||||
public static RuleAttrInfo addModelBuild (RuleAttrAddModel ruleAttrAddModel, Supplier<Long> ruleId, Supplier<String> createBy) {
|
||||
return RuleAttrInfo.builder()
|
||||
.ruleId(ruleId.get())
|
||||
.name(ruleAttrAddModel.getName())
|
||||
.attrValue(String.join(",", ruleAttrAddModel.getValueList()))
|
||||
.createBy(createBy.get())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -15,6 +16,9 @@ import com.muyu.product.domain.req.RuleInfoSaveReq;
|
|||
import com.muyu.product.domain.req.RuleInfoEditReq;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 商品规格对象 rule_info
|
||||
*
|
||||
|
@ -47,10 +51,6 @@ public class RuleInfo extends BaseEntity {
|
|||
@ApiModelProperty(name = "规格状态", value = "规格状态")
|
||||
private String status;
|
||||
|
||||
@Excel(name = "规格备注")
|
||||
@ApiModelProperty(name = "规格备注", value = "规格备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
|
@ -68,7 +68,6 @@ public class RuleInfo extends BaseEntity {
|
|||
return RuleInfo.builder()
|
||||
.name(ruleInfoSaveReq.getName())
|
||||
.status(ruleInfoSaveReq.getStatus())
|
||||
.status(ruleInfoSaveReq.getRemark())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -76,17 +75,25 @@ public class RuleInfo extends BaseEntity {
|
|||
* 修改构造器
|
||||
*/
|
||||
public static RuleInfo editBuild(Long id, RuleInfoEditReq ruleInfoEditReq){
|
||||
if (ruleInfoEditReq.getStatus().equals("Y")) {
|
||||
ruleInfoEditReq.setStatus("正常");
|
||||
}else{
|
||||
ruleInfoEditReq.setStatus("停用");
|
||||
}
|
||||
return RuleInfo.builder()
|
||||
.id(id)
|
||||
.name(ruleInfoEditReq.getName())
|
||||
.status(ruleInfoEditReq.getStatus())
|
||||
.status(ruleInfoEditReq.getRemark())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ruleInfoAddModel 添加模型
|
||||
* @param createBy 创建者
|
||||
* @return 规格对象
|
||||
*/
|
||||
public static RuleInfo addModelBuild (RuleInfoAddModel ruleInfoAddModel, Supplier<String> createBy) {
|
||||
return RuleInfo.builder()
|
||||
.name(ruleInfoAddModel.getName())
|
||||
.status(ruleInfoAddModel.getStatus())
|
||||
.createBy(createBy.get())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.RuleAttrInfo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: 规格属性,添加模型
|
||||
* @Date 2024-3-4 下午 02:28
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class RuleAttrAddModel extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 规格属性名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 规格属性值集合
|
||||
*/
|
||||
private List<String> valueList;
|
||||
|
||||
public static RuleAttrAddModel infoBuild (RuleAttrInfo ruleAttrInfo) {
|
||||
return RuleAttrAddModel.builder()
|
||||
.name(ruleAttrInfo.getName())
|
||||
.valueList(Arrays.stream(ruleAttrInfo.getAttrValue().split(",")).toList())
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.req.RuleInfoSaveReq;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: 规格保存模型
|
||||
* @Date 2024-3-4 下午 02:33
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class RuleInfoAddModel extends BaseEntity {
|
||||
|
||||
/** 规格名称 */
|
||||
private String name;
|
||||
|
||||
/** 规格状态 */
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 规格属性集合
|
||||
*/
|
||||
private List<RuleAttrAddModel> ruleAttrList;
|
||||
|
||||
public static RuleInfoAddModel saveReqBuild(RuleInfoSaveReq req){
|
||||
return RuleInfoAddModel.builder()
|
||||
.name(req.getName())
|
||||
.status(req.getStatus())
|
||||
.ruleAttrList(req.getRuleAttrList())
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.AttributeGroup;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: 共有属性组
|
||||
* @Date 2024-3-6 下午 02:29
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TemplateAttributeGroupModel extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 组名称
|
||||
*/
|
||||
private String groupName;
|
||||
|
||||
/**
|
||||
* 属性组下属性集合
|
||||
*/
|
||||
private List<TemplateAttributeModel> attributeList;
|
||||
|
||||
/**
|
||||
* 是否有效
|
||||
* @return
|
||||
*/
|
||||
public boolean isEffective(){
|
||||
return StringUtils.isNotEmpty(groupName) && attributeList != null && !attributeList.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param attributeGroup
|
||||
* @param attributeList
|
||||
* @return
|
||||
*/
|
||||
public static TemplateAttributeGroupModel attributeGroupBuild(AttributeGroup attributeGroup,
|
||||
Function<Long, List<TemplateAttributeModel>> attributeList){
|
||||
return TemplateAttributeGroupModel.builder()
|
||||
.groupName(attributeGroup.getName())
|
||||
.attributeList(attributeList.apply(attributeGroup.getId()))
|
||||
.build();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: 共有属性
|
||||
* @Date 2024-3-6 下午 02:30
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TemplateAttributeModel extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 属性名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
}
|
|
@ -23,10 +23,6 @@ public class RuleInfoEditReq extends BaseEntity {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 规格名称 */
|
||||
@ApiModelProperty(name = "主键", value = "主键")
|
||||
private Integer id;
|
||||
|
||||
/** 规格名称 */
|
||||
@ApiModelProperty(name = "规格名称", value = "规格名称")
|
||||
private String name;
|
||||
|
@ -35,7 +31,4 @@ public class RuleInfoEditReq extends BaseEntity {
|
|||
@ApiModelProperty(name = "规格状态", value = "规格状态")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty(name = "规格备注", value = "规格备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.product.domain.req;
|
||||
|
||||
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||
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
|
||||
*
|
||||
|
@ -23,22 +26,16 @@ public class RuleInfoSaveReq extends BaseEntity {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
|
||||
@ApiModelProperty(name = "主键", value = "主键")
|
||||
private Long id;
|
||||
|
||||
/** 规格名称 */
|
||||
|
||||
@ApiModelProperty(name = "规格名称", value = "规格名称")
|
||||
private String name;
|
||||
|
||||
/** 规格状态 */
|
||||
|
||||
@ApiModelProperty(name = "规格状态", value = "规格状态")
|
||||
private String status;
|
||||
|
||||
|
||||
@ApiModelProperty(name = "规格备注", value = "规格备注")
|
||||
private String remark;
|
||||
/**
|
||||
* 规格属性集合
|
||||
*/
|
||||
private List<RuleAttrAddModel> ruleAttrList;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package com.muyu.product.domain.resp;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.model.TemplateAttributeGroupModel;
|
||||
import com.muyu.product.domain.model.TemplateAttributeModel;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: 商品类别公共元素
|
||||
* @Date 2024-3-6 下午 02:25
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CategoryCommonElementResp extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 共有属性组
|
||||
*/
|
||||
private List<TemplateAttributeGroupModel> templateAttributeGroupList;
|
||||
|
||||
/**
|
||||
* 共有属性
|
||||
*/
|
||||
private List<TemplateAttributeModel> templateAttributeList;
|
||||
|
||||
/**
|
||||
* 自有属性(所有未包含属性)
|
||||
*/
|
||||
private List<TemplateAttributeModel> attributeList;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.muyu.product.domain.resp;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.RuleInfo;
|
||||
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.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: 规格返回结果集
|
||||
* @Date 2024-3-4 下午 04:08
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class RuleInfoResp extends BaseEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
/** 规格名称 */
|
||||
private String name;
|
||||
|
||||
/** 规格状态 */
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 规格属性集合
|
||||
*/
|
||||
private List<RuleAttrAddModel> ruleAttrList;
|
||||
|
||||
public static RuleInfoResp infoBuild (RuleInfo ruleInfo, Function<Long, List<RuleAttrAddModel>> ruleAttrList) {
|
||||
return RuleInfoResp.builder()
|
||||
.id(ruleInfo.getId())
|
||||
.name(ruleInfo.getName())
|
||||
.status(ruleInfo.getStatus())
|
||||
.ruleAttrList(ruleAttrList.apply(ruleInfo.getId()))
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -54,8 +54,6 @@ public class AttributeGroupController extends BaseController {
|
|||
return Result.success(tableDataInfo);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
@ApiOperation("获取属性组列表")
|
||||
@RequiresPermissions("product:attributeGroup:list1")
|
||||
@GetMapping("listAll")
|
||||
|
@ -65,7 +63,6 @@ public class AttributeGroupController extends BaseController {
|
|||
return Result.success(page);
|
||||
}
|
||||
|
||||
>>>>>>> 3028276 (属性组)
|
||||
/**
|
||||
* 导出属性组列表
|
||||
*/
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.controller;
|
|||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.common.core.text.Convert;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -45,18 +46,13 @@ public class BrandInfoController extends BaseController {
|
|||
@ApiOperation("获取品牌信息列表")
|
||||
@RequiresPermissions("product:brand:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<BrandInfo>> list(BrandInfoQueryReq brandInfoQueryReq) {
|
||||
startPage();
|
||||
public Result list(BrandInfoQueryReq brandInfoQueryReq) {
|
||||
boolean isPage = brandInfoQueryReq.getParams().get("isPage") == null || Convert.toBool(brandInfoQueryReq.getParams().get("isPage"), true);
|
||||
if (isPage){
|
||||
startPage();
|
||||
}
|
||||
List<BrandInfo> list = brandInfoService.list(BrandInfo.queryBuild(brandInfoQueryReq));
|
||||
return getDataTable(list);
|
||||
}
|
||||
@ApiOperation("获取品牌信息列表")
|
||||
@RequiresPermissions("product:brand:list")
|
||||
@GetMapping("/listBrand")
|
||||
public Result<TableDataInfo<BrandInfo>> listBrand(BrandInfoQueryReq brandInfoQueryReq){
|
||||
startPage();
|
||||
List<BrandInfo> list=brandInfoService.listBrand(BrandInfo.queryBuild(brandInfoQueryReq));
|
||||
return getDataTable(list);
|
||||
return isPage ? getDataTable(list) : Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.muyu.product.domain.AttributeGroup;
|
|||
import com.muyu.product.domain.AttributeInfo;
|
||||
import com.muyu.product.domain.BrandInfo;
|
||||
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||
import com.muyu.product.domain.resp.CategoryCommonElementResp;
|
||||
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -80,6 +81,17 @@ public class CategoryInfoController extends BaseController {
|
|||
return Result.success(categoryInfoService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取品类信息详细信息
|
||||
*/
|
||||
@ApiOperation("获取品类信息共有属性信息")
|
||||
@RequiresPermissions("product:category:query")
|
||||
@GetMapping(value = "/getTemplateAttribute/{cateGoryId}")
|
||||
@ApiImplicitParam(name = "cateGoryId", value = "cateGoryId", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<CategoryCommonElementResp> getTemplateAttributeByCateGoryId(@PathVariable("cateGoryId") Long cateGoryId) {
|
||||
return Result.success(categoryInfoService.getTemplateAttributeByCateGoryId(cateGoryId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增品类信息
|
||||
*/
|
||||
|
|
|
@ -108,13 +108,4 @@ public class ProjectInfoController extends BaseController {
|
|||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(projectInfoService.removeBatchByIds(ids));
|
||||
}
|
||||
|
||||
@RequiresPermissions("product:info:remove1")
|
||||
@Log(title = "商品信息",businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/type/{ids}")
|
||||
@ApiOperation("删除商品信息")
|
||||
@ApiImplicitParam(name ="id",value = "id",required = true,dataType = "long", paramType = "path",dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> removeInfo(@PathVariable List<Long> ids){
|
||||
return toAjax(projectInfoService.removeBatchByIds(ids));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.muyu.product.controller;
|
|||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.mysql.cj.protocol.ResultStreamer;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -87,14 +86,6 @@ public class ProjectSkuInfoController extends BaseController {
|
|||
return toAjax(projectSkuInfoService.save(ProjectSkuInfo.saveBuild(projectSkuInfoSaveReq)));
|
||||
}
|
||||
|
||||
@RequiresPermissions("product:sku:add1")
|
||||
@Log(title ="商品SKU",businessType = BusinessType.INSERT)
|
||||
@PostMapping("/sku/add")
|
||||
@ApiOperation("新增商品SKU")
|
||||
public Result<String> addSKU(@RequestBody ProjectSkuInfoSaveReq projectSkuInfoSaveReq){
|
||||
return toAjax(projectSkuInfoService.save(ProjectSkuInfo.saveBuild(projectSkuInfoSaveReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商品SKU
|
||||
*/
|
||||
|
@ -117,13 +108,4 @@ public class ProjectSkuInfoController extends BaseController {
|
|||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(projectSkuInfoService.removeBatchByIds(ids));
|
||||
}
|
||||
|
||||
@RequiresPermissions("product:sku:remove2")
|
||||
@Log(title = "商品SKU",businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/sku/{ids}")
|
||||
@ApiOperation("删除商品SKU")
|
||||
@ApiImplicitParam(name = "id",value = "id",required = true,dataType = "Long",paramType = "path",dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> removeSku(@PathVariable List<Long> ids){
|
||||
return toAjax(projectSkuInfoService.removeBatchByIds(ids));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@ package com.muyu.product.controller;
|
|||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.common.core.text.Convert;
|
||||
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -45,10 +48,13 @@ public class RuleInfoController extends BaseController {
|
|||
@ApiOperation("获取商品规格列表")
|
||||
@RequiresPermissions("product:rule:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<RuleInfo>> list(RuleInfoQueryReq ruleInfoQueryReq) {
|
||||
startPage();
|
||||
List<RuleInfo> list = ruleInfoService.list(RuleInfo.queryBuild(ruleInfoQueryReq));
|
||||
return getDataTable(list);
|
||||
public Result list(RuleInfoQueryReq ruleInfoQueryReq) {
|
||||
boolean isPage = ruleInfoQueryReq.getParams().get("isPage") == null || Convert.toBool(ruleInfoQueryReq.getParams().get("isPage"), true);
|
||||
if (isPage){
|
||||
startPage();
|
||||
}
|
||||
TableDataInfo<RuleInfoResp> tableDataInfo = ruleInfoService.queryList(ruleInfoQueryReq);
|
||||
return isPage ? Result.success(tableDataInfo) : Result.success(tableDataInfo.getRows());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,12 +89,7 @@ public class RuleInfoController extends BaseController {
|
|||
@PostMapping
|
||||
@ApiOperation("新增商品规格")
|
||||
public Result<String> add(@RequestBody RuleInfoSaveReq ruleInfoSaveReq) {
|
||||
if (ruleInfoSaveReq.getStatus().equals("Y")){
|
||||
ruleInfoSaveReq.setStatus("正常");
|
||||
}else {
|
||||
ruleInfoSaveReq.setStatus("停用");
|
||||
}
|
||||
return toAjax(ruleInfoService.save(RuleInfo.saveBuild(ruleInfoSaveReq)));
|
||||
return toAjax(ruleInfoService.save(RuleInfoAddModel.saveReqBuild(ruleInfoSaveReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,11 +100,6 @@ public class RuleInfoController extends BaseController {
|
|||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改商品规格")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody RuleInfoEditReq ruleInfoEditReq) {
|
||||
if (ruleInfoEditReq.getStatus().equals("Y")){
|
||||
ruleInfoEditReq.setStatus("正常");
|
||||
}else {
|
||||
ruleInfoEditReq.setStatus("停用");
|
||||
}
|
||||
return toAjax(ruleInfoService.updateById(RuleInfo.editBuild(id,ruleInfoEditReq)));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,5 +19,4 @@ public interface BrandInfoService extends IService<BrandInfo> {
|
|||
*/
|
||||
public List<BrandInfo> list(BrandInfo brandInfo);
|
||||
|
||||
List<BrandInfo> listBrand(BrandInfo brandInfo);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.muyu.product.domain.BrandInfo;
|
|||
import com.muyu.product.domain.CategoryInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||
import com.muyu.product.domain.resp.CategoryCommonElementResp;
|
||||
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
||||
|
||||
/**
|
||||
|
@ -59,4 +60,11 @@ public interface CategoryInfoService extends IService<CategoryInfo> {
|
|||
* @return 父级以上的属性、属性组、品牌集合
|
||||
*/
|
||||
CategoryParentCommonElementResp parentCommonElement (Long categoryId);
|
||||
|
||||
/**
|
||||
* 通过品类ID获取品类共有属性
|
||||
* @param cateGoryId 品类ID
|
||||
* @return 品类共有属性
|
||||
*/
|
||||
CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
package com.muyu.product.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.RuleInfoQueryReq;
|
||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||
|
||||
/**
|
||||
* 商品规格Service接口
|
||||
|
@ -19,4 +24,12 @@ public interface RuleInfoService extends IService<RuleInfo> {
|
|||
*/
|
||||
public List<RuleInfo> list(RuleInfo ruleInfo);
|
||||
|
||||
/**
|
||||
* 添加规格信息
|
||||
* @param ruleInfoAddModel 规格添加模型
|
||||
* @return 时候成功
|
||||
*/
|
||||
public boolean save(RuleInfoAddModel ruleInfoAddModel);
|
||||
|
||||
TableDataInfo<RuleInfoResp> queryList (RuleInfoQueryReq ruleInfoQueryReq);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class BrandInfoServiceImpl extends ServiceImpl<BrandInfoMapper, BrandInfo
|
|||
|
||||
|
||||
if (ObjUtils.notNull(brandInfo.getNam())){
|
||||
queryWrapper.eq(BrandInfo::getNam, brandInfo.getNam());
|
||||
queryWrapper.like(BrandInfo::getNam, brandInfo.getNam());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(brandInfo.getLogo())){
|
||||
|
@ -53,25 +53,6 @@ public class BrandInfoServiceImpl extends ServiceImpl<BrandInfoMapper, BrandInfo
|
|||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BrandInfo> listBrand(BrandInfo brandInfo) {
|
||||
LambdaQueryWrapper<BrandInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (ObjUtils.notNull(brandInfo.getNam())){
|
||||
queryWrapper.eq(BrandInfo::getNam,brandInfo.getNam());
|
||||
}
|
||||
if (ObjUtils.notNull(brandInfo.getLogo())){
|
||||
queryWrapper.eq(BrandInfo::getLogo,brandInfo.getLogo());
|
||||
}
|
||||
if (ObjUtils.notNull(brandInfo.getStart())){
|
||||
queryWrapper.eq(BrandInfo::getStart, brandInfo.getStart());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(brandInfo.getIntroduction())){
|
||||
queryWrapper.eq(BrandInfo::getIntroduction, brandInfo.getIntroduction());
|
||||
}
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(BrandInfo entity) {
|
||||
entity.setCreateBy(SecurityUtils.getUsername());
|
||||
|
|
|
@ -1,25 +1,31 @@
|
|||
package com.muyu.product.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
import com.muyu.product.domain.*;
|
||||
import com.muyu.product.domain.base.CategoryBase;
|
||||
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||
import com.muyu.product.domain.model.TemplateAttributeGroupModel;
|
||||
import com.muyu.product.domain.model.TemplateAttributeModel;
|
||||
import com.muyu.product.domain.resp.CategoryCommonElementResp;
|
||||
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
||||
import com.muyu.product.mapper.CategoryInfoMapper;
|
||||
import com.muyu.product.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.product.mapper.CategoryInfoMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 品类信息Service业务层处理
|
||||
*
|
||||
|
@ -28,7 +34,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, CategoryInfo> implements CategoryInfoService {
|
||||
public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, CategoryInfo> implements CategoryInfoService {
|
||||
|
||||
|
||||
@Autowired
|
||||
|
@ -40,6 +46,9 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
@Autowired
|
||||
private AsCategoryBrandService asCategoryBrandService;
|
||||
|
||||
@Autowired
|
||||
private AsAttributeGroupService asAttributeGroupService;
|
||||
|
||||
@Autowired
|
||||
private AttributeInfoService attributeInfoService;
|
||||
|
||||
|
@ -53,30 +62,31 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
* 查询品类信息列表
|
||||
*
|
||||
* @param categoryInfo 品类信息
|
||||
*
|
||||
* @return 品类信息
|
||||
*/
|
||||
@Override
|
||||
public List<CategoryInfo> list(CategoryInfo categoryInfo) {
|
||||
public List<CategoryInfo> list (CategoryInfo categoryInfo) {
|
||||
LambdaQueryWrapper<CategoryInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
|
||||
if (ObjUtils.notNull(categoryInfo.getName())){
|
||||
if (ObjUtils.notNull(categoryInfo.getName())) {
|
||||
queryWrapper.like(CategoryInfo::getName, categoryInfo.getName());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(categoryInfo.getImage())){
|
||||
if (ObjUtils.notNull(categoryInfo.getImage())) {
|
||||
queryWrapper.eq(CategoryInfo::getImage, categoryInfo.getImage());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(categoryInfo.getParentId())){
|
||||
if (ObjUtils.notNull(categoryInfo.getParentId())) {
|
||||
queryWrapper.eq(CategoryInfo::getParentId, categoryInfo.getParentId());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(categoryInfo.getStart())){
|
||||
if (ObjUtils.notNull(categoryInfo.getStart())) {
|
||||
queryWrapper.eq(CategoryInfo::getStart, categoryInfo.getStart());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(categoryInfo.getIntroduction())){
|
||||
if (ObjUtils.notNull(categoryInfo.getIntroduction())) {
|
||||
queryWrapper.eq(CategoryInfo::getIntroduction, categoryInfo.getIntroduction());
|
||||
}
|
||||
|
||||
|
@ -85,12 +95,12 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean save(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||
public boolean save (CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||
CategoryInfo categoryInfo = CategoryInfo.saveModelBuild(categoryInfoSaveModel);
|
||||
boolean save = this.save(categoryInfo);
|
||||
Long categoryInfoId = categoryInfo.getId();
|
||||
List<Long> attributeIdList = categoryInfoSaveModel.getAttributeIdList();
|
||||
if (attributeIdList != null && !attributeIdList.isEmpty()){
|
||||
if (attributeIdList != null && !attributeIdList.isEmpty()) {
|
||||
asCategoryAttributeService.saveBatch(
|
||||
attributeIdList.stream()
|
||||
.map(attributeId -> AsCategoryAttribute.categoryBuild(categoryInfoId, attributeId))
|
||||
|
@ -98,7 +108,7 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
);
|
||||
}
|
||||
List<Long> attributeGroupIdList = categoryInfoSaveModel.getAttributeGroupIdList();
|
||||
if (attributeGroupIdList != null && !attributeGroupIdList.isEmpty()){
|
||||
if (attributeGroupIdList != null && !attributeGroupIdList.isEmpty()) {
|
||||
asCategoryAttributeGroupService.saveBatch(
|
||||
attributeGroupIdList.stream()
|
||||
.map(attributeGroupId -> AsCategoryAttributeGroup.categoryBuild(categoryInfoId, attributeGroupId))
|
||||
|
@ -106,7 +116,7 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
);
|
||||
}
|
||||
List<Long> brandIdList = categoryInfoSaveModel.getBrandIdList();
|
||||
if (brandIdList != null && !brandIdList.isEmpty()){
|
||||
if (brandIdList != null && !brandIdList.isEmpty()) {
|
||||
asCategoryBrandService.saveBatch(
|
||||
brandIdList.stream()
|
||||
.map(brandId -> AsCategoryBrand.categoryBuild(categoryInfoId, brandId))
|
||||
|
@ -129,20 +139,20 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
LambdaQueryWrapper<AsCategoryAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AsCategoryAttributeGroup::getCategoryId, categoryId);
|
||||
List<AsCategoryAttributeGroup> asCategoryAttributeGroupList = asCategoryAttributeGroupService.list(queryWrapper);
|
||||
if (asCategoryAttributeGroupList != null && !asCategoryAttributeGroupList.isEmpty()){
|
||||
if (asCategoryAttributeGroupList != null && !asCategoryAttributeGroupList.isEmpty()) {
|
||||
List<Long> attributeGroupIdList = asCategoryAttributeGroupList.stream()
|
||||
.map(AsCategoryAttributeGroup::getAttributeGroupId)
|
||||
.toList();
|
||||
attributeGroupList.addAll(attributeGroupService.listByIds(attributeGroupIdList));
|
||||
}
|
||||
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||
if (categoryInfo.getParentId() != 0){
|
||||
if (attributeGroupList.isEmpty()){
|
||||
if (categoryInfo.getParentId() != 0) {
|
||||
if (attributeGroupList.isEmpty()) {
|
||||
attributeGroupList.addAll(getAttributeGroup(categoryInfo.getParentId()));
|
||||
}else {
|
||||
} else {
|
||||
List<AttributeGroup> attributeGroups = getAttributeGroup(categoryInfo.getParentId());
|
||||
attributeGroups.forEach(attributeGroup -> {
|
||||
if (!attributeGroupList.contains(attributeGroup)){
|
||||
if (!attributeGroupList.contains(attributeGroup)) {
|
||||
attributeGroupList.add(attributeGroup);
|
||||
}
|
||||
});
|
||||
|
@ -164,20 +174,20 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
LambdaQueryWrapper<AsCategoryBrand> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AsCategoryBrand::getCategoryId, categoryId);
|
||||
List<AsCategoryBrand> asCategoryBrandList = asCategoryBrandService.list(queryWrapper);
|
||||
if (asCategoryBrandList != null && !asCategoryBrandList.isEmpty()){
|
||||
if (asCategoryBrandList != null && !asCategoryBrandList.isEmpty()) {
|
||||
List<Long> brandIdList = asCategoryBrandList.stream()
|
||||
.map(AsCategoryBrand::getBrandId)
|
||||
.toList();
|
||||
brandInfoList.addAll(brandInfoService.listByIds(brandIdList));
|
||||
}
|
||||
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||
if (categoryInfo.getParentId() != 0){
|
||||
if (brandInfoList.isEmpty()){
|
||||
if (categoryInfo.getParentId() != 0) {
|
||||
if (brandInfoList.isEmpty()) {
|
||||
brandInfoList.addAll(getBrand(categoryInfo.getParentId()));
|
||||
}else {
|
||||
} else {
|
||||
List<BrandInfo> brandInfos = getBrand(categoryInfo.getParentId());
|
||||
brandInfos.forEach(brandInfo -> {
|
||||
if (!brandInfoList.contains(brandInfo)){
|
||||
if (!brandInfoList.contains(brandInfo)) {
|
||||
brandInfoList.add(brandInfo);
|
||||
}
|
||||
});
|
||||
|
@ -200,20 +210,20 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
LambdaQueryWrapper<AsCategoryAttribute> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AsCategoryAttribute::getCategoryId, categoryId);
|
||||
List<AsCategoryAttribute> asCategoryAttributeList = asCategoryAttributeService.list(queryWrapper);
|
||||
if (asCategoryAttributeList != null && !asCategoryAttributeList.isEmpty()){
|
||||
if (asCategoryAttributeList != null && !asCategoryAttributeList.isEmpty()) {
|
||||
List<Long> attributeIdList = asCategoryAttributeList.stream()
|
||||
.map(AsCategoryAttribute::getAttributeId)
|
||||
.toList();
|
||||
attributeInfoList.addAll(attributeInfoService.listByIds(attributeIdList));
|
||||
}
|
||||
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||
if (categoryInfo.getParentId() != 0){
|
||||
if (attributeInfoList.isEmpty()){
|
||||
if (categoryInfo.getParentId() != 0) {
|
||||
if (attributeInfoList.isEmpty()) {
|
||||
attributeInfoList.addAll(getAttribute(categoryInfo.getParentId()));
|
||||
}else {
|
||||
} else {
|
||||
List<AttributeInfo> attributeInfos = getAttribute(categoryInfo.getParentId());
|
||||
attributeInfos.forEach(attributeInfoQuery -> {
|
||||
if (!attributeInfoList.contains(attributeInfoQuery)){
|
||||
if (!attributeInfoList.contains(attributeInfoQuery)) {
|
||||
attributeInfoList.add(attributeInfoQuery);
|
||||
}
|
||||
});
|
||||
|
@ -223,16 +233,15 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
}
|
||||
|
||||
|
||||
|
||||
public <T,AS> List<T> getCommon(Long categoryId,IService<AS> iService,IService<T> bsiService){
|
||||
public <T, AS> List<T> getCommon (Long categoryId, IService<AS> iService, IService<T> bsiService) {
|
||||
List<T> list = new ArrayList();
|
||||
QueryWrapper<AS> asQueryWrapper = new QueryWrapper<>();
|
||||
asQueryWrapper.eq("category_id", categoryId);
|
||||
List<AS> asList = iService.list(asQueryWrapper);
|
||||
if (asList != null && !asList.isEmpty()){
|
||||
if (asList != null && !asList.isEmpty()) {
|
||||
List<Long> baseIdList = asList.stream()
|
||||
.map(as -> {
|
||||
if (as instanceof CategoryBase categoryBase){
|
||||
if (as instanceof CategoryBase categoryBase) {
|
||||
return categoryBase.getBaseId();
|
||||
}
|
||||
return null;
|
||||
|
@ -241,13 +250,13 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
list.addAll(bsiService.listByIds(baseIdList));
|
||||
}
|
||||
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||
if (categoryInfo.getParentId() != 0){
|
||||
if (list.isEmpty()){
|
||||
if (categoryInfo.getParentId() != 0) {
|
||||
if (list.isEmpty()) {
|
||||
list.addAll(getCommon(categoryInfo.getParentId(), iService, bsiService));
|
||||
}else {
|
||||
} else {
|
||||
List<T> commonList = getCommon(categoryInfo.getParentId(), iService, bsiService);
|
||||
commonList.forEach(common -> {
|
||||
if (!list.contains(common)){
|
||||
if (!list.contains(common)) {
|
||||
list.add(common);
|
||||
}
|
||||
});
|
||||
|
@ -271,4 +280,93 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
.brandInfoList(getCommon(categoryId, asCategoryBrandService, brandInfoService))
|
||||
.build();
|
||||
}
|
||||
|
||||
private void getParentIdListByCateGoryId(List<Long> parentIdList, Long cateGoryId){
|
||||
if (cateGoryId.equals(0L)){
|
||||
return;
|
||||
}
|
||||
CategoryInfo categoryInfo = this.getById(cateGoryId);
|
||||
parentIdList.add(categoryInfo.getId());
|
||||
getParentIdListByCateGoryId(parentIdList, categoryInfo.getParentId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过品类ID获取品类共有属性
|
||||
*
|
||||
* @param cateGoryId 品类ID
|
||||
*
|
||||
* @return 品类共有属性
|
||||
*/
|
||||
@Override
|
||||
public CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId) {
|
||||
ArrayList<Long> cateGoryIdList = new ArrayList<>();
|
||||
getParentIdListByCateGoryId(cateGoryIdList,cateGoryId);
|
||||
LambdaQueryWrapper<AsCategoryAttributeGroup> asCategoryAttributeGroupLambdaQueryWrapper = new LambdaQueryWrapper<>() {{
|
||||
in(AsCategoryAttributeGroup::getCategoryId, cateGoryIdList);
|
||||
}};
|
||||
List<AsCategoryAttributeGroup> categoryAttributeGroupList = asCategoryAttributeGroupService.list(asCategoryAttributeGroupLambdaQueryWrapper);
|
||||
List<TemplateAttributeGroupModel> attributeGroupModelList = categoryAttributeGroupList.stream()
|
||||
.map(asCategoryAttributeGroup -> TemplateAttributeGroupModel.attributeGroupBuild(
|
||||
attributeGroupService.getById(asCategoryAttributeGroup.getAttributeGroupId()),
|
||||
attributeGroupId -> {
|
||||
LambdaQueryWrapper<AsAttributeGroup> asAttributeGroupLambdaQueryWrapper = new LambdaQueryWrapper<>() {{
|
||||
eq(AsAttributeGroup::getGroupId, asCategoryAttributeGroup.getAttributeGroupId());
|
||||
}};
|
||||
List<Long> attributeList = asAttributeGroupService.list(asAttributeGroupLambdaQueryWrapper).stream()
|
||||
.map(AsAttributeGroup::getAttributeId)
|
||||
.toList();
|
||||
if (attributeList.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return attributeInfoService.listByIds(attributeList).stream()
|
||||
.map(AttributeInfo::buildTemplateModel)
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
))
|
||||
.filter(TemplateAttributeGroupModel::isEffective)
|
||||
.toList();
|
||||
Set<Long> attributeIdSet = new HashSet<>();
|
||||
if (!attributeGroupModelList.isEmpty()){
|
||||
attributeIdSet.addAll(
|
||||
attributeGroupModelList.stream()
|
||||
.flatMap((Function<? super TemplateAttributeGroupModel,Stream<TemplateAttributeModel>>) templateAttributeGroupModel -> templateAttributeGroupModel.getAttributeList().stream())
|
||||
.map(TemplateAttributeModel::getId)
|
||||
.toList()
|
||||
);
|
||||
}
|
||||
List<TemplateAttributeModel> templateAttributeModelList =new ArrayList<>();
|
||||
LambdaQueryWrapper<AsCategoryAttribute> categoryAttributeLambdaQueryWrapper=new LambdaQueryWrapper<>();
|
||||
categoryAttributeLambdaQueryWrapper.in(AsCategoryAttribute::getCategoryId,cateGoryIdList);
|
||||
List<AsCategoryAttribute> asCategoryAttributeList=asCategoryAttributeService.list(categoryAttributeLambdaQueryWrapper);
|
||||
List<Long> templateAttributeIdList = asCategoryAttributeList.stream()
|
||||
.map(AsCategoryAttribute::getAttributeId)
|
||||
.filter(templateAttributeId -> !attributeIdSet.contains(templateAttributeId))
|
||||
.toList();
|
||||
if (asCategoryAttributeList!=null && ! asCategoryAttributeList.isEmpty())
|
||||
asCategoryAttributeList.stream()
|
||||
.map(AsCategoryAttribute::getAttributeId)
|
||||
.filter(templateAttributeId -> !attributeIdSet.contains(templateAttributeId))
|
||||
.toList();
|
||||
templateAttributeModelList=attributeInfoService.listByIds(templateAttributeIdList).stream()
|
||||
.map(AttributeInfo::buildTemplateModel)
|
||||
.toList();
|
||||
List<TemplateAttributeModel> attributeModelList=new ArrayList<>();
|
||||
if (!templateAttributeModelList.isEmpty()){
|
||||
attributeIdSet.addAll(
|
||||
templateAttributeModelList.stream().map(TemplateAttributeModel::getId).toList()
|
||||
);
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<AttributeInfo> attributeInfoLambdaQueryWrapper=new LambdaQueryWrapper<>();
|
||||
attributeInfoLambdaQueryWrapper.notIn(!attributeIdSet.isEmpty(),AttributeInfo::getId,attributeIdSet);
|
||||
attributeModelList=attributeInfoService.list(attributeInfoLambdaQueryWrapper).stream().map(AttributeInfo::buildTemplateModel).toList();
|
||||
|
||||
return CategoryCommonElementResp.builder()
|
||||
.templateAttributeGroupList(attributeGroupModelList)
|
||||
.attributeList(attributeModelList)
|
||||
.build();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,25 @@
|
|||
package com.muyu.product.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
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.model.RuleAttrAddModel;
|
||||
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||
import com.muyu.product.domain.req.RuleInfoQueryReq;
|
||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||
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;
|
||||
|
@ -21,6 +37,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
@Service
|
||||
public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo> implements RuleInfoService {
|
||||
|
||||
@Autowired
|
||||
private RuleAttrInfoService ruleAttrInfoService;
|
||||
|
||||
/**
|
||||
* 查询商品规格列表
|
||||
*
|
||||
|
@ -46,4 +65,41 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
|||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加规格信息
|
||||
*
|
||||
* @param ruleInfoAddModel 规格添加模型
|
||||
*
|
||||
* @return 时候成功
|
||||
*/
|
||||
@Override
|
||||
public boolean save (RuleInfoAddModel ruleInfoAddModel) {
|
||||
RuleInfo ruleInfo = RuleInfo.addModelBuild(ruleInfoAddModel, SecurityUtils::getUsername);
|
||||
boolean save = this.save(ruleInfo);
|
||||
ruleAttrInfoService.saveBatch(
|
||||
ruleInfoAddModel.getRuleAttrList().stream()
|
||||
.map(ruleAttrAddModel -> RuleAttrInfo.addModelBuild(ruleAttrAddModel, ruleInfo::getId, SecurityUtils::getUsername))
|
||||
.toList()
|
||||
);
|
||||
return save;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<RuleInfoResp> queryList (RuleInfoQueryReq ruleInfoQueryReq) {
|
||||
List<RuleInfo> list = this.list(RuleInfo.queryBuild(ruleInfoQueryReq));
|
||||
List<RuleInfoResp> ruleInfoRespList = list.stream()
|
||||
.map(ruleInfo -> RuleInfoResp.infoBuild(ruleInfo, ruleId -> {
|
||||
LambdaQueryWrapper<RuleAttrInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(RuleAttrInfo::getRuleId, ruleId);
|
||||
return ruleAttrInfoService.list(queryWrapper).stream().map(RuleAttrAddModel::infoBuild).toList();
|
||||
}))
|
||||
.toList();
|
||||
boolean isPage = ruleInfoQueryReq.getParams().get("isPage") == null || Convert.toBool(ruleInfoQueryReq.getParams().get("isPage"), true);
|
||||
|
||||
return TableDataInfo.<RuleInfoResp>builder()
|
||||
.rows(ruleInfoRespList)
|
||||
.total(isPage ? new PageInfo<>(list).getTotal() : 0)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,10 +14,10 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 122.51.111.225:8848
|
||||
server-addr: 127.0.0.1:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 122.51.111.225:8848
|
||||
server-addr: 127.0.0.1:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
Loading…
Reference in New Issue