调整商品代码生成模块
parent
657e4d035b
commit
2bbfa40265
@ -1,100 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.attrkey;
|
||||
|
||||
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.attrkey.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.attrkey.AttrKeyDO;
|
||||
import cn.iocoder.yudao.module.product.convert.attrkey.AttrKeyConvert;
|
||||
import cn.iocoder.yudao.module.product.service.attrkey.AttrKeyService;
|
||||
|
||||
@Api(tags = "管理后台 - 规格名称")
|
||||
@RestController
|
||||
@RequestMapping("/product/attr-key")
|
||||
@Validated
|
||||
public class AttrKeyController {
|
||||
|
||||
@Resource
|
||||
private AttrKeyService attrKeyService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建规格名称")
|
||||
@PreAuthorize("@ss.hasPermission('product:attr-key:create')")
|
||||
public CommonResult<Integer> createAttrKey(@Valid @RequestBody AttrKeyCreateReqVO createReqVO) {
|
||||
return success(attrKeyService.createAttrKey(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新规格名称")
|
||||
@PreAuthorize("@ss.hasPermission('product:attr-key:update')")
|
||||
public CommonResult<Boolean> updateAttrKey(@Valid @RequestBody AttrKeyUpdateReqVO updateReqVO) {
|
||||
attrKeyService.updateAttrKey(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除规格名称")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Integer.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:attr-key:delete')")
|
||||
public CommonResult<Boolean> deleteAttrKey(@RequestParam("id") Integer id) {
|
||||
attrKeyService.deleteAttrKey(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得规格名称")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Integer.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:attr-key:query')")
|
||||
public CommonResult<AttrKeyRespVO> getAttrKey(@RequestParam("id") Integer id) {
|
||||
AttrKeyDO attrKey = attrKeyService.getAttrKey(id);
|
||||
return success(AttrKeyConvert.INSTANCE.convert(attrKey));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得规格名称列表")
|
||||
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:attr-key:query')")
|
||||
public CommonResult<List<AttrKeyRespVO>> getAttrKeyList(@RequestParam("ids") Collection<Integer> ids) {
|
||||
List<AttrKeyDO> list = attrKeyService.getAttrKeyList(ids);
|
||||
return success(AttrKeyConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得规格名称分页")
|
||||
@PreAuthorize("@ss.hasPermission('product:attr-key:query')")
|
||||
public CommonResult<PageResult<AttrKeyRespVO>> getAttrKeyPage(@Valid AttrKeyPageReqVO pageVO) {
|
||||
PageResult<AttrKeyDO> pageResult = attrKeyService.getAttrKeyPage(pageVO);
|
||||
return success(AttrKeyConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出规格名称 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('product:attr-key:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportAttrKeyExcel(@Valid AttrKeyExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<AttrKeyDO> list = attrKeyService.getAttrKeyList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<AttrKeyExcelVO> datas = AttrKeyConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "规格名称.xls", "数据", AttrKeyExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,100 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.attrvalue;
|
||||
|
||||
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.attrvalue.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.attrvalue.AttrValueDO;
|
||||
import cn.iocoder.yudao.module.product.convert.attrvalue.AttrValueConvert;
|
||||
import cn.iocoder.yudao.module.product.service.attrvalue.AttrValueService;
|
||||
|
||||
@Api(tags = "管理后台 - 规格值")
|
||||
@RestController
|
||||
@RequestMapping("/product/attr-value")
|
||||
@Validated
|
||||
public class AttrValueController {
|
||||
|
||||
@Resource
|
||||
private AttrValueService attrValueService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建规格值")
|
||||
@PreAuthorize("@ss.hasPermission('product:attr-value:create')")
|
||||
public CommonResult<Integer> createAttrValue(@Valid @RequestBody AttrValueCreateReqVO createReqVO) {
|
||||
return success(attrValueService.createAttrValue(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新规格值")
|
||||
@PreAuthorize("@ss.hasPermission('product:attr-value:update')")
|
||||
public CommonResult<Boolean> updateAttrValue(@Valid @RequestBody AttrValueUpdateReqVO updateReqVO) {
|
||||
attrValueService.updateAttrValue(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除规格值")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Integer.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:attr-value:delete')")
|
||||
public CommonResult<Boolean> deleteAttrValue(@RequestParam("id") Integer id) {
|
||||
attrValueService.deleteAttrValue(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得规格值")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Integer.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:attr-value:query')")
|
||||
public CommonResult<AttrValueRespVO> getAttrValue(@RequestParam("id") Integer id) {
|
||||
AttrValueDO attrValue = attrValueService.getAttrValue(id);
|
||||
return success(AttrValueConvert.INSTANCE.convert(attrValue));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得规格值列表")
|
||||
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:attr-value:query')")
|
||||
public CommonResult<List<AttrValueRespVO>> getAttrValueList(@RequestParam("ids") Collection<Integer> ids) {
|
||||
List<AttrValueDO> list = attrValueService.getAttrValueList(ids);
|
||||
return success(AttrValueConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得规格值分页")
|
||||
@PreAuthorize("@ss.hasPermission('product:attr-value:query')")
|
||||
public CommonResult<PageResult<AttrValueRespVO>> getAttrValuePage(@Valid AttrValuePageReqVO pageVO) {
|
||||
PageResult<AttrValueDO> pageResult = attrValueService.getAttrValuePage(pageVO);
|
||||
return success(AttrValueConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出规格值 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('product:attr-value:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportAttrValueExcel(@Valid AttrValueExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<AttrValueDO> list = attrValueService.getAttrValueList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<AttrValueExcelVO> datas = AttrValueConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "规格值.xls", "数据", AttrValueExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,100 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.property;
|
||||
|
||||
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.property.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.PropertyDO;
|
||||
import cn.iocoder.yudao.module.product.convert.property.PropertyConvert;
|
||||
import cn.iocoder.yudao.module.product.service.property.PropertyService;
|
||||
|
||||
@Api(tags = "管理后台 - 规格名称")
|
||||
@RestController
|
||||
@RequestMapping("/product/property")
|
||||
@Validated
|
||||
public class PropertyController {
|
||||
|
||||
@Resource
|
||||
private PropertyService propertyService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建规格名称")
|
||||
@PreAuthorize("@ss.hasPermission('product:property:create')")
|
||||
public CommonResult<Long> createProperty(@Valid @RequestBody PropertyCreateReqVO createReqVO) {
|
||||
return success(propertyService.createProperty(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新规格名称")
|
||||
@PreAuthorize("@ss.hasPermission('product:property:update')")
|
||||
public CommonResult<Boolean> updateProperty(@Valid @RequestBody PropertyUpdateReqVO updateReqVO) {
|
||||
propertyService.updateProperty(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除规格名称")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:property:delete')")
|
||||
public CommonResult<Boolean> deleteProperty(@RequestParam("id") Long id) {
|
||||
propertyService.deleteProperty(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得规格名称")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:property:query')")
|
||||
public CommonResult<PropertyRespVO> getProperty(@RequestParam("id") Long id) {
|
||||
PropertyDO property = propertyService.getProperty(id);
|
||||
return success(PropertyConvert.INSTANCE.convert(property));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得规格名称列表")
|
||||
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
|
||||
@PreAuthorize("@ss.hasPermission('product:property:query')")
|
||||
public CommonResult<List<PropertyRespVO>> getPropertyList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<PropertyDO> list = propertyService.getPropertyList(ids);
|
||||
return success(PropertyConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得规格名称分页")
|
||||
@PreAuthorize("@ss.hasPermission('product:property:query')")
|
||||
public CommonResult<PageResult<PropertyRespVO>> getPropertyPage(@Valid PropertyPageReqVO pageVO) {
|
||||
PageResult<PropertyDO> pageResult = propertyService.getPropertyPage(pageVO);
|
||||
return success(PropertyConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出规格名称 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('product:property:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportPropertyExcel(@Valid PropertyExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<PropertyDO> list = propertyService.getPropertyList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<PropertyExcelVO> datas = PropertyConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "规格名称.xls", "数据", PropertyExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,100 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
4
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrvalue/vo/AttrValueCreateReqVO.java → yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/PropertyValueCreateReqVO.java
4
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrvalue/vo/AttrValueCreateReqVO.java → yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/PropertyValueCreateReqVO.java
24
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrvalue/vo/AttrValueExportReqVO.java → yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/PropertyValueExportReqVO.java
24
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrvalue/vo/AttrValueExportReqVO.java → yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/PropertyValueExportReqVO.java
4
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrvalue/vo/AttrValueUpdateReqVO.java → yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/PropertyValueUpdateReqVO.java
4
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrvalue/vo/AttrValueUpdateReqVO.java → yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/PropertyValueUpdateReqVO.java
@ -1,34 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.convert.attrkey;
|
||||
|
||||
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.attrkey.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.attrkey.AttrKeyDO;
|
||||
|
||||
/**
|
||||
* 规格名称 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface AttrKeyConvert {
|
||||
|
||||
AttrKeyConvert INSTANCE = Mappers.getMapper(AttrKeyConvert.class);
|
||||
|
||||
AttrKeyDO convert(AttrKeyCreateReqVO bean);
|
||||
|
||||
AttrKeyDO convert(AttrKeyUpdateReqVO bean);
|
||||
|
||||
AttrKeyRespVO convert(AttrKeyDO bean);
|
||||
|
||||
List<AttrKeyRespVO> convertList(List<AttrKeyDO> list);
|
||||
|
||||
PageResult<AttrKeyRespVO> convertPage(PageResult<AttrKeyDO> page);
|
||||
|
||||
List<AttrKeyExcelVO> convertList02(List<AttrKeyDO> list);
|
||||
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.convert.attrvalue;
|
||||
|
||||
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.attrvalue.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.attrvalue.AttrValueDO;
|
||||
|
||||
/**
|
||||
* 规格值 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface AttrValueConvert {
|
||||
|
||||
AttrValueConvert INSTANCE = Mappers.getMapper(AttrValueConvert.class);
|
||||
|
||||
AttrValueDO convert(AttrValueCreateReqVO bean);
|
||||
|
||||
AttrValueDO convert(AttrValueUpdateReqVO bean);
|
||||
|
||||
AttrValueRespVO convert(AttrValueDO bean);
|
||||
|
||||
List<AttrValueRespVO> convertList(List<AttrValueDO> list);
|
||||
|
||||
PageResult<AttrValueRespVO> convertPage(PageResult<AttrValueDO> page);
|
||||
|
||||
List<AttrValueExcelVO> convertList02(List<AttrValueDO> list);
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
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 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);
|
||||
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.dal.mysql.attrkey;
|
||||
|
||||
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.attrkey.AttrKeyDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.attrkey.vo.*;
|
||||
|
||||
/**
|
||||
* 规格名称 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface AttrKeyMapper extends BaseMapperX<AttrKeyDO> {
|
||||
|
||||
default PageResult<AttrKeyDO> selectPage(AttrKeyPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<AttrKeyDO>()
|
||||
.betweenIfPresent(AttrKeyDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.likeIfPresent(AttrKeyDO::getAttrName, reqVO.getAttrName())
|
||||
.eqIfPresent(AttrKeyDO::getStatus, reqVO.getStatus())
|
||||
.orderByDesc(AttrKeyDO::getId));
|
||||
}
|
||||
|
||||
default List<AttrKeyDO> selectList(AttrKeyExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<AttrKeyDO>()
|
||||
.betweenIfPresent(AttrKeyDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.likeIfPresent(AttrKeyDO::getAttrName, reqVO.getAttrName())
|
||||
.eqIfPresent(AttrKeyDO::getStatus, reqVO.getStatus())
|
||||
.orderByDesc(AttrKeyDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.dal.mysql.attrvalue;
|
||||
|
||||
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.attrvalue.AttrValueDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo.*;
|
||||
|
||||
/**
|
||||
* 规格值 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface AttrValueMapper extends BaseMapperX<AttrValueDO> {
|
||||
|
||||
default PageResult<AttrValueDO> selectPage(AttrValuePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<AttrValueDO>()
|
||||
.betweenIfPresent(AttrValueDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.eqIfPresent(AttrValueDO::getAttrKeyId, reqVO.getAttrKeyId())
|
||||
.likeIfPresent(AttrValueDO::getAttrValueName, reqVO.getAttrValueName())
|
||||
.eqIfPresent(AttrValueDO::getStatus, reqVO.getStatus())
|
||||
.orderByDesc(AttrValueDO::getId));
|
||||
}
|
||||
|
||||
default List<AttrValueDO> selectList(AttrValueExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<AttrValueDO>()
|
||||
.betweenIfPresent(AttrValueDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.eqIfPresent(AttrValueDO::getAttrKeyId, reqVO.getAttrKeyId())
|
||||
.likeIfPresent(AttrValueDO::getAttrValueName, reqVO.getAttrValueName())
|
||||
.eqIfPresent(AttrValueDO::getStatus, reqVO.getStatus())
|
||||
.orderByDesc(AttrValueDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -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.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,38 @@
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,82 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.service.attrkey;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.attrkey.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.attrkey.AttrKeyDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import cn.iocoder.yudao.module.product.convert.attrkey.AttrKeyConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.attrkey.AttrKeyMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 规格名称 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class AttrKeyServiceImpl implements AttrKeyService {
|
||||
|
||||
@Resource
|
||||
private AttrKeyMapper attrKeyMapper;
|
||||
|
||||
@Override
|
||||
public Integer createAttrKey(AttrKeyCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
AttrKeyDO attrKey = AttrKeyConvert.INSTANCE.convert(createReqVO);
|
||||
attrKeyMapper.insert(attrKey);
|
||||
// 返回
|
||||
return attrKey.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAttrKey(AttrKeyUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validateAttrKeyExists(updateReqVO.getId());
|
||||
// 更新
|
||||
AttrKeyDO updateObj = AttrKeyConvert.INSTANCE.convert(updateReqVO);
|
||||
attrKeyMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAttrKey(Integer id) {
|
||||
// 校验存在
|
||||
this.validateAttrKeyExists(id);
|
||||
// 删除
|
||||
attrKeyMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateAttrKeyExists(Integer id) {
|
||||
if (attrKeyMapper.selectById(id) == null) {
|
||||
throw exception(ATTR_KEY_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttrKeyDO getAttrKey(Integer id) {
|
||||
return attrKeyMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttrKeyDO> getAttrKeyList(Collection<Integer> ids) {
|
||||
return attrKeyMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<AttrKeyDO> getAttrKeyPage(AttrKeyPageReqVO pageReqVO) {
|
||||
return attrKeyMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttrKeyDO> getAttrKeyList(AttrKeyExportReqVO exportReqVO) {
|
||||
return attrKeyMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,82 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.service.attrvalue;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.attrvalue.AttrValueDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import cn.iocoder.yudao.module.product.convert.attrvalue.AttrValueConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.attrvalue.AttrValueMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 规格值 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class AttrValueServiceImpl implements AttrValueService {
|
||||
|
||||
@Resource
|
||||
private AttrValueMapper attrValueMapper;
|
||||
|
||||
@Override
|
||||
public Integer createAttrValue(AttrValueCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
AttrValueDO attrValue = AttrValueConvert.INSTANCE.convert(createReqVO);
|
||||
attrValueMapper.insert(attrValue);
|
||||
// 返回
|
||||
return attrValue.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAttrValue(AttrValueUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validateAttrValueExists(updateReqVO.getId());
|
||||
// 更新
|
||||
AttrValueDO updateObj = AttrValueConvert.INSTANCE.convert(updateReqVO);
|
||||
attrValueMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAttrValue(Integer id) {
|
||||
// 校验存在
|
||||
this.validateAttrValueExists(id);
|
||||
// 删除
|
||||
attrValueMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateAttrValueExists(Integer id) {
|
||||
if (attrValueMapper.selectById(id) == null) {
|
||||
throw exception(ATTR_VALUE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttrValueDO getAttrValue(Integer id) {
|
||||
return attrValueMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttrValueDO> getAttrValueList(Collection<Integer> ids) {
|
||||
return attrValueMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<AttrValueDO> getAttrValuePage(AttrValuePageReqVO pageReqVO) {
|
||||
return attrValueMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttrValueDO> getAttrValueList(AttrValueExportReqVO exportReqVO) {
|
||||
return attrValueMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
package cn.iocoder.yudao.module.product.service.property;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.PropertyDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import cn.iocoder.yudao.module.product.convert.property.PropertyConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.property.PropertyMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 规格名称 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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
package cn.iocoder.yudao.module.product.service.propertyvalue;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.propertyvalue.PropertyValueDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import cn.iocoder.yudao.module.product.convert.propertyvalue.PropertyValueConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.propertyvalue.PropertyValueMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 规格值 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class PropertyValueServiceImpl implements PropertyValueService {
|
||||
|
||||
@Resource
|
||||
private PropertyValueMapper propertyValueMapper;
|
||||
|
||||
@Override
|
||||
public Integer createPropertyValue(PropertyValueCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
PropertyValueDO propertyValue = PropertyValueConvert.INSTANCE.convert(createReqVO);
|
||||
propertyValueMapper.insert(propertyValue);
|
||||
// 返回
|
||||
return propertyValue.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePropertyValue(PropertyValueUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validatePropertyValueExists(updateReqVO.getId());
|
||||
// 更新
|
||||
PropertyValueDO updateObj = PropertyValueConvert.INSTANCE.convert(updateReqVO);
|
||||
propertyValueMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePropertyValue(Integer id) {
|
||||
// 校验存在
|
||||
this.validatePropertyValueExists(id);
|
||||
// 删除
|
||||
propertyValueMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validatePropertyValueExists(Integer id) {
|
||||
if (propertyValueMapper.selectById(id) == null) {
|
||||
throw exception(PROPERTY_VALUE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyValueDO getPropertyValue(Integer id) {
|
||||
return propertyValueMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PropertyValueDO> getPropertyValueList(Collection<Integer> ids) {
|
||||
return propertyValueMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<PropertyValueDO> getPropertyValuePage(PropertyValuePageReqVO pageReqVO) {
|
||||
return propertyValueMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PropertyValueDO> getPropertyValueList(PropertyValueExportReqVO exportReqVO) {
|
||||
return propertyValueMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,168 +0,0 @@
|
||||
package cn.iocoder.yudao.module.product.service.attrkey;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
import cn.iocoder.yudao.module.product.controller.admin.attrkey.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.attrkey.AttrKeyDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.attrkey.AttrKeyMapper;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.*;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* {@link AttrKeyServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Import(AttrKeyServiceImpl.class)
|
||||
public class AttrKeyServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private AttrKeyServiceImpl attrKeyService;
|
||||
|
||||
@Resource
|
||||
private AttrKeyMapper attrKeyMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateAttrKey_success() {
|
||||
// 准备参数
|
||||
AttrKeyCreateReqVO reqVO = randomPojo(AttrKeyCreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
Integer attrKeyId = attrKeyService.createAttrKey(reqVO);
|
||||
// 断言
|
||||
assertNotNull(attrKeyId);
|
||||
// 校验记录的属性是否正确
|
||||
AttrKeyDO attrKey = attrKeyMapper.selectById(attrKeyId);
|
||||
assertPojoEquals(reqVO, attrKey);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAttrKey_success() {
|
||||
// mock 数据
|
||||
AttrKeyDO dbAttrKey = randomPojo(AttrKeyDO.class);
|
||||
attrKeyMapper.insert(dbAttrKey);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
AttrKeyUpdateReqVO reqVO = randomPojo(AttrKeyUpdateReqVO.class, o -> {
|
||||
o.setId(dbAttrKey.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
attrKeyService.updateAttrKey(reqVO);
|
||||
// 校验是否更新正确
|
||||
AttrKeyDO attrKey = attrKeyMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, attrKey);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAttrKey_notExists() {
|
||||
// 准备参数
|
||||
AttrKeyUpdateReqVO reqVO = randomPojo(AttrKeyUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> attrKeyService.updateAttrKey(reqVO), ATTR_KEY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteAttrKey_success() {
|
||||
// mock 数据
|
||||
AttrKeyDO dbAttrKey = randomPojo(AttrKeyDO.class);
|
||||
attrKeyMapper.insert(dbAttrKey);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Integer id = dbAttrKey.getId();
|
||||
|
||||
// 调用
|
||||
attrKeyService.deleteAttrKey(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(attrKeyMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteAttrKey_notExists() {
|
||||
// 准备参数
|
||||
// Integer id = randomIntegerId();
|
||||
Integer id = 1;
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> attrKeyService.deleteAttrKey(id), ATTR_KEY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetAttrKeyPage() {
|
||||
// mock 数据
|
||||
AttrKeyDO dbAttrKey = randomPojo(AttrKeyDO.class, o -> { // 等会查询到
|
||||
o.setCreateTime(null);
|
||||
o.setAttrName(null);
|
||||
o.setStatus(null);
|
||||
});
|
||||
attrKeyMapper.insert(dbAttrKey);
|
||||
// 测试 createTime 不匹配
|
||||
attrKeyMapper.insert(cloneIgnoreId(dbAttrKey, o -> o.setCreateTime(null)));
|
||||
// 测试 attrName 不匹配
|
||||
attrKeyMapper.insert(cloneIgnoreId(dbAttrKey, o -> o.setAttrName(null)));
|
||||
// 测试 status 不匹配
|
||||
attrKeyMapper.insert(cloneIgnoreId(dbAttrKey, o -> o.setStatus(null)));
|
||||
// 准备参数
|
||||
AttrKeyPageReqVO reqVO = new AttrKeyPageReqVO();
|
||||
reqVO.setBeginCreateTime(null);
|
||||
reqVO.setEndCreateTime(null);
|
||||
reqVO.setAttrName(null);
|
||||
reqVO.setStatus(null);
|
||||
|
||||
// 调用
|
||||
PageResult<AttrKeyDO> pageResult = attrKeyService.getAttrKeyPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbAttrKey, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetAttrKeyList() {
|
||||
// mock 数据
|
||||
AttrKeyDO dbAttrKey = randomPojo(AttrKeyDO.class, o -> { // 等会查询到
|
||||
o.setCreateTime(null);
|
||||
o.setAttrName(null);
|
||||
o.setStatus(null);
|
||||
});
|
||||
attrKeyMapper.insert(dbAttrKey);
|
||||
// 测试 createTime 不匹配
|
||||
attrKeyMapper.insert(cloneIgnoreId(dbAttrKey, o -> o.setCreateTime(null)));
|
||||
// 测试 attrName 不匹配
|
||||
attrKeyMapper.insert(cloneIgnoreId(dbAttrKey, o -> o.setAttrName(null)));
|
||||
// 测试 status 不匹配
|
||||
attrKeyMapper.insert(cloneIgnoreId(dbAttrKey, o -> o.setStatus(null)));
|
||||
// 准备参数
|
||||
AttrKeyExportReqVO reqVO = new AttrKeyExportReqVO();
|
||||
reqVO.setBeginCreateTime(null);
|
||||
reqVO.setEndCreateTime(null);
|
||||
reqVO.setAttrName(null);
|
||||
reqVO.setStatus(null);
|
||||
|
||||
// 调用
|
||||
List<AttrKeyDO> list = attrKeyService.getAttrKeyList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbAttrKey, list.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue