商品模块添加修改
parent
b063dfca72
commit
85cca29ca5
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.product.domain.model.AttrValueModel;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
@ -11,6 +12,8 @@ import lombok.experimental.SuperBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品属性中间表对象 attribute_product
|
* 商品属性中间表对象 attribute_product
|
||||||
*
|
*
|
||||||
|
@ -41,55 +44,12 @@ public class AttributeProduct extends BaseEntity
|
||||||
@Excel(name = "属性值")
|
@Excel(name = "属性值")
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
public void setId(Long id)
|
public static AttributeProduct attrValueModelBuild(AttrValueModel attrValueModel, Supplier<Long> productId) {
|
||||||
{
|
return AttributeProduct.builder()
|
||||||
this.id = id;
|
.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,16 +2,15 @@ package com.muyu.product.domain;
|
||||||
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.product.domain.model.ProductAddModel;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.SuperBuilder;
|
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.Date;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品;对象 product_info
|
* 商品;对象 product_info
|
||||||
|
@ -24,45 +23,89 @@ import java.util.Date;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class ProductInfo extends BaseEntity
|
public class ProductInfo extends BaseEntity {
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 主键 */
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/** 商品名 */
|
/**
|
||||||
|
* 商品名
|
||||||
|
*/
|
||||||
@Excel(name = "商品名")
|
@Excel(name = "商品名")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/** 商品信息 */
|
/**
|
||||||
|
* 商品信息
|
||||||
|
*/
|
||||||
@Excel(name = "商品信息")
|
@Excel(name = "商品信息")
|
||||||
private String introduction;
|
private String introduction;
|
||||||
|
|
||||||
/** 品牌编号 */
|
/**
|
||||||
|
* 品牌编号
|
||||||
|
*/
|
||||||
@Excel(name = "品牌编号")
|
@Excel(name = "品牌编号")
|
||||||
private Long brandId;
|
private Long brandId;
|
||||||
|
|
||||||
/** 图片 */
|
/**
|
||||||
|
* 图片
|
||||||
|
*/
|
||||||
@Excel(name = "图片")
|
@Excel(name = "图片")
|
||||||
private String images;
|
private String images;
|
||||||
|
|
||||||
/** 发货地 */
|
/**
|
||||||
|
* 发货地
|
||||||
|
*/
|
||||||
@Excel(name = "轮播图")
|
@Excel(name = "轮播图")
|
||||||
private String slideshow;
|
private String slideshow;
|
||||||
|
|
||||||
/** 商品状态 */
|
|
||||||
@Excel(name = "商品状态")
|
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/** 创建人 */
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
private String createdBy;
|
private String createdBy;
|
||||||
|
|
||||||
/** 创建时间 */
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
private Date createdTime;
|
private Date createdTime;
|
||||||
|
private Date updatedTime;
|
||||||
|
|
||||||
/** 更新人 */
|
/**
|
||||||
|
* 更新人
|
||||||
|
*/
|
||||||
private String updatedBy;
|
private String updatedBy;
|
||||||
|
|
||||||
|
|
||||||
|
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 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();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.product.domain.model.ProductSkuModel;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
@ -12,6 +13,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规格商品中间对象 rule_product
|
* 规格商品中间对象 rule_product
|
||||||
|
@ -39,10 +41,15 @@ public class RuleProduct extends BaseEntity
|
||||||
@Excel(name = "规格编号")
|
@Excel(name = "规格编号")
|
||||||
private String sku;
|
private String sku;
|
||||||
|
|
||||||
/** 规格值 */
|
private Long stock;
|
||||||
@Excel(name = "规格值")
|
|
||||||
private String ruleValue;
|
|
||||||
private Integer stock;
|
|
||||||
private BigDecimal price;
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,5 +30,5 @@ public class ProductInfoSaveReq extends BaseEntity {
|
||||||
|
|
||||||
private List<AttrValueModel> attrValueList;
|
private List<AttrValueModel> attrValueList;
|
||||||
|
|
||||||
private List<ProductSkuModel> productList;
|
private List<ProductSkuModel> productSkuModelList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,8 @@ package com.muyu.product.controller;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.muyu.product.domain.req.ProductInfoSaveReq;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
@ -76,9 +78,9 @@ public class ProductInfoController extends BaseController
|
||||||
@RequiresPermissions("product:product_info:add")
|
@RequiresPermissions("product:product_info:add")
|
||||||
@Log(title = "商品;", businessType = BusinessType.INSERT)
|
@Log(title = "商品;", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@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")
|
@RequiresPermissions("product:product_info:edit")
|
||||||
@Log(title = "商品;", businessType = BusinessType.UPDATE)
|
@Log(title = "商品;", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public Result edit(@RequestBody ProductInfo productInfo)
|
public Result edit(@RequestBody ProductInfoSaveReq productInfoSaveReq)
|
||||||
{
|
{
|
||||||
return toAjax(productInfoService.updateProductInfo(productInfo));
|
return toAjax(productInfoService.updateProductInfo(productInfoSaveReq));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.product.domain.Address;
|
import com.muyu.product.domain.Address;
|
||||||
import com.muyu.product.domain.ProductInfo;
|
import com.muyu.product.domain.ProductInfo;
|
||||||
|
import com.muyu.product.domain.req.ProductInfoSaveReq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品;Service接口
|
* 商品;Service接口
|
||||||
|
@ -41,10 +42,10 @@ public interface IProductInfoService extends IService<ProductInfo>
|
||||||
/**
|
/**
|
||||||
* 修改商品;
|
* 修改商品;
|
||||||
*
|
*
|
||||||
* @param productInfo 商品;
|
* @param productInfoSaveReq 商品;
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int updateProductInfo(ProductInfo productInfo);
|
int updateProductInfo(ProductInfoSaveReq productInfoSaveReq);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除商品;
|
* 批量删除商品;
|
||||||
|
@ -61,4 +62,6 @@ public interface IProductInfoService extends IService<ProductInfo>
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int deleteProductInfoById(Long id);
|
int deleteProductInfoById(Long id);
|
||||||
|
|
||||||
|
boolean save(ProductInfoSaveReq productInfoSaveReq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,24 @@
|
||||||
package com.muyu.product.service.impl;
|
package com.muyu.product.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.common.core.utils.DateUtils;
|
import com.muyu.common.core.utils.DateUtils;
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.product.domain.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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.muyu.product.mapper.ProductInfoMapper;
|
|
||||||
import com.muyu.product.domain.ProductInfo;
|
import java.util.List;
|
||||||
import com.muyu.product.service.IProductInfoService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品;Service业务层处理
|
* 商品;Service业务层处理
|
||||||
|
@ -17,11 +27,16 @@ import com.muyu.product.service.IProductInfoService;
|
||||||
* @date 2024-02-29
|
* @date 2024-02-29
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper,ProductInfo> implements IProductInfoService
|
public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, ProductInfo> implements IProductInfoService {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProductInfoMapper productInfoMapper;
|
private ProductInfoMapper productInfoMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IAttributeProductService attributeProductService;
|
||||||
|
@Autowired
|
||||||
|
private IRuleProductService ruleProductService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询商品;
|
* 查询商品;
|
||||||
*
|
*
|
||||||
|
@ -29,8 +44,8 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper,Produc
|
||||||
* @return 商品;
|
* @return 商品;
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ProductInfo selectProductInfoById(Long id)
|
public ProductInfo selectProductInfoById(Long id) {
|
||||||
{
|
|
||||||
return productInfoMapper.selectProductInfoById(id);
|
return productInfoMapper.selectProductInfoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,8 +56,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper,Produc
|
||||||
* @return 商品;
|
* @return 商品;
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<ProductInfo> selectProductInfoList(ProductInfo productInfo)
|
public List<ProductInfo> selectProductInfoList(ProductInfo productInfo) {
|
||||||
{
|
|
||||||
return productInfoMapper.selectProductInfoList(productInfo);
|
return productInfoMapper.selectProductInfoList(productInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,22 +67,55 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper,Produc
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertProductInfo(ProductInfo productInfo)
|
public int insertProductInfo(ProductInfo productInfo) {
|
||||||
{
|
|
||||||
return productInfoMapper.insertProductInfo(productInfo);
|
return productInfoMapper.insertProductInfo(productInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改商品;
|
* 修改商品;
|
||||||
*
|
*
|
||||||
* @param productInfo 商品;
|
* @param productInfoSaveReq 商品;
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateProductInfo(ProductInfo productInfo)
|
public int updateProductInfo(ProductInfoSaveReq productInfoSaveReq) {
|
||||||
{
|
productInfoSaveReq.setUpdateTime(DateUtils.getNowDate());
|
||||||
productInfo.setUpdateTime(DateUtils.getNowDate());
|
|
||||||
return productInfoMapper.updateProductInfo(productInfo);
|
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 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteProductInfoByIds(Long[] ids)
|
public int deleteProductInfoByIds(Long[] ids) {
|
||||||
{
|
|
||||||
return productInfoMapper.deleteProductInfoByIds(ids);
|
return productInfoMapper.deleteProductInfoByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,8 +136,23 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper,Produc
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteProductInfoById(Long id)
|
public int deleteProductInfoById(Long id) {
|
||||||
{
|
|
||||||
return productInfoMapper.deleteProductInfoById(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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue