商品规格实体类增加Product前缀
parent
9dad9e555f
commit
733a3c4615
@ -1,14 +1,12 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.property.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@ApiModel("管理后台 - 规格名称创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PropertyCreateReqVO extends PropertyBaseVO {
|
||||
public class ProductPropertyCreateReqVO extends ProductPropertyBaseVO {
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.product.convert.property;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.*;
|
||||
|
||||
/**
|
||||
* 规格名称 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProductPropertyConvert {
|
||||
|
||||
ProductPropertyConvert INSTANCE = Mappers.getMapper(ProductPropertyConvert.class);
|
||||
|
||||
ProductPropertyDO convert(ProductPropertyCreateReqVO bean);
|
||||
|
||||
ProductPropertyDO convert(ProductPropertyUpdateReqVO bean);
|
||||
|
||||
ProductPropertyRespVO convert(ProductPropertyDO bean);
|
||||
|
||||
List<ProductPropertyRespVO> convertList(List<ProductPropertyDO> list);
|
||||
|
||||
PageResult<ProductPropertyRespVO> convertPage(PageResult<ProductPropertyDO> page);
|
||||
|
||||
List<ProductPropertyExcelVO> convertList02(List<ProductPropertyDO> list);
|
||||
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.convert.property;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.PropertyDO;
|
||||
|
||||
/**
|
||||
* 规格名称 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface PropertyConvert {
|
||||
|
||||
PropertyConvert INSTANCE = Mappers.getMapper(PropertyConvert.class);
|
||||
|
||||
PropertyDO convert(PropertyCreateReqVO bean);
|
||||
|
||||
PropertyDO convert(PropertyUpdateReqVO bean);
|
||||
|
||||
PropertyRespVO convert(PropertyDO bean);
|
||||
|
||||
List<PropertyRespVO> convertList(List<PropertyDO> list);
|
||||
|
||||
PageResult<PropertyRespVO> convertPage(PageResult<PropertyDO> page);
|
||||
|
||||
List<PropertyExcelVO> convertList02(List<PropertyDO> list);
|
||||
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.product.dal.mysql.property;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.*;
|
||||
|
||||
/**
|
||||
* 规格名称 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProductPropertyMapper extends BaseMapperX<ProductPropertyDO> {
|
||||
|
||||
default PageResult<ProductPropertyDO> selectPage(ProductPropertyPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ProductPropertyDO>()
|
||||
.likeIfPresent(ProductPropertyDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ProductPropertyDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(ProductPropertyDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc(ProductPropertyDO::getId));
|
||||
}
|
||||
|
||||
default List<ProductPropertyDO> selectList(ProductPropertyExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<ProductPropertyDO>()
|
||||
.likeIfPresent(ProductPropertyDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ProductPropertyDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(ProductPropertyDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc(ProductPropertyDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.dal.mysql.property;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.PropertyDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.*;
|
||||
|
||||
/**
|
||||
* 规格名称 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface PropertyMapper extends BaseMapperX<PropertyDO> {
|
||||
|
||||
default PageResult<PropertyDO> selectPage(PropertyPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<PropertyDO>()
|
||||
.likeIfPresent(PropertyDO::getName, reqVO.getName())
|
||||
.eqIfPresent(PropertyDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(PropertyDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc(PropertyDO::getId));
|
||||
}
|
||||
|
||||
default List<PropertyDO> selectList(PropertyExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<PropertyDO>()
|
||||
.likeIfPresent(PropertyDO::getName, reqVO.getName())
|
||||
.eqIfPresent(PropertyDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(PropertyDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc(PropertyDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package cn.iocoder.yudao.module.product.service.property;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.*;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPropertyCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPropertyUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.product.convert.property.ProductPropertyConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 规格名称 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ProductPropertyServiceImpl implements ProductPropertyService {
|
||||
|
||||
@Resource
|
||||
private ProductPropertyMapper productPropertyMapper;
|
||||
|
||||
@Override
|
||||
public Long createProperty(ProductPropertyCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
ProductPropertyDO property = ProductPropertyConvert.INSTANCE.convert(createReqVO);
|
||||
productPropertyMapper.insert(property);
|
||||
// 返回
|
||||
return property.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProperty(ProductPropertyUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validatePropertyExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ProductPropertyDO updateObj = ProductPropertyConvert.INSTANCE.convert(updateReqVO);
|
||||
productPropertyMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteProperty(Long id) {
|
||||
// 校验存在
|
||||
this.validatePropertyExists(id);
|
||||
// 删除
|
||||
productPropertyMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validatePropertyExists(Long id) {
|
||||
if (productPropertyMapper.selectById(id) == null) {
|
||||
throw exception(PROPERTY_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductPropertyDO getProperty(Long id) {
|
||||
return productPropertyMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductPropertyDO> getPropertyList(Collection<Long> ids) {
|
||||
return productPropertyMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProductPropertyDO> getPropertyPage(ProductPropertyPageReqVO pageReqVO) {
|
||||
return productPropertyMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductPropertyDO> getPropertyList(ProductPropertyExportReqVO exportReqVO) {
|
||||
return productPropertyMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,85 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.service.property;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.PropertyCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.PropertyExportReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.PropertyPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.PropertyUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.product.convert.property.PropertyConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.PropertyDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.property.PropertyMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 规格名称 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class PropertyServiceImpl implements PropertyService {
|
||||
|
||||
@Resource
|
||||
private PropertyMapper propertyMapper;
|
||||
|
||||
@Override
|
||||
public Long createProperty(PropertyCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
PropertyDO property = PropertyConvert.INSTANCE.convert(createReqVO);
|
||||
propertyMapper.insert(property);
|
||||
// 返回
|
||||
return property.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProperty(PropertyUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validatePropertyExists(updateReqVO.getId());
|
||||
// 更新
|
||||
PropertyDO updateObj = PropertyConvert.INSTANCE.convert(updateReqVO);
|
||||
propertyMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteProperty(Long id) {
|
||||
// 校验存在
|
||||
this.validatePropertyExists(id);
|
||||
// 删除
|
||||
propertyMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validatePropertyExists(Long id) {
|
||||
if (propertyMapper.selectById(id) == null) {
|
||||
throw exception(PROPERTY_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyDO getProperty(Long id) {
|
||||
return propertyMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PropertyDO> getPropertyList(Collection<Long> ids) {
|
||||
return propertyMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<PropertyDO> getPropertyPage(PropertyPageReqVO pageReqVO) {
|
||||
return propertyMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PropertyDO> getPropertyList(PropertyExportReqVO exportReqVO) {
|
||||
return propertyMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue