Compare commits
3 Commits
9fec99677e
...
85cca29ca5
Author | SHA1 | Date |
---|---|---|
|
85cca29ca5 | |
|
b063dfca72 | |
|
8733328cb1 |
|
@ -23,9 +23,5 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-security</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -37,7 +37,6 @@ public class AttributeGroup extends BaseEntity
|
|||
@Excel(name = "组名")
|
||||
private String name;
|
||||
|
||||
private List<Attribute> attributeList;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态")
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
|||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.product.domain.model.AttrValueModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -11,6 +12,8 @@ import lombok.experimental.SuperBuilder;
|
|||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 商品属性中间表对象 attribute_product
|
||||
*
|
||||
|
@ -41,55 +44,12 @@ public class AttributeProduct extends BaseEntity
|
|||
@Excel(name = "属性值")
|
||||
private String value;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
public static AttributeProduct attrValueModelBuild(AttrValueModel attrValueModel, Supplier<Long> productId) {
|
||||
return AttributeProduct.builder()
|
||||
.attributeId(attrValueModel.getId())
|
||||
.productId(productId.get())
|
||||
.value(attrValueModel.getValue())
|
||||
.build();
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setProductId(Long productId)
|
||||
{
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public Long getProductId()
|
||||
{
|
||||
return productId;
|
||||
}
|
||||
public void setAttributeId(Long attributeId)
|
||||
{
|
||||
this.attributeId = attributeId;
|
||||
}
|
||||
|
||||
public Long getAttributeId()
|
||||
{
|
||||
return attributeId;
|
||||
}
|
||||
public void setValue(String value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("productId", getProductId())
|
||||
.append("attributeId", getAttributeId())
|
||||
.append("value", getValue())
|
||||
.append("remark", getRemark())
|
||||
.append("createBy", SecurityUtils.getUsername())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", SecurityUtils.getUsername())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.muyu.product.domain;
|
|||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||
import com.muyu.product.domain.req.CategoryReq;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -40,13 +40,13 @@ public class BrandCategory extends BaseEntity
|
|||
private Long brandId;
|
||||
|
||||
|
||||
public static List<BrandCategory> saveBuilderList(CategoryInfoSaveModel categoryReq, Supplier<String> getUsername) {
|
||||
public static List<BrandCategory> saveBuilderList(CategoryReq categoryReq, Supplier<String> getUsername) {
|
||||
return categoryReq.getCheckedBrandIds().stream().map(
|
||||
brandId -> BrandCategory.saveBuilder(categoryReq.getId(),brandId,getUsername)
|
||||
).toList();
|
||||
}
|
||||
|
||||
private static BrandCategory saveBuilder(Long categoryId, Long brandId, Supplier<String> getUsername) {
|
||||
public static BrandCategory saveBuilder(Long categoryId, Long brandId, Supplier<String> getUsername) {
|
||||
return BrandCategory.builder()
|
||||
.brandId(brandId)
|
||||
.categoryId(categoryId)
|
||||
|
@ -54,4 +54,13 @@ public class BrandCategory extends BaseEntity
|
|||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static BrandCategory saveBrandBuilder(Long id, Long brandId, Supplier<String> username) {
|
||||
return BrandCategory.builder()
|
||||
.categoryId(id)
|
||||
.brandId(brandId)
|
||||
.createBy(username.get())
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.muyu.product.domain;
|
|||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||
import com.muyu.product.domain.req.CategoryReq;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -48,7 +48,7 @@ public class CategoryAttribute extends BaseEntity
|
|||
.build();
|
||||
}
|
||||
|
||||
public static List<CategoryAttribute> saveBuilder(CategoryInfoSaveModel categoryReq, Supplier<String> username) {
|
||||
public static List<CategoryAttribute> saveBuilder(CategoryReq categoryReq, Supplier<String> username) {
|
||||
return categoryReq.getCheckedAttributeIds().stream().map(
|
||||
attributeId -> categoryBuilder(categoryReq.getId(),attributeId,username)
|
||||
).toList();
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.muyu.product.domain;
|
|||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||
import com.muyu.product.domain.req.CategoryReq;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -61,7 +61,7 @@ public class CategoryAttributeGroup extends BaseEntity {
|
|||
.build();
|
||||
}
|
||||
|
||||
public static List<CategoryAttributeGroup> saveBuilderList(CategoryInfoSaveModel categoryReq, Supplier<String> username) {
|
||||
public static List<CategoryAttributeGroup> saveBuilderList(CategoryReq categoryReq, Supplier<String> username) {
|
||||
return categoryReq.getCheckedAttributeGroupIds().stream().map(
|
||||
groupId -> saveBuilder(categoryReq.getId(), groupId, username)
|
||||
).toList();
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.muyu.product.domain;
|
|||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.TreeEntity;
|
||||
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||
import com.muyu.product.domain.req.CategoryReq;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
@ -57,7 +56,7 @@ public class CategoryInfo extends TreeEntity
|
|||
|
||||
|
||||
/** 响应值对象 */
|
||||
public static CategoryInfo saveCategoryBuilder(CategoryInfoSaveModel req){
|
||||
public static CategoryInfo saveCategoryBuilder(CategoryReq req){
|
||||
return CategoryInfo.builder()
|
||||
.name(req.getName())
|
||||
.status(req.getStatus())
|
||||
|
@ -69,7 +68,7 @@ public class CategoryInfo extends TreeEntity
|
|||
.build();
|
||||
}
|
||||
|
||||
public static CategoryInfo saveBuilder(CategoryInfoSaveModel categoryReq) {
|
||||
public static CategoryInfo saveBuilder(CategoryReq categoryReq) {
|
||||
return CategoryInfo.builder()
|
||||
.id(categoryReq.getId())
|
||||
.name(categoryReq.getName())
|
||||
|
|
|
@ -2,16 +2,15 @@ package com.muyu.product.domain;
|
|||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.product.domain.model.ProductAddModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 商品;对象 product_info
|
||||
|
@ -24,152 +23,89 @@ import java.util.Date;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ProductInfo extends BaseEntity
|
||||
{
|
||||
public class ProductInfo extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/** 商品名 */
|
||||
/**
|
||||
* 商品名
|
||||
*/
|
||||
@Excel(name = "商品名")
|
||||
private String name;
|
||||
|
||||
/** 商品信息 */
|
||||
/**
|
||||
* 商品信息
|
||||
*/
|
||||
@Excel(name = "商品信息")
|
||||
private String introduction;
|
||||
|
||||
/** 品牌编号 */
|
||||
/**
|
||||
* 品牌编号
|
||||
*/
|
||||
@Excel(name = "品牌编号")
|
||||
private Long brandId;
|
||||
|
||||
/** 图片 */
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
@Excel(name = "图片")
|
||||
private String images;
|
||||
|
||||
/** 发货地 */
|
||||
@Excel(name = "发货地")
|
||||
private String addressSend;
|
||||
/**
|
||||
* 发货地
|
||||
*/
|
||||
@Excel(name = "轮播图")
|
||||
private String slideshow;
|
||||
|
||||
/** 商品状态 */
|
||||
@Excel(name = "商品状态")
|
||||
private String status;
|
||||
|
||||
/** 创建人 */
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/** 创建时间 */
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
private Date updatedTime;
|
||||
|
||||
/** 更新人 */
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updatedBy;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
|
||||
public static ProductInfo saveModelBuild(ProductAddModel productAddModel, Supplier<String> createBy) {
|
||||
return ProductInfo.builder()
|
||||
.id(productAddModel.getId())
|
||||
.name(productAddModel.getName())
|
||||
.status(productAddModel.getStatus())
|
||||
.images(productAddModel.getImages())
|
||||
.brandId(productAddModel.getBrandId())
|
||||
.slideshow(productAddModel.getSlideshow())
|
||||
.introduction(productAddModel.getIntroduction())
|
||||
.createdBy(createBy.get())
|
||||
.createdTime(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
public static ProductInfo updateBuilder(ProductAddModel model, Supplier<String> username) {
|
||||
return ProductInfo.builder()
|
||||
.id(model.getId())
|
||||
.name(model.getName())
|
||||
.status(model.getStatus())
|
||||
.images(model.getImages())
|
||||
.brandId(model.getBrandId())
|
||||
.slideshow(model.getSlideshow())
|
||||
.introduction(model.getIntroduction())
|
||||
.updatedBy(username.get())
|
||||
.updatedTime(new Date())
|
||||
.build();
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
public void setIntroduction(String introduction)
|
||||
{
|
||||
this.introduction = introduction;
|
||||
}
|
||||
|
||||
public String getIntroduction()
|
||||
{
|
||||
return introduction;
|
||||
}
|
||||
public void setBrandId(Long brandId)
|
||||
{
|
||||
this.brandId = brandId;
|
||||
}
|
||||
|
||||
public Long getBrandId()
|
||||
{
|
||||
return brandId;
|
||||
}
|
||||
public void setImages(String images)
|
||||
{
|
||||
this.images = images;
|
||||
}
|
||||
|
||||
public String getImages()
|
||||
{
|
||||
return images;
|
||||
}
|
||||
public void setAddressSend(String addressSend)
|
||||
{
|
||||
this.addressSend = addressSend;
|
||||
}
|
||||
|
||||
public String getAddressSend()
|
||||
{
|
||||
return addressSend;
|
||||
}
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
public void setCreatedBy(String createdBy)
|
||||
{
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
public String getCreatedBy()
|
||||
{
|
||||
return createdBy;
|
||||
}
|
||||
public void setCreatedTime(Date createdTime)
|
||||
{
|
||||
this.createdTime = createdTime;
|
||||
}
|
||||
|
||||
public Date getCreatedTime()
|
||||
{
|
||||
return createdTime;
|
||||
}
|
||||
public void setUpdatedBy(String updatedBy)
|
||||
{
|
||||
this.updatedBy = updatedBy;
|
||||
}
|
||||
|
||||
public String getUpdatedBy()
|
||||
{
|
||||
return updatedBy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("name", getName())
|
||||
.append("introduction", getIntroduction())
|
||||
.append("brandId", getBrandId())
|
||||
.append("images", getImages())
|
||||
.append("addressSend", getAddressSend())
|
||||
.append("status", getStatus())
|
||||
.append("remark", getRemark())
|
||||
.append("createdBy", getCreatedBy())
|
||||
.append("createdTime", getCreatedTime())
|
||||
.append("updatedBy", getUpdatedBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
|||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.product.domain.model.ProductSkuModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -11,6 +12,9 @@ import lombok.experimental.SuperBuilder;
|
|||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 规格商品中间对象 rule_product
|
||||
*
|
||||
|
@ -35,11 +39,17 @@ public class RuleProduct extends BaseEntity
|
|||
|
||||
/** 规格编号 */
|
||||
@Excel(name = "规格编号")
|
||||
private Long ruleId;
|
||||
|
||||
/** 规格值 */
|
||||
@Excel(name = "规格值")
|
||||
private String ruleValue;
|
||||
private String sku;
|
||||
|
||||
private Long stock;
|
||||
private BigDecimal price;
|
||||
|
||||
public static RuleProduct productSkuModelBuild(ProductSkuModel productSkuModel, Supplier<Long> productId) {
|
||||
return RuleProduct.builder()
|
||||
.productId(productId.get())
|
||||
.sku(productSkuModel.getSku())
|
||||
.stock(productSkuModel.getStock())
|
||||
.price(productSkuModel.getPrice())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @ClassName AttrValueModel
|
||||
* @Description 描述
|
||||
* @Author SaiSai.Liu
|
||||
* @Date 2024/3/22/0022 20:11
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AttrValueModel {
|
||||
private Long id;
|
||||
private String value;
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.muyu.product.domain.model;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName ProductAddModel
|
||||
* @Description 描述
|
||||
* @Author SaiSai.Liu
|
||||
* @Date 2024/3/22/0022 20:22
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "ProjectInfoSaveReq", description = "商品信息")
|
||||
public class ProductAddModel extends BaseEntity {
|
||||
/** 主键 */
|
||||
private Long id;
|
||||
|
||||
/** 商品名 */
|
||||
@Excel(name = "商品名")
|
||||
private String name;
|
||||
|
||||
/** 商品信息 */
|
||||
@Excel(name = "商品信息")
|
||||
private String introduction;
|
||||
|
||||
/** 品牌编号 */
|
||||
@Excel(name = "品牌编号")
|
||||
private Long brandId;
|
||||
|
||||
/** 图片 */
|
||||
@Excel(name = "图片")
|
||||
private String images;
|
||||
|
||||
/** 发货地 */
|
||||
@Excel(name = "轮播图")
|
||||
private String slideshow;
|
||||
|
||||
/** 商品状态 */
|
||||
@Excel(name = "商品状态")
|
||||
private String status;
|
||||
|
||||
/** 创建人 */
|
||||
private String createdBy;
|
||||
|
||||
/** 创建时间 */
|
||||
private Date createdTime;
|
||||
|
||||
/** 更新人 */
|
||||
private String updatedBy;
|
||||
|
||||
}
|
|
@ -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 ProductSkuModel
|
||||
* @Description 描述
|
||||
* @Author SaiSai.Liu
|
||||
* @Date 2024/3/22/0022 20:12
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ProductSkuModel {
|
||||
private String sku;
|
||||
private Long stock;
|
||||
private BigDecimal price;
|
||||
private String image;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.muyu.product.domain.req;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.product.domain.model.AttrValueModel;
|
||||
import com.muyu.product.domain.model.ProductAddModel;
|
||||
import com.muyu.product.domain.model.ProductSkuModel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName ProductInfoSaveReq
|
||||
* @Description 描述
|
||||
* @Author SaiSai.Liu
|
||||
* @Date 2024/3/22/0022 20:17
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "ProjectInfoSaveReq", description = "商品信息")
|
||||
public class ProductInfoSaveReq extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ProductAddModel productAddModel;
|
||||
|
||||
private List<AttrValueModel> attrValueList;
|
||||
|
||||
private List<ProductSkuModel> productSkuModelList;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.muyu.product.domain.req;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @ClassName ProductSkuInfoEditReq
|
||||
* @Description 描述
|
||||
* @Author SaiSai.Liu
|
||||
* @Date 2024/3/22/0022 19:52
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "ProjectSkuInfoEditReq", description = "商品SKU")
|
||||
public class ProductSkuInfoEditReq extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Long projectId;
|
||||
private String sku;
|
||||
private Long stock;
|
||||
private BigDecimal price;
|
||||
private String image;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.muyu.product.domain.resp;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName ProductInfoResp
|
||||
* @Description 描述
|
||||
* @Author SaiSai.Liu
|
||||
* @Date 2024/3/23/0023 9:47
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ProductInfoResp extends BaseEntity {
|
||||
private Long id;
|
||||
|
||||
}
|
|
@ -1,30 +1,19 @@
|
|||
package com.muyu.product.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||
import com.muyu.product.domain.req.CategoryReq;
|
||||
import com.muyu.product.domain.resp.CategoryResp;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.product.domain.CategoryInfo;
|
||||
import com.muyu.product.domain.req.CategoryReq;
|
||||
import com.muyu.product.domain.resp.CategoryResp;
|
||||
import com.muyu.product.service.ICategoryInfoService;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 品类信息Controller
|
||||
|
@ -34,8 +23,7 @@ import com.muyu.common.core.utils.poi.ExcelUtil;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/category_info")
|
||||
public class CategoryInfoController extends BaseController
|
||||
{
|
||||
public class CategoryInfoController extends BaseController {
|
||||
@Autowired
|
||||
private ICategoryInfoService categoryInfoService;
|
||||
|
||||
|
@ -44,9 +32,8 @@ public class CategoryInfoController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("product:category_info:list")
|
||||
@GetMapping("/list")
|
||||
public Result list(CategoryInfoSaveModel categoryInfoSaveModel)
|
||||
{
|
||||
List<CategoryResp> list = categoryInfoService.selectCategoryInfoList(categoryInfoSaveModel);
|
||||
public Result list(CategoryReq categoryReq) {
|
||||
List<CategoryResp> list = categoryInfoService.selectCategoryInfoList(categoryReq);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
|
@ -56,9 +43,8 @@ public class CategoryInfoController extends BaseController
|
|||
@RequiresPermissions("product:category_info:export")
|
||||
@Log(title = "品类信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CategoryInfoSaveModel categoryInfoSaveModel)
|
||||
{
|
||||
List<CategoryResp> list = categoryInfoService.selectCategoryInfoList(categoryInfoSaveModel);
|
||||
public void export(HttpServletResponse response, CategoryReq categoryReq) {
|
||||
List<CategoryResp> list = categoryInfoService.selectCategoryInfoList(categoryReq);
|
||||
ExcelUtil<CategoryResp> util = new ExcelUtil<CategoryResp>(CategoryResp.class);
|
||||
util.exportExcel(response, list, "品类信息数据");
|
||||
}
|
||||
|
@ -68,8 +54,7 @@ public class CategoryInfoController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("product:category_info:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
public Result getInfo(@PathVariable("id") Long id) {
|
||||
return success(categoryInfoService.selectCategoryInfoById(id));
|
||||
}
|
||||
|
||||
|
@ -79,9 +64,8 @@ public class CategoryInfoController extends BaseController
|
|||
@RequiresPermissions("product:category_info:add")
|
||||
@Log(title = "品类信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result add(@RequestBody CategoryReq categoryReq)
|
||||
{
|
||||
return toAjax(categoryInfoService.save(CategoryInfoSaveModel.saveBuilder(categoryReq, SecurityUtils::getUsername )));
|
||||
public Result add(@RequestBody CategoryReq categoryReq) {
|
||||
return toAjax(categoryInfoService.save(categoryReq));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,9 +74,8 @@ public class CategoryInfoController extends BaseController
|
|||
@RequiresPermissions("product:category_info:edit")
|
||||
@Log(title = "品类信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result edit(@RequestBody CategoryInfoSaveModel categoryInfoSaveModel)
|
||||
{
|
||||
return toAjax(categoryInfoService.updateCategoryInfo(categoryInfoSaveModel));
|
||||
public Result edit(@RequestBody CategoryReq categoryReq) {
|
||||
return toAjax(categoryInfoService.updateCategoryInfo(categoryReq));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,9 +83,8 @@ public class CategoryInfoController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("product:category_info:remove")
|
||||
@Log(title = "品类信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result remove(@PathVariable Long[] ids)
|
||||
{
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result remove(@PathVariable Long[] ids) {
|
||||
return toAjax(categoryInfoService.deleteCategoryInfoByIds(ids));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.muyu.product.controller;
|
|||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.product.domain.req.ProductInfoSaveReq;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
@ -76,9 +78,9 @@ public class ProductInfoController extends BaseController
|
|||
@RequiresPermissions("product:product_info:add")
|
||||
@Log(title = "商品;", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result add(@RequestBody ProductInfo productInfo)
|
||||
public Result add(@RequestBody ProductInfoSaveReq productInfoSaveReq)
|
||||
{
|
||||
return toAjax(productInfoService.insertProductInfo(productInfo));
|
||||
return toAjax(productInfoService.save(productInfoSaveReq));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,9 +89,9 @@ public class ProductInfoController extends BaseController
|
|||
@RequiresPermissions("product:product_info:edit")
|
||||
@Log(title = "商品;", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result edit(@RequestBody ProductInfo productInfo)
|
||||
public Result edit(@RequestBody ProductInfoSaveReq productInfoSaveReq)
|
||||
{
|
||||
return toAjax(productInfoService.updateProductInfo(productInfo));
|
||||
return toAjax(productInfoService.updateProductInfo(productInfoSaveReq));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
package com.muyu.product.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.product.domain.Address;
|
||||
import com.muyu.product.domain.CategoryInfo;
|
||||
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||
import com.muyu.product.domain.req.CategoryReq;
|
||||
import com.muyu.product.domain.resp.CategoryResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 品类信息Service接口
|
||||
*
|
||||
* @author Saisai
|
||||
* @date 2024-02-29
|
||||
*/
|
||||
public interface ICategoryInfoService extends IService<CategoryInfo>
|
||||
{
|
||||
public interface ICategoryInfoService extends IService<CategoryInfo> {
|
||||
/**
|
||||
* 查询品类信息
|
||||
*
|
||||
|
@ -28,26 +25,19 @@ public interface ICategoryInfoService extends IService<CategoryInfo>
|
|||
/**
|
||||
* 查询品类信息列表
|
||||
*
|
||||
* @param categoryInfoSaveModel 品类信息
|
||||
* @param categoryReq 品类信息
|
||||
* @return 品类信息集合
|
||||
*/
|
||||
List<CategoryResp> selectCategoryInfoList(CategoryInfoSaveModel categoryInfoSaveModel);
|
||||
List<CategoryResp> selectCategoryInfoList(CategoryReq categoryReq);
|
||||
|
||||
/**
|
||||
* 新增品类信息
|
||||
*
|
||||
* @param categoryInfoSaveModel 品类信息
|
||||
* @return 结果
|
||||
*/
|
||||
int insertCategoryInfo(CategoryInfoSaveModel categoryInfoSaveModel);
|
||||
|
||||
/**
|
||||
* 修改品类信息
|
||||
*
|
||||
* @param categoryInfoSaveModel 品类信息
|
||||
* @param categoryReq 品类信息
|
||||
* @return 结果
|
||||
*/
|
||||
boolean updateCategoryInfo(CategoryInfoSaveModel categoryInfoSaveModel);
|
||||
boolean updateCategoryInfo(CategoryReq categoryReq);
|
||||
|
||||
/**
|
||||
* 批量删除品类信息
|
||||
|
@ -65,5 +55,5 @@ public interface ICategoryInfoService extends IService<CategoryInfo>
|
|||
*/
|
||||
int deleteCategoryInfoById(Long id);
|
||||
|
||||
boolean save(CategoryInfoSaveModel categoryInfoSaveModel);
|
||||
boolean save(CategoryReq categoryReq);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.product.domain.Address;
|
||||
import com.muyu.product.domain.ProductInfo;
|
||||
import com.muyu.product.domain.req.ProductInfoSaveReq;
|
||||
|
||||
/**
|
||||
* 商品;Service接口
|
||||
|
@ -41,10 +42,10 @@ public interface IProductInfoService extends IService<ProductInfo>
|
|||
/**
|
||||
* 修改商品;
|
||||
*
|
||||
* @param productInfo 商品;
|
||||
* @param productInfoSaveReq 商品;
|
||||
* @return 结果
|
||||
*/
|
||||
int updateProductInfo(ProductInfo productInfo);
|
||||
int updateProductInfo(ProductInfoSaveReq productInfoSaveReq);
|
||||
|
||||
/**
|
||||
* 批量删除商品;
|
||||
|
@ -61,4 +62,6 @@ public interface IProductInfoService extends IService<ProductInfo>
|
|||
* @return 结果
|
||||
*/
|
||||
int deleteProductInfoById(Long id);
|
||||
|
||||
boolean save(ProductInfoSaveReq productInfoSaveReq);
|
||||
}
|
||||
|
|
|
@ -3,8 +3,12 @@ package com.muyu.product.service.impl;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.product.domain.*;
|
||||
import com.muyu.product.domain.BrandCategory;
|
||||
import com.muyu.product.domain.CategoryAttribute;
|
||||
import com.muyu.product.domain.CategoryAttributeGroup;
|
||||
import com.muyu.product.domain.CategoryInfo;
|
||||
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||
import com.muyu.product.domain.req.CategoryReq;
|
||||
import com.muyu.product.domain.resp.CategoryResp;
|
||||
import com.muyu.product.mapper.CategoryInfoMapper;
|
||||
import com.muyu.product.service.*;
|
||||
|
@ -53,19 +57,19 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
/**
|
||||
* 查询品类信息列表
|
||||
*
|
||||
* @param categoryInfoSaveModel 品类信息
|
||||
* @param categoryReq 品类信息
|
||||
* @return 品类信息
|
||||
*/
|
||||
@Override
|
||||
public List<CategoryResp> selectCategoryInfoList(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||
public List<CategoryResp> selectCategoryInfoList(CategoryReq categoryReq) {
|
||||
//三大响应结果集
|
||||
// List<CategoryAttribute> categoryAttributes = CategoryAttribute.saveBuilder(categoryInfoSaveModel, SecurityUtils::getUsername);
|
||||
// List<CategoryAttributeGroup> categoryAttributeGroups = CategoryAttributeGroup.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername);
|
||||
// List<BrandCategory> brandCategories = BrandCategory.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername);
|
||||
// List<CategoryAttribute> categoryAttributes = CategoryAttribute.saveBuilder(categoryReq, SecurityUtils::getUsername);
|
||||
// List<CategoryAttributeGroup> categoryAttributeGroups = CategoryAttributeGroup.saveBuilderList(categoryReq, SecurityUtils::getUsername);
|
||||
// List<BrandCategory> brandCategories = BrandCategory.saveBuilderList(categoryReq, SecurityUtils::getUsername);
|
||||
// List<CategoryInfo> categoryInfos = null;
|
||||
|
||||
|
||||
List<CategoryResp> list = categoryInfoMapper.selectCategoryInfoList(CategoryInfo.saveBuilder(categoryInfoSaveModel)).stream().map(categoryInfo -> {
|
||||
List<CategoryResp> list = categoryInfoMapper.selectCategoryInfoList(CategoryInfo.saveBuilder(categoryReq)).stream().map(categoryInfo -> {
|
||||
CategoryInfoSaveModel infoSaveModel = new CategoryInfoSaveModel();
|
||||
infoSaveModel.setId(categoryInfo.getId());
|
||||
List<Long> attrIds = categoryAttributeService.list(new LambdaQueryWrapper<CategoryAttribute>().eq(CategoryAttribute::getCategoryId, categoryInfo.getId())).stream().map(CategoryAttribute::getAttributeId).toList();
|
||||
|
@ -87,59 +91,43 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增品类信息
|
||||
*
|
||||
* @param categoryInfoSaveModel 品类信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertCategoryInfo(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||
CategoryInfo categoryInfo = CategoryInfo.saveBuilder(categoryInfoSaveModel);
|
||||
int i = categoryInfoMapper.insertCategoryInfo(categoryInfo);
|
||||
categoryInfoSaveModel.setId(categoryInfo.getId());
|
||||
categoryAttributeService.saveBatch(CategoryAttribute.saveBuilder(categoryInfoSaveModel, SecurityUtils::getUsername));
|
||||
categoryAttributeGroupService.saveBatch(CategoryAttributeGroup.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername));
|
||||
brandCategoryService.saveBatch(BrandCategory.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername));
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改品类信息
|
||||
*
|
||||
* @param categoryInfoSaveModel 品类信息
|
||||
* @param categoryReq 品类信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean updateCategoryInfo(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||
CategoryInfo categoryInfo = CategoryInfo.saveBuilder(categoryInfoSaveModel);
|
||||
|
||||
boolean updated = this.update(new LambdaQueryWrapper<CategoryInfo>().eq(CategoryInfo::getId, categoryInfo.getId()));
|
||||
// LambdaQueryWrapper<CategoryAttribute> attributeWrapper = new LambdaQueryWrapper<CategoryAttribute>().eq(CategoryAttribute::getCategoryId,categoryInfoSaveModel.getId());
|
||||
public boolean updateCategoryInfo(CategoryReq categoryReq) {
|
||||
CategoryInfo categoryInfo = CategoryInfo.saveBuilder(categoryReq);
|
||||
// boolean updated = this.update(new LambdaQueryWrapper<CategoryInfo>().eq(CategoryInfo::getId, categoryInfo.getId()));
|
||||
boolean b = this.updateById(categoryInfo);
|
||||
// LambdaQueryWrapper<CategoryAttribute> attributeWrapper = new LambdaQueryWrapper<CategoryAttribute>().eq(CategoryAttribute::getCategoryId,categoryReq.getId());
|
||||
//删除中间表数据
|
||||
categoryAttributeService.remove(new LambdaQueryWrapper<CategoryAttribute>()
|
||||
.eq(CategoryAttribute::getCategoryId, categoryInfoSaveModel.getId())
|
||||
.eq(CategoryAttribute::getCategoryId, categoryReq.getId())
|
||||
);
|
||||
//添加新数据
|
||||
categoryAttributeService.saveBatch(CategoryAttribute.saveBuilder(categoryInfoSaveModel, SecurityUtils::getUsername));
|
||||
categoryAttributeService.saveBatch(CategoryAttribute.saveBuilder(categoryReq, SecurityUtils::getUsername));
|
||||
//修改属性组中间表
|
||||
// LambdaQueryWrapper<CategoryAttributeGroup> groupWrapper = new LambdaQueryWrapper<CategoryAttributeGroup>();
|
||||
categoryAttributeGroupService.remove(new LambdaQueryWrapper<CategoryAttributeGroup>()
|
||||
.eq(CategoryAttributeGroup::getCategoryId, categoryInfoSaveModel.getId())
|
||||
.eq(CategoryAttributeGroup::getCategoryId, categoryReq.getId())
|
||||
);
|
||||
categoryAttributeGroupService.saveBatch(
|
||||
CategoryAttributeGroup.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername)
|
||||
CategoryAttributeGroup.saveBuilderList(categoryReq, SecurityUtils::getUsername)
|
||||
);
|
||||
// LambdaQueryWrapper<BrandCategory> brandWrapper = new LambdaQueryWrapper<BrandCategory>();
|
||||
brandCategoryService.remove(
|
||||
new LambdaQueryWrapper<BrandCategory>()
|
||||
.eq(BrandCategory::getCategoryId, categoryInfoSaveModel.getId())
|
||||
.eq(BrandCategory::getCategoryId, categoryReq.getId())
|
||||
);
|
||||
brandCategoryService.saveBatch(
|
||||
BrandCategory.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername)
|
||||
BrandCategory.saveBuilderList(categoryReq, SecurityUtils::getUsername)
|
||||
);
|
||||
|
||||
return updated;
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,19 +158,19 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
/**
|
||||
* 品类数据添加
|
||||
*
|
||||
* @param categoryInfoSaveModel
|
||||
* @param categoryReq
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean save(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||
public boolean save(CategoryReq categoryReq) {
|
||||
//通过品类信息构建体构建品类对象
|
||||
CategoryInfo categoryInfo = CategoryInfo.saveCategoryBuilder(categoryInfoSaveModel);
|
||||
CategoryInfo categoryInfo = CategoryInfo.saveCategoryBuilder(categoryReq);
|
||||
//调用重载方法
|
||||
boolean save = this.save(categoryInfo);
|
||||
//获取当前品类主键
|
||||
Long id = categoryInfo.getId();
|
||||
//获取已选属性主键集
|
||||
List<Long> checkedAttributeIds = categoryInfoSaveModel.getCheckedAttributeIds();
|
||||
List<Long> checkedAttributeIds = categoryReq.getCheckedAttributeIds();
|
||||
//判断已选属性集是否为空
|
||||
if (checkedAttributeIds != null && !checkedAttributeIds.isEmpty()) {
|
||||
categoryAttributeService.saveBatch(
|
||||
|
@ -190,13 +178,20 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
.map(attributeId -> CategoryAttribute.categoryBuilder(id, attributeId, SecurityUtils::getUsername)).toList()
|
||||
);
|
||||
}
|
||||
List<Long> attributeGroupIds = categoryInfoSaveModel.getCheckedAttributeGroupIds();
|
||||
List<Long> attributeGroupIds = categoryReq.getCheckedAttributeGroupIds();
|
||||
if (attributeGroupIds != null && !attributeGroupIds.isEmpty()) {
|
||||
categoryAttributeGroupService.saveBatch(
|
||||
attributeGroupIds.stream().
|
||||
map(groupId -> CategoryAttributeGroup.saveBuilder(id, groupId, SecurityUtils::getUsername)).toList()
|
||||
);
|
||||
}
|
||||
List<Long> brandIds = categoryReq.getCheckedBrandIds();
|
||||
if (brandIds != null && !brandIds.isEmpty()) {
|
||||
brandCategoryService.saveBatch(
|
||||
brandIds.stream().
|
||||
map(brandId -> BrandCategory.saveBrandBuilder(id, brandId, SecurityUtils::getUsername)).toList()
|
||||
);
|
||||
}
|
||||
return save;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,24 @@
|
|||
package com.muyu.product.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.product.domain.AttributeProduct;
|
||||
import com.muyu.product.domain.ProductInfo;
|
||||
import com.muyu.product.domain.RuleProduct;
|
||||
import com.muyu.product.domain.model.AttrValueModel;
|
||||
import com.muyu.product.domain.model.ProductAddModel;
|
||||
import com.muyu.product.domain.model.ProductSkuModel;
|
||||
import com.muyu.product.domain.req.ProductInfoSaveReq;
|
||||
import com.muyu.product.mapper.ProductInfoMapper;
|
||||
import com.muyu.product.service.IAttributeProductService;
|
||||
import com.muyu.product.service.IProductInfoService;
|
||||
import com.muyu.product.service.IRuleProductService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.product.mapper.ProductInfoMapper;
|
||||
import com.muyu.product.domain.ProductInfo;
|
||||
import com.muyu.product.service.IProductInfoService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品;Service业务层处理
|
||||
|
@ -17,11 +27,16 @@ import com.muyu.product.service.IProductInfoService;
|
|||
* @date 2024-02-29
|
||||
*/
|
||||
@Service
|
||||
public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper,ProductInfo> implements IProductInfoService
|
||||
{
|
||||
public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, ProductInfo> implements IProductInfoService {
|
||||
@Autowired
|
||||
private ProductInfoMapper productInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private IAttributeProductService attributeProductService;
|
||||
@Autowired
|
||||
private IRuleProductService ruleProductService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询商品;
|
||||
*
|
||||
|
@ -29,8 +44,8 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper,Produc
|
|||
* @return 商品;
|
||||
*/
|
||||
@Override
|
||||
public ProductInfo selectProductInfoById(Long id)
|
||||
{
|
||||
public ProductInfo selectProductInfoById(Long id) {
|
||||
|
||||
return productInfoMapper.selectProductInfoById(id);
|
||||
}
|
||||
|
||||
|
@ -41,8 +56,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper,Produc
|
|||
* @return 商品;
|
||||
*/
|
||||
@Override
|
||||
public List<ProductInfo> selectProductInfoList(ProductInfo productInfo)
|
||||
{
|
||||
public List<ProductInfo> selectProductInfoList(ProductInfo productInfo) {
|
||||
return productInfoMapper.selectProductInfoList(productInfo);
|
||||
}
|
||||
|
||||
|
@ -53,22 +67,55 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper,Produc
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertProductInfo(ProductInfo productInfo)
|
||||
{
|
||||
public int insertProductInfo(ProductInfo productInfo) {
|
||||
return productInfoMapper.insertProductInfo(productInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商品;
|
||||
*
|
||||
* @param productInfo 商品;
|
||||
* @param productInfoSaveReq 商品;
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateProductInfo(ProductInfo productInfo)
|
||||
{
|
||||
productInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
return productInfoMapper.updateProductInfo(productInfo);
|
||||
public int updateProductInfo(ProductInfoSaveReq productInfoSaveReq) {
|
||||
productInfoSaveReq.setUpdateTime(DateUtils.getNowDate());
|
||||
|
||||
ProductInfo productInfo = ProductInfo.updateBuilder(productInfoSaveReq.getProductAddModel(), SecurityUtils::getUsername);
|
||||
int i = productInfoMapper.updateProductInfo(productInfo);
|
||||
if (i > 0) {
|
||||
//删除原数据
|
||||
LambdaQueryWrapper<AttributeProduct> eq = new LambdaQueryWrapper<AttributeProduct>().eq(AttributeProduct::getProductId, productInfo.getId());
|
||||
attributeProductService.remove(eq);
|
||||
LambdaQueryWrapper<RuleProduct> ruleEq = new LambdaQueryWrapper<RuleProduct>().eq(RuleProduct::getProductId, productInfo.getId());
|
||||
ruleProductService.remove(ruleEq);
|
||||
//添加新数据
|
||||
this.add(productInfoSaveReq, productInfo);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装添加其他表数据方法
|
||||
* @param productInfoSaveReq
|
||||
* @param productInfo
|
||||
*/
|
||||
public void add(ProductInfoSaveReq productInfoSaveReq, ProductInfo productInfo) {
|
||||
List<AttrValueModel> attrValueList = productInfoSaveReq.getAttrValueList();
|
||||
List<AttributeProduct> attrProduct = attrValueList.stream()
|
||||
.map(attrValueModel -> AttributeProduct.attrValueModelBuild(attrValueModel, productInfo::getId))
|
||||
.toList();
|
||||
if (!attrProduct.isEmpty()) {
|
||||
attributeProductService.saveBatch(attrProduct);
|
||||
}
|
||||
// sku ProductSkuModel -》 ProductSkuInfo
|
||||
List<ProductSkuModel> productSkuModelList = productInfoSaveReq.getProductSkuModelList();
|
||||
List<RuleProduct> productSkuInfoList = productSkuModelList.stream().map(
|
||||
productSkuModel -> RuleProduct.productSkuModelBuild(productSkuModel, productInfo::getId)
|
||||
).toList();
|
||||
if (!productSkuInfoList.isEmpty()) {
|
||||
ruleProductService.saveBatch(productSkuInfoList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,8 +125,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper,Produc
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteProductInfoByIds(Long[] ids)
|
||||
{
|
||||
public int deleteProductInfoByIds(Long[] ids) {
|
||||
return productInfoMapper.deleteProductInfoByIds(ids);
|
||||
}
|
||||
|
||||
|
@ -90,8 +136,23 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper,Produc
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteProductInfoById(Long id)
|
||||
{
|
||||
public int deleteProductInfoById(Long id) {
|
||||
return productInfoMapper.deleteProductInfoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加新数据
|
||||
* @param productInfoSaveReq
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean save(ProductInfoSaveReq productInfoSaveReq) {
|
||||
ProductAddModel productAddModel = productInfoSaveReq.getProductAddModel();
|
||||
ProductInfo productInfo = ProductInfo.saveModelBuild(productAddModel, SecurityUtils::getUsername);
|
||||
boolean save = this.save(productInfo);
|
||||
if (save) {
|
||||
this.add(productInfoSaveReq, productInfo);
|
||||
}
|
||||
return save;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="introduction" column="introduction" />
|
||||
<result property="brandId" column="brand_id" />
|
||||
<result property="images" column="images" />
|
||||
<result property="addressSend" column="address_send" />
|
||||
<result property="slideshow" column="slideshow" />
|
||||
<result property="status" column="status" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createdBy" column="created_by" />
|
||||
|
@ -20,7 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</resultMap>
|
||||
|
||||
<sql id="selectProductInfoVo">
|
||||
select id, name, introduction, brand_id, images, address_send, status, remark, created_by, created_time, updated_by, update_time from product_info
|
||||
select id, name, introduction, brand_id, images, slideshow, status, remark, created_by, created_time, updated_by, update_time from product_info
|
||||
</sql>
|
||||
|
||||
<select id="selectProductInfoList" parameterType="com.muyu.product.domain.ProductInfo" resultMap="ProductInfoResult">
|
||||
|
@ -30,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="introduction != null and introduction != ''"> and introduction = #{introduction}</if>
|
||||
<if test="brandId != null "> and brand_id = #{brandId}</if>
|
||||
<if test="images != null and images != ''"> and images = #{images}</if>
|
||||
<if test="addressSend != null and addressSend != ''"> and address_send = #{addressSend}</if>
|
||||
<if test="slideshow != null and slideshow != ''"> and slideshow = #{slideshow}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="introduction != null and introduction != ''">introduction,</if>
|
||||
<if test="brandId != null">brand_id,</if>
|
||||
<if test="images != null">images,</if>
|
||||
<if test="addressSend != null">address_send,</if>
|
||||
<if test="slideshow != null">slideshow,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="createdBy != null">created_by,</if>
|
||||
|
@ -60,7 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="introduction != null and introduction != ''">#{introduction},</if>
|
||||
<if test="brandId != null">#{brandId},</if>
|
||||
<if test="images != null">#{images},</if>
|
||||
<if test="addressSend != null">#{addressSend},</if>
|
||||
<if test="slideshow != null">#{slideshow},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="createdBy != null">#{createdBy},</if>
|
||||
|
@ -77,7 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="introduction != null and introduction != ''">introduction = #{introduction},</if>
|
||||
<if test="brandId != null">brand_id = #{brandId},</if>
|
||||
<if test="images != null">images = #{images},</if>
|
||||
<if test="addressSend != null">address_send = #{addressSend},</if>
|
||||
<if test="slideshow != null">slideshow = #{slideshow},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="createdBy != null">created_by = #{createdBy},</if>
|
||||
|
|
10
pom.xml
10
pom.xml
|
@ -218,11 +218,11 @@
|
|||
<version>${muyu.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.alibaba.cloud</groupId>-->
|
||||
<!-- <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>-->
|
||||
<!-- <version>2021.1</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
|
Loading…
Reference in New Issue