修改 system-service-app 导入的数据库脚本
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
package cn.iocoder.mall.product.biz.bo.product;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品 SKU BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductSkuBO implements Serializable {
|
||||
|
||||
/**
|
||||
* sku 编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 商品编号
|
||||
*/
|
||||
private Integer spuId;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 图片地址
|
||||
*/
|
||||
private String picURL;
|
||||
// /**
|
||||
// * 规格值数组
|
||||
// */
|
||||
// // TODO 芋艿,这个属性目前未进行设置
|
||||
// private List<ProductAttrAndValuePairBO> attrs;
|
||||
/**
|
||||
* 价格,单位:分
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 库存数量
|
||||
*/
|
||||
private Integer quantity;
|
||||
|
||||
}
|
||||
@@ -30,16 +30,8 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
|
||||
@Autowired
|
||||
private ProductSpuMapper productSpuMapper;
|
||||
@Autowired
|
||||
private ProductSkuMapper productSkuMapper;
|
||||
@Autowired
|
||||
private ProductCategoryMapper productCategoryMapper;
|
||||
@Autowired
|
||||
private ProductAttrService productAttrService;
|
||||
@Autowired
|
||||
private ProductCategoryService productCategoryService;
|
||||
|
||||
@Override
|
||||
public ProductSpuDetailBO getProductSpuDetail(Integer spuId) {
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package cn.iocoder.mall.product.api.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品 SKU BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductSkuBO implements Serializable {
|
||||
|
||||
/**
|
||||
* sku 编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 商品编号
|
||||
*/
|
||||
private Integer spuId;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 图片地址
|
||||
*/
|
||||
private String picURL;
|
||||
// /**
|
||||
// * 规格值数组
|
||||
// */
|
||||
// // TODO 芋艿,这个属性目前未进行设置
|
||||
// private List<ProductAttrAndValuePairBO> attrs;
|
||||
/**
|
||||
* 价格,单位:分
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 库存数量
|
||||
*/
|
||||
private Integer quantity;
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package cn.iocoder.mall.product.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* Product 规格添加 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductAttrAddDTO {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@NotEmpty(message = "规格名不能为空")
|
||||
private String name;
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package cn.iocoder.mall.product.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Product 规格修改 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductAttrUpdateDTO {
|
||||
|
||||
/**
|
||||
* 规格编号
|
||||
*/
|
||||
@NotNull(message = "规格编号不能为空")
|
||||
private Integer id;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@NotEmpty(message = "规格名不能为空")
|
||||
private String name;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package cn.iocoder.mall.product.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Product 规格值添加 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductAttrValueAddDTO {
|
||||
|
||||
/**
|
||||
* 规格编号
|
||||
*/
|
||||
@NotNull(message = "规格编号不能为空")
|
||||
private Integer attrId;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@NotEmpty(message = "规格值名不能为空")
|
||||
private String name;
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package cn.iocoder.mall.product.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Product 规格值修改 DTO
|
||||
*
|
||||
* 注意,不允许修改所属规格
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductAttrValueUpdateDTO {
|
||||
|
||||
/**
|
||||
* 规格值编号
|
||||
*/
|
||||
@NotNull(message = "规格编号不能为空")
|
||||
private Integer id;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@NotEmpty(message = "规格名不能为空")
|
||||
private String name;
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package cn.iocoder.mall.product.config;
|
||||
|
||||
import cn.iocoder.mall.product.message.MQStreamProducer;
|
||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@EnableBinding(MQStreamProducer.class)
|
||||
public class MQStreamConfiguration {
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package cn.iocoder.mall.product.message;
|
||||
|
||||
import org.springframework.cloud.stream.annotation.Output;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
/**
|
||||
* Spring Cloud Stream Source 接口
|
||||
*/
|
||||
public interface MQStreamProducer {
|
||||
|
||||
/**
|
||||
* 商品更新 Output
|
||||
*/
|
||||
String PRODUCT_UPDATE_OUTPUT = "product-update-output";
|
||||
|
||||
@Output(PRODUCT_UPDATE_OUTPUT)
|
||||
MessageChannel productUpdateOutput();
|
||||
|
||||
// default boolean sendProductUpdateMessage(ProductUpdateMessage message) {
|
||||
// // 创建 Spring Message 对象
|
||||
// Message<ProductUpdateMessage> springMessage = MessageBuilder.withPayload(message)
|
||||
// .build();
|
||||
// // 发送消息
|
||||
// return productUpdateOutput().send(springMessage);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -35,28 +35,6 @@ public class ProductAttrServiceImpl implements ProductAttrService {
|
||||
@Autowired
|
||||
private ProductAttrValueMapper productAttrValueMapper;
|
||||
|
||||
@Override
|
||||
public ProductAttrPageBO getProductAttrPage(ProductAttrPageDTO productAttrPageDTO) {
|
||||
ProductAttrPageBO productAttrPageBO = new ProductAttrPageBO();
|
||||
// 查询分页数据
|
||||
int offset = (productAttrPageDTO.getPageNo()-1) * productAttrPageDTO.getPageSize();
|
||||
productAttrPageBO.setAttrs(ProductAttrConvert.INSTANCE.convert(productAttrMapper.selectListByNameLike(productAttrPageDTO.getName(),
|
||||
offset, productAttrPageDTO.getPageSize())));
|
||||
// 查询分页总数
|
||||
productAttrPageBO.setCount(productAttrMapper.selectCountByNameLike(productAttrPageDTO.getName()));
|
||||
// 将规格值拼接上去
|
||||
if (!productAttrPageBO.getAttrs().isEmpty()) {
|
||||
Set<Integer> attrIds = productAttrPageBO.getAttrs().stream().map(ProductAttrDetailBO::getId).collect(Collectors.toSet());
|
||||
List<ProductAttrValueDO> attrValues = productAttrValueMapper.selectListByAttrIds(attrIds);
|
||||
ImmutableListMultimap<Integer, ProductAttrValueDO> attrValueMap = Multimaps.index(attrValues, ProductAttrValueDO::getAttrId); // KEY 是 attrId ,VALUE 是 ProductAttrValueDO 数组
|
||||
for (ProductAttrDetailBO productAttrDetailBO : productAttrPageBO.getAttrs()) {
|
||||
productAttrDetailBO.setValues(ProductAttrConvert.INSTANCE.convert2(((attrValueMap).get(productAttrDetailBO.getId()))));
|
||||
}
|
||||
}
|
||||
// 返回结果
|
||||
return productAttrPageBO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductAttrSimpleBO> getProductAttrList() {
|
||||
// 查询所有开启的规格数组
|
||||
@@ -74,57 +52,5 @@ public class ProductAttrServiceImpl implements ProductAttrService {
|
||||
return attrs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductAttrValueBO addProductAttrValue(Integer adminId, ProductAttrValueAddDTO productAttrValueAddDTO) {
|
||||
// 校验规格名不重复
|
||||
if (productAttrValueMapper.selectByAttrIdAndName(productAttrValueAddDTO.getAttrId(), productAttrValueAddDTO.getName()) != null) {
|
||||
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_VALUE_EXISTS.getCode());
|
||||
}
|
||||
// 插入到数据库
|
||||
ProductAttrValueDO productAttrValueDO = ProductAttrConvert.INSTANCE.convert(productAttrValueAddDTO)
|
||||
.setStatus(ProductAttrConstants.ATTR_VALUE_STATUS_ENABLE);
|
||||
productAttrValueDO.setCreateTime(new Date());
|
||||
productAttrValueDO.setDeleted(DeletedStatusEnum.DELETED_NO.getValue());
|
||||
productAttrValueMapper.insert(productAttrValueDO);
|
||||
// 返回成功
|
||||
return ProductAttrConvert.INSTANCE.convert2(productAttrValueDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateProductAttrValue(Integer adminId, ProductAttrValueUpdateDTO productAttrValueUpdateDTO) {
|
||||
// 校验存在
|
||||
ProductAttrValueDO productAttrValueDO = productAttrValueMapper.selectById(productAttrValueUpdateDTO.getId());
|
||||
if (productAttrValueDO == null) {
|
||||
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_VALUE_NOT_EXIST.getCode());
|
||||
}
|
||||
// 校验规格名不重复
|
||||
ProductAttrValueDO existsAttrDO = productAttrValueMapper.selectByAttrIdAndName(productAttrValueDO.getAttrId(), productAttrValueUpdateDTO.getName());
|
||||
if (existsAttrDO != null && !existsAttrDO.getId().equals(productAttrValueUpdateDTO.getId())) {
|
||||
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_VALUE_EXISTS.getCode());
|
||||
}
|
||||
// 更新到数据库
|
||||
ProductAttrValueDO updateProductValue = ProductAttrConvert.INSTANCE.convert(productAttrValueUpdateDTO);
|
||||
productAttrValueMapper.update(updateProductValue);
|
||||
// 返回成功
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateProductAttrValueStatus(Integer adminId, Integer productAttrValueId, Integer status) {
|
||||
// 校验存在
|
||||
ProductAttrValueDO productAttrValueDO = productAttrValueMapper.selectById(productAttrValueId);
|
||||
if (productAttrValueDO == null) {
|
||||
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_VALUE_NOT_EXIST.getCode());
|
||||
}
|
||||
// 校验状态
|
||||
if (productAttrValueDO.getStatus().equals(status)) {
|
||||
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_ATTR_VALUE_STATUS_EQUALS.getCode());
|
||||
}
|
||||
// 更新到数据库
|
||||
ProductAttrValueDO updateProductAttrValue = new ProductAttrValueDO().setId(productAttrValueId).setStatus(status);
|
||||
productAttrValueMapper.update(updateProductAttrValue);
|
||||
// 返回成功
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,9 +42,6 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
@Autowired
|
||||
private ProductAttrServiceImpl productAttrService;
|
||||
|
||||
@Autowired
|
||||
private MQStreamProducer mqStreamProducer;
|
||||
|
||||
// @Override
|
||||
// public ProductSpuBO getProductSpuDetail(Integer id) {
|
||||
// ProductSpuDO productSpuDO = productSpuMapper.selectById(id);
|
||||
@@ -86,15 +83,6 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
return spus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductSpuDetailBO addProductSpu(Integer adminId, ProductSpuAddDTO productSpuAddDTO) {
|
||||
// 如果新增生成,发送创建商品 Topic 消息
|
||||
// TODO 芋艿,先不考虑事务的问题。等后面的 fescar 一起搞
|
||||
sendProductUpdateMessage(productSpuDetailBO.getId());
|
||||
// 返回成功
|
||||
return productSpuDetailBO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateProductSpuSort(Integer adminId, Integer spuId, Integer sort) {
|
||||
// 校验 Spu 是否存在
|
||||
|
||||
Reference in New Issue
Block a user