商品分类的迁移,继续未完成,继续先提交下~

This commit is contained in:
YunaiV
2020-07-25 00:10:10 +08:00
parent b209505f99
commit a99afdc833
44 changed files with 731 additions and 674 deletions

View File

@@ -1,55 +0,0 @@
package cn.iocoder.mall.product.biz.bo.category;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
* @Description: 商品分类 - 商品分类统一BO
*/
@Data
@Accessors(chain = true)
public class ProductCategoryBO {
/**
* 分类编号
*/
private Integer id;
/**
* 父分类编号
*
* 如果不存在父级,则 pid = 0 。
*/
private Integer pid;
/**
* 名称
*/
private String name;
/**
* 描述
*/
private String description;
/**
* 分类图片
*/
private String picUrl;
/**
* 排序值
*/
private Integer sort;
/**
* 状态
*
* 1-开启
* 2-关闭
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
}

View File

@@ -1,5 +0,0 @@
/**
* author: sin
* time: 2020/5/3 8:31 下午
*/
package cn.iocoder.mall.product.biz.bo;

View File

@@ -1,26 +0,0 @@
package cn.iocoder.mall.product.biz.config;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@MapperScan("cn.iocoder.mall.product.biz.dao") // 扫描对应的 Mapper 接口
@EnableTransactionManagement(proxyTargetClass = true)
// 启动事务管理。为什么使用 proxyTargetClass 参数,参见 https://blog.csdn.net/huang_550/article/details/76492600
public class DatabaseConfiguration {
@Bean
public ISqlInjector sqlInjector() {
return new DefaultSqlInjector(); // MyBatis Plus 逻辑删除
}
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor(); // MyBatis Plus 分页插件
}
}

View File

@@ -1,58 +0,0 @@
package cn.iocoder.mall.product.biz.convert.category;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryBO;
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;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
* @Description: 商品分类 - 服务层数据转换
*/
@Mapper
public interface ProductCategoryConvert {
ProductCategoryConvert INSTANCE = Mappers.getMapper(ProductCategoryConvert.class);
/**
* 商品分类统一DO转BO
* @param category
* @return
*/
ProductCategoryBO convertToBO(ProductCategoryDO category);
/**
* 商品分类列表 - DO转换BO {@link #convertToBO(ProductCategoryDO)}
* @param category
* @return
*/
List<ProductCategoryBO> convertToAllListBO(List<ProductCategoryDO> category);
/**
* 新增商品分类 - DTO转换DO
* @param productCategoryAddDTO
* @return
*/
ProductCategoryDO convertToDO(ProductCategoryAddDTO productCategoryAddDTO);
/**
* 更新商品分类 - DTO转换DO
* @param productCategoryUpdateDTO
* @return
*/
ProductCategoryDO convertToDO(ProductCategoryUpdateDTO productCategoryUpdateDTO);
/**
* 更新商品分类状态 - DTO转换DO
* @param productCategoryUpdateStatusDTO
* @return
*/
ProductCategoryDO convertToDO(ProductCategoryUpdateStatusDTO productCategoryUpdateStatusDTO);
}

View File

@@ -1,5 +0,0 @@
/**
* author: sin
* time: 2020/5/3 8:31 下午
*/
package cn.iocoder.mall.product.biz.convert;

View File

@@ -1,25 +0,0 @@
package cn.iocoder.mall.product.biz.dao.category;
import cn.iocoder.mall.product.biz.dataobject.category.ProductCategoryDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Repository;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
* @Description: 商品分类数据持久层
*/
@Repository
public interface ProductCategoryMapper extends BaseMapper<ProductCategoryDO> {
/**
* 查询商品分类的下一级子分类数量
* @param productCategoryId
* @return
*/
default Integer selectChildCategoryCount(Integer productCategoryId) {
return this.selectCount(
Wrappers.<ProductCategoryDO>lambdaQuery().eq(ProductCategoryDO::getPid, productCategoryId)
);
}
}

View File

@@ -1,5 +0,0 @@
/**
* author: sin
* time: 2020/5/3 8:28 下午
*/
package cn.iocoder.mall.product.biz.dao;

View File

@@ -1,50 +0,0 @@
package cn.iocoder.mall.product.biz.dataobject.category;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 商品分类
*/
@Data
@Accessors(chain = true)
@TableName("product_category")
public class ProductCategoryDO extends DeletableDO {
/**
* 分类编号
*/
private Integer id;
/**
* 父分类编号
*
* 如果不存在父级,则 pid = 0 。
*/
private Integer pid;
/**
* 名称
*/
private String name;
/**
* 描述
*/
private String description;
/**
* 分类图片
*/
private String picUrl;
/**
* 排序值
*/
private Integer sort;
/**
* 状态
*
* 1-开启
* 2-关闭
*/
private Integer status;
}

View File

@@ -1,5 +0,0 @@
/**
* author: sin
* time: 2020/5/3 8:27 下午
*/
package cn.iocoder.mall.product.biz.dataobject;

View File

@@ -1,48 +0,0 @@
package cn.iocoder.mall.product.biz.dto.category;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
* @Description: 商品分类 - 创建商品分类DTO
*/
@Data
@Accessors(chain = true)
public class ProductCategoryAddDTO {
/**
* 管理员id
*/
@NotNull(message = "管理员id不能为空")
private Integer adminId;
/**
* 父分类编号
*/
@NotNull(message = "父分类编号不能为空")
private Integer pid;
/**
* 名称
*/
@NotNull(message = "名称不能为空")
private String name;
/**
* 描述
*/
@NotNull(message = "描述不能为空")
private String description;
/**
* 分类图片
*/
private String picUrl;
/**
* 排序值
*/
@NotNull(message = "排序值不能为空")
private Integer sort;
}

View File

@@ -1,28 +0,0 @@
package cn.iocoder.mall.product.biz.dto.category;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
* @Description: 商品分类 - 删除商品分类DTO
*/
@Data
@Accessors(chain = true)
public class ProductCategoryDeleteDTO {
/**
* 管理员id
*/
@NotNull(message = "管理员id不能为空")
private Integer adminId;
/**
* 商品分类编号
*/
@NotNull(message = "编号不能为空")
private Integer id;
}

View File

@@ -1,52 +0,0 @@
package cn.iocoder.mall.product.biz.dto.category;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
* @Description: 商品分类 - 更新商品分类DTO
*/
@Data
@Accessors(chain = true)
public class ProductCategoryUpdateDTO {
/**
* 管理员id
*/
@NotNull(message = "管理员id不能为空")
private Integer adminId;
/**
* 编号
*/
@NotNull(message = "编号不能为空")
private Integer id;
/**
* 父分类编号
*/
@NotNull(message = "父分类编号不能为空")
private Integer pid;
/**
* 名称
*/
@NotNull(message = "名称不能为空")
private String name;
/**
* 描述
*/
@NotNull(message = "描述不能为空")
private String description;
/**
* 分类图片
*/
private String picUrl;
/**
* 排序值
*/
@NotNull(message = "描述不能为空")
private Integer sort;
}

View File

@@ -1,33 +0,0 @@
package cn.iocoder.mall.product.biz.dto.category;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
* @Description: 商品分类 - 更新商品分类状态DTO
*/
@Data
@Accessors(chain = true)
public class ProductCategoryUpdateStatusDTO {
/**
* 管理员id
*/
@NotNull(message = "管理员id不能为空")
private Integer adminId;
/**
* 商品分类编号
*/
@NotNull(message = "编号不能为空")
private Integer id;
/**
* 状态
*/
@NotNull(message = "状态不能为空")
private Integer status;
}

View File

@@ -1,69 +0,0 @@
package cn.iocoder.mall.product.biz.service.category;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryBO;
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 org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import java.util.List;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
* @Description: 商品分类 - 服务层
*/
@Validated
public interface ProductCategoryService {
/**
* 获取所有商品分类
*
* @return
*/
List<ProductCategoryBO> getAllProductCategory();
/**
* 新增商品分类
*
* @param productCategoryAddDTO
* @return
*/
ProductCategoryBO addProductCategory(@Valid ProductCategoryAddDTO productCategoryAddDTO);
/**
* 更新商品分类
*
* @param productCategoryUpdateDTO
* @return
*/
Boolean updateProductCategory(@Valid ProductCategoryUpdateDTO productCategoryUpdateDTO);
/**
* 更新商品分类状态
*
* @param productCategoryUpdateStatusDTO
* @return
*/
Boolean updateProductCategoryStatus(@Valid ProductCategoryUpdateStatusDTO productCategoryUpdateStatusDTO);
/**
* 删除商品分类
*
* @param productCategoryDeleteDTO
* @return
*/
Boolean deleteProductCategory(@Valid ProductCategoryDeleteDTO productCategoryDeleteDTO);
/**
* 校验分类是否可用
*
* @param productCategoryId 分类ID
* @return 商品分类
*/
ProductCategoryDO validProductCategory(Integer productCategoryId);
}

View File

@@ -1,42 +0,0 @@
package cn.iocoder.mall.product.biz.service.category;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.mall.mybatis.core.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.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.ProductErrorCodeEnum;
import cn.iocoder.mall.product.biz.enums.category.ProductCategoryNodeEnum;
import cn.iocoder.mall.product.biz.enums.category.ProductCategoryStatusEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import static cn.iocoder.mall.product.biz.enums.ProductErrorCodeEnum.*;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
* @Description: 商品分类 - 服务实现层
*/
@Service
public class ProductCategoryServiceImpl implements ProductCategoryService {
@Autowired
private ProductCategoryMapper productCategoryMapper;
@Override
public List<ProductCategoryBO> getAllProductCategory() {
List<ProductCategoryDO> categoryList = productCategoryMapper.selectList(null);
return ProductCategoryConvert.INSTANCE.convertToAllListBO(categoryList);
}
}

View File

@@ -1,5 +0,0 @@
/**
* author: sin
* time: 2020/5/3 8:31 下午
*/
package cn.iocoder.mall.product.biz.service;

View File

