Merge remote-tracking branch 'origin/feature/1.8.0-uniapp' into feature/1.8.0-uniapp
commit
72019f727e
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.property.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.ProductPropertyValueCreateReqVO;
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("管理后台 - 规格名称创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ProductPropertyCreateReqVO extends ProductPropertyBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "属性值")
|
||||
@NotNull(message = "属性值不能为空")
|
||||
List<ProductPropertyValueCreateReqVO> propertyValueList;
|
||||
|
||||
}
|
||||
@ -1,18 +1,23 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.property.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.ProductPropertyValueCreateReqVO;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("管理后台 - 规格名称更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PropertyUpdateReqVO extends PropertyBaseVO {
|
||||
public class ProductPropertyUpdateReqVO extends ProductPropertyBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "主键", required = true)
|
||||
@NotNull(message = "主键不能为空")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "属性值")
|
||||
@NotNull(message = "属性值不能为空")
|
||||
List<ProductPropertyValueCreateReqVO> propertyValueList;
|
||||
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
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 {
|
||||
|
||||
}
|
||||
@ -1,100 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.propertyvalue;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.propertyvalue.PropertyValueDO;
|
||||
import cn.iocoder.yudao.module.product.convert.propertyvalue.PropertyValueConvert;
|
||||
import cn.iocoder.yudao.module.product.service.propertyvalue.PropertyValueService;
|
||||
|
||||
@Api(tags = "管理后台 - 规格值")
|
||||
@RestController
|
||||
@RequestMapping("/product/property-value")
|
||||
@Validated
|
||||
public class PropertyValueController {
|
||||
|
||||
@Resource
|
||||
private PropertyValueService propertyValueService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建规格值")
|
||||
@PreAuthorize("@ss.hasPermission('product:property-value:create')")
|
||||
public CommonResult<Integer> createPropertyValue(@Valid @RequestBody PropertyValueCreateReqVO createReqVO) {
|
||||
return success(propertyValueService.createPropertyValue(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新规格值")
|
||||
@PreAuthorize("@ss.hasPermission('product:property-value:update')")
|
||||
public CommonResult<Boolean> updatePropertyValue(@Valid @RequestBody PropertyValueUpdateReqVO updateReqVO) {
|
||||
propertyValueService.updatePropertyValue(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除规格值")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Integer.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:property-value:delete')")
|
||||
public CommonResult<Boolean> deletePropertyValue(@RequestParam("id") Integer id) {
|
||||
propertyValueService.deletePropertyValue(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得规格值")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Integer.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:property-value:query')")
|
||||
public CommonResult<PropertyValueRespVO> getPropertyValue(@RequestParam("id") Integer id) {
|
||||
PropertyValueDO propertyValue = propertyValueService.getPropertyValue(id);
|
||||
return success(PropertyValueConvert.INSTANCE.convert(propertyValue));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得规格值列表")
|
||||
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:property-value:query')")
|
||||
public CommonResult<List<PropertyValueRespVO>> getPropertyValueList(@RequestParam("ids") Collection<Integer> ids) {
|
||||
List<PropertyValueDO> list = propertyValueService.getPropertyValueList(ids);
|
||||
return success(PropertyValueConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得规格值分页")
|
||||
@PreAuthorize("@ss.hasPermission('product:property-value:query')")
|
||||
public CommonResult<PageResult<PropertyValueRespVO>> getPropertyValuePage(@Valid PropertyValuePageReqVO pageVO) {
|
||||
PageResult<PropertyValueDO> pageResult = propertyValueService.getPropertyValuePage(pageVO);
|
||||
return success(PropertyValueConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出规格值 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('product:property-value:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportPropertyValueExcel(@Valid PropertyValueExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<PropertyValueDO> list = propertyValueService.getPropertyValueList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<PropertyValueExcelVO> datas = PropertyValueConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "规格值.xls", "数据", PropertyValueExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
||||
2
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/PropertyValueBaseVO.java → yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/ProductPropertyValueBaseVO.java
2
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/PropertyValueBaseVO.java → yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/ProductPropertyValueBaseVO.java
4
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/PropertyValueCreateReqVO.java → yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/ProductPropertyValueCreateReqVO.java
4
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/PropertyValueCreateReqVO.java → yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/ProductPropertyValueCreateReqVO.java
@ -1,14 +1,12 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.propertyvalue.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 PropertyValueCreateReqVO extends PropertyValueBaseVO {
|
||||
public class ProductPropertyValueCreateReqVO extends ProductPropertyValueBaseVO {
|
||||
|
||||
}
|
||||
2
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/PropertyValueRespVO.java → yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/ProductPropertyValueRespVO.java
2
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/PropertyValueRespVO.java → yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/ProductPropertyValueRespVO.java
3
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/PropertyValueUpdateReqVO.java → yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/ProductPropertyValueUpdateReqVO.java
3
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/PropertyValueUpdateReqVO.java → yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/ProductPropertyValueUpdateReqVO.java
@ -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,34 @@
|
||||
package cn.iocoder.yudao.module.product.convert.propertyvalue;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.propertyvalue.ProductPropertyValueDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.*;
|
||||
|
||||
/**
|
||||
* 规格值 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProductPropertyValueConvert {
|
||||
|
||||
ProductPropertyValueConvert INSTANCE = Mappers.getMapper(ProductPropertyValueConvert.class);
|
||||
|
||||
ProductPropertyValueDO convert(ProductPropertyValueCreateReqVO bean);
|
||||
|
||||
ProductPropertyValueDO convert(ProductPropertyValueUpdateReqVO bean);
|
||||
|
||||
ProductPropertyValueRespVO convert(ProductPropertyValueDO bean);
|
||||
|
||||
List<ProductPropertyValueRespVO> convertList(List<ProductPropertyValueDO> list);
|
||||
|
||||
PageResult<ProductPropertyValueRespVO> convertPage(PageResult<ProductPropertyValueDO> page);
|
||||
|
||||
List<ProductPropertyValueDO> convertList03(List<ProductPropertyValueCreateReqVO> list);
|
||||
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.convert.propertyvalue;
|
||||
|
||||
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.propertyvalue.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.propertyvalue.PropertyValueDO;
|
||||
|
||||
/**
|
||||
* 规格值 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface PropertyValueConvert {
|
||||
|
||||
PropertyValueConvert INSTANCE = Mappers.getMapper(PropertyValueConvert.class);
|
||||
|
||||
PropertyValueDO convert(PropertyValueCreateReqVO bean);
|
||||
|
||||
PropertyValueDO convert(PropertyValueUpdateReqVO bean);
|
||||
|
||||
PropertyValueRespVO convert(PropertyValueDO bean);
|
||||
|
||||
List<PropertyValueRespVO> convertList(List<PropertyValueDO> list);
|
||||
|
||||
PageResult<PropertyValueRespVO> convertPage(PageResult<PropertyValueDO> page);
|
||||
|
||||
List<PropertyValueExcelVO> convertList02(List<PropertyValueDO> 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,29 @@
|
||||
package cn.iocoder.yudao.module.product.dal.mysql.propertyvalue;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
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.propertyvalue.ProductPropertyValueDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 规格值 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProductPropertyValueMapper extends BaseMapperX<ProductPropertyValueDO> {
|
||||
|
||||
default List<ProductPropertyValueDO> getPropertyValueListByPropertyId(List<Long> propertyIds){
|
||||
return selectList(new LambdaQueryWrapperX<ProductPropertyValueDO>()
|
||||
.inIfPresent(ProductPropertyValueDO::getPropertyId, propertyIds));
|
||||
}
|
||||
|
||||
default void deletePropertyValueByPropertyId(Long propertyId){
|
||||
LambdaQueryWrapperX<ProductPropertyValueDO> queryWrapperX = new LambdaQueryWrapperX<>();
|
||||
queryWrapperX.eq(ProductPropertyValueDO::getPropertyId, propertyId)
|
||||
.eq(ProductPropertyValueDO::getDeleted, false);
|
||||
delete(queryWrapperX);
|
||||
}
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.dal.mysql.propertyvalue;
|
||||
|
||||
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.propertyvalue.PropertyValueDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.*;
|
||||
|
||||
/**
|
||||
* 规格值 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface PropertyValueMapper extends BaseMapperX<PropertyValueDO> {
|
||||
|
||||
default PageResult<PropertyValueDO> selectPage(PropertyValuePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<PropertyValueDO>()
|
||||
.eqIfPresent(PropertyValueDO::getPropertyId, reqVO.getPropertyId())
|
||||
.likeIfPresent(PropertyValueDO::getName, reqVO.getName())
|
||||
.eqIfPresent(PropertyValueDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(PropertyValueDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc(PropertyValueDO::getId));
|
||||
}
|
||||
|
||||
default List<PropertyValueDO> selectList(PropertyValueExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<PropertyValueDO>()
|
||||
.eqIfPresent(PropertyValueDO::getPropertyId, reqVO.getPropertyId())
|
||||
.likeIfPresent(PropertyValueDO::getName, reqVO.getName())
|
||||
.eqIfPresent(PropertyValueDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(PropertyValueDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc(PropertyValueDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,143 @@
|
||||
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.controller.admin.propertyvalue.vo.ProductPropertyValueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.ProductPropertyValueRespVO;
|
||||
import cn.iocoder.yudao.module.product.convert.property.ProductPropertyConvert;
|
||||
import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.propertyvalue.ProductPropertyValueDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyMapper;
|
||||
import cn.iocoder.yudao.module.product.service.propertyvalue.ProductPropertyValueService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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;
|
||||
|
||||
@Resource
|
||||
private ProductPropertyValueService productPropertyValueService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createProperty(ProductPropertyCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
ProductPropertyDO property = ProductPropertyConvert.INSTANCE.convert(createReqVO);
|
||||
productPropertyMapper.insert(property);
|
||||
|
||||
//插入属性值
|
||||
List<ProductPropertyValueCreateReqVO> propertyValueList = createReqVO.getPropertyValueList();
|
||||
List<ProductPropertyValueDO> productPropertyValueDOList = ProductPropertyValueConvert.INSTANCE.convertList03(propertyValueList);
|
||||
productPropertyValueDOList.stream().forEach(x-> x.setPropertyId(property.getId()));
|
||||
productPropertyValueService.batchInsert(productPropertyValueDOList);
|
||||
// 返回
|
||||
return property.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateProperty(ProductPropertyUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validatePropertyExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ProductPropertyDO updateObj = ProductPropertyConvert.INSTANCE.convert(updateReqVO);
|
||||
productPropertyMapper.updateById(updateObj);
|
||||
//更新属性值,先删后加
|
||||
productPropertyValueService.deletePropertyValueByPropertyId(updateReqVO.getId());
|
||||
List<ProductPropertyValueCreateReqVO> propertyValueList = updateReqVO.getPropertyValueList();
|
||||
List<ProductPropertyValueDO> productPropertyValueDOList = ProductPropertyValueConvert.INSTANCE.convertList03(propertyValueList);
|
||||
productPropertyValueDOList.stream().forEach(x-> x.setPropertyId(updateReqVO.getId()));
|
||||
productPropertyValueService.batchInsert(productPropertyValueDOList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteProperty(Long id) {
|
||||
// 校验存在
|
||||
this.validatePropertyExists(id);
|
||||
// 删除
|
||||
productPropertyMapper.deleteById(id);
|
||||
//同步删除属性值
|
||||
productPropertyValueService.deletePropertyValueByPropertyId(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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProductPropertyRespVO> getPropertyListPage(ProductPropertyPageReqVO pageReqVO) {
|
||||
//获取属性列表
|
||||
PageResult<ProductPropertyDO> pageResult = productPropertyMapper.selectPage(pageReqVO);
|
||||
PageResult<ProductPropertyRespVO> propertyRespVOPageResult = ProductPropertyConvert.INSTANCE.convertPage(pageResult);
|
||||
List<Long> propertyIds = propertyRespVOPageResult.getList().stream().map(x -> x.getId()).collect(Collectors.toList());
|
||||
|
||||
//获取属性值列表
|
||||
List<ProductPropertyValueDO> productPropertyValueDOList = productPropertyValueService.getPropertyValueListByPropertyId(propertyIds);
|
||||
List<ProductPropertyValueRespVO> propertyValueRespVOList = ProductPropertyValueConvert.INSTANCE.convertList(productPropertyValueDOList);
|
||||
//组装一对多
|
||||
propertyRespVOPageResult.getList().stream().forEach(x->{
|
||||
Long propertyId = x.getId();
|
||||
List<ProductPropertyValueRespVO> valueDOList = propertyValueRespVOList.stream().filter(v -> v.getPropertyId().equals(propertyId)).collect(Collectors.toList());
|
||||
x.setPropertyValueList(valueDOList);
|
||||
});
|
||||
return propertyRespVOPageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductPropertyRespVO getPropertyResp(Long id) {
|
||||
//查询规格
|
||||
ProductPropertyDO property = getProperty(id);
|
||||
ProductPropertyRespVO propertyRespVO = ProductPropertyConvert.INSTANCE.convert(property);
|
||||
//查询属性值
|
||||
List<ProductPropertyValueDO> valueDOList = productPropertyValueService.getPropertyValueListByPropertyId(Arrays.asList(id));
|
||||
List<ProductPropertyValueRespVO> propertyValueRespVOS = ProductPropertyValueConvert.INSTANCE.convertList(valueDOList);
|
||||
//组装
|
||||
propertyRespVO.setPropertyValueList(propertyValueRespVOS);
|
||||
return propertyRespVO;
|
||||
}
|
||||
|
||||
}
|
||||
@ -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