调整商品模块结构

This commit is contained in:
jwf1173
2020-05-12 18:23:27 +08:00
parent a29fb12b8a
commit 03857426aa
45 changed files with 165 additions and 124 deletions

View File

@@ -2,8 +2,8 @@ package cn.iocoder.mall.product.biz.convert.attr;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.product.biz.bo.attr.*;
import cn.iocoder.mall.product.biz.dataobject.product.ProductAttrDO;
import cn.iocoder.mall.product.biz.dataobject.product.ProductAttrValueDO;
import cn.iocoder.mall.product.biz.dataobject.attr.ProductAttrDO;
import cn.iocoder.mall.product.biz.dataobject.attr.ProductAttrValueDO;
import cn.iocoder.mall.product.biz.dto.attr.ProductAttrUpdateDTO;
import cn.iocoder.mall.product.biz.dto.attr.ProductAttrValueAddDTO;
import cn.iocoder.mall.product.biz.dto.attr.ProductAttrValueUpdateDTO;

View File

@@ -2,7 +2,7 @@ package cn.iocoder.mall.product.biz.convert.brand;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.product.biz.bo.brand.ProductBrandBO;
import cn.iocoder.mall.product.biz.dataobject.product.ProductBrandDO;
import cn.iocoder.mall.product.biz.dataobject.brand.ProductBrandDO;
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandAddDTO;
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandUpdateDTO;
import com.baomidou.mybatisplus.core.metadata.IPage;

View File

@@ -1,9 +1,10 @@
package cn.iocoder.mall.product.biz.convert.category;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryBO;
import cn.iocoder.mall.product.biz.dataobject.product.ProductCategoryDO;
import cn.iocoder.mall.product.biz.dataobject.category.ProductCategoryDO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateStatusDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@@ -47,4 +48,11 @@ public interface ProductCategoryConvert {
*/
ProductCategoryDO convertToDO(ProductCategoryUpdateDTO productCategoryUpdateDTO);
/**
* 更新商品分类状态 - DTO转换DO
* @param productCategoryUpdateStatusDTO
* @return
*/
ProductCategoryDO convertToDO(ProductCategoryUpdateStatusDTO productCategoryUpdateStatusDTO);
}

View File

@@ -2,9 +2,9 @@ package cn.iocoder.mall.product.biz.convert.product;
import cn.iocoder.common.framework.util.StringUtil;
import cn.iocoder.mall.product.biz.bo.product.*;
import cn.iocoder.mall.product.biz.dataobject.product.ProductCategoryDO;
import cn.iocoder.mall.product.biz.dataobject.product.ProductSkuDO;
import cn.iocoder.mall.product.biz.dataobject.product.ProductSpuDO;
import cn.iocoder.mall.product.biz.dataobject.category.ProductCategoryDO;
import cn.iocoder.mall.product.biz.dataobject.spu.ProductSkuDO;
import cn.iocoder.mall.product.biz.dataobject.spu.ProductSpuDO;
import cn.iocoder.mall.product.biz.dto.product.ProductSkuAddOrUpdateDTO;
import cn.iocoder.mall.product.biz.dto.product.ProductSpuAddDTO;
import cn.iocoder.mall.product.biz.dto.product.ProductSpuUpdateDTO;

View File

@@ -1,7 +1,7 @@
package cn.iocoder.mall.product.biz.convert.product;
import cn.iocoder.mall.product.biz.bo.product.UserProductSpuCollectionsBO;
import cn.iocoder.mall.product.biz.dataobject.product.UserProductSpuCollectionsDO;
import cn.iocoder.mall.product.biz.dataobject.spu.UserProductSpuCollectionsDO;
import cn.iocoder.mall.product.biz.dto.product.UserProductSpuCollectionsAddDTO;
import cn.iocoder.mall.product.biz.dto.product.UserProductSpuCollectionsUpdateDTO;
import org.mapstruct.Mapper;

View File

@@ -1,6 +1,6 @@
package cn.iocoder.mall.product.biz.dao.product;
package cn.iocoder.mall.product.biz.dao.attr;
import cn.iocoder.mall.product.biz.dataobject.product.ProductAttrDO;
import cn.iocoder.mall.product.biz.dataobject.attr.ProductAttrDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;

View File

@@ -1,6 +1,6 @@
package cn.iocoder.mall.product.biz.dao.product;
package cn.iocoder.mall.product.biz.dao.attr;
import cn.iocoder.mall.product.biz.dataobject.product.ProductAttrValueDO;
import cn.iocoder.mall.product.biz.dataobject.attr.ProductAttrValueDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;

View File

@@ -1,6 +1,6 @@
package cn.iocoder.mall.product.biz.dao.product;
package cn.iocoder.mall.product.biz.dao.brand;
import cn.iocoder.mall.product.biz.dataobject.product.ProductBrandDO;
import cn.iocoder.mall.product.biz.dataobject.brand.ProductBrandDO;
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandPageDTO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

