12.4,第2版
parent
a40991aec4
commit
85905d3297
|
@ -23,5 +23,21 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
<version>2.3.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-oas</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -49,6 +49,9 @@ public class AttributeGroup extends BaseEntity {
|
|||
@ApiModelProperty(name = "状态", value = "状态", required = true)
|
||||
private String states;
|
||||
|
||||
@ApiModelProperty(name = "备注" ,value = "状态" ,required = true)
|
||||
private String remark;
|
||||
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
|
@ -67,6 +70,7 @@ public class AttributeGroup extends BaseEntity {
|
|||
return AttributeGroup.builder()
|
||||
.name(attributeGroupSaveReq.getName())
|
||||
.states(attributeGroupSaveReq.getStates())
|
||||
.remark(attributeGroupSaveReq.getRemark())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -78,6 +82,7 @@ public class AttributeGroup extends BaseEntity {
|
|||
.id(id)
|
||||
.name(attributeGroupEditReq.getName())
|
||||
.states(attributeGroupEditReq.getStates())
|
||||
.remark(attributeGroupEditReq.getRemark())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.muyu.product.domain.req.CategoryInfoEditReq;
|
|||
import com.muyu.common.core.web.domain.TreeEntity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -62,6 +63,56 @@ public class CategoryInfo extends TreeEntity {
|
|||
@ApiModelProperty(name = "介绍", value = "介绍")
|
||||
private String introduction;
|
||||
|
||||
@ApiModelProperty(name = "备注", value = "备注")
|
||||
private String remark;
|
||||
|
||||
@Override
|
||||
public Long getParentId() {
|
||||
return super.getParentId() != null ? super.getParentId() : 0L;
|
||||
}
|
||||
|
||||
/**
|
||||
* 安全地获取父级ID
|
||||
*/
|
||||
public Long getSafeParentId() {
|
||||
return Optional.ofNullable(super.getParentId()).orElse(0L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否有父级
|
||||
*/
|
||||
public boolean hasParent() {
|
||||
Long parentId = getParentId();
|
||||
return parentId != null && parentId != 0;
|
||||
}
|
||||
|
||||
// 修改构造器方法,添加对 parentId 的安全处理
|
||||
public static CategoryInfo saveBuild(CategoryInfoSaveReq categoryInfoSaveReq, Supplier<String> supplier) {
|
||||
return CategoryInfo.builder()
|
||||
.name(categoryInfoSaveReq.getName())
|
||||
.image(categoryInfoSaveReq.getImage())
|
||||
.start(categoryInfoSaveReq.getStart())
|
||||
.remark(categoryInfoSaveReq.getRemark())
|
||||
.introduction(categoryInfoSaveReq.getIntroduction())
|
||||
.parentId(Optional.ofNullable(categoryInfoSaveReq.getParentId()).orElse(0L))
|
||||
.createBy(supplier.get())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CategoryInfo saveModelBuild(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||
return CategoryInfo.builder()
|
||||
.name(categoryInfoSaveModel.getName())
|
||||
.image(categoryInfoSaveModel.getImage())
|
||||
.start(categoryInfoSaveModel.getStart())
|
||||
.remark(categoryInfoSaveModel.getRemark())
|
||||
.introduction(categoryInfoSaveModel.getIntroduction())
|
||||
.parentId(Optional.ofNullable(categoryInfoSaveModel.getParentId()).orElse(0L))
|
||||
.createBy(categoryInfoSaveModel.getCreateBy())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
|
@ -74,43 +125,15 @@ public class CategoryInfo extends TreeEntity {
|
|||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加构造器
|
||||
*/
|
||||
public static CategoryInfo saveBuild(CategoryInfoSaveReq categoryInfoSaveReq, Supplier<String> supplier){
|
||||
return CategoryInfo.builder()
|
||||
.name(categoryInfoSaveReq.getName())
|
||||
.image(categoryInfoSaveReq.getImage())
|
||||
.start(categoryInfoSaveReq.getStart())
|
||||
.introduction(categoryInfoSaveReq.getIntroduction())
|
||||
.parentId(categoryInfoSaveReq.getParentId())
|
||||
.createBy(supplier.get())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改构造器
|
||||
*/
|
||||
public static CategoryInfo editBuild(Long id, CategoryInfoEditReq categoryInfoEditReq){
|
||||
return CategoryInfo.builder()
|
||||
.id(id)
|
||||
.name(categoryInfoEditReq.getName())
|
||||
.image(categoryInfoEditReq.getImage())
|
||||
.remark(categoryInfoEditReq.getRemark())
|
||||
.start(categoryInfoEditReq.getStart())
|
||||
.introduction(categoryInfoEditReq.getIntroduction())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CategoryInfo saveModelBuild(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||
return CategoryInfo.builder()
|
||||
.name(categoryInfoSaveModel.getName())
|
||||
.image(categoryInfoSaveModel.getImage())
|
||||
.start(categoryInfoSaveModel.getStart())
|
||||
.introduction(categoryInfoSaveModel.getIntroduction())
|
||||
.parentId(categoryInfoSaveModel.getParentId())
|
||||
.createBy(categoryInfoSaveModel.getCreateBy())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,10 +90,10 @@ public class ProjectInfo extends BaseEntity {
|
|||
@Excel(name = "品牌")
|
||||
@ApiModelProperty(name = "品牌", value = "品牌")
|
||||
private Long brandId;
|
||||
/** 拼团id */
|
||||
@Excel(name = "拼团id")
|
||||
@ApiModelProperty(name = "拼团id", value = "拼团id")
|
||||
private Long teamId;
|
||||
|
||||
@ApiModelProperty(name = "备注", value = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
|
@ -152,4 +152,17 @@ public class ProjectInfo extends BaseEntity {
|
|||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ProjectInfo that = (ProjectInfo) o;
|
||||
// 需要先判断 id 是否为 null
|
||||
return (id != null && id.equals(that.id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id != null ? id.hashCode() : 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,16 +66,21 @@ public class ProjectSkuInfo extends BaseEntity {
|
|||
@ApiModelProperty(name = "规格图片", value = "规格图片", required = true)
|
||||
private String image;
|
||||
|
||||
@Excel(name = "规格值")
|
||||
@ApiModelProperty(name = "规格值", value = "规格值")
|
||||
private String specValues;
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
public static ProjectSkuInfo queryBuild( ProjectSkuInfoQueryReq projectSkuInfoQueryReq){
|
||||
public static ProjectSkuInfo queryBuild(ProjectSkuInfoQueryReq projectSkuInfoQueryReq){
|
||||
return ProjectSkuInfo.builder()
|
||||
.projectId(projectSkuInfoQueryReq.getProjectId())
|
||||
.sku(projectSkuInfoQueryReq.getSku())
|
||||
.stock(projectSkuInfoQueryReq.getStock())
|
||||
.price(projectSkuInfoQueryReq.getPrice())
|
||||
.image(projectSkuInfoQueryReq.getImage())
|
||||
.specValues(projectSkuInfoQueryReq.getSpecValues())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -89,6 +94,7 @@ public class ProjectSkuInfo extends BaseEntity {
|
|||
.stock(projectSkuInfoSaveReq.getStock())
|
||||
.price(projectSkuInfoSaveReq.getPrice())
|
||||
.image(projectSkuInfoSaveReq.getImage())
|
||||
.specValues(projectSkuInfoSaveReq.getSpecValues())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -103,6 +109,7 @@ public class ProjectSkuInfo extends BaseEntity {
|
|||
.stock(projectSkuInfoEditReq.getStock())
|
||||
.price(projectSkuInfoEditReq.getPrice())
|
||||
.image(projectSkuInfoEditReq.getImage())
|
||||
.specValues(projectSkuInfoEditReq.getSpecValues())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -113,6 +120,7 @@ public class ProjectSkuInfo extends BaseEntity {
|
|||
.image(productSkuModel.getImage())
|
||||
.stock(productSkuModel.getStock())
|
||||
.price(productSkuModel.getPrice())
|
||||
.specValues(productSkuModel.getSpecValues())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -51,11 +51,8 @@ public class RuleInfo extends BaseEntity {
|
|||
@ApiModelProperty(name = "规格状态", value = "规格状态")
|
||||
private String status;
|
||||
|
||||
/** 规格状态 */
|
||||
@Excel(name = "规格描述")
|
||||
@ApiModelProperty(name = "规格描述", value = "规格描述")
|
||||
@ApiModelProperty(name = "备注", value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
|
@ -63,6 +60,7 @@ public class RuleInfo extends BaseEntity {
|
|||
return RuleInfo.builder()
|
||||
.name(ruleInfoQueryReq.getName())
|
||||
.status(ruleInfoQueryReq.getStatus())
|
||||
.remark(ruleInfoQueryReq.getRemark())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -72,6 +70,7 @@ public class RuleInfo extends BaseEntity {
|
|||
public static RuleInfo saveBuild(RuleInfoSaveReq ruleInfoSaveReq){
|
||||
return RuleInfo.builder()
|
||||
.name(ruleInfoSaveReq.getName())
|
||||
.remark(ruleInfoSaveReq.getRemark())
|
||||
.status(ruleInfoSaveReq.getStatus())
|
||||
.build();
|
||||
}
|
||||
|
@ -84,21 +83,19 @@ public class RuleInfo extends BaseEntity {
|
|||
.id(id)
|
||||
.name(ruleInfoEditReq.getName())
|
||||
.status(ruleInfoEditReq.getStatus())
|
||||
.remark(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();
|
||||
public static RuleInfo addModelBuild(RuleInfoAddModel model, Supplier<String> userNameSupplier) {
|
||||
RuleInfo ruleInfo = new RuleInfo();
|
||||
ruleInfo.setName(model.getName());
|
||||
ruleInfo.setRemark(model.getRemark());
|
||||
ruleInfo.setStatus(model.getStatus()); // 设置状态
|
||||
ruleInfo.setCreateBy(userNameSupplier.get());
|
||||
ruleInfo.setCreateTime(new Date());
|
||||
ruleInfo.setUpdateBy(userNameSupplier.get());
|
||||
ruleInfo.setUpdateTime(new Date());
|
||||
return ruleInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package com.muyu.product.domain.base;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.oas.annotations.EnableOpenApi;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
import java.util.Collections;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
/**
|
||||
* @ClassName SwaggerConfig
|
||||
* @Description 描述
|
||||
* @Author zhang
|
||||
* @Date 2024/11/19 22:02
|
||||
*/
|
||||
@Configuration
|
||||
@EnableOpenApi
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Bean
|
||||
public Docket publicApi() {
|
||||
return new Docket(DocumentationType.OAS_30)
|
||||
.groupName("public-api")
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.muyu.controller"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Docket adminApi() {
|
||||
return new Docket(DocumentationType.OAS_30)
|
||||
.groupName("admin-api")
|
||||
.apiInfo(adminApiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.muyu.admin"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("公共API")
|
||||
.description("公共接口文档")
|
||||
.version("1.0")
|
||||
.build();
|
||||
}
|
||||
|
||||
private ApiInfo adminApiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("管理API")
|
||||
.description("管理接口文档")
|
||||
.version("1.0")
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -43,6 +43,8 @@ public class CategoryInfoSaveModel extends TreeEntity {
|
|||
/** 介绍 */
|
||||
private String introduction;
|
||||
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 商品属性组关联ID
|
||||
*/
|
||||
|
@ -65,6 +67,7 @@ public class CategoryInfoSaveModel extends TreeEntity {
|
|||
.name(categoryInfoSaveReq.getName())
|
||||
.image(categoryInfoSaveReq.getImage())
|
||||
.start(categoryInfoSaveReq.getStart())
|
||||
.remark(categoryInfoSaveReq.getRemark())
|
||||
.introduction(categoryInfoSaveReq.getIntroduction())
|
||||
.parentId(categoryInfoSaveReq.getParentId())
|
||||
.attributeGroupIdList(categoryInfoSaveReq.getAttributeGroupIdList())
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
|
@ -18,21 +23,92 @@ import java.math.BigDecimal;
|
|||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "商品SKU模型", description = "商品SKU信息")
|
||||
public class ProductSkuModel {
|
||||
|
||||
/** sku */
|
||||
@ApiModelProperty(name = "sku", value = "sku", required = true)
|
||||
/** SKU编码 */
|
||||
@NotBlank(message = "SKU编码不能为空")
|
||||
@Excel(name = "SKU编码")
|
||||
@ApiModelProperty(name = "sku", value = "SKU编码", required = true, example = "SP123456")
|
||||
private String sku;
|
||||
|
||||
/** 商品库存 */
|
||||
@ApiModelProperty(name = "商品库存", value = "商品库存", required = true)
|
||||
@NotNull(message = "商品库存不能为空")
|
||||
@Min(value = 0, message = "商品库存不能小于0")
|
||||
@Excel(name = "商品库存")
|
||||
@ApiModelProperty(name = "stock", value = "商品库存", required = true, example = "100")
|
||||
private Long stock;
|
||||
|
||||
/** 商品价格 */
|
||||
@ApiModelProperty(name = "商品价格", value = "商品价格", required = true)
|
||||
/** 销售价格 */
|
||||
@NotNull(message = "销售价格不能为空")
|
||||
@DecimalMin(value = "0.01", message = "销售价格必须大于0")
|
||||
@Excel(name = "销售价格")
|
||||
@ApiModelProperty(name = "price", value = "销售价格", required = true, example = "99.99")
|
||||
private BigDecimal price;
|
||||
|
||||
/** 市场价格 */
|
||||
@Excel(name = "市场价格")
|
||||
@ApiModelProperty(name = "marketPrice", value = "市场价格", example = "129.99")
|
||||
private BigDecimal marketPrice;
|
||||
|
||||
/** 成本价格 */
|
||||
@Excel(name = "成本价格")
|
||||
@ApiModelProperty(name = "costPrice", value = "成本价格", example = "59.99")
|
||||
private BigDecimal costPrice;
|
||||
|
||||
/** 规格图片 */
|
||||
@ApiModelProperty(name = "规格图片", value = "规格图片", required = true)
|
||||
@NotBlank(message = "规格图片不能为空")
|
||||
@Excel(name = "规格图片")
|
||||
@ApiModelProperty(name = "image", value = "规格图片", required = true)
|
||||
private String image;
|
||||
|
||||
/** 规格值JSON */
|
||||
@ApiModelProperty(name = "specValues", value = "规格值JSON", example = "{\"颜色\":\"红色\",\"尺寸\":\"XL\"}")
|
||||
private String specValues;
|
||||
|
||||
/** 商品条形码 */
|
||||
@Excel(name = "商品条形码")
|
||||
@ApiModelProperty(name = "barcode", value = "商品条形码")
|
||||
private String barcode;
|
||||
|
||||
/** 预警库存 */
|
||||
@Min(value = 0, message = "预警库存不能小于0")
|
||||
@Excel(name = "预警库存")
|
||||
@ApiModelProperty(name = "lowStock", value = "预警库存", example = "10")
|
||||
private Integer lowStock;
|
||||
|
||||
/** 锁定库存 */
|
||||
@Excel(name = "锁定库存")
|
||||
@ApiModelProperty(name = "lockStock", value = "锁定库存", example = "0")
|
||||
private Integer lockStock;
|
||||
|
||||
/** 销量 */
|
||||
@Excel(name = "销量")
|
||||
@ApiModelProperty(name = "sales", value = "销量", example = "0")
|
||||
private Integer sales;
|
||||
|
||||
/** 状态(0-禁用 1-启用) */
|
||||
@Excel(name = "状态", readConverterExp = "0=禁用,1=启用")
|
||||
@ApiModelProperty(name = "status", value = "状态(0-禁用 1-启用)", example = "1")
|
||||
private String status;
|
||||
|
||||
/** SKU名称 */
|
||||
@Excel(name = "SKU名称")
|
||||
@ApiModelProperty(name = "skuName", value = "SKU名称")
|
||||
private String skuName;
|
||||
|
||||
/** 重量(克) */
|
||||
@Excel(name = "重量(克)")
|
||||
@ApiModelProperty(name = "weight", value = "重量(克)")
|
||||
private Double weight;
|
||||
|
||||
/** 体积(cm³) */
|
||||
@Excel(name = "体积(cm³)")
|
||||
@ApiModelProperty(name = "volume", value = "体积(cm³)")
|
||||
private Double volume;
|
||||
|
||||
/** 排序号 */
|
||||
@Excel(name = "排序号")
|
||||
@ApiModelProperty(name = "sort", value = "排序号", example = "1")
|
||||
private Integer sort;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.ProjectInfo;
|
||||
import com.muyu.product.domain.req.ProjectInfoEditReq;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: 商品添加模型
|
||||
|
@ -17,43 +23,97 @@ import lombok.experimental.SuperBuilder;
|
|||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ProjectAddModel extends BaseEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
/** 商品名称 */
|
||||
@ApiModelProperty(name = "商品名称", value = "商品名称")
|
||||
@NotBlank(message = "商品名称不能为空")
|
||||
@ApiModelProperty(name = "name", value = "商品名称", required = true)
|
||||
private String name;
|
||||
|
||||
/** 商品描述 */
|
||||
@ApiModelProperty(name = "商品描述", value = "商品描述")
|
||||
@ApiModelProperty(name = "introduction", value = "商品描述")
|
||||
private String introduction;
|
||||
|
||||
/** 主类型 */
|
||||
@ApiModelProperty(name = "主类型", value = "主类型")
|
||||
@ApiModelProperty(name = "mianType", value = "主类型")
|
||||
private Long mianType;
|
||||
|
||||
/** 父类型 */
|
||||
@ApiModelProperty(name = "父类型", value = "父类型")
|
||||
@ApiModelProperty(name = "parentType", value = "父类型")
|
||||
private Long parentType;
|
||||
|
||||
/** 商品类型 */
|
||||
@ApiModelProperty(name = "商品类型", value = "商品类型")
|
||||
@NotNull(message = "商品类型不能为空")
|
||||
@ApiModelProperty(name = "type", value = "商品类型", required = true)
|
||||
private Long type;
|
||||
|
||||
/** 商品图片 */
|
||||
@ApiModelProperty(name = "商品图片", value = "商品图片")
|
||||
/** 商品主图 */
|
||||
@NotBlank(message = "商品主图不能为空")
|
||||
@ApiModelProperty(name = "image", value = "商品主图", required = true)
|
||||
private String image;
|
||||
|
||||
/** 商品轮播图 */
|
||||
@ApiModelProperty(name = "商品轮播图", value = "商品轮播图")
|
||||
@ApiModelProperty(name = "carouselImages", value = "商品轮播图(多个图片用逗号分隔)")
|
||||
private String carouselImages;
|
||||
|
||||
/** 商品状态 */
|
||||
@ApiModelProperty(name = "商品状态", value = "商品状态")
|
||||
/** 商品状态(0-下架 1-上架) */
|
||||
@ApiModelProperty(name = "status", value = "商品状态(0-下架 1-上架)")
|
||||
private String status;
|
||||
|
||||
/** 规格 */
|
||||
@ApiModelProperty(name = "规格", value = "规格")
|
||||
/** 规格ID */
|
||||
@ApiModelProperty(name = "ruleId", value = "规格ID")
|
||||
private Long ruleId;
|
||||
|
||||
/** 品牌 */
|
||||
@ApiModelProperty(name = "品牌", value = "品牌")
|
||||
/** 品牌ID */
|
||||
@ApiModelProperty(name = "brandId", value = "品牌ID")
|
||||
private Long brandId;
|
||||
|
||||
/** SKU列表 */
|
||||
@ApiModelProperty(name = "skuList", value = "SKU列表")
|
||||
private List<ProductSkuModel> skuList;
|
||||
|
||||
/** 销售价格 */
|
||||
@ApiModelProperty(name = "salePrice", value = "销售价格")
|
||||
private Double salePrice;
|
||||
|
||||
/** 市场价格 */
|
||||
@ApiModelProperty(name = "marketPrice", value = "市场价格")
|
||||
private Double marketPrice;
|
||||
|
||||
/** 库存数量 */
|
||||
@ApiModelProperty(name = "stock", value = "库存数量")
|
||||
private Integer stock;
|
||||
|
||||
/** 排序号 */
|
||||
@ApiModelProperty(name = "sort", value = "排序号")
|
||||
private Integer sort;
|
||||
|
||||
/** 是否推荐(0-否 1-是) */
|
||||
@ApiModelProperty(name = "isRecommend", value = "是否推荐(0-否 1-是)")
|
||||
private String isRecommend;
|
||||
|
||||
/** 商品详情 */
|
||||
@ApiModelProperty(name = "detail", value = "商品详情")
|
||||
private String detail;
|
||||
|
||||
/** 规格属性JSON */
|
||||
@ApiModelProperty(name = "specJson", value = "规格属性JSON")
|
||||
private String specJson;
|
||||
|
||||
|
||||
public static ProjectInfo editBuild(Long id, ProjectInfoEditReq projectInfoEditReq){
|
||||
return ProjectInfo.builder()
|
||||
.id(id)
|
||||
.name(projectInfoEditReq.getProjectAddModel().getName())
|
||||
.introduction(projectInfoEditReq.getProjectAddModel().getIntroduction())
|
||||
.mianType(projectInfoEditReq.getProjectAddModel().getMianType())
|
||||
.parentType(projectInfoEditReq.getProjectAddModel().getParentType())
|
||||
.type(projectInfoEditReq.getProjectAddModel().getType())
|
||||
.image(projectInfoEditReq.getProjectAddModel().getImage())
|
||||
.carouselImages(projectInfoEditReq.getProjectAddModel().getCarouselImages())
|
||||
.status(projectInfoEditReq.getProjectAddModel().getStatus())
|
||||
.ruleId(projectInfoEditReq.getProjectAddModel().getRuleId())
|
||||
.brandId(projectInfoEditReq.getProjectAddModel().getBrandId())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @ClassName ProjectModel
|
||||
* @Description 描述
|
||||
* @Author zhang
|
||||
* @Date 2024/11/19 21:45
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ProjectModel {
|
||||
private Long id;
|
||||
private String value;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @ClassName ProjectSKUModel
|
||||
* @Description 描述
|
||||
* @Author zhang
|
||||
* @Date 2024/11/19 21:45
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ProjectSKUModel {
|
||||
private String sku;
|
||||
private Long stock;
|
||||
private BigDecimal price;
|
||||
private String image;
|
||||
}
|
|
@ -33,8 +33,16 @@ public class RuleAttrAddModel extends BaseEntity {
|
|||
/**
|
||||
* 规格属性值集合
|
||||
*/
|
||||
|
||||
private String attrValue;
|
||||
|
||||
private String status = "Y";
|
||||
|
||||
|
||||
private List<String> valueList;
|
||||
|
||||
// private List<RuleAttrAddModel> ruleAttrList;
|
||||
|
||||
public static RuleAttrAddModel infoBuild (RuleAttrInfo ruleAttrInfo) {
|
||||
return RuleAttrAddModel.builder()
|
||||
.name(ruleAttrInfo.getName())
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.RuleAttrInfo;
|
||||
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 RuleAttrAssModel
|
||||
* @Description 描述
|
||||
* @Author zhang
|
||||
* @Date 2024/11/14 16:03
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class RuleAttrAssModel 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();
|
||||
}
|
||||
}
|
|
@ -23,12 +23,16 @@ import java.util.List;
|
|||
@EqualsAndHashCode(callSuper = true)
|
||||
public class RuleInfoAddModel extends BaseEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
/** 规格名称 */
|
||||
private String name;
|
||||
|
||||
/** 规格状态 */
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 规格属性集合
|
||||
*/
|
||||
|
@ -38,6 +42,7 @@ public class RuleInfoAddModel extends BaseEntity {
|
|||
return RuleInfoAddModel.builder()
|
||||
.name(req.getName())
|
||||
.status(req.getStatus())
|
||||
.remark(req.getRemark())
|
||||
.ruleAttrList(req.getRuleAttrList())
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ public class TemplateAttributeModel extends BaseEntity {
|
|||
*/
|
||||
private String code;
|
||||
|
||||
private String value;
|
||||
|
||||
public static TemplateAttributeModel attributeInfoBuild(AttributeInfo attributeInfo){
|
||||
return TemplateAttributeModel.builder()
|
||||
.id(attributeInfo.getId())
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.muyu.product.domain.req;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -33,5 +36,10 @@ public class AttributeGroupEditReq extends BaseEntity {
|
|||
@ApiModelProperty(name = "状态", value = "状态", required = true)
|
||||
private String states;
|
||||
|
||||
@ApiModelProperty(name = "备注", value = "备注", required = true)
|
||||
private String remark;
|
||||
|
||||
private List<AttributeInfoSaveReq> attributeList;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import lombok.experimental.SuperBuilder;
|
|||
import io.swagger.annotations.*;
|
||||
import com.muyu.common.core.web.domain.TreeEntity;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -44,7 +43,6 @@ public class CategoryInfoSaveReq extends TreeEntity {
|
|||
/** 是否启用 */
|
||||
|
||||
@ApiModelProperty(name = "是否启用", value = "是否启用", required = true)
|
||||
@NotNull()
|
||||
private String start;
|
||||
|
||||
/** 介绍 */
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package com.muyu.product.domain.req;
|
||||
|
||||
import com.muyu.product.domain.ProjectInfo;
|
||||
import com.muyu.product.domain.ProjectSkuInfo;
|
||||
import com.muyu.product.domain.model.ProjectAddModel;
|
||||
import com.muyu.product.domain.model.ProjectModel;
|
||||
import com.muyu.product.domain.model.ProjectSKUModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -8,6 +13,10 @@ import lombok.experimental.SuperBuilder;
|
|||
import io.swagger.annotations.*;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品信息对象 project_info
|
||||
*
|
||||
|
@ -63,4 +72,34 @@ public class ProjectInfoEditReq extends BaseEntity {
|
|||
@ApiModelProperty(name = "品牌", value = "品牌")
|
||||
private Long brandId;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "商品信息", required = true)
|
||||
@NotNull(message = "商品信息不能为空")
|
||||
private ProjectInfo projectInfo;
|
||||
|
||||
@ApiModelProperty("SKU列表")
|
||||
private List<ProjectSkuInfo> skuList;
|
||||
|
||||
// 添加非空校验注解
|
||||
@NotNull(message = "商品信息不能为空")
|
||||
public ProjectInfo getProjectInfo() {
|
||||
return projectInfo;
|
||||
}
|
||||
|
||||
public List<ProjectSkuInfo> getSkuList() {
|
||||
return skuList != null ? skuList : new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setProjectInfo(ProjectInfo projectInfo) {
|
||||
this.projectInfo = projectInfo;
|
||||
}
|
||||
|
||||
public void setSkuList(List<ProjectSkuInfo> skuList) {
|
||||
this.skuList = skuList;
|
||||
}
|
||||
|
||||
private ProjectAddModel projectAddModel;
|
||||
private List<ProjectModel> attrValueList;
|
||||
private List<ProjectSKUModel> productSkuList;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.muyu.product.domain.req;
|
||||
|
||||
import com.muyu.product.domain.ProjectInfo;
|
||||
import com.muyu.product.domain.ProjectSkuInfo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -8,6 +10,8 @@ import lombok.experimental.SuperBuilder;
|
|||
import io.swagger.annotations.*;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品信息对象 project_info
|
||||
*
|
||||
|
@ -63,4 +67,10 @@ public class ProjectInfoQueryReq extends BaseEntity {
|
|||
@ApiModelProperty(name = "品牌", value = "品牌")
|
||||
private Long brandId;
|
||||
|
||||
@ApiModelProperty(name = "商品信息", value = "商品信息")
|
||||
private ProjectInfo projectInfo;
|
||||
|
||||
@ApiModelProperty(name = "商品SKU", value = "商品SKU")
|
||||
private List<ProjectSkuInfo> skuList;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.muyu.product.domain.req;
|
||||
|
||||
import com.muyu.product.domain.ProjectInfo;
|
||||
import com.muyu.product.domain.ProjectSkuInfo;
|
||||
import com.muyu.product.domain.model.AttrValueModel;
|
||||
import com.muyu.product.domain.model.ProductSkuModel;
|
||||
import com.muyu.product.domain.model.ProjectAddModel;
|
||||
|
@ -43,4 +45,10 @@ public class ProjectInfoSaveReq extends BaseEntity {
|
|||
*/
|
||||
private List<ProductSkuModel> productSkuList;
|
||||
|
||||
@ApiModelProperty(name = "规格值", value = "规格值")
|
||||
private String specValues;
|
||||
|
||||
private ProjectInfo projectInfo;
|
||||
private List<ProjectSkuInfo> skuList;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package com.muyu.product.domain.req;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import com.muyu.product.domain.ProjectInfo;
|
||||
import com.muyu.product.domain.ProjectSkuInfo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -43,5 +47,10 @@ public class ProjectSkuInfoEditReq extends BaseEntity {
|
|||
/** 规格图片 */
|
||||
@ApiModelProperty(name = "规格图片", value = "规格图片", required = true)
|
||||
private String image;
|
||||
@ApiModelProperty(name = "规格值", value = "规格值")
|
||||
private String specValues;
|
||||
|
||||
private ProjectInfo projectInfo;
|
||||
private List<ProjectSkuInfo> skuList;
|
||||
|
||||
}
|
||||
|
|
|
@ -44,4 +44,7 @@ public class ProjectSkuInfoQueryReq extends BaseEntity {
|
|||
@ApiModelProperty(name = "规格图片", value = "规格图片")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty(name = "规格值", value = "规格值")
|
||||
private String specValues;
|
||||
|
||||
}
|
||||
|
|
|
@ -54,4 +54,7 @@ public class ProjectSkuInfoSaveReq extends BaseEntity {
|
|||
@ApiModelProperty(name = "规格图片", value = "规格图片", required = true)
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty(name = "规格值", value = "规格值")
|
||||
private String specValues;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
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;
|
||||
|
||||
/**
|
||||
* @ClassName RuleAttrInfoReq
|
||||
* @Description 描述
|
||||
* @Author zhang
|
||||
* @Date 2024/11/14 16:28
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class RuleAttrInfoReq {
|
||||
|
||||
private String name;
|
||||
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
|
||||
|
||||
private List<RuleAttrAddModel> ruleAttrList;
|
||||
}
|
|
@ -7,6 +7,9 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 规格详情对象 rule_attr_info
|
||||
|
@ -43,4 +46,8 @@ public class RuleAttrInfoSaveReq extends BaseEntity {
|
|||
@ApiModelProperty(name = "规格值", value = "规格值")
|
||||
private String attrValue;
|
||||
|
||||
@NotBlank(message = "规格名称不能为空")
|
||||
@Length(max = 50, message = "规格名称长度不能超过50个字符")
|
||||
private String attrName;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package com.muyu.product.domain.req;
|
||||
|
||||
import com.muyu.product.domain.RuleAttrInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName RuleGroupUpdResp
|
||||
* @Description 描述
|
||||
* @Author zhang
|
||||
* @Date 2024/11/13 22:24
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RuleGroupUpdResp {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String status;
|
||||
|
||||
private List<RuleAttrInfo> ruleAttrList;
|
||||
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package com.muyu.product.domain.req;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -35,14 +34,7 @@ public class RuleInfoEditReq extends BaseEntity {
|
|||
@ApiModelProperty(name = "规格状态", value = "规格状态")
|
||||
private String status;
|
||||
|
||||
/** 规格状态 */
|
||||
@Excel(name = "规格描述")
|
||||
@ApiModelProperty(name = "规格描述", value = "规格描述")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 规格属性集合
|
||||
*/
|
||||
private List<RuleAttrAddModel> ruleAttrList;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ public class AttributeGroupPageResp extends BaseEntity {
|
|||
/** 状态 */
|
||||
private String states;
|
||||
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 属性对象集合
|
||||
*/
|
||||
|
@ -48,11 +50,11 @@ public class AttributeGroupPageResp extends BaseEntity {
|
|||
.attributeInfoList(attributeInfos)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static AttributeGroupPageResp groupFunBuild (AttributeGroup attributeGroup, Function<Long,List<AttributeInfo> > function) {
|
||||
return AttributeGroupPageResp.builder()
|
||||
.id(attributeGroup.getId())
|
||||
.name(attributeGroup.getName())
|
||||
.remark(attributeGroup.getRemark())
|
||||
.states(attributeGroup.getStates())
|
||||
.attributeInfoList(function.apply(attributeGroup.getId()))
|
||||
.build();
|
||||
|
|
|
@ -9,14 +9,16 @@ import lombok.NoArgsConstructor;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 修改回显的详细信息
|
||||
* @ClassName AttributeGroupUpdateResp
|
||||
* @Description 描述
|
||||
* @Author zhang
|
||||
* @Date 2024/11/13 13:58
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AttributeGroupUpdResp {
|
||||
|
||||
public class AttributeGroupUpdateResp {
|
||||
/** 属性组编号 */
|
||||
private Long id;
|
||||
|
||||
|
@ -25,9 +27,8 @@ public class AttributeGroupUpdResp {
|
|||
|
||||
/** 状态 */
|
||||
private String states;
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 属性ID集合
|
||||
*/
|
||||
private List<AttributeInfo> attributeList;
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.muyu.product.domain.resp;
|
||||
|
||||
import com.muyu.common.core.utils.bean.BeanUtils;
|
||||
import com.muyu.product.domain.CategoryInfo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName CategoryInfoDetailResp
|
||||
* @Description 描述
|
||||
* @Author zhang
|
||||
* @Date 2024/11/14 23:34
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "CategoryInfoDetailResp",description = "品类信息详情响应")
|
||||
public class CategoryInfoDetailResp extends CategoryInfo {
|
||||
@ApiModelProperty("关联的属性ID列表")
|
||||
private List<Long> attributeIdList;
|
||||
|
||||
@ApiModelProperty("关联的属性组ID列表")
|
||||
private List<Long> attributeGroupIdList;
|
||||
|
||||
@ApiModelProperty("关联的品牌ID列表")
|
||||
private List<Long> brandIdList;
|
||||
|
||||
@ApiModelProperty("父级品类名称")
|
||||
private String parentName;
|
||||
|
||||
public static CategoryInfoDetailResp of(CategoryInfo categoryInfo, String parentName) {
|
||||
CategoryInfoDetailResp resp = new CategoryInfoDetailResp();
|
||||
// 复制基本属性
|
||||
BeanUtils.copyProperties(categoryInfo, resp);
|
||||
// 设置父级名称
|
||||
resp.setParentName(parentName);
|
||||
return resp;
|
||||
}
|
||||
|
||||
public static CategoryInfoDetailResp of(CategoryInfo categoryInfo) {
|
||||
return of(categoryInfo, null);
|
||||
}
|
||||
}
|
|
@ -61,4 +61,6 @@ public class ProjectDetailResp {
|
|||
* 属性组集合
|
||||
*/
|
||||
private List<TemplateAttributeGroupModel> attributeGroupList;
|
||||
|
||||
private List<ProjectSkuInfo> skuList;
|
||||
}
|
||||
|
|
|
@ -32,17 +32,23 @@ public class RuleInfoResp extends BaseEntity {
|
|||
/** 规格状态 */
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 规格属性集合
|
||||
*/
|
||||
private List<RuleAttrAddModel> ruleAttrList;
|
||||
|
||||
public static RuleInfoResp infoBuild (RuleInfo ruleInfo, Function<Long, List<RuleAttrAddModel>> ruleAttrList) {
|
||||
private Boolean isUsed;
|
||||
|
||||
public static RuleInfoResp infoBuild(RuleInfo ruleInfo, Function<Long, List<RuleAttrAddModel>> ruleAttrList, Function<Long, Boolean> isUsedFunc) {
|
||||
return RuleInfoResp.builder()
|
||||
.id(ruleInfo.getId())
|
||||
.name(ruleInfo.getName())
|
||||
.remark(ruleInfo.getRemark())
|
||||
.status(ruleInfo.getStatus())
|
||||
.ruleAttrList(ruleAttrList.apply(ruleInfo.getId()))
|
||||
.isUsed(isUsedFunc.apply(ruleInfo.getId()))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
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.model.RuleAttrAddModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格修改响应对象
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RuleInfoUpdResp {
|
||||
|
||||
/** 主键 */
|
||||
@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;
|
||||
|
||||
/** 规格状态 */
|
||||
@Excel(name = "规格描述")
|
||||
@ApiModelProperty(name = "规格描述", value = "规格描述")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 规格属性集合
|
||||
*/
|
||||
private List<RuleAttrAddModel> ruleAttrList;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.muyu.product.domain.vo;
|
||||
|
||||
import com.muyu.product.domain.AttributeGroup;
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import com.muyu.product.domain.ProjectSkuInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.management.Attribute;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName ProductVo
|
||||
* @Description 描述
|
||||
* @Author zhang
|
||||
* @Date 2024/11/22 16:06
|
||||
*/
|
||||
@Data
|
||||
public class ProductVo {
|
||||
private Long id;
|
||||
private String name; // 商品名称
|
||||
private String introduction; // 商品描述
|
||||
private String mainType; // 主类型
|
||||
private String parentType; // 父类型
|
||||
private String type; // 商品类型
|
||||
private String image; // 商品图片
|
||||
private String carouselImages; // 轮播图
|
||||
private String status; // 商品状态
|
||||
private Long ruleId; // 规格ID
|
||||
private Long brandId; // 品牌ID
|
||||
private String remark; // 备注
|
||||
|
||||
// 属性相关
|
||||
private List<AttributeGroup> templateAttributeGroupList; // 属性组列表
|
||||
private List<AttributeInfo> templateAttributeList; // 模板属性
|
||||
private List<AttributeInfo> attributeList; // 自定义属性
|
||||
|
||||
// SKU相关
|
||||
private List<ProjectSkuInfo> skuList; // SKU列表
|
||||
}
|
|
@ -90,6 +90,11 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-ui</artifactId>
|
||||
<version>1.6.15</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -5,12 +5,14 @@ import com.muyu.common.security.annotation.EnableMyFeignClients;
|
|||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import springfox.documentation.oas.annotations.EnableOpenApi;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: 商品启动类
|
||||
* @Date 2024-2-26 下午 04:07
|
||||
*/
|
||||
@EnableOpenApi
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
|
@ -21,3 +23,4 @@ public class MuYuProductApplication {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import com.muyu.product.domain.model.AttributeGroupSaveModel;
|
||||
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpdateResp;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -75,8 +75,8 @@ public class AttributeGroupController extends BaseController {
|
|||
@RequiresPermissions("product:attributeGroup:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<AttributeGroupUpdResp> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(attributeGroupService.getUpdById(id));
|
||||
public Result<AttributeGroupUpdateResp> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(attributeGroupService.getUpdateById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,9 +100,11 @@ public class AttributeGroupController extends BaseController {
|
|||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改属性组")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody AttributeGroupEditReq attributeGroupEditReq) {
|
||||
return toAjax(attributeGroupService.updateById(AttributeGroup.editBuild(id,attributeGroupEditReq)));
|
||||
// return toAjax(attributeGroupService.updateAttributeGroup(id,attributeGroupEditReq));
|
||||
return attributeGroupService.updateAttributeGroup2(id,attributeGroupEditReq);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除属性组
|
||||
*/
|
||||
|
@ -114,4 +116,23 @@ public class AttributeGroupController extends BaseController {
|
|||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(attributeGroupService.removeBatchByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
*/
|
||||
@PutMapping("/{id}/status/{status}")
|
||||
@ApiOperation("修改规格状态")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "规格id", required = true, dataType = "Long", paramType = "path"),
|
||||
@ApiImplicitParam(name = "status", value = "状态(Y/N)", required = true, dataType = "String", paramType = "path")
|
||||
})
|
||||
public Result<String> UpdateStatus(@PathVariable("id") Long id, @PathVariable("status") String status) {
|
||||
AttributeGroup attributeGroup = new AttributeGroup();
|
||||
attributeGroup.setId(id);
|
||||
attributeGroup.setStates(status);
|
||||
return toAjax(attributeGroupService.updateById(attributeGroup));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.product.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
@ -10,6 +11,7 @@ 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.CategoryInfoDetailResp;
|
||||
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -52,33 +54,39 @@ public class CategoryInfoController extends BaseController {
|
|||
@ApiOperation("获取品类信息列表")
|
||||
@RequiresPermissions("product:category:list")
|
||||
@GetMapping("/list")
|
||||
public Result<List<CategoryInfo>> list(CategoryInfo categoryInfo) {
|
||||
List<CategoryInfo> list = categoryInfoService.list(categoryInfo);
|
||||
public Result<List<CategoryInfoDetailResp>> list(CategoryInfo categoryInfo) {
|
||||
try {
|
||||
categoryInfo = Optional.ofNullable(categoryInfo).orElse(new CategoryInfo());
|
||||
List<CategoryInfoDetailResp> list = categoryInfoService.listWithParent(categoryInfo);
|
||||
return Result.success(list);
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出品类信息列表
|
||||
*/
|
||||
@ApiOperation("导出品类信息列表")
|
||||
@RequiresPermissions("product:category:export")
|
||||
@Log(title = "品类信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CategoryInfo categoryInfo) {
|
||||
List<CategoryInfo> list = categoryInfoService.list(categoryInfo);
|
||||
ExcelUtil<CategoryInfo> util = new ExcelUtil<CategoryInfo>(CategoryInfo.class);
|
||||
util.exportExcel(response, list, "品类信息数据");
|
||||
}
|
||||
// @ApiOperation("导出品类信息列表")
|
||||
// @RequiresPermissions("product:category:export")
|
||||
// @Log(title = "品类信息", businessType = BusinessType.EXPORT)
|
||||
// @PostMapping("/export")
|
||||
// public void export(HttpServletResponse response, CategoryInfo categoryInfo) {
|
||||
// List<CategoryInfo> list = categoryInfoService.list(categoryInfo);
|
||||
// ExcelUtil<CategoryInfo> util = new ExcelUtil<CategoryInfo>(CategoryInfo.class);
|
||||
// util.exportExcel(response, list, "品类信息数据");
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取品类信息详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiOperation("获取品类信息详细信息")
|
||||
@RequiresPermissions("product:category:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<CategoryInfo> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(categoryInfoService.getById(id));
|
||||
public Result<CategoryInfoDetailResp> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(categoryInfoService.getDetailById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,26 +116,37 @@ public class CategoryInfoController extends BaseController {
|
|||
/**
|
||||
* 修改品类信息
|
||||
*/
|
||||
@RequiresPermissions("product:category:edit")
|
||||
@Log(title = "品类信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改品类信息")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody CategoryInfoEditReq categoryInfoEditReq) {
|
||||
return toAjax(categoryInfoService.updateById(CategoryInfo.editBuild(id,categoryInfoEditReq)));
|
||||
@RequiresPermissions("product:category:edit")
|
||||
@Log(title = "品类信息", businessType = BusinessType.UPDATE)
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody CategoryInfoSaveModel updateModel) {
|
||||
return toAjax(categoryInfoService.updateCategoryInfo(id, updateModel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除品类信息
|
||||
*/
|
||||
// @RequiresPermissions("product:category:remove")
|
||||
// @Log(title = "品类信息", businessType = BusinessType.DELETE)
|
||||
// @DeleteMapping("/{ids}")
|
||||
// @ApiOperation("删除品类信息")
|
||||
// @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
// public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
// return toAjax(categoryInfoService.removeBatchByIds(ids));
|
||||
// }
|
||||
@RequiresPermissions("product:category:remove")
|
||||
@Log(title = "品类信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除品类信息")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
@ApiImplicitParam(name = "ids", value = "品类ID列表", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(categoryInfoService.removeBatchByIds(ids));
|
||||
try {
|
||||
return toAjax(categoryInfoService.removeCategories(ids));
|
||||
} catch (RuntimeException e) {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过品类ID获取父级以上的属性、属性组、品牌集合
|
||||
* @param categoryId 品类ID
|
||||
|
@ -141,4 +160,5 @@ public class CategoryInfoController extends BaseController {
|
|||
) {
|
||||
return Result.success(categoryInfoService.parentCommonElement(categoryId));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.muyu.product.domain.req.ProjectInfoSaveReq;
|
|||
import com.muyu.product.domain.req.ProjectInfoEditReq;
|
||||
import com.muyu.product.service.ProjectInfoService;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
/**
|
||||
* 商品信息Controller
|
||||
|
@ -41,21 +42,20 @@ public class ProjectInfoController extends BaseController {
|
|||
@Autowired
|
||||
private ProjectInfoService projectInfoService;
|
||||
|
||||
@Autowired
|
||||
private ProjectInfoCache projectInfoCache;
|
||||
|
||||
/**
|
||||
* 查询商品信息列表
|
||||
*/
|
||||
@ApiOperation("获取商品信息列表")
|
||||
@ApiOperation(value = "获取商品信息列表")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectInfoQueryReq", value = "查询参数", paramType = "query", dataTypeClass = ProjectInfoQueryReq.class)
|
||||
})
|
||||
@RequiresPermissions("product:info:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<ProjectInfo>> list(ProjectInfoQueryReq projectInfoQueryReq) {
|
||||
public Result<TableDataInfo<ProjectInfo>> list(@ApiIgnore ProjectInfoQueryReq projectInfoQueryReq) {
|
||||
startPage();
|
||||
List<ProjectInfo> list = projectInfoService.list(ProjectInfo.queryBuild(projectInfoQueryReq));
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出商品信息列表
|
||||
*/
|
||||
|
@ -77,7 +77,8 @@ public class ProjectInfoController extends BaseController {
|
|||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<ProjectInfo> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(projectInfoCache.get(id));
|
||||
ProjectInfo byId = projectInfoService.getById(id);
|
||||
return Result.success(byId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,7 +122,9 @@ public class ProjectInfoController extends BaseController {
|
|||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改商品信息")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody ProjectInfoEditReq projectInfoEditReq) {
|
||||
return toAjax(projectInfoService.updateById(ProjectInfo.editBuild(id,projectInfoEditReq)));
|
||||
System.out.println("---------"+projectInfoEditReq);
|
||||
// return toAjax(projectInfoService.updateById(ProjectInfo.editBuild(id,projectInfoEditReq)));
|
||||
return projectInfoService.UpdProjectInfo(id,projectInfoEditReq);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,4 +138,7 @@ public class ProjectInfoController extends BaseController {
|
|||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(projectInfoService.removeBatchByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,9 +4,10 @@ import java.util.List;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.common.core.text.Convert;
|
||||
import com.muyu.product.domain.RuleAttrInfo;
|
||||
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||
import com.muyu.product.domain.req.*;
|
||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||
import com.muyu.product.domain.resp.RuleInfoUpdResp;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -24,9 +25,6 @@ import com.muyu.common.log.annotation.Log;
|
|||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.product.domain.RuleInfo;
|
||||
import com.muyu.product.domain.req.RuleInfoQueryReq;
|
||||
import com.muyu.product.domain.req.RuleInfoSaveReq;
|
||||
import com.muyu.product.domain.req.RuleInfoEditReq;
|
||||
import com.muyu.product.service.RuleInfoService;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
|
||||
|
@ -78,7 +76,7 @@ public class RuleInfoController extends BaseController {
|
|||
@RequiresPermissions("product:rule:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<RuleInfoUpdResp> getInfo(@PathVariable("id") Long id) {
|
||||
public Result<RuleInfoResp> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(ruleInfoService.getUpdById(id));
|
||||
}
|
||||
|
||||
|
@ -100,9 +98,10 @@ public class RuleInfoController extends BaseController {
|
|||
@Log(title = "商品规格", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改商品规格")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody RuleInfoEditReq ruleInfoEditReq) {
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody RuleAttrInfoReq ruleInfoEditReq) {
|
||||
// return toAjax(ruleInfoService.updateById(RuleInfo.editBuild(id,ruleInfoEditReq)));
|
||||
return toAjax(ruleInfoService.updateById(id, ruleInfoEditReq));
|
||||
ruleInfoService.edit3(id,ruleInfoEditReq);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,4 +115,19 @@ public class RuleInfoController extends BaseController {
|
|||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(ruleInfoService.removeBatchByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/{id}/status/{status}")
|
||||
@ApiOperation("修改规格状态")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "规格ID", required = true, dataType = "Long", paramType = "path"),
|
||||
@ApiImplicitParam(name = "status", value = "状态(Y/N)", required = true, dataType = "String", paramType = "path")
|
||||
})
|
||||
public Result<String> updateStatus(@PathVariable("id") Long id, @PathVariable("status") String status) {
|
||||
RuleInfo ruleInfo = new RuleInfo();
|
||||
ruleInfo.setId(id);
|
||||
ruleInfo.setStatus(status);
|
||||
return toAjax(ruleInfoService.updateById(ruleInfo));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.muyu.product.mapper;
|
|||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.product.domain.AsAttributeGroup;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 属性与组中间Mapper接口
|
||||
|
@ -10,6 +12,11 @@ import com.muyu.product.domain.AsAttributeGroup;
|
|||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface AsAttributeGroupMapper extends BaseMapper<AsAttributeGroup> {
|
||||
|
||||
void shanchu(Long id);
|
||||
|
||||
void insertBatch(@Param("id") Long id, @Param("id1") Long id1);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.mapper;
|
|||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.product.domain.AttributeGroup;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 属性组Mapper接口
|
||||
|
@ -12,4 +13,5 @@ import com.muyu.product.domain.AttributeGroup;
|
|||
*/
|
||||
public interface AttributeGroupMapper extends BaseMapper<AttributeGroup> {
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.mapper;
|
|||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.product.domain.ProjectInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 商品信息Mapper接口
|
||||
|
@ -10,6 +11,7 @@ import com.muyu.product.domain.ProjectInfo;
|
|||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProjectInfoMapper extends BaseMapper<ProjectInfo> {
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.mapper;
|
|||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.product.domain.ProjectSkuInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 商品SKUMapper接口
|
||||
|
@ -10,6 +11,7 @@ import com.muyu.product.domain.ProjectSkuInfo;
|
|||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProjectSkuInfoMapper extends BaseMapper<ProjectSkuInfo> {
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,12 @@ package com.muyu.product.mapper;
|
|||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.product.domain.RuleAttrInfo;
|
||||
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||
import com.muyu.product.domain.req.RuleAttrInfoReq;
|
||||
import com.muyu.product.domain.req.RuleInfoEditReq;
|
||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 规格详情Mapper接口
|
||||
|
@ -10,6 +16,15 @@ import com.muyu.product.domain.RuleAttrInfo;
|
|||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface RuleAttrInfoMapper extends BaseMapper<RuleAttrInfo> {
|
||||
|
||||
void updRule(@Param("id") Long id,@Param("req") RuleAttrInfoReq req);
|
||||
|
||||
void deleteRule(@Param("id") Long id);
|
||||
|
||||
List<RuleAttrAddModel> getRuleAttrInfo(@Param("id") Long id);
|
||||
RuleInfoResp getRuleAttrInfo2(@Param("id") Long id);
|
||||
|
||||
void addRuleAttrModel(@Param("id")Long id,@Param("name")String name,@Param("valueData") String substring);
|
||||
}
|
||||
|
|
|
@ -19,4 +19,16 @@ public interface AsAttributeGroupService extends IService<AsAttributeGroup> {
|
|||
*/
|
||||
public List<AsAttributeGroup> list(AsAttributeGroup asAttributeGroup);
|
||||
|
||||
/**
|
||||
* 删除属性与组中间
|
||||
* @param id
|
||||
*/
|
||||
void delete(Long id);
|
||||
|
||||
/**
|
||||
* 添加中间表
|
||||
* @param id
|
||||
* @param id1
|
||||
*/
|
||||
void insertBath(Long id,Long id1);
|
||||
}
|
||||
|
|
|
@ -2,13 +2,15 @@ package com.muyu.product.service;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.product.domain.AttributeGroup;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import com.muyu.product.domain.model.AttributeGroupSaveModel;
|
||||
import com.muyu.product.domain.req.AttributeGroupEditReq;
|
||||
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpdateResp;
|
||||
|
||||
/**
|
||||
* 属性组Service接口
|
||||
|
@ -41,9 +43,14 @@ public interface AttributeGroupService extends IService<AttributeGroup> {
|
|||
public Boolean save(AttributeGroupSaveModel attributeGroupSaveModel);
|
||||
|
||||
/**
|
||||
* 根据ID查询属性组的修改
|
||||
* 根据id查询属性组的修改
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
AttributeGroupUpdResp getUpdById(Long id);
|
||||
AttributeGroupUpdateResp getUpdateById(Long id);
|
||||
|
||||
// public Boolean updateAttributeGroup(Long id, AttributeGroupEditReq editReq);
|
||||
|
||||
|
||||
Result<String> updateAttributeGroup2(Long id, AttributeGroupEditReq attributeGroupEditReq);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ 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.CategoryInfoDetailResp;
|
||||
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
||||
|
||||
/**
|
||||
|
@ -24,7 +25,8 @@ public interface CategoryInfoService extends IService<CategoryInfo> {
|
|||
* @param categoryInfo 品类信息
|
||||
* @return 品类信息集合
|
||||
*/
|
||||
public List<CategoryInfo> list(CategoryInfo categoryInfo);
|
||||
List<CategoryInfoDetailResp> listWithParent(CategoryInfo categoryInfo);
|
||||
// public List<CategoryInfo> list(CategoryInfo categoryInfo);
|
||||
|
||||
/**
|
||||
* 保存
|
||||
|
@ -69,4 +71,12 @@ public interface CategoryInfoService extends IService<CategoryInfo> {
|
|||
CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId);
|
||||
|
||||
public <T, AS> List<T> getCommon (Long categoryId, IService<AS> iService, IService<T> bsiService);
|
||||
|
||||
|
||||
// 添加新方法
|
||||
CategoryInfoDetailResp getDetailById(Long id);
|
||||
|
||||
boolean updateCategoryInfo(Long id, CategoryInfoSaveModel updateModel);
|
||||
|
||||
boolean removeCategories(List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package com.muyu.product.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.product.domain.ProjectInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.product.domain.req.ProjectInfoEditReq;
|
||||
import com.muyu.product.domain.req.ProjectInfoSaveReq;
|
||||
import com.muyu.product.domain.resp.ProjectDetailResp;
|
||||
|
||||
|
@ -35,4 +38,6 @@ public interface ProjectInfoService extends IService<ProjectInfo> {
|
|||
*/
|
||||
ProjectDetailResp getDetailInfo (Long id);
|
||||
|
||||
|
||||
Result UpdProjectInfo(Long id, ProjectInfoEditReq projectInfoEditReq);
|
||||
}
|
||||
|
|
|
@ -33,4 +33,13 @@ public interface ProjectSkuInfoService extends IService<ProjectSkuInfo> {
|
|||
* @return 商品SKU信息
|
||||
*/
|
||||
List<ProjectSkuInfo> listByProjectId (Long projectId);
|
||||
|
||||
|
||||
boolean updateBatch(List<ProjectSkuInfo> skuList);
|
||||
|
||||
boolean updateStock(Long id, Long stock);
|
||||
|
||||
boolean deleteById(Long id);
|
||||
|
||||
boolean deleteBatch(List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.service;
|
|||
import java.util.List;
|
||||
import com.muyu.product.domain.RuleAttrInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||
|
||||
/**
|
||||
* 规格详情Service接口
|
||||
|
@ -25,4 +26,6 @@ public interface RuleAttrInfoService extends IService<RuleAttrInfo> {
|
|||
* @return 规格详情集合
|
||||
*/
|
||||
List<RuleAttrInfo> getInfoByRuleId (Long ruleId);
|
||||
|
||||
List<RuleAttrAddModel> getRuleAttrInfo(Long id);
|
||||
}
|
||||
|
|
|
@ -3,13 +3,15 @@ package com.muyu.product.service;
|
|||
import java.util.List;
|
||||
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.product.domain.RuleAttrInfo;
|
||||
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.RuleAttrInfoReq;
|
||||
import com.muyu.product.domain.req.RuleGroupUpdResp;
|
||||
import com.muyu.product.domain.req.RuleInfoEditReq;
|
||||
import com.muyu.product.domain.req.RuleInfoQueryReq;
|
||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||
import com.muyu.product.domain.resp.RuleInfoUpdResp;
|
||||
|
||||
/**
|
||||
* 商品规格Service接口
|
||||
|
@ -35,18 +37,15 @@ public interface RuleInfoService extends IService<RuleInfo> {
|
|||
|
||||
TableDataInfo<RuleInfoResp> queryList (RuleInfoQueryReq ruleInfoQueryReq);
|
||||
|
||||
/**
|
||||
* 通过规格ID获取规格修改详细信息
|
||||
* @param id 规格ID
|
||||
* @return
|
||||
*/
|
||||
RuleInfoUpdResp getUpdById(Long id);
|
||||
RuleInfoResp getUpdById(Long id);
|
||||
|
||||
/**
|
||||
* 通过ID修改规格属性
|
||||
* @param id ID
|
||||
* @param ruleInfoEditReq 请求对象
|
||||
* @return
|
||||
*/
|
||||
boolean updateById(Long id, RuleInfoEditReq ruleInfoEditReq);
|
||||
RuleInfoResp getUpdById2(Long id);
|
||||
|
||||
RuleInfoResp getUpdById3(Long id);
|
||||
|
||||
void edit(Long id, RuleAttrInfoReq ruleInfoEditReq);
|
||||
void edit2(Long id, RuleAttrInfoReq ruleInfoEditReq);
|
||||
void edit3(Long id, RuleAttrInfoReq ruleInfoEditReq);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.product.mapper.AsAttributeGroupMapper;
|
||||
import com.muyu.product.domain.AsAttributeGroup;
|
||||
|
@ -21,6 +22,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
@Service
|
||||
public class AsAttributeGroupServiceImpl extends ServiceImpl<AsAttributeGroupMapper, AsAttributeGroup> implements AsAttributeGroupService {
|
||||
|
||||
@Autowired
|
||||
private AsAttributeGroupMapper mapper;
|
||||
|
||||
|
||||
/**
|
||||
* 查询属性与组中间列表
|
||||
*
|
||||
|
@ -42,4 +47,14 @@ public class AsAttributeGroupServiceImpl extends ServiceImpl<AsAttributeGroupMap
|
|||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long id) {
|
||||
mapper.shanchu(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertBath(Long id, Long id1) {
|
||||
mapper.insertBatch(id,id1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,4 +46,6 @@ public class AsProductAttributeInfoServiceImpl extends ServiceImpl<AsProductAttr
|
|||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,14 +3,17 @@ package com.muyu.product.service.impl;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.product.domain.AsAttributeGroup;
|
||||
import com.muyu.product.domain.AttributeGroup;
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import com.muyu.product.domain.model.AttributeGroupSaveModel;
|
||||
import com.muyu.product.domain.req.AttributeGroupEditReq;
|
||||
import com.muyu.product.domain.req.AttributeInfoSaveReq;
|
||||
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpdateResp;
|
||||
import com.muyu.product.mapper.AttributeGroupMapper;
|
||||
import com.muyu.product.service.AsAttributeGroupService;
|
||||
import com.muyu.product.service.AttributeGroupService;
|
||||
|
@ -21,6 +24,8 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 属性组Service业务层处理
|
||||
|
@ -32,6 +37,9 @@ import java.util.List;
|
|||
@Service
|
||||
public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper, AttributeGroup> implements AttributeGroupService {
|
||||
|
||||
@Autowired
|
||||
private AsAttributeGroupService attributeGroupService;
|
||||
|
||||
@Autowired
|
||||
private AsAttributeGroupService asAttributeGroupService;
|
||||
|
||||
|
@ -49,11 +57,15 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
|
|||
public TableDataInfo<AttributeGroupPageResp> page (AttributeGroup attributeGroupQuery) {
|
||||
List<AttributeGroup> list = this.list(attributeGroupQuery);
|
||||
List<AttributeGroupPageResp> pageRespList = list.stream()
|
||||
.map(attributeGroup ->
|
||||
AttributeGroupPageResp.groupFunBuild(
|
||||
attributeGroup, groupId -> attributeInfoService.attributeListByGroupId(groupId)
|
||||
)
|
||||
)
|
||||
.map(attributeGroup -> {
|
||||
AttributeGroupPageResp resp = AttributeGroupPageResp.groupFunBuild(
|
||||
attributeGroup,
|
||||
groupId -> attributeInfoService.attributeListByGroupId(groupId)
|
||||
);
|
||||
// 确保设置备注字段
|
||||
resp.setRemark(attributeGroup.getRemark());
|
||||
return resp;
|
||||
})
|
||||
.toList();
|
||||
return TableDataInfo.<AttributeGroupPageResp>builder()
|
||||
.total(new PageInfo(list).getTotal())
|
||||
|
@ -99,7 +111,7 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
|
|||
Long attributeGroupId = attributeGroup.getId();
|
||||
List<Long> attributeIdList = attributeGroupSaveModel.getAttributeIdList();
|
||||
|
||||
asAttributeGroupService.saveBatch(
|
||||
attributeGroupService.saveBatch(
|
||||
attributeIdList.stream()
|
||||
.map(attributeId -> AsAttributeGroup.buildGroup(attributeGroupId, attributeId))
|
||||
.toList()
|
||||
|
@ -108,22 +120,108 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
|
|||
}
|
||||
|
||||
@Override
|
||||
public AttributeGroupUpdResp getUpdById(Long id) {
|
||||
public AttributeGroupUpdateResp getUpdateById(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()
|
||||
|
||||
List<Long> idlist = asAttributeGroupList.stream()
|
||||
.map(AsAttributeGroup::getAttributeId)
|
||||
.toList();
|
||||
List<AttributeInfo> attributeInfoList = attributeInfoService.listByIds(attributeIdList);
|
||||
|
||||
return AttributeGroupUpdResp.builder()
|
||||
.id(attributeGroup.getId())
|
||||
List<AttributeInfo> infoList = attributeInfoService.listByIds(idlist);
|
||||
|
||||
|
||||
return AttributeGroupUpdateResp.builder().id(attributeGroup.getId())
|
||||
.name(attributeGroup.getName())
|
||||
.states(attributeGroup.getStates())
|
||||
.attributeList(attributeInfoList)
|
||||
.attributeList(infoList)
|
||||
.remark(attributeGroup.getRemark())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> updateAttributeGroup2(Long id, AttributeGroupEditReq attributeGroupEditReq) {
|
||||
|
||||
|
||||
AttributeGroup attributeGroup = AttributeGroup.editBuild(id, attributeGroupEditReq);
|
||||
this.updateById(attributeGroup);
|
||||
|
||||
attributeGroupService.delete(id);
|
||||
|
||||
List<AttributeInfoSaveReq> attributeList = attributeGroupEditReq.getAttributeList();
|
||||
for (AttributeInfoSaveReq attributeInfoSaveReq : attributeList) {
|
||||
attributeGroupService.insertBath(attributeInfoSaveReq.getId(),id);
|
||||
}
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
// @Transactional
|
||||
// public Boolean updateAttributeGroup(Long id, AttributeGroupEditReq editReq) {
|
||||
// // 更新基本信息
|
||||
// AttributeGroup attributeGroup = AttributeGroup.editBuild(id, editReq);
|
||||
// boolean updated = this.updateById(attributeGroup);
|
||||
//
|
||||
// if (updated && editReq.getAttributeIds() != null) {
|
||||
// // 删除原有关联
|
||||
// LambdaQueryWrapper<AsAttributeGroup> deleteWrapper = new LambdaQueryWrapper<>();
|
||||
// deleteWrapper.eq(AsAttributeGroup::getGroupId, id);
|
||||
// asAttributeGroupService.remove(deleteWrapper);
|
||||
//
|
||||
// // 添加新的关联
|
||||
// List<AsAttributeGroup> newRelations = editReq.getAttributeIds().stream()
|
||||
// .map(attributeId -> AsAttributeGroup.buildGroup(id, attributeId))
|
||||
// .toList();
|
||||
//
|
||||
// if (!newRelations.isEmpty()) {
|
||||
// asAttributeGroupService.saveBatch(newRelations);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return updated;
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// @Transactional
|
||||
// public Boolean updateAttributeGroup(Long id, AttributeGroupEditReq editReq) {
|
||||
// // 更新基本信息
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,29 +1,31 @@
|
|||
package com.muyu.product.service.impl;
|
||||
|
||||
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
|
||||
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.common.core.utils.StringUtils;
|
||||
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.CategoryInfoDetailResp;
|
||||
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.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
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.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
|
@ -58,6 +60,62 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
@Autowired
|
||||
private AttributeGroupService attributeGroupService;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectInfoService projectInfoService;
|
||||
|
||||
@Autowired
|
||||
private AsProductAttributeInfoService asProductAttributeInfoService;
|
||||
|
||||
@Override
|
||||
public List<CategoryInfoDetailResp> listWithParent(CategoryInfo categoryInfo) {
|
||||
// 1. 添加空值检查, 改为使用Optional
|
||||
categoryInfo = Optional.ofNullable(categoryInfo).orElse(new CategoryInfo());
|
||||
|
||||
// 2. 查询品类列表
|
||||
LambdaQueryWrapper<CategoryInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StringUtils.isNotEmpty(categoryInfo.getName())) {
|
||||
queryWrapper.like(CategoryInfo::getName, categoryInfo.getName());
|
||||
}
|
||||
// ... 其他查询条件
|
||||
|
||||
List<CategoryInfo> categoryList = list(queryWrapper);
|
||||
if (CollectionUtils.isEmpty(categoryList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// 3. 获取所有父级ID时添加空值检查
|
||||
Set<Long> parentIds = categoryList.stream()
|
||||
.map(CategoryInfo::getParentId)
|
||||
.filter(Objects::nonNull) // 添加非空过滤
|
||||
.filter(id -> id != 0)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 4. 批量查询父级品类
|
||||
Map<Long, String> parentNameMap = new HashMap<>();
|
||||
if (!parentIds.isEmpty()) {
|
||||
List<CategoryInfo> parentCategories = listByIds(parentIds);
|
||||
parentNameMap = parentCategories.stream()
|
||||
.collect(Collectors.toMap(
|
||||
CategoryInfo::getId,
|
||||
CategoryInfo::getName,
|
||||
(k1, k2) -> k1
|
||||
));
|
||||
}
|
||||
|
||||
// 5. 转换为响应对象
|
||||
Map<Long, String> finalParentNameMap = parentNameMap;
|
||||
return categoryList.stream()
|
||||
.map(category -> {
|
||||
String parentName = null;
|
||||
if (category.getParentId() != null && category.getParentId() != 0) {
|
||||
parentName = finalParentNameMap.get(category.getParentId());
|
||||
}
|
||||
return CategoryInfoDetailResp.of(category, parentName);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询品类信息列表
|
||||
*
|
||||
|
@ -65,33 +123,55 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
*
|
||||
* @return 品类信息
|
||||
*/
|
||||
@Override
|
||||
public List<CategoryInfo> list (CategoryInfo categoryInfo) {
|
||||
LambdaQueryWrapper<CategoryInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
|
||||
if (ObjUtils.notNull(categoryInfo.getName())) {
|
||||
queryWrapper.like(CategoryInfo::getName, categoryInfo.getName());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(categoryInfo.getImage())) {
|
||||
queryWrapper.eq(CategoryInfo::getImage, categoryInfo.getImage());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(categoryInfo.getParentId())) {
|
||||
queryWrapper.eq(CategoryInfo::getParentId, categoryInfo.getParentId());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(categoryInfo.getStart())) {
|
||||
queryWrapper.eq(CategoryInfo::getStart, categoryInfo.getStart());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(categoryInfo.getIntroduction())) {
|
||||
queryWrapper.eq(CategoryInfo::getIntroduction, categoryInfo.getIntroduction());
|
||||
}
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
// @Override
|
||||
// public List<CategoryInfo> list(CategoryInfo categoryInfo) {
|
||||
// // 1. 查询品类列表
|
||||
// LambdaQueryWrapper<CategoryInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// if (ObjUtils.notNull(categoryInfo.getName())) {
|
||||
// queryWrapper.like(CategoryInfo::getName, categoryInfo.getName());
|
||||
// }
|
||||
// if (ObjUtils.notNull(categoryInfo.getImage())) {
|
||||
// queryWrapper.eq(CategoryInfo::getImage, categoryInfo.getImage());
|
||||
// }
|
||||
// if (ObjUtils.notNull(categoryInfo.getParentId())) {
|
||||
// queryWrapper.eq(CategoryInfo::getParentId, categoryInfo.getParentId());
|
||||
// }
|
||||
// if (ObjUtils.notNull(categoryInfo.getStart())) {
|
||||
// queryWrapper.eq(CategoryInfo::getStart, categoryInfo.getStart());
|
||||
// }
|
||||
// if (ObjUtils.notNull(categoryInfo.getIntroduction())) {
|
||||
// queryWrapper.eq(CategoryInfo::getIntroduction, categoryInfo.getIntroduction());
|
||||
// }
|
||||
//
|
||||
// List<CategoryInfo> categoryList = list(queryWrapper);
|
||||
//
|
||||
// // 2. 获取所有父级ID
|
||||
// Set<Long> parentIds = categoryList.stream()
|
||||
// .map(CategoryInfo::getParentId)
|
||||
// .filter(id -> id != 0)
|
||||
// .collect(Collectors.toSet());
|
||||
//
|
||||
// // 3. 批量查询父级品类
|
||||
// Map<Long, String> parentNameMap = new HashMap<>();
|
||||
// if (!parentIds.isEmpty()) {
|
||||
// List<CategoryInfo> parentCategories = listByIds(parentIds);
|
||||
// parentNameMap = parentCategories.stream()
|
||||
// .collect(Collectors.toMap(
|
||||
// CategoryInfo::getId,
|
||||
// CategoryInfo::getName
|
||||
// ));
|
||||
// }
|
||||
//
|
||||
// // 4. 转换为响应对象
|
||||
// Map<Long, String> finalParentNameMap = parentNameMap;
|
||||
// return categoryList.stream()
|
||||
// .map(category -> {
|
||||
// String parentName = category.getParentId() != 0 ?
|
||||
// finalParentNameMap.get(category.getParentId()) : null;
|
||||
// return CategoryInfoDetailResp.of(category, parentName);
|
||||
// })
|
||||
// .collect(Collectors.toList());
|
||||
// }
|
||||
|
||||
/**
|
||||
* 保存商品品类
|
||||
|
@ -140,22 +220,41 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
*/
|
||||
@Override
|
||||
public List<AttributeGroup> getAttributeGroup (Long categoryId) {
|
||||
// 1. 空值检查
|
||||
if (categoryId == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<AttributeGroup> attributeGroupList = new ArrayList<>();
|
||||
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||
|
||||
// 2. 添加空值检查
|
||||
if (categoryInfo == null) {
|
||||
return attributeGroupList;
|
||||
}
|
||||
|
||||
// 3. 查询当前品类关联的属性组
|
||||
LambdaQueryWrapper<AsCategoryAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AsCategoryAttributeGroup::getCategoryId, categoryId);
|
||||
List<AsCategoryAttributeGroup> asCategoryAttributeGroupList = asCategoryAttributeGroupService.list(queryWrapper);
|
||||
|
||||
// 4. 获取并添加当前品类的属性组
|
||||
if (asCategoryAttributeGroupList != null && !asCategoryAttributeGroupList.isEmpty()) {
|
||||
List<Long> attributeGroupIdList = asCategoryAttributeGroupList.stream()
|
||||
.map(AsCategoryAttributeGroup::getAttributeGroupId)
|
||||
.toList();
|
||||
.collect(Collectors.toList());
|
||||
attributeGroupList.addAll(attributeGroupService.listByIds(attributeGroupIdList));
|
||||
}
|
||||
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||
if (categoryInfo.getParentId() != 0) {
|
||||
|
||||
// 5. 递归获取父级品类的属性组
|
||||
CategoryInfo categoryInfo1 = this.getById(categoryId);
|
||||
if (categoryInfo1.getParentId() != 0) {
|
||||
if (attributeGroupList.isEmpty()) {
|
||||
attributeGroupList.addAll(getAttributeGroup(categoryInfo.getParentId()));
|
||||
// 如果当前没有属性组,直接添加父级的所有属性组
|
||||
attributeGroupList.addAll(getAttributeGroup(categoryInfo1.getParentId()));
|
||||
} else {
|
||||
List<AttributeGroup> attributeGroups = getAttributeGroup(categoryInfo.getParentId());
|
||||
// 如果当前有属性组,只添加不重复的父级属性组
|
||||
List<AttributeGroup> attributeGroups = getAttributeGroup(categoryInfo1.getParentId());
|
||||
attributeGroups.forEach(attributeGroup -> {
|
||||
if (!attributeGroupList.contains(attributeGroup)) {
|
||||
attributeGroupList.add(attributeGroup);
|
||||
|
@ -163,6 +262,7 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
return attributeGroupList;
|
||||
}
|
||||
|
||||
|
@ -211,29 +311,56 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
*/
|
||||
@Override
|
||||
public List<AttributeInfo> getAttribute (Long categoryId) {
|
||||
// 1. 入参校验
|
||||
if (categoryId == null || categoryId == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<AttributeInfo> attributeInfoList = new ArrayList<>();
|
||||
|
||||
// 2. 获取当前分类信息,使用Optional安全处理
|
||||
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||
if (categoryInfo == null) {
|
||||
return attributeInfoList;
|
||||
}
|
||||
|
||||
// 3. 查询当前分类关联的属性
|
||||
LambdaQueryWrapper<AsCategoryAttribute> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AsCategoryAttribute::getCategoryId, categoryId);
|
||||
List<AsCategoryAttribute> asCategoryAttributeList = asCategoryAttributeService.list(queryWrapper);
|
||||
if (asCategoryAttributeList != null && !asCategoryAttributeList.isEmpty()) {
|
||||
|
||||
// 4. 获取当前分类的属性
|
||||
if (CollectionUtils.isEmpty(asCategoryAttributeList)) {
|
||||
List<Long> attributeIdList = asCategoryAttributeList.stream()
|
||||
.map(AsCategoryAttribute::getAttributeId)
|
||||
.toList();
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(attributeIdList)) {
|
||||
attributeInfoList.addAll(attributeInfoService.listByIds(attributeIdList));
|
||||
}
|
||||
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||
if (categoryInfo.getParentId() != 0) {
|
||||
}
|
||||
|
||||
// 5. 处理父级属性,使用安全的parentId获取方式
|
||||
Long parentId = categoryInfo.getSafeParentId(); // 使用我们之前添加的安全获取方法
|
||||
if (parentId != 0) {
|
||||
CategoryInfo parentCategory = this.getById(parentId);
|
||||
if (parentCategory != null) {
|
||||
if (attributeInfoList.isEmpty()) {
|
||||
attributeInfoList.addAll(getAttribute(categoryInfo.getParentId()));
|
||||
// 如果当前没有属性,直接添加父级的所有属性
|
||||
attributeInfoList.addAll(getAttribute(parentId));
|
||||
} else {
|
||||
List<AttributeInfo> attributeInfos = getAttribute(categoryInfo.getParentId());
|
||||
attributeInfos.forEach(attributeInfoQuery -> {
|
||||
if (!attributeInfoList.contains(attributeInfoQuery)) {
|
||||
attributeInfoList.add(attributeInfoQuery);
|
||||
}
|
||||
});
|
||||
// 如果当前有属性,只添加不重复的父级属性
|
||||
List<AttributeInfo> parentAttributes = getAttribute(parentId);
|
||||
if (CollectionUtils.isEmpty(parentAttributes)) {
|
||||
for (AttributeInfo attributeInfo : parentAttributes) {
|
||||
if (!attributeInfoList.contains(attributeInfo)) {
|
||||
attributeInfoList.add(attributeInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return attributeInfoList;
|
||||
}
|
||||
|
||||
|
@ -308,13 +435,10 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
getParentIdListByCateGoryId(cateGoryIdList, cateGoryId);
|
||||
// 取出和品类相关联的属性组关系 - 中间表
|
||||
LambdaQueryWrapper<AsCategoryAttributeGroup> asCategoryAttributeGroupLambdaQueryWrapper = new LambdaQueryWrapper<>(){{
|
||||
in(AsCategoryAttributeGroup::getCategoryId, cateGoryIdList);
|
||||
}};
|
||||
in(AsCategoryAttributeGroup::getCategoryId, cateGoryIdList);}};
|
||||
List<AsCategoryAttributeGroup> categoryAttributeGroupList = asCategoryAttributeGroupService.list(asCategoryAttributeGroupLambdaQueryWrapper);
|
||||
List<TemplateAttributeGroupModel> attributeGroupModelList = categoryAttributeGroupList.stream()
|
||||
.map(AsCategoryAttributeGroup::getAttributeGroupId)
|
||||
.distinct()
|
||||
.map(attributeGroupId -> TemplateAttributeGroupModel.attributeGroupBuild(
|
||||
.map(AsCategoryAttributeGroup::getAttributeGroupId).distinct().map(attributeGroupId -> TemplateAttributeGroupModel.attributeGroupBuild(
|
||||
attributeGroupService.getById(attributeGroupId),
|
||||
applyAttributeGroupId -> {
|
||||
LambdaQueryWrapper<AsAttributeGroup> asAttributeGroupQueryWrapper = new LambdaQueryWrapper<>() {{
|
||||
|
@ -344,7 +468,6 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
.toList()
|
||||
);
|
||||
}
|
||||
|
||||
List<TemplateAttributeModel> templateAttributeModelList = new ArrayList<>();
|
||||
LambdaQueryWrapper<AsCategoryAttribute> categoryAttributeQueryWrapper = new LambdaQueryWrapper<>();
|
||||
categoryAttributeQueryWrapper.in(AsCategoryAttribute::getCategoryId, cateGoryIdList);
|
||||
|
@ -360,21 +483,195 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
}
|
||||
|
||||
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();
|
||||
|
||||
|
||||
|
||||
attributeGroupModelList.forEach(TemplateAttributeGroupModel->{
|
||||
TemplateAttributeGroupModel.getAttributeList().forEach(TemplateAttributeModel->{
|
||||
Long id = TemplateAttributeModel.getId();
|
||||
LambdaQueryWrapper<AsProductAttributeInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(AsProductAttributeInfo::getAttributeId,id);
|
||||
List<AsProductAttributeInfo> list = this.asProductAttributeInfoService.list(queryWrapper);
|
||||
list.forEach(AsProductAttributeInfo->{
|
||||
TemplateAttributeModel.setValue(AsProductAttributeInfo.getValue());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
templateAttributeModelList.forEach(TemplateAttributeModel ->{
|
||||
Long id = TemplateAttributeModel.getId();
|
||||
LambdaQueryWrapper<AsProductAttributeInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(AsProductAttributeInfo::getAttributeId,id);
|
||||
List<AsProductAttributeInfo> list = this.asProductAttributeInfoService.list(lambdaQueryWrapper);
|
||||
list.forEach(asProductAttributeInfo -> {
|
||||
TemplateAttributeModel.setValue(asProductAttributeInfo.getValue());
|
||||
});
|
||||
});
|
||||
|
||||
attributeModelList.forEach(templateAttributeModel -> {
|
||||
Long id = templateAttributeModel.getId();
|
||||
LambdaQueryWrapper<AsProductAttributeInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(AsProductAttributeInfo::getAttributeId,id);
|
||||
List<AsProductAttributeInfo> list = this.asProductAttributeInfoService.list(lambdaQueryWrapper);
|
||||
list.forEach(asProductAttributeInfo -> {
|
||||
templateAttributeModel.setValue(asProductAttributeInfo.getValue());
|
||||
});
|
||||
});
|
||||
return CategoryCommonElementResp.builder()
|
||||
.templateAttributeGroupList(attributeGroupModelList)
|
||||
.templateAttributeList(templateAttributeModelList)
|
||||
.attributeList(attributeModelList)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CategoryInfoDetailResp getDetailById(Long id) {
|
||||
// 获取基本信息
|
||||
CategoryInfo categoryInfo = this.getById(id);
|
||||
if (categoryInfo == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CategoryInfoDetailResp resp = CategoryInfoDetailResp.of(categoryInfo);
|
||||
|
||||
// 获取关联的属性ID列表
|
||||
LambdaQueryWrapper<AsCategoryAttribute> attrWrapper = new LambdaQueryWrapper<>();
|
||||
attrWrapper.eq(AsCategoryAttribute::getCategoryId, id);
|
||||
List<AsCategoryAttribute> categoryAttributes = asCategoryAttributeService.list(attrWrapper);
|
||||
List<Long> attributeIds = categoryAttributes.stream()
|
||||
.map(AsCategoryAttribute::getAttributeId)
|
||||
.collect(Collectors.toList());
|
||||
resp.setAttributeIdList(attributeIds);
|
||||
|
||||
// 获取关联的属性组ID列表
|
||||
LambdaQueryWrapper<AsCategoryAttributeGroup> groupWrapper = new LambdaQueryWrapper<>();
|
||||
groupWrapper.eq(AsCategoryAttributeGroup::getCategoryId, id);
|
||||
List<AsCategoryAttributeGroup> categoryGroups = asCategoryAttributeGroupService.list(groupWrapper);
|
||||
List<Long> groupIds = categoryGroups.stream()
|
||||
.map(AsCategoryAttributeGroup::getAttributeGroupId)
|
||||
.collect(Collectors.toList());
|
||||
resp.setAttributeGroupIdList(groupIds);
|
||||
|
||||
// 获取关联的品牌ID列表
|
||||
LambdaQueryWrapper<AsCategoryBrand> brandWrapper = new LambdaQueryWrapper<>();
|
||||
brandWrapper.eq(AsCategoryBrand::getCategoryId, id);
|
||||
List<AsCategoryBrand> categoryBrands = asCategoryBrandService.list(brandWrapper);
|
||||
List<Long> brandIds = categoryBrands.stream()
|
||||
.map(AsCategoryBrand::getBrandId)
|
||||
.collect(Collectors.toList());
|
||||
resp.setBrandIdList(brandIds);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateCategoryInfo(Long id, CategoryInfoSaveModel updateModel) {
|
||||
// 更新基本信息
|
||||
CategoryInfo categoryInfo = CategoryInfo.saveModelBuild(updateModel);
|
||||
categoryInfo.setId(id);
|
||||
this.updateById(categoryInfo);
|
||||
|
||||
// 更新关联属性
|
||||
updateAssociations(id,
|
||||
updateModel.getAttributeIdList(),
|
||||
updateModel.getAttributeGroupIdList(),
|
||||
updateModel.getBrandIdList()
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeCategories(List<Long> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return false;
|
||||
}
|
||||
// 删除品类关联数据
|
||||
for (Long categoryId : ids) {
|
||||
//检查是否有子类目
|
||||
LambdaQueryWrapper<CategoryInfo> childWrapper = new LambdaQueryWrapper<>();
|
||||
childWrapper.eq(CategoryInfo::getParentId,categoryId);
|
||||
long count = this.count(childWrapper);
|
||||
if (count > 0){
|
||||
CategoryInfo category = this.getById(categoryId);
|
||||
throw new RuntimeException("品类【"+category.getName()+"】存在子类目 ,不能删除");
|
||||
}
|
||||
//检查最后一级是否关联商品
|
||||
LambdaQueryWrapper<ProjectInfo> projectWrapper = new LambdaQueryWrapper<>();
|
||||
projectWrapper.eq(ProjectInfo::getMianType,categoryId)
|
||||
.or()
|
||||
.eq(ProjectInfo::getParentType,categoryId)
|
||||
.or()
|
||||
.eq(ProjectInfo::getType,categoryId);
|
||||
long projectCount = projectInfoService.count(projectWrapper);
|
||||
if (projectCount > 0){
|
||||
CategoryInfo category = this.getById(categoryId);
|
||||
throw new RuntimeException("品类【"+category.getName()+"】已关联项目,不能删除");
|
||||
}
|
||||
|
||||
|
||||
// 删除品类-属性关联
|
||||
LambdaQueryWrapper<AsCategoryAttribute> attrWrapper = new LambdaQueryWrapper<>();
|
||||
attrWrapper.eq(AsCategoryAttribute::getCategoryId, categoryId);
|
||||
asCategoryAttributeService.remove(attrWrapper);
|
||||
|
||||
// 删除品类-属性组关联
|
||||
LambdaQueryWrapper<AsCategoryAttributeGroup> groupWrapper = new LambdaQueryWrapper<>();
|
||||
groupWrapper.eq(AsCategoryAttributeGroup::getCategoryId, categoryId);
|
||||
asCategoryAttributeGroupService.remove(groupWrapper);
|
||||
|
||||
// 删除品类-品牌关联
|
||||
LambdaQueryWrapper<AsCategoryBrand> brandWrapper = new LambdaQueryWrapper<>();
|
||||
brandWrapper.eq(AsCategoryBrand::getCategoryId, categoryId);
|
||||
asCategoryBrandService.remove(brandWrapper);
|
||||
}
|
||||
|
||||
// 删除品类
|
||||
return this.removeBatchByIds(ids);
|
||||
}
|
||||
private void updateAssociations(Long categoryId,
|
||||
List<Long> attributeIds,
|
||||
List<Long> groupIds,
|
||||
List<Long> brandIds) {
|
||||
// 删除原有关联
|
||||
asCategoryAttributeService.remove(new LambdaQueryWrapper<AsCategoryAttribute>()
|
||||
.eq(AsCategoryAttribute::getCategoryId, categoryId));
|
||||
asCategoryAttributeGroupService.remove(new LambdaQueryWrapper<AsCategoryAttributeGroup>()
|
||||
.eq(AsCategoryAttributeGroup::getCategoryId, categoryId));
|
||||
asCategoryBrandService.remove(new LambdaQueryWrapper<AsCategoryBrand>()
|
||||
.eq(AsCategoryBrand::getCategoryId, categoryId));
|
||||
|
||||
// 保存新关联
|
||||
if (!CollectionUtils.isEmpty(attributeIds)) {
|
||||
asCategoryAttributeService.saveBatch(attributeIds.stream()
|
||||
.map(attrId -> AsCategoryAttribute.categoryBuild(categoryId, attrId))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(groupIds)) {
|
||||
asCategoryAttributeGroupService.saveBatch(groupIds.stream()
|
||||
.map(groupId -> AsCategoryAttributeGroup.categoryBuild(categoryId, groupId))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(brandIds)) {
|
||||
asCategoryBrandService.saveBatch(brandIds.stream()
|
||||
.map(brandId -> AsCategoryBrand.categoryBuild(categoryId, brandId))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,10 +4,15 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.product.domain.*;
|
||||
import com.muyu.product.domain.model.*;
|
||||
import com.muyu.product.domain.req.ProjectInfoEditReq;
|
||||
import com.muyu.product.domain.req.ProjectInfoSaveReq;
|
||||
import com.muyu.product.domain.resp.CategoryCommonElementResp;
|
||||
import com.muyu.product.domain.resp.ProjectDetailResp;
|
||||
|
@ -18,6 +23,7 @@ import org.springframework.stereotype.Service;
|
|||
import com.muyu.product.mapper.ProjectInfoMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 商品信息Service业务层处理
|
||||
|
@ -99,10 +105,6 @@ public class ProjectInfoServiceImpl extends ServiceImpl<ProjectInfoMapper, Proje
|
|||
queryWrapper.eq(ProjectInfo::getBrandId, projectInfo.getBrandId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
|
@ -229,4 +231,89 @@ public class ProjectInfoServiceImpl extends ServiceImpl<ProjectInfoMapper, Proje
|
|||
.attributeGroupList(templateAttributeGroupList)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result UpdProjectInfo(Long id, ProjectInfoEditReq projectInfoEditReq) {
|
||||
// 调用 updateById 方法,修改商品基本信息
|
||||
this.updateById(ProjectAddModel.editBuild(id,projectInfoEditReq));
|
||||
//检查属性列表是否为空
|
||||
if(!com.alibaba.nacos.common.utils.CollectionUtils.isEmpty(projectInfoEditReq.getAttrValueList())){
|
||||
//拿到属性值不为空的 构建 AttributeInfo 对象列表
|
||||
List<AttributeInfo> attributeInfos = projectInfoEditReq.getAttrValueList().stream().filter(projectModel -> !StringUtils.isBlank(projectModel.getValue())).map(item->{
|
||||
AttributeInfo attributeInfo =AttributeInfo.builder().id(item.getId()).name(item.getValue()).build();
|
||||
return attributeInfo;
|
||||
}).toList();
|
||||
//批量修改属性信息
|
||||
attributeInfoService.updateBatchById(attributeInfos);
|
||||
}
|
||||
//检查产品的SKU列表是否为空
|
||||
if(!CollectionUtils.isEmpty(projectInfoEditReq.getProductSkuList())){
|
||||
//构建 ProjectSkuInfo 对象列表
|
||||
List<ProjectSkuInfo> skuInfoList = projectInfoEditReq.getProductSkuList().stream().map(projectSkuInfoModel-> {
|
||||
ProjectSkuInfo projectSkuInfo = ProjectSkuInfo.builder().sku(projectSkuInfoModel.getSku())
|
||||
.image(projectSkuInfoModel.getImage())
|
||||
.stock(projectSkuInfoModel.getStock())
|
||||
.price(projectSkuInfoModel.getPrice())
|
||||
.build();
|
||||
return projectSkuInfo;
|
||||
}).toList();
|
||||
//循环遍历 SKU 列表 循环修改
|
||||
skuInfoList.forEach(projectSkuInfoModel->{
|
||||
LambdaUpdateWrapper<ProjectSkuInfo> wrapper = new LambdaUpdateWrapper<>();
|
||||
//如果图片不为空,则修改图片字段
|
||||
if(!StringUtils.isBlank(projectSkuInfoModel.getImage())){
|
||||
wrapper.set(ProjectSkuInfo::getImage,projectSkuInfoModel.getImage());
|
||||
}
|
||||
//修改库存和价格字段
|
||||
wrapper.set(ProjectSkuInfo::getStock,projectSkuInfoModel.getStock());
|
||||
wrapper.set(ProjectSkuInfo::getPrice,projectSkuInfoModel.getPrice());
|
||||
//修改条件 为SKU字段
|
||||
wrapper.eq(ProjectSkuInfo::getSku,projectSkuInfoModel.getSku());
|
||||
//执行更新操作
|
||||
projectSkuInfoService.update(null,wrapper);
|
||||
});
|
||||
}
|
||||
return Result.success(null,"修改");
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Result UpdProjectInfo(Long id, ProjectInfoEditReq projectInfoEditReq) {
|
||||
// this.updateById(ProjectAddModel.editBuild(id,projectInfoEditReq));
|
||||
// if(!CollectionUtils.isEmpty(projectInfoEditReq.getAttrValueList())){
|
||||
// List<AttributeInfo> attributeInfoList= projectInfoEditReq.getAttrValueList().stream().filter(attributeInfoUpdModel->!StringUtils.isBlank(attributeInfoUpdModel.getValue()))
|
||||
// .map(item->{
|
||||
// AttributeInfo attributeInfo = AttributeInfo.builder().id(item.getId()).name(item.getValue()).build();
|
||||
// return attributeInfo;
|
||||
// }).toList();
|
||||
// attributeInfoService.updateBatchById(attributeInfoList);
|
||||
// }
|
||||
//
|
||||
// if(!CollectionUtils.isEmpty(projectInfoEditReq.getProductSkuList())){
|
||||
// List<ProjectSkuInfo> skuInfoList =projectInfoEditReq.getProductSkuList().stream().map(projectSKUModel -> {
|
||||
// ProjectSkuInfo projectSkuInfo = ProjectSkuInfo.builder()
|
||||
// .sku(projectSKUModel.getSku())
|
||||
// .image(projectSKUModel.getImage())
|
||||
// .stock(projectSKUModel.getStock())
|
||||
// .price(projectSKUModel.getPrice())
|
||||
// .build();
|
||||
// return projectSkuInfo;
|
||||
// }).toList();
|
||||
// skuInfoList.forEach(projectSkuInfo -> {
|
||||
// LambdaUpdateWrapper<ProjectSkuInfo> wrapper = new LambdaUpdateWrapper<>();
|
||||
// if(!StringUtils.isBlank(projectSkuInfo.getImage())){
|
||||
// wrapper.set(ProjectSkuInfo::getImage,projectSkuInfo.getImage());
|
||||
// }
|
||||
// wrapper.set(ProjectSkuInfo::getStock,projectSkuInfo.getStock());
|
||||
// wrapper.set(ProjectSkuInfo::getPrice,projectSkuInfo.getPrice());
|
||||
// wrapper.eq(ProjectSkuInfo::getSku, projectSkuInfo.getSku());
|
||||
// projectSkuInfoService.update(null,wrapper);
|
||||
// });
|
||||
//
|
||||
// }
|
||||
// return Result.success("修改成功");
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.muyu.product.domain.ProjectSkuInfo;
|
|||
import com.muyu.product.service.ProjectSkuInfoService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 商品SKUService业务层处理
|
||||
|
@ -88,4 +89,34 @@ public class ProjectSkuInfoServiceImpl extends ServiceImpl<ProjectSkuInfoMapper,
|
|||
queryWrapper.eq(ProjectSkuInfo::getProjectId, projectId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateBatch(List<ProjectSkuInfo> skuList) {
|
||||
return this.updateBatchById(skuList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateStock(Long id, Long stock) {
|
||||
ProjectSkuInfo skuInfo = new ProjectSkuInfo();
|
||||
skuInfo.setId(id);
|
||||
skuInfo.setStock(stock);
|
||||
return this.updateById(skuInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean deleteById(Long id) {
|
||||
return this.removeById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean deleteBatch(List<Long> ids) {
|
||||
return this.removeByIds(ids);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,9 @@ package com.muyu.product.service.impl;
|
|||
import java.util.List;
|
||||
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.product.mapper.RuleAttrInfoMapper;
|
||||
import com.muyu.product.domain.RuleAttrInfo;
|
||||
|
@ -21,6 +23,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
@Service
|
||||
public class RuleAttrInfoServiceImpl extends ServiceImpl<RuleAttrInfoMapper, RuleAttrInfo> implements RuleAttrInfoService {
|
||||
|
||||
@Autowired
|
||||
private RuleAttrInfoMapper ruleAttrInfoMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 查询规格详情列表
|
||||
*
|
||||
|
@ -64,4 +70,10 @@ public class RuleAttrInfoServiceImpl extends ServiceImpl<RuleAttrInfoMapper, Rul
|
|||
queryWrapper.eq(RuleAttrInfo::getRuleId, ruleId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RuleAttrAddModel> getRuleAttrInfo(Long id) {
|
||||
List<RuleAttrAddModel> ruleAttrInfoList= ruleAttrInfoMapper.getRuleAttrInfo(id);
|
||||
return ruleAttrInfoList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +1,33 @@
|
|||
package com.muyu.product.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
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.utils.StringUtils;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.product.domain.ProjectInfo;
|
||||
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.RuleAttrInfoReq;
|
||||
import com.muyu.product.domain.req.RuleGroupUpdResp;
|
||||
import com.muyu.product.domain.req.RuleInfoEditReq;
|
||||
import com.muyu.product.domain.req.RuleInfoQueryReq;
|
||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||
import com.muyu.product.domain.resp.RuleInfoUpdResp;
|
||||
import com.muyu.product.mapper.ProjectInfoMapper;
|
||||
import com.muyu.product.mapper.RuleAttrInfoMapper;
|
||||
import com.muyu.product.service.RuleAttrInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.math3.stat.descriptive.summary.Product;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.product.mapper.RuleInfoMapper;
|
||||
|
@ -43,6 +49,12 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
|||
@Autowired
|
||||
private RuleAttrInfoService ruleAttrInfoService;
|
||||
|
||||
@Autowired
|
||||
private RuleAttrInfoMapper attrInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private ProjectInfoMapper projectInfoMapper;
|
||||
|
||||
/**
|
||||
* 查询商品规格列表
|
||||
*
|
||||
|
@ -62,6 +74,10 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
|||
queryWrapper.eq(RuleInfo::getStatus, ruleInfo.getStatus());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(ruleInfo.getRemark())){
|
||||
queryWrapper.eq(RuleInfo::getRemark,ruleInfo.getRemark());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -78,13 +94,27 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
|||
*/
|
||||
@Override
|
||||
public boolean save (RuleInfoAddModel ruleInfoAddModel) {
|
||||
// 验证状态值
|
||||
if (!Arrays.asList("Y", "N").contains(ruleInfoAddModel.getStatus())) {
|
||||
throw new RuntimeException("状态值无效,必须是 'Y' 或 'N'");
|
||||
}
|
||||
|
||||
RuleInfo ruleInfo = RuleInfo.addModelBuild(ruleInfoAddModel, SecurityUtils::getUsername);
|
||||
boolean save = this.save(ruleInfo);
|
||||
|
||||
// 保存规格属性
|
||||
if (!ruleInfoAddModel.getRuleAttrList().isEmpty()) {
|
||||
ruleAttrInfoService.saveBatch(
|
||||
ruleInfoAddModel.getRuleAttrList().stream()
|
||||
.map(ruleAttrAddModel -> RuleAttrInfo.addModelBuild(ruleAttrAddModel, ruleInfo::getId, SecurityUtils::getUsername))
|
||||
.map(ruleAttrAddModel -> RuleAttrInfo.addModelBuild(
|
||||
ruleAttrAddModel,
|
||||
ruleInfo::getId,
|
||||
SecurityUtils::getUsername
|
||||
))
|
||||
.toList()
|
||||
);
|
||||
}
|
||||
|
||||
return save;
|
||||
}
|
||||
|
||||
|
@ -97,13 +127,20 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
|||
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 -> {
|
||||
.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();
|
||||
}))
|
||||
return ruleAttrInfoService.list(queryWrapper).stream()
|
||||
.map(RuleAttrAddModel::infoBuild)
|
||||
.toList();
|
||||
boolean isPage = ruleInfoQueryReq.getParams().get("isPage") == null || Convert.toBool(ruleInfoQueryReq.getParams().get("isPage"), true);
|
||||
},
|
||||
this::checkRuleIsUsed // 添加检查规格使用状态的方法
|
||||
))
|
||||
.toList();
|
||||
boolean isPage = ruleInfoQueryReq.getParams().get("isPage") == null
|
||||
|| Convert.toBool(ruleInfoQueryReq.getParams().get("isPage"), true);
|
||||
|
||||
return TableDataInfo.<RuleInfoResp>builder()
|
||||
.rows(ruleInfoRespList)
|
||||
|
@ -111,34 +148,243 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
|||
.build();
|
||||
}
|
||||
|
||||
private Boolean checkRuleIsUsed(Long ruleId) {
|
||||
// 检查商品信息表中是否存在使用该规格的商品
|
||||
LambdaQueryWrapper<ProjectInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ProjectInfo::getRuleId, ruleId);
|
||||
return projectInfoMapper.exists(queryWrapper);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public RuleInfoAddModel getUpdById(Long id) {
|
||||
//
|
||||
// RuleInfo ruleInfo = this.getById(id);
|
||||
// if (ruleInfo==null){
|
||||
// throw new RuntimeException("没有这个商品规格");
|
||||
// }
|
||||
//
|
||||
// List<RuleAttrAddModel> ruleAttrInfos = ruleAttrInfoService.getRuleAttrInfo(ruleInfo.getId());
|
||||
// ArrayList<RuleAttrAddModel> arrayList = new ArrayList<>();
|
||||
//
|
||||
// RuleAttrAddModel ruleAttrAddModel = new RuleAttrAddModel();
|
||||
//
|
||||
// for (RuleAttrAddModel ruleAttrInfo : ruleAttrInfos) {
|
||||
// ruleAttrAddModel.setName(ruleAttrInfo.getName());
|
||||
// }
|
||||
//
|
||||
//// List<String> list = ruleAttrInfos.stream().map((RuleAttrAddModel t) -> RuleAttrInfo.getAttrValue(t)).toList();
|
||||
//
|
||||
// ruleAttrAddModel.setValueList(list);
|
||||
// arrayList.add(ruleAttrAddModel);
|
||||
//
|
||||
// RuleInfoAddModel resp = new RuleInfoAddModel();
|
||||
// resp.setId(ruleInfo.getId());
|
||||
// resp.setName(ruleInfo.getName());
|
||||
// resp.setStatus(ruleInfo.getStatus());
|
||||
// resp.setRuleAttrList(arrayList);
|
||||
//
|
||||
// return resp;
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public RuleInfoUpdResp getUpdById(Long id) {
|
||||
public RuleInfoResp getUpdById(Long id){
|
||||
// RuleInfoResp getRuleById = attrInfoMapper.getRuleAttrInfo2(id);
|
||||
// List<RuleAttrAddModel> ruleAttrList = getRuleById.getRuleAttrList();
|
||||
//
|
||||
// for (RuleAttrAddModel ruleAttrAddModel : ruleAttrList) {
|
||||
// String attrValue = ruleAttrAddModel.getAttrValue();
|
||||
// String[] split = attrValue.split(",");
|
||||
// ruleAttrAddModel.setValueList(List.of(split));
|
||||
// }
|
||||
// return getRuleById;
|
||||
RuleInfo ruleInfo = this.getById(id);
|
||||
if (ruleInfo == null) {
|
||||
throw new RuntimeException("商品规格不存在");
|
||||
}
|
||||
|
||||
// 2. 查询规格属性信息
|
||||
LambdaQueryWrapper<RuleAttrInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(RuleAttrInfo::getRuleId, id);
|
||||
List<RuleAttrInfo> ruleAttrInfoList = this.ruleAttrInfoService.list(queryWrapper);
|
||||
return RuleInfoUpdResp.builder()
|
||||
List<RuleAttrInfo> attrInfoList = ruleAttrInfoService.list(queryWrapper);
|
||||
|
||||
// 3. 转换属性信息
|
||||
List<RuleAttrAddModel> ruleAttrList = attrInfoList.stream()
|
||||
.map(attrInfo -> {
|
||||
RuleAttrAddModel model = new RuleAttrAddModel();
|
||||
model.setName(attrInfo.getName());
|
||||
// 处理属性值列表
|
||||
if (StringUtils.isNotEmpty(attrInfo.getAttrValue())) {
|
||||
List<String> valueList = Arrays.asList(attrInfo.getAttrValue().split(","));
|
||||
// 去除空值和空白字符
|
||||
valueList = valueList.stream()
|
||||
.filter(StringUtils::isNotEmpty)
|
||||
.map(String::trim)
|
||||
.collect(Collectors.toList());
|
||||
model.setValueList(valueList);
|
||||
}
|
||||
return model;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 4. 构建返回对象
|
||||
return RuleInfoResp.builder()
|
||||
.id(ruleInfo.getId())
|
||||
.name(ruleInfo.getName())
|
||||
.status(ruleInfo.getStatus())
|
||||
.remark(ruleInfo.getRemark())
|
||||
.ruleAttrList(ruleAttrInfoList.stream().map(RuleAttrAddModel::infoBuild).toList())
|
||||
.ruleAttrList(ruleAttrList)
|
||||
.createTime(ruleInfo.getCreateTime())
|
||||
.updateTime(ruleInfo.getUpdateTime())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateById(Long id, RuleInfoEditReq ruleInfoEditReq) {
|
||||
boolean update = this.updateById(RuleInfo.editBuild(id, ruleInfoEditReq));
|
||||
if (update) {
|
||||
public RuleInfoResp getUpdById2(Long id) {
|
||||
// 1. 查询基础规格信息
|
||||
RuleInfo ruleInfo = this.getById(id);
|
||||
if (ruleInfo == null) {
|
||||
throw new RuntimeException("商品规格不存在");
|
||||
}
|
||||
|
||||
// 2. 查询规格属性信息并转换
|
||||
LambdaQueryWrapper<RuleAttrInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(RuleAttrInfo::getRuleId, id);
|
||||
this.ruleAttrInfoService.remove(queryWrapper);
|
||||
ruleAttrInfoService.saveBatch(
|
||||
ruleInfoEditReq.getRuleAttrList().stream()
|
||||
.map(ruleAttrAddModel -> RuleAttrInfo.addModelBuild(ruleAttrAddModel, () -> id, SecurityUtils::getUsername))
|
||||
.toList()
|
||||
);
|
||||
List<RuleAttrAddModel> ruleAttrList = ruleAttrInfoService.list(queryWrapper).stream()
|
||||
.map(attrInfo -> {
|
||||
RuleAttrAddModel model = new RuleAttrAddModel();
|
||||
model.setName(attrInfo.getName());
|
||||
model.setValueList(Arrays.asList(attrInfo.getAttrValue().split(",")));
|
||||
return model;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 3. 构建返回对象
|
||||
return RuleInfoResp.builder()
|
||||
.id(ruleInfo.getId())
|
||||
.name(ruleInfo.getName())
|
||||
.status(ruleInfo.getStatus())
|
||||
.ruleAttrList(ruleAttrList)
|
||||
.build();
|
||||
}
|
||||
return update;
|
||||
|
||||
@Override
|
||||
public RuleInfoResp getUpdById3(Long id) {
|
||||
RuleInfo ruleInfo = this.getById(id);
|
||||
if (ruleInfo==null){
|
||||
throw new RuntimeException("商品规格不存在");
|
||||
}
|
||||
LambdaQueryWrapper<RuleAttrInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(RuleAttrInfo::getRuleId,id);
|
||||
List<RuleAttrAddModel> ruleAttrList = ruleAttrInfoService.list(queryWrapper).stream()
|
||||
.map(attrInfo -> {
|
||||
RuleAttrAddModel model = new RuleAttrAddModel();
|
||||
model.setName(attrInfo.getName());
|
||||
model.setValueList(Arrays.asList(attrInfo.getAttrValue().split(",")));
|
||||
return model;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return RuleInfoResp.builder()
|
||||
.id(ruleInfo.getId())
|
||||
.name(ruleInfo.getName())
|
||||
.status(ruleInfo.getStatus())
|
||||
.ruleAttrList(ruleAttrList)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void edit(Long id, RuleAttrInfoReq req) {
|
||||
attrInfoMapper.updRule(id,req);
|
||||
attrInfoMapper.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);
|
||||
attrInfoMapper.addRuleAttrModel(id,ruleAttrAddModel.getName(),substring);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit2(Long id, RuleAttrInfoReq req) {
|
||||
RuleInfo ruleInfo = RuleInfo.builder()
|
||||
.id(id)
|
||||
.name(req.getName())
|
||||
.status(req.getStatus())
|
||||
.updateTime(new Date())
|
||||
.updateBy(SecurityUtils.getUsername())
|
||||
.build();
|
||||
this.updateById(ruleInfo);
|
||||
|
||||
// 2. 删除原有的规格属性
|
||||
LambdaQueryWrapper<RuleAttrInfo> deleteWrapper = new LambdaQueryWrapper<>();
|
||||
deleteWrapper.eq(RuleAttrInfo::getRuleId, id);
|
||||
ruleAttrInfoService.remove(deleteWrapper);
|
||||
|
||||
// 3. 批量新增规格属性
|
||||
if (ObjUtils.notNull(req.getRuleAttrList())) {
|
||||
List<RuleAttrInfo> attrInfoList = req.getRuleAttrList().stream()
|
||||
.map(attr -> {
|
||||
// 处理属性值列表转换为逗号分隔的字符串
|
||||
String attrValue = attr.getValueList().stream()
|
||||
.filter(StringUtils::isNotEmpty)
|
||||
.map(String::trim)
|
||||
.collect(Collectors.joining(","));
|
||||
|
||||
return RuleAttrInfo.builder()
|
||||
.ruleId(id)
|
||||
.name(attr.getName())
|
||||
.attrValue(attrValue)
|
||||
.createTime(new Date())
|
||||
.updateTime(new Date())
|
||||
.createBy(SecurityUtils.getUsername())
|
||||
.updateBy(SecurityUtils.getUsername())
|
||||
.build();
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
ruleAttrInfoService.saveBatch(attrInfoList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit3(Long id, RuleAttrInfoReq req) {
|
||||
// 更新规格基本信息
|
||||
updateById(RuleInfo.builder()
|
||||
.id(id)
|
||||
.name(req.getName())
|
||||
.remark(req.getRemark())
|
||||
.status(req.getStatus())
|
||||
.updateTime(new Date())
|
||||
.build());
|
||||
|
||||
// 删除并新增规格属性
|
||||
ruleAttrInfoService.remove(new LambdaQueryWrapper<RuleAttrInfo>()
|
||||
.eq(RuleAttrInfo::getRuleId, id));
|
||||
|
||||
if (ObjUtils.notNull(req.getRuleAttrList())) {
|
||||
ruleAttrInfoService.saveBatch(req.getRuleAttrList().stream()
|
||||
.map(attr -> RuleAttrInfo.builder()
|
||||
.ruleId(id)
|
||||
.name(attr.getName())
|
||||
.attrValue(String.join(",", attr.getValueList()))
|
||||
.createTime(new Date())
|
||||
.updateTime(new Date())
|
||||
.createBy(SecurityUtils.getUsername())
|
||||
.build())
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,14 @@ server:
|
|||
|
||||
# Spring
|
||||
spring:
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
swagger:
|
||||
enable: true
|
||||
application-name: ${spring.application.name}
|
||||
application-version: 1.0
|
||||
application-description: 商品服务接口文档
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-product
|
||||
|
@ -26,3 +34,9 @@ spring:
|
|||
logging:
|
||||
level:
|
||||
com.muyu.product.mapper: DEBUG
|
||||
springdoc:
|
||||
api-docs:
|
||||
enabled: true
|
||||
swagger-ui:
|
||||
path: /swagger-ui.html
|
||||
disable-swagger-default-url: true
|
||||
|
|
|
@ -18,4 +18,14 @@
|
|||
<sql id="selectAsAttributeGroupVo">
|
||||
select id, group_id, attribute_id, remark, create_by, create_time, update_by, update_time from as_attribute_group
|
||||
</sql>
|
||||
|
||||
<sql id="selectAttributeGroupVo">
|
||||
select id, name, states, create_by, create_time, updata_by, updata_time, remark from attribute_group
|
||||
</sql>
|
||||
<insert id="insertBatch">
|
||||
insert into as_attribute_group(group_id,attribute_id) values (#{id1},#{id})
|
||||
</insert>
|
||||
<delete id="shanchu">
|
||||
delete from as_attribute_group where group_id=#{id}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
|
|
@ -15,7 +15,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAttributeGroupVo">
|
||||
select id, name, states, create_by, create_time, updata_by, updata_time, remark from attribute_group
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -19,4 +19,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<sql id="selectRuleAttrInfoVo">
|
||||
select id, rule_id, name, attr_value, remark, create_by, create_time, update_by, update_time from rule_attr_info
|
||||
</sql>
|
||||
<insert id="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">
|
||||
delete from rule_attr_info where rule_id=#{id}
|
||||
|
||||
|
||||
|
||||
</delete>
|
||||
<select id="getRuleAttrInfo" resultType="com.muyu.product.domain.model.RuleAttrAddModel">
|
||||
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>
|
||||
<select id="getRuleAttrInfo2" resultType="com.muyu.product.domain.resp.RuleInfoResp">
|
||||
SELECT
|
||||
rule_info.`id` AS rid,
|
||||
rule_info.`name`,
|
||||
rule_attr_info.`name` AS rname,
|
||||
attr_value
|
||||
FROM
|
||||
rule_info
|
||||
INNER JOIN rule_attr_info ON rule_info.id = rule_attr_info.rule_id
|
||||
WHERE rule_info.`id`=#{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue