商品品牌的迁移,准备和前端管理后台对接

This commit is contained in:
YunaiV
2020-07-25 22:29:38 +08:00
parent 2b8459680b
commit 24f3e697b8
81 changed files with 931 additions and 2169 deletions

View File

@@ -1,35 +0,0 @@
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.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;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface ProductBrandConvert {
ProductBrandConvert INSTANCE = Mappers.getMapper(ProductBrandConvert.class);
@Mapping(source = "records", target = "list")
PageResult<ProductBrandBO> convertPage(IPage<ProductBrandDO> bean);
@Mappings({})
List<ProductBrandBO> convert(List<ProductBrandDO> brands);
@Mappings({})
ProductBrandBO convert(ProductBrandDO brand);
@Mappings({})
ProductBrandDO convert(ProductBrandUpdateDTO brand);
@Mappings({})
ProductBrandDO convert(ProductBrandAddDTO brand);
}

View File

@@ -1,25 +0,0 @@
package cn.iocoder.mall.product.biz.dao.brand;
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;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;
@Repository
public interface ProductBrandMapper extends BaseMapper<ProductBrandDO> {
default IPage<ProductBrandDO> selectPageByParams(ProductBrandPageDTO productBrandPageDTO) {
Page<ProductBrandDO> page = new Page<>(productBrandPageDTO.getPageNo(), productBrandPageDTO.getPageSize());
LambdaQueryWrapper<ProductBrandDO> queryWrapper = Wrappers.<ProductBrandDO>query().lambda()
.like(StringUtils.isNotBlank(productBrandPageDTO.getName()), ProductBrandDO::getName, productBrandPageDTO.getName())
.like(StringUtils.isNotBlank(productBrandPageDTO.getDescription()), ProductBrandDO::getName, productBrandPageDTO.getDescription())
.eq(null != productBrandPageDTO.getStatus(), ProductBrandDO::getName, productBrandPageDTO.getStatus())
.eq(ProductBrandDO::getDeleted, false);
return selectPage(page, queryWrapper);
}
}

View File

@@ -1,43 +0,0 @@
package cn.iocoder.mall.product.biz.dataobject.brand;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* Product 品牌
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ProductBrandDO extends DeletableDO {
/**
* 规格编号
*/
private Integer id;
/**
* 名称
*/
private String name;
/**
* 描述
*/
private String description;
/**
* 图片地址
*/
private String picUrl;
/**
* 状态
* <p>
* 1-开启
* 2-禁用
*/
private Integer status;
}

View File

@@ -1,43 +0,0 @@
package cn.iocoder.mall.product.biz.dto.brand;
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 ProductBrandAddDTO {
/**
* 名称
*/
@NotEmpty(message = "品牌名不能为空")
private String name;
/**
* 描述
*/
@NotEmpty(message = "品牌描述不能为空")
private String description;
/**
* 图片地址
*/
@NotEmpty(message = "品牌图片地址不能为空")
private String picUrl;
/**
* 状态
*
* 1-开启
* 2-禁用
*/
@NotNull(message = "品牌状态不能为空")
private Integer status;
}

View File

@@ -1,31 +0,0 @@
package cn.iocoder.mall.product.biz.dto.brand;
import cn.iocoder.common.framework.vo.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 商品品牌分页 DTO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ProductBrandPageDTO extends PageParam {
/**
* 名称
*/
private String name;
/**
* 描述
*/
private String description;
/**
* 状态 1-开启 2-禁用
*/
private Integer status;
}

View File

@@ -1,49 +0,0 @@
package cn.iocoder.mall.product.biz.dto.brand;
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 ProductBrandUpdateDTO {
/**
* 主键
*/
@NotNull(message = "品牌主键不能为空")
private Integer id;
/**
* 名称
*/
@NotEmpty(message = "品牌名不能为空")
private String name;
/**
* 描述
*/
@NotEmpty(message = "品牌描述不能为空")
private String description;
/**
* 图片地址
*/
@NotEmpty(message = "品牌图片地址不能为空")
private String picUrl;
/**
* 状态
*
* 1-开启
* 2-禁用
*/
@NotNull(message = "品牌状态不能为空")
private Integer status;
}

View File

@@ -1,45 +0,0 @@
package cn.iocoder.mall.product.biz.service.brand;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.product.biz.bo.brand.ProductBrandBO;
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;
public interface ProductBrandService {
/**
* 获取品牌分页数据
*
* @param productBrandPageDTO 翻页参数
* @return
*/
PageResult<ProductBrandBO> getProductBrandPage(ProductBrandPageDTO productBrandPageDTO);
/**
* 获取品牌明细
*
* @param id 主键
* @return
*/
ProductBrandBO getProductBrand(Integer id);
/**
* 添加品牌
*
* @param productBrandAddDTO 添加参数
* @return
*/
ProductBrandBO addProductBrand(Integer adminId, ProductBrandAddDTO productBrandAddDTO);
/**
* 更新品牌
*
* @param productBrandUpdateDTO 更新参数
* @return
*/
Boolean updateProductBrand(Integer adminId, ProductBrandUpdateDTO productBrandUpdateDTO);
}

View File

@@ -1,66 +0,0 @@
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.core.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.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 com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* 商品规格 Service 实现类
*
* @see ProductBrandDO
*/
@Service
public class ProductBrandServiceImpl implements ProductBrandService {
@Autowired
private ProductBrandMapper productBrandMapper;
@Override
public PageResult<ProductBrandBO> getProductBrandPage(ProductBrandPageDTO productBrandPageDTO) {
IPage<ProductBrandDO> brandPage = productBrandMapper.selectPageByParams(productBrandPageDTO);
return ProductBrandConvert.INSTANCE.convertPage(brandPage);
}
@Override
public ProductBrandBO getProductBrand(Integer brandId) {
return ProductBrandConvert.INSTANCE.convert(productBrandMapper.selectById(brandId));
}
@Override
public ProductBrandBO addProductBrand(Integer adminId, ProductBrandAddDTO productBrandAddDTO) {
// 校验品牌名不重复
int count = productBrandMapper.selectCount(Wrappers.<ProductBrandDO>query().lambda()
.eq(ProductBrandDO::getName, productBrandAddDTO.getName())
.eq(ProductBrandDO::getDeleted, false));
if (count > 0) {
throw ServiceExceptionUtil.exception(ProductErrorCodeEnum.PRODUCT_BRAND_EXIST.getCode());
}
ProductBrandDO productBrandDO = ProductBrandConvert.INSTANCE.convert(productBrandAddDTO);
productBrandDO.setCreateTime(new Date());
productBrandDO.setDeleted(DeletedStatusEnum.DELETED_NO.getValue());
productBrandMapper.insert(productBrandDO);
return ProductBrandConvert.INSTANCE.convert(productBrandDO);
}
@Override
public Boolean updateProductBrand(Integer adminId, ProductBrandUpdateDTO productBrandUpdateDTO) {
ProductBrandDO productBrandDO = ProductBrandConvert.INSTANCE.convert(productBrandUpdateDTO);
productBrandDO.setUpdateTime(new Date());
productBrandMapper.updateById(productBrandDO);
return true;
}
}