View File

@@ -1,9 +1,7 @@
package cn.iocoder.mall.product.biz.dao.product;
package cn.iocoder.mall.product.biz.dao.category;
import cn.iocoder.mall.product.biz.dataobject.product.ProductBrandDO;
import cn.iocoder.mall.product.biz.dataobject.product.ProductCategoryDO;
import cn.iocoder.mall.product.biz.dataobject.category.ProductCategoryDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
/**

View File

@@ -1,6 +1,6 @@
package cn.iocoder.mall.product.biz.dao.product;
package cn.iocoder.mall.product.biz.dao.spu;
import cn.iocoder.mall.product.biz.dataobject.product.ProductSkuDO;
import cn.iocoder.mall.product.biz.dataobject.spu.ProductSkuDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Repository;

View File

@@ -1,6 +1,6 @@
package cn.iocoder.mall.product.biz.dao.product;
package cn.iocoder.mall.product.biz.dao.spu;
import cn.iocoder.mall.product.biz.dataobject.product.ProductSpuDO;
import cn.iocoder.mall.product.biz.dataobject.spu.ProductSpuDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;

View File

@@ -1,6 +1,6 @@
package cn.iocoder.mall.product.biz.dao.product;
package cn.iocoder.mall.product.biz.dao.spu;
import cn.iocoder.mall.product.biz.dataobject.product.UserProductSpuCollectionsDO;
import cn.iocoder.mall.product.biz.dataobject.spu.UserProductSpuCollectionsDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

View File

@@ -1,4 +1,4 @@
package cn.iocoder.mall.product.biz.dataobject.product;
package cn.iocoder.mall.product.biz.dataobject.attr;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import lombok.Data;

View File

@@ -1,4 +1,4 @@
package cn.iocoder.mall.product.biz.dataobject.product;
package cn.iocoder.mall.product.biz.dataobject.attr;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import lombok.Data;

View File

@@ -1,4 +1,4 @@
package cn.iocoder.mall.product.biz.dataobject.product;
package cn.iocoder.mall.product.biz.dataobject.brand;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import lombok.Data;

View File

@@ -1,4 +1,4 @@
package cn.iocoder.mall.product.biz.dataobject.product;
package cn.iocoder.mall.product.biz.dataobject.category;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.TableName;

View File

@@ -1,6 +1,7 @@
package cn.iocoder.mall.product.biz.dataobject.product;
package cn.iocoder.mall.product.biz.dataobject.spu;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import cn.iocoder.mall.product.biz.dataobject.attr.ProductAttrDO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

View File

@@ -1,4 +1,4 @@
package cn.iocoder.mall.product.biz.dataobject.product;
package cn.iocoder.mall.product.biz.dataobject.spu;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import lombok.Data;

View File

@@ -1,4 +1,4 @@
package cn.iocoder.mall.product.biz.dataobject.product;
package cn.iocoder.mall.product.biz.dataobject.spu;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

View File

@@ -1,4 +1,4 @@
package cn.iocoder.mall.product.biz.dataobject.product;
package cn.iocoder.mall.product.biz.dataobject.stock;
import lombok.Data;
import lombok.experimental.Accessors;

View File

@@ -1,4 +1,4 @@
package cn.iocoder.mall.product.biz.service.product;
package cn.iocoder.mall.product.biz.service.attr;
import cn.iocoder.common.framework.constant.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;

View File

@@ -1,4 +1,4 @@
package cn.iocoder.mall.product.biz.service.product.impl;
package cn.iocoder.mall.product.biz.service.attr;
import cn.iocoder.common.framework.util.CollectionUtil;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
@@ -10,14 +10,13 @@ import cn.iocoder.mall.product.biz.bo.attr.ProductAttrValueBO;
import cn.iocoder.mall.product.biz.bo.attr.ProductAttrWithValueBO;
import cn.iocoder.mall.product.biz.bo.product.ProductAttrAndValuePairBO;
import cn.iocoder.mall.product.biz.convert.attr.ProductAttrConvert;
import cn.iocoder.mall.product.biz.dao.product.ProductAttrMapper;
import cn.iocoder.mall.product.biz.dao.product.ProductAttrValueMapper;
import cn.iocoder.mall.product.biz.dataobject.product.ProductAttrDO;
import cn.iocoder.mall.product.biz.dataobject.product.ProductAttrValueDO;
import cn.iocoder.mall.product.biz.dao.attr.ProductAttrMapper;
import cn.iocoder.mall.product.biz.dao.attr.ProductAttrValueMapper;
import cn.iocoder.mall.product.biz.dataobject.attr.ProductAttrDO;
import cn.iocoder.mall.product.biz.dataobject.attr.ProductAttrValueDO;
import cn.iocoder.mall.product.biz.dto.attr.*;
import cn.iocoder.mall.product.biz.enums.ProductErrorCodeEnum;
import cn.iocoder.mall.product.biz.enums.product.ProductAttrConstants;
import cn.iocoder.mall.product.biz.service.product.ProductAttrService;
import cn.iocoder.mall.product.biz.enums.attr.ProductAttrConstants;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -32,8 +31,8 @@ import java.util.stream.Collectors;
/**
* 商品规格 Service 实现类
*
* @see cn.iocoder.mall.product.biz.dataobject.product.ProductAttrDO
* @see cn.iocoder.mall.product.biz.dataobject.product.ProductAttrValueDO
* @see ProductAttrDO
* @see ProductAttrValueDO
*/
@Service
public class ProductAttrServiceImpl implements ProductAttrService {

View File

@@ -1,4 +1,4 @@
package cn.iocoder.mall.product.biz.service.product;
package cn.iocoder.mall.product.biz.service.brand;
import cn.iocoder.common.framework.vo.PageResult;

View File

@@ -1,17 +1,16 @@
package cn.iocoder.mall.product.biz.service.product.impl;
package cn.iocoder.mall.product.biz.service.brand;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.mybatis.enums.DeletedStatusEnum;
import cn.iocoder.mall.product.biz.bo.brand.ProductBrandBO;
import cn.iocoder.mall.product.biz.convert.brand.ProductBrandConvert;
import cn.iocoder.mall.product.biz.dao.product.ProductBrandMapper;
import cn.iocoder.mall.product.biz.dataobject.product.ProductBrandDO;
import cn.iocoder.mall.product.biz.dao.brand.ProductBrandMapper;
import cn.iocoder.mall.product.biz.dataobject.brand.ProductBrandDO;
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandAddDTO;
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandPageDTO;
import cn.iocoder.mall.product.biz.dto.brand.ProductBrandUpdateDTO;
import cn.iocoder.mall.product.biz.enums.ProductErrorCodeEnum;
import cn.iocoder.mall.product.biz.service.product.ProductBrandService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -1,10 +1,11 @@
package cn.iocoder.mall.product.biz.service.product;
package cn.iocoder.mall.product.biz.service.category;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryBO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryDeleteDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateStatusDTO;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import java.util.List;
@@ -15,6 +16,7 @@ import java.util.List;
* @Date: 2020/5/6
* @Description: 商品分类 - 服务层
*/
@Validated
public interface ProductCategoryService {
/**

View File

@@ -1,22 +1,21 @@
package cn.iocoder.mall.product.biz.service.product.impl;
package cn.iocoder.mall.product.biz.service.category;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.mall.mybatis.enums.DeletedStatusEnum;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryBO;
import cn.iocoder.mall.product.biz.convert.category.ProductCategoryConvert;
import cn.iocoder.mall.product.biz.dao.product.ProductCategoryMapper;
import cn.iocoder.mall.product.biz.dataobject.product.ProductCategoryDO;
import cn.iocoder.mall.product.biz.dao.category.ProductCategoryMapper;
import cn.iocoder.mall.product.biz.dataobject.category.ProductCategoryDO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryDeleteDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateStatusDTO;
import cn.iocoder.mall.product.biz.enums.product.ProductCategoryConstants;
import cn.iocoder.mall.product.biz.service.product.ProductCategoryService;
import cn.iocoder.mall.product.biz.enums.category.ProductCategoryConstants;
import cn.iocoder.mall.product.biz.enums.category.ProductCategoryStatusEnum;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@@ -28,7 +27,6 @@ import static cn.iocoder.mall.product.biz.enums.ProductErrorCodeEnum.*;
* @Description: 商品分类 - 服务实现层
*/
@Service
@Validated
public class ProductCategoryServiceImpl implements ProductCategoryService {
@Autowired
@@ -55,7 +53,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
validParent(productCategoryAddDTO.getPid());
// 保存到数据库
ProductCategoryDO productCategory = ProductCategoryConvert.INSTANCE.convertToDO(productCategoryAddDTO)
.setStatus(ProductCategoryConstants.STATUS_ENABLE);
.setStatus(ProductCategoryStatusEnum.ENABLED.getStatus());
productCategory.setCreateTime(new Date());
productCategory.setDeleted(DeletedStatusEnum.DELETED_NO.getValue());
productCategoryMapper.insert(productCategory);
@@ -87,8 +85,8 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_PARENT_NOT_EXISTS);
}
// 更新到数据库
ProductCategoryDO productCategoryDO = ProductCategoryConvert.INSTANCE.convertToDO(productCategoryUpdateDTO);
productCategoryMapper.updateById(productCategoryDO);
ProductCategoryDO updateProductCategory = ProductCategoryConvert.INSTANCE.convertToDO(productCategoryUpdateDTO);
productCategoryMapper.updateById(updateProductCategory);
// TODO 伟帆 操作日志
return true;
}
@@ -100,25 +98,22 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
*/
@Override
public Boolean updateProductCategoryStatus(ProductCategoryUpdateStatusDTO productCategoryUpdateStatusDTO) {
Integer productCategoryId = productCategoryUpdateStatusDTO.getId();
Integer status = productCategoryUpdateStatusDTO.getStatus();
// 校验商品分类是否存在
ProductCategoryDO productCategoryDO = productCategoryMapper.selectById(productCategoryId);
ProductCategoryDO productCategoryDO = productCategoryMapper.selectById(productCategoryUpdateStatusDTO.getId());
if (productCategoryDO == null) {
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_NOT_EXISTS);
}
// 判断更新状态是否存在
if (!ProductCategoryConstants.STATUS_ENABLE.equals(status)
&& !ProductCategoryConstants.STATUS_DISABLE.equals(status)) {
if (Arrays.stream(ProductCategoryStatusEnum.ARRAYS).noneMatch(status -> status == productCategoryUpdateStatusDTO.getStatus())) {
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_STATUS_NOT_EXISTS);
}
// 如果状态相同则返回错误
if (productCategoryDO.getStatus().equals(status)) {
if (productCategoryDO.getStatus().equals(productCategoryUpdateStatusDTO.getStatus())) {
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_STATUS_EQUALS);
}
// 更新商品分类
productCategoryDO.setId(productCategoryId).setStatus(status);
productCategoryMapper.updateById(productCategoryDO);
// 更新商品分类状态
ProductCategoryDO updateCategoryStatus = ProductCategoryConvert.INSTANCE.convertToDO(productCategoryUpdateStatusDTO);
productCategoryMapper.updateById(updateCategoryStatus);
// TODO 伟帆 操作日志
return true;
}
@@ -137,7 +132,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_NOT_EXISTS);
}
// 只有禁用的商品分类才可以删除
if (ProductCategoryConstants.STATUS_ENABLE.equals(productCategory.getStatus())) {
if (ProductCategoryStatusEnum.ENABLED.getStatus().equals(productCategory.getStatus())) {
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_DELETE_ONLY_DISABLE);
}
// 只有不存在子分类才可以删除