@@ -1,69 +0,0 @@
package cn.iocoder.mall.product.rest.convert.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 cn.iocoder.mall.product.rest.request.category.AdminsProductCategoryAddRequest;
import cn.iocoder.mall.product.rest.request.category.AdminsProductCategoryUpdateRequest;
import cn.iocoder.mall.product.rest.request.category.AdminsProductCategoryUpdateStatusRequest;
import cn.iocoder.mall.product.rest.response.category.AdminsProductCategoryAddResponse;
import cn.iocoder.mall.product.rest.response.category.AdminsProductCategoryTreeNodeResponse;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
* @Description: 管理员 - 商品分类 - API层数据转换
*/
@Mapper
public interface AdminsProductCategoryConvert {
AdminsProductCategoryConvert INSTANCE = Mappers.getMapper(AdminsProductCategoryConvert.class);
/**
* 商品分类列表 - BO转换Response
* @param productCategoryAllListBO
* @return
*/
AdminsProductCategoryTreeNodeResponse convertToTreeNodeResponse(ProductCategoryBO productCategoryAllListBO);
/**
* 新增商品分类 - Request转DTO
* @param adminsProductCategoryAddRequest
* @return
*/
ProductCategoryAddDTO convertToAddDTO(Integer adminId, AdminsProductCategoryAddRequest adminsProductCategoryAddRequest);
/**
* 新增商品分类 - BO转Response
* @param productCategoryAddBO
* @return
*/
AdminsProductCategoryAddResponse convertToAddResponse(ProductCategoryBO productCategoryAddBO);
/**
* 更新商品分类 - Request转DTO
* @param adminsProductCategoryUpdateRequest
* @return
*/
ProductCategoryUpdateDTO convertToUpdateDTO(Integer adminId, AdminsProductCategoryUpdateRequest adminsProductCategoryUpdateRequest);
/**
* 更新商品分类状态 - Request转DTO
* @param adminsProductCategoryUpdateStatusRequest
* @return
*/
ProductCategoryUpdateStatusDTO convertToUpdateStatusDTO(Integer adminId, AdminsProductCategoryUpdateStatusRequest adminsProductCategoryUpdateStatusRequest);
/**
* 删除商品分类 - Request转DTO
* @param adminId 管理员id
* @param id 商品分类id
* @return
*/
ProductCategoryDeleteDTO convertToDeleteDTO(Integer adminId, Integer id);
}

View File

@@ -1,38 +0,0 @@
package cn.iocoder.mall.product.rest.request.category;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
* @Description: 管理员 - 商品分类 - 创建商品分类Request
*/
@ApiModel("创建商品分类Request")
@Data
@Accessors(chain = true)
public class AdminsProductCategoryAddRequest {
@ApiModelProperty(name = "pid", value = "父级分类编号", required = true, example = "1")
@NotNull(message = "父分类编号不能为空")
private Integer pid;
@ApiModelProperty(name = "name", value = "分类名字(标识)", required = true, example = "admin/info")
@NotNull(message = "名称不能为空")
private String name;
@ApiModelProperty(name = "description", value = "描述", required = true, example = "1")
@NotNull(message = "描述不能为空")
private String description;
@ApiModelProperty(name = "picUrl", value = "分类图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg/")
private String picUrl;
@ApiModelProperty(name = "sort", value = "排序", required = true, example = "1")
@NotNull(message = "排序值不能为空")
private Integer sort;
}

View File

@@ -1,42 +0,0 @@
package cn.iocoder.mall.product.rest.request.category;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
* @Description: 管理员 - 商品分类 - 更新商品分类Request
*/
@ApiModel("更新商品分类Request")
@Data
@Accessors(chain = true)
public class AdminsProductCategoryUpdateRequest {
@ApiModelProperty(name = "id", value = "分类编号", required = true, example = "1")
@NotNull(message = "编号不能为空")
private Integer id;
@ApiModelProperty(name = "pid", value = "父级分类编号", required = true, example = "1")
@NotNull(message = "父分类编号不能为空")
private Integer pid;
@ApiModelProperty(name = "name", value = "分类名字(标识)", required = true, example = "admin/info")
@NotNull(message = "名称不能为空")
private String name;
@ApiModelProperty(name = "description", value = "描述", required = true, example = "1")
@NotNull(message = "描述不能为空")
private String description;
@ApiModelProperty(name = "picUrl", value = "分类图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg/")
private String picUrl;
@ApiModelProperty(name = "sort", value = "排序", required = true, example = "1")
@NotNull(message = "排序值不能为空")
private Integer sort;
}

View File

@@ -1,27 +0,0 @@
package cn.iocoder.mall.product.rest.request.category;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
* @Description: 管理员 - 商品分类 - 更新商品分类状态Request
*/
@ApiModel("更新商品分类状态Request")
@Data
@Accessors(chain = true)
public class AdminsProductCategoryUpdateStatusRequest {
@ApiModelProperty(name = "id", value = "分类编号", required = true, example = "1")
@NotNull(message = "编号不能为空")
private Integer id;
@ApiModelProperty(name = "status", value = "状态。1 - 开启2 - 禁用", required = true, example = "1")
@NotNull(message = "状态不能为空")
private Integer status;
}