View File

@@ -1,4 +1,4 @@
package cn.iocoder.mall.product.biz.service.product;
package cn.iocoder.mall.product.biz.service.spu;
import cn.iocoder.mall.product.biz.bo.product.ProductSpuDetailBO;

View File

@@ -1,20 +1,19 @@
package cn.iocoder.mall.product.biz.service.product.impl;
package cn.iocoder.mall.product.biz.service.spu;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.util.StringUtil;
import cn.iocoder.mall.product.biz.bo.product.ProductAttrAndValuePairBO;
import cn.iocoder.mall.product.biz.bo.product.ProductSpuDetailBO;
import cn.iocoder.mall.product.biz.convert.product.ProductSpuConvert;
import cn.iocoder.mall.product.biz.dao.product.ProductCategoryMapper;
import cn.iocoder.mall.product.biz.dao.product.ProductSkuMapper;
import cn.iocoder.mall.product.biz.dao.product.ProductSpuMapper;
import cn.iocoder.mall.product.biz.dataobject.product.ProductCategoryDO;
import cn.iocoder.mall.product.biz.dataobject.product.ProductSkuDO;
import cn.iocoder.mall.product.biz.dataobject.product.ProductSpuDO;
import cn.iocoder.mall.product.biz.dao.category.ProductCategoryMapper;
import cn.iocoder.mall.product.biz.dao.spu.ProductSkuMapper;
import cn.iocoder.mall.product.biz.dao.spu.ProductSpuMapper;
import cn.iocoder.mall.product.biz.dataobject.category.ProductCategoryDO;
import cn.iocoder.mall.product.biz.dataobject.spu.ProductSkuDO;
import cn.iocoder.mall.product.biz.dataobject.spu.ProductSpuDO;
import cn.iocoder.mall.product.biz.enums.ProductErrorCodeEnum;
import cn.iocoder.mall.product.biz.enums.product.ProductSpuConstants;
import cn.iocoder.mall.product.biz.service.product.ProductAttrService;
import cn.iocoder.mall.product.biz.service.product.ProductSpuService;
import cn.iocoder.mall.product.biz.enums.spu.ProductSpuConstants;
import cn.iocoder.mall.product.biz.service.attr.ProductAttrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.product.biz.dao.product.ProductSpuMapper">
<mapper namespace="cn.iocoder.mall.product.biz.dao.spu.ProductSpuMapper">
</mapper>