Commit 9f9004624b0b9954e74d0ea4cf2be445bb7f8339
1 parent
0d017e4b
商品规格属性代码生成
Showing
29 changed files
with
1233 additions
and
1 deletions
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java
| ... | ... | @@ -16,4 +16,10 @@ public interface ErrorCodeConstants { |
| 16 | 16 | |
| 17 | 17 | // ========== 品牌相关编号 1008002000 ========== |
| 18 | 18 | ErrorCode BRAND_NOT_EXISTS = new ErrorCode(1008002000, "品牌不存在"); |
| 19 | + | |
| 20 | + // ========== 规格名称 1008003000 ========== | |
| 21 | + ErrorCode ATTR_KEY_NOT_EXISTS = new ErrorCode(1008003000, "规格名称不存在"); | |
| 22 | + | |
| 23 | + // ========== 规格值 1008004000 ========== | |
| 24 | + ErrorCode ATTR_VALUE_NOT_EXISTS = new ErrorCode(1008004000, "规格值不存在"); | |
| 19 | 25 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrkey/AttrKeyController.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.attrkey; | |
| 2 | + | |
| 3 | +import org.springframework.web.bind.annotation.*; | |
| 4 | +import javax.annotation.Resource; | |
| 5 | +import org.springframework.validation.annotation.Validated; | |
| 6 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 7 | +import io.swagger.annotations.*; | |
| 8 | + | |
| 9 | +import javax.validation.constraints.*; | |
| 10 | +import javax.validation.*; | |
| 11 | +import javax.servlet.http.*; | |
| 12 | +import java.util.*; | |
| 13 | +import java.io.IOException; | |
| 14 | + | |
| 15 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 16 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 17 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 18 | + | |
| 19 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 20 | + | |
| 21 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | |
| 22 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | |
| 23 | + | |
| 24 | +import cn.iocoder.yudao.module.product.controller.admin.attrkey.vo.*; | |
| 25 | +import cn.iocoder.yudao.module.product.dal.dataobject.attrkey.AttrKeyDO; | |
| 26 | +import cn.iocoder.yudao.module.product.convert.attrkey.AttrKeyConvert; | |
| 27 | +import cn.iocoder.yudao.module.product.service.attrkey.AttrKeyService; | |
| 28 | + | |
| 29 | +@Api(tags = "管理后台 - 规格名称") | |
| 30 | +@RestController | |
| 31 | +@RequestMapping("/product/attr-key") | |
| 32 | +@Validated | |
| 33 | +public class AttrKeyController { | |
| 34 | + | |
| 35 | + @Resource | |
| 36 | + private AttrKeyService attrKeyService; | |
| 37 | + | |
| 38 | + @PostMapping("/create") | |
| 39 | + @ApiOperation("创建规格名称") | |
| 40 | + @PreAuthorize("@ss.hasPermission('product:attr-key:create')") | |
| 41 | + public CommonResult<Integer> createAttrKey(@Valid @RequestBody AttrKeyCreateReqVO createReqVO) { | |
| 42 | + return success(attrKeyService.createAttrKey(createReqVO)); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @PutMapping("/update") | |
| 46 | + @ApiOperation("更新规格名称") | |
| 47 | + @PreAuthorize("@ss.hasPermission('product:attr-key:update')") | |
| 48 | + public CommonResult<Boolean> updateAttrKey(@Valid @RequestBody AttrKeyUpdateReqVO updateReqVO) { | |
| 49 | + attrKeyService.updateAttrKey(updateReqVO); | |
| 50 | + return success(true); | |
| 51 | + } | |
| 52 | + | |
| 53 | + @DeleteMapping("/delete") | |
| 54 | + @ApiOperation("删除规格名称") | |
| 55 | + @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Integer.class) | |
| 56 | + @PreAuthorize("@ss.hasPermission('product:attr-key:delete')") | |
| 57 | + public CommonResult<Boolean> deleteAttrKey(@RequestParam("id") Integer id) { | |
| 58 | + attrKeyService.deleteAttrKey(id); | |
| 59 | + return success(true); | |
| 60 | + } | |
| 61 | + | |
| 62 | + @GetMapping("/get") | |
| 63 | + @ApiOperation("获得规格名称") | |
| 64 | + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Integer.class) | |
| 65 | + @PreAuthorize("@ss.hasPermission('product:attr-key:query')") | |
| 66 | + public CommonResult<AttrKeyRespVO> getAttrKey(@RequestParam("id") Integer id) { | |
| 67 | + AttrKeyDO attrKey = attrKeyService.getAttrKey(id); | |
| 68 | + return success(AttrKeyConvert.INSTANCE.convert(attrKey)); | |
| 69 | + } | |
| 70 | + | |
| 71 | + @GetMapping("/list") | |
| 72 | + @ApiOperation("获得规格名称列表") | |
| 73 | + @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) | |
| 74 | + @PreAuthorize("@ss.hasPermission('product:attr-key:query')") | |
| 75 | + public CommonResult<List<AttrKeyRespVO>> getAttrKeyList(@RequestParam("ids") Collection<Integer> ids) { | |
| 76 | + List<AttrKeyDO> list = attrKeyService.getAttrKeyList(ids); | |
| 77 | + return success(AttrKeyConvert.INSTANCE.convertList(list)); | |
| 78 | + } | |
| 79 | + | |
| 80 | + @GetMapping("/page") | |
| 81 | + @ApiOperation("获得规格名称分页") | |
| 82 | + @PreAuthorize("@ss.hasPermission('product:attr-key:query')") | |
| 83 | + public CommonResult<PageResult<AttrKeyRespVO>> getAttrKeyPage(@Valid AttrKeyPageReqVO pageVO) { | |
| 84 | + PageResult<AttrKeyDO> pageResult = attrKeyService.getAttrKeyPage(pageVO); | |
| 85 | + return success(AttrKeyConvert.INSTANCE.convertPage(pageResult)); | |
| 86 | + } | |
| 87 | + | |
| 88 | + @GetMapping("/export-excel") | |
| 89 | + @ApiOperation("导出规格名称 Excel") | |
| 90 | + @PreAuthorize("@ss.hasPermission('product:attr-key:export')") | |
| 91 | + @OperateLog(type = EXPORT) | |
| 92 | + public void exportAttrKeyExcel(@Valid AttrKeyExportReqVO exportReqVO, | |
| 93 | + HttpServletResponse response) throws IOException { | |
| 94 | + List<AttrKeyDO> list = attrKeyService.getAttrKeyList(exportReqVO); | |
| 95 | + // 导出 Excel | |
| 96 | + List<AttrKeyExcelVO> datas = AttrKeyConvert.INSTANCE.convertList02(list); | |
| 97 | + ExcelUtils.write(response, "规格名称.xls", "数据", AttrKeyExcelVO.class, datas); | |
| 98 | + } | |
| 99 | + | |
| 100 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrkey/vo/AttrKeyBaseVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.attrkey.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import javax.validation.constraints.*; | |
| 7 | + | |
| 8 | +/** | |
| 9 | +* 规格名称 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 10 | +* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 11 | +*/ | |
| 12 | +@Data | |
| 13 | +public class AttrKeyBaseVO { | |
| 14 | + | |
| 15 | + @ApiModelProperty(value = "规格名称") | |
| 16 | + private String attrName; | |
| 17 | + | |
| 18 | + @ApiModelProperty(value = "状态: 1 开启 ,2 禁用") | |
| 19 | + private Integer status; | |
| 20 | + | |
| 21 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrkey/vo/AttrKeyCreateReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.attrkey.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import javax.validation.constraints.*; | |
| 7 | + | |
| 8 | +@ApiModel("管理后台 - 规格名称创建 Request VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class AttrKeyCreateReqVO extends AttrKeyBaseVO { | |
| 13 | + | |
| 14 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrkey/vo/AttrKeyExcelVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.attrkey.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | + | |
| 7 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 规格名称 Excel VO | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +@Data | |
| 15 | +public class AttrKeyExcelVO { | |
| 16 | + | |
| 17 | + @ExcelProperty("主键") | |
| 18 | + private Integer id; | |
| 19 | + | |
| 20 | + @ExcelProperty("创建时间") | |
| 21 | + private Date createTime; | |
| 22 | + | |
| 23 | + @ExcelProperty("规格名称") | |
| 24 | + private String attrName; | |
| 25 | + | |
| 26 | + @ExcelProperty("状态: 1 开启 ,2 禁用") | |
| 27 | + private Integer status; | |
| 28 | + | |
| 29 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrkey/vo/AttrKeyExportReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.attrkey.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 8 | + | |
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 10 | + | |
| 11 | +@ApiModel(value = "管理后台 - 规格名称 Excel 导出 Request VO", description = "参数和 AttrKeyPageReqVO 是一致的") | |
| 12 | +@Data | |
| 13 | +public class AttrKeyExportReqVO { | |
| 14 | + | |
| 15 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 16 | + @ApiModelProperty(value = "开始创建时间") | |
| 17 | + private Date beginCreateTime; | |
| 18 | + | |
| 19 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 20 | + @ApiModelProperty(value = "结束创建时间") | |
| 21 | + private Date endCreateTime; | |
| 22 | + | |
| 23 | + @ApiModelProperty(value = "规格名称") | |
| 24 | + private String attrName; | |
| 25 | + | |
| 26 | + @ApiModelProperty(value = "状态: 1 开启 ,2 禁用") | |
| 27 | + private Integer status; | |
| 28 | + | |
| 29 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrkey/vo/AttrKeyPageReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.attrkey.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 8 | + | |
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 10 | + | |
| 11 | +@ApiModel("管理后台 - 规格名称分页 Request VO") | |
| 12 | +@Data | |
| 13 | +@EqualsAndHashCode(callSuper = true) | |
| 14 | +@ToString(callSuper = true) | |
| 15 | +public class AttrKeyPageReqVO extends PageParam { | |
| 16 | + | |
| 17 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 18 | + @ApiModelProperty(value = "开始创建时间") | |
| 19 | + private Date beginCreateTime; | |
| 20 | + | |
| 21 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 22 | + @ApiModelProperty(value = "结束创建时间") | |
| 23 | + private Date endCreateTime; | |
| 24 | + | |
| 25 | + @ApiModelProperty(value = "规格名称") | |
| 26 | + private String attrName; | |
| 27 | + | |
| 28 | + @ApiModelProperty(value = "状态: 1 开启 ,2 禁用") | |
| 29 | + private Integer status; | |
| 30 | + | |
| 31 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrkey/vo/AttrKeyRespVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.attrkey.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | + | |
| 7 | +@ApiModel("管理后台 - 规格名称 Response VO") | |
| 8 | +@Data | |
| 9 | +@EqualsAndHashCode(callSuper = true) | |
| 10 | +@ToString(callSuper = true) | |
| 11 | +public class AttrKeyRespVO extends AttrKeyBaseVO { | |
| 12 | + | |
| 13 | + @ApiModelProperty(value = "主键", required = true) | |
| 14 | + private Integer id; | |
| 15 | + | |
| 16 | + @ApiModelProperty(value = "创建时间") | |
| 17 | + private Date createTime; | |
| 18 | + | |
| 19 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrkey/vo/AttrKeyUpdateReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.attrkey.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import javax.validation.constraints.*; | |
| 7 | + | |
| 8 | +@ApiModel("管理后台 - 规格名称更新 Request VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class AttrKeyUpdateReqVO extends AttrKeyBaseVO { | |
| 13 | + | |
| 14 | + @ApiModelProperty(value = "主键", required = true) | |
| 15 | + @NotNull(message = "主键不能为空") | |
| 16 | + private Integer id; | |
| 17 | + | |
| 18 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrvalue/AttrValueController.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.attrvalue; | |
| 2 | + | |
| 3 | +import org.springframework.web.bind.annotation.*; | |
| 4 | +import javax.annotation.Resource; | |
| 5 | +import org.springframework.validation.annotation.Validated; | |
| 6 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 7 | +import io.swagger.annotations.*; | |
| 8 | + | |
| 9 | +import javax.validation.constraints.*; | |
| 10 | +import javax.validation.*; | |
| 11 | +import javax.servlet.http.*; | |
| 12 | +import java.util.*; | |
| 13 | +import java.io.IOException; | |
| 14 | + | |
| 15 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 16 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 17 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 18 | + | |
| 19 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 20 | + | |
| 21 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | |
| 22 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | |
| 23 | + | |
| 24 | +import cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo.*; | |
| 25 | +import cn.iocoder.yudao.module.product.dal.dataobject.attrvalue.AttrValueDO; | |
| 26 | +import cn.iocoder.yudao.module.product.convert.attrvalue.AttrValueConvert; | |
| 27 | +import cn.iocoder.yudao.module.product.service.attrvalue.AttrValueService; | |
| 28 | + | |
| 29 | +@Api(tags = "管理后台 - 规格值") | |
| 30 | +@RestController | |
| 31 | +@RequestMapping("/product/attr-value") | |
| 32 | +@Validated | |
| 33 | +public class AttrValueController { | |
| 34 | + | |
| 35 | + @Resource | |
| 36 | + private AttrValueService attrValueService; | |
| 37 | + | |
| 38 | + @PostMapping("/create") | |
| 39 | + @ApiOperation("创建规格值") | |
| 40 | + @PreAuthorize("@ss.hasPermission('product:attr-value:create')") | |
| 41 | + public CommonResult<Integer> createAttrValue(@Valid @RequestBody AttrValueCreateReqVO createReqVO) { | |
| 42 | + return success(attrValueService.createAttrValue(createReqVO)); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @PutMapping("/update") | |
| 46 | + @ApiOperation("更新规格值") | |
| 47 | + @PreAuthorize("@ss.hasPermission('product:attr-value:update')") | |
| 48 | + public CommonResult<Boolean> updateAttrValue(@Valid @RequestBody AttrValueUpdateReqVO updateReqVO) { | |
| 49 | + attrValueService.updateAttrValue(updateReqVO); | |
| 50 | + return success(true); | |
| 51 | + } | |
| 52 | + | |
| 53 | + @DeleteMapping("/delete") | |
| 54 | + @ApiOperation("删除规格值") | |
| 55 | + @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Integer.class) | |
| 56 | + @PreAuthorize("@ss.hasPermission('product:attr-value:delete')") | |
| 57 | + public CommonResult<Boolean> deleteAttrValue(@RequestParam("id") Integer id) { | |
| 58 | + attrValueService.deleteAttrValue(id); | |
| 59 | + return success(true); | |
| 60 | + } | |
| 61 | + | |
| 62 | + @GetMapping("/get") | |
| 63 | + @ApiOperation("获得规格值") | |
| 64 | + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Integer.class) | |
| 65 | + @PreAuthorize("@ss.hasPermission('product:attr-value:query')") | |
| 66 | + public CommonResult<AttrValueRespVO> getAttrValue(@RequestParam("id") Integer id) { | |
| 67 | + AttrValueDO attrValue = attrValueService.getAttrValue(id); | |
| 68 | + return success(AttrValueConvert.INSTANCE.convert(attrValue)); | |
| 69 | + } | |
| 70 | + | |
| 71 | + @GetMapping("/list") | |
| 72 | + @ApiOperation("获得规格值列表") | |
| 73 | + @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) | |
| 74 | + @PreAuthorize("@ss.hasPermission('product:attr-value:query')") | |
| 75 | + public CommonResult<List<AttrValueRespVO>> getAttrValueList(@RequestParam("ids") Collection<Integer> ids) { | |
| 76 | + List<AttrValueDO> list = attrValueService.getAttrValueList(ids); | |
| 77 | + return success(AttrValueConvert.INSTANCE.convertList(list)); | |
| 78 | + } | |
| 79 | + | |
| 80 | + @GetMapping("/page") | |
| 81 | + @ApiOperation("获得规格值分页") | |
| 82 | + @PreAuthorize("@ss.hasPermission('product:attr-value:query')") | |
| 83 | + public CommonResult<PageResult<AttrValueRespVO>> getAttrValuePage(@Valid AttrValuePageReqVO pageVO) { | |
| 84 | + PageResult<AttrValueDO> pageResult = attrValueService.getAttrValuePage(pageVO); | |
| 85 | + return success(AttrValueConvert.INSTANCE.convertPage(pageResult)); | |
| 86 | + } | |
| 87 | + | |
| 88 | + @GetMapping("/export-excel") | |
| 89 | + @ApiOperation("导出规格值 Excel") | |
| 90 | + @PreAuthorize("@ss.hasPermission('product:attr-value:export')") | |
| 91 | + @OperateLog(type = EXPORT) | |
| 92 | + public void exportAttrValueExcel(@Valid AttrValueExportReqVO exportReqVO, | |
| 93 | + HttpServletResponse response) throws IOException { | |
| 94 | + List<AttrValueDO> list = attrValueService.getAttrValueList(exportReqVO); | |
| 95 | + // 导出 Excel | |
| 96 | + List<AttrValueExcelVO> datas = AttrValueConvert.INSTANCE.convertList02(list); | |
| 97 | + ExcelUtils.write(response, "规格值.xls", "数据", AttrValueExcelVO.class, datas); | |
| 98 | + } | |
| 99 | + | |
| 100 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrvalue/vo/AttrValueBaseVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import javax.validation.constraints.*; | |
| 7 | + | |
| 8 | +/** | |
| 9 | +* 规格值 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 10 | +* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 11 | +*/ | |
| 12 | +@Data | |
| 13 | +public class AttrValueBaseVO { | |
| 14 | + | |
| 15 | + @ApiModelProperty(value = "规格键id") | |
| 16 | + private String attrKeyId; | |
| 17 | + | |
| 18 | + @ApiModelProperty(value = "规格值名字") | |
| 19 | + private String attrValueName; | |
| 20 | + | |
| 21 | + @ApiModelProperty(value = "状态: 1 开启 ,2 禁用") | |
| 22 | + private Integer status; | |
| 23 | + | |
| 24 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrvalue/vo/AttrValueCreateReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import javax.validation.constraints.*; | |
| 7 | + | |
| 8 | +@ApiModel("管理后台 - 规格值创建 Request VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class AttrValueCreateReqVO extends AttrValueBaseVO { | |
| 13 | + | |
| 14 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrvalue/vo/AttrValueExcelVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | + | |
| 7 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 规格值 Excel VO | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +@Data | |
| 15 | +public class AttrValueExcelVO { | |
| 16 | + | |
| 17 | + @ExcelProperty("主键") | |
| 18 | + private Integer id; | |
| 19 | + | |
| 20 | + @ExcelProperty("创建时间") | |
| 21 | + private Date createTime; | |
| 22 | + | |
| 23 | + @ExcelProperty("规格键id") | |
| 24 | + private String attrKeyId; | |
| 25 | + | |
| 26 | + @ExcelProperty("规格值名字") | |
| 27 | + private String attrValueName; | |
| 28 | + | |
| 29 | + @ExcelProperty("状态: 1 开启 ,2 禁用") | |
| 30 | + private Integer status; | |
| 31 | + | |
| 32 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrvalue/vo/AttrValueExportReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 8 | + | |
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 10 | + | |
| 11 | +@ApiModel(value = "管理后台 - 规格值 Excel 导出 Request VO", description = "参数和 AttrValuePageReqVO 是一致的") | |
| 12 | +@Data | |
| 13 | +public class AttrValueExportReqVO { | |
| 14 | + | |
| 15 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 16 | + @ApiModelProperty(value = "开始创建时间") | |
| 17 | + private Date beginCreateTime; | |
| 18 | + | |
| 19 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 20 | + @ApiModelProperty(value = "结束创建时间") | |
| 21 | + private Date endCreateTime; | |
| 22 | + | |
| 23 | + @ApiModelProperty(value = "规格键id") | |
| 24 | + private String attrKeyId; | |
| 25 | + | |
| 26 | + @ApiModelProperty(value = "规格值名字") | |
| 27 | + private String attrValueName; | |
| 28 | + | |
| 29 | + @ApiModelProperty(value = "状态: 1 开启 ,2 禁用") | |
| 30 | + private Integer status; | |
| 31 | + | |
| 32 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrvalue/vo/AttrValuePageReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 8 | + | |
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 10 | + | |
| 11 | +@ApiModel("管理后台 - 规格值分页 Request VO") | |
| 12 | +@Data | |
| 13 | +@EqualsAndHashCode(callSuper = true) | |
| 14 | +@ToString(callSuper = true) | |
| 15 | +public class AttrValuePageReqVO extends PageParam { | |
| 16 | + | |
| 17 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 18 | + @ApiModelProperty(value = "开始创建时间") | |
| 19 | + private Date beginCreateTime; | |
| 20 | + | |
| 21 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 22 | + @ApiModelProperty(value = "结束创建时间") | |
| 23 | + private Date endCreateTime; | |
| 24 | + | |
| 25 | + @ApiModelProperty(value = "规格键id") | |
| 26 | + private String attrKeyId; | |
| 27 | + | |
| 28 | + @ApiModelProperty(value = "规格值名字") | |
| 29 | + private String attrValueName; | |
| 30 | + | |
| 31 | + @ApiModelProperty(value = "状态: 1 开启 ,2 禁用") | |
| 32 | + private Integer status; | |
| 33 | + | |
| 34 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrvalue/vo/AttrValueRespVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | + | |
| 7 | +@ApiModel("管理后台 - 规格值 Response VO") | |
| 8 | +@Data | |
| 9 | +@EqualsAndHashCode(callSuper = true) | |
| 10 | +@ToString(callSuper = true) | |
| 11 | +public class AttrValueRespVO extends AttrValueBaseVO { | |
| 12 | + | |
| 13 | + @ApiModelProperty(value = "主键", required = true) | |
| 14 | + private Integer id; | |
| 15 | + | |
| 16 | + @ApiModelProperty(value = "创建时间") | |
| 17 | + private Date createTime; | |
| 18 | + | |
| 19 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/attrvalue/vo/AttrValueUpdateReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import javax.validation.constraints.*; | |
| 7 | + | |
| 8 | +@ApiModel("管理后台 - 规格值更新 Request VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class AttrValueUpdateReqVO extends AttrValueBaseVO { | |
| 13 | + | |
| 14 | + @ApiModelProperty(value = "主键", required = true) | |
| 15 | + @NotNull(message = "主键不能为空") | |
| 16 | + private Integer id; | |
| 17 | + | |
| 18 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/attrkey/AttrKeyConvert.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.convert.attrkey; | |
| 2 | + | |
| 3 | +import java.util.*; | |
| 4 | + | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | + | |
| 7 | +import org.mapstruct.Mapper; | |
| 8 | +import org.mapstruct.factory.Mappers; | |
| 9 | +import cn.iocoder.yudao.module.product.controller.admin.attrkey.vo.*; | |
| 10 | +import cn.iocoder.yudao.module.product.dal.dataobject.attrkey.AttrKeyDO; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 规格名称 Convert | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@Mapper | |
| 18 | +public interface AttrKeyConvert { | |
| 19 | + | |
| 20 | + AttrKeyConvert INSTANCE = Mappers.getMapper(AttrKeyConvert.class); | |
| 21 | + | |
| 22 | + AttrKeyDO convert(AttrKeyCreateReqVO bean); | |
| 23 | + | |
| 24 | + AttrKeyDO convert(AttrKeyUpdateReqVO bean); | |
| 25 | + | |
| 26 | + AttrKeyRespVO convert(AttrKeyDO bean); | |
| 27 | + | |
| 28 | + List<AttrKeyRespVO> convertList(List<AttrKeyDO> list); | |
| 29 | + | |
| 30 | + PageResult<AttrKeyRespVO> convertPage(PageResult<AttrKeyDO> page); | |
| 31 | + | |
| 32 | + List<AttrKeyExcelVO> convertList02(List<AttrKeyDO> list); | |
| 33 | + | |
| 34 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/attrvalue/AttrValueConvert.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.convert.attrvalue; | |
| 2 | + | |
| 3 | +import java.util.*; | |
| 4 | + | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | + | |
| 7 | +import org.mapstruct.Mapper; | |
| 8 | +import org.mapstruct.factory.Mappers; | |
| 9 | +import cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo.*; | |
| 10 | +import cn.iocoder.yudao.module.product.dal.dataobject.attrvalue.AttrValueDO; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 规格值 Convert | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@Mapper | |
| 18 | +public interface AttrValueConvert { | |
| 19 | + | |
| 20 | + AttrValueConvert INSTANCE = Mappers.getMapper(AttrValueConvert.class); | |
| 21 | + | |
| 22 | + AttrValueDO convert(AttrValueCreateReqVO bean); | |
| 23 | + | |
| 24 | + AttrValueDO convert(AttrValueUpdateReqVO bean); | |
| 25 | + | |
| 26 | + AttrValueRespVO convert(AttrValueDO bean); | |
| 27 | + | |
| 28 | + List<AttrValueRespVO> convertList(List<AttrValueDO> list); | |
| 29 | + | |
| 30 | + PageResult<AttrValueRespVO> convertPage(PageResult<AttrValueDO> page); | |
| 31 | + | |
| 32 | + List<AttrValueExcelVO> convertList02(List<AttrValueDO> list); | |
| 33 | + | |
| 34 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/attrkey/AttrKeyDO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.dal.dataobject.attrkey; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import com.baomidou.mybatisplus.annotation.*; | |
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 规格名称 DO | |
| 10 | + * | |
| 11 | + * @author 芋道源码 | |
| 12 | + */ | |
| 13 | +@TableName("product_attr_key") | |
| 14 | +@KeySequence("product_attr_key_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 15 | +@Data | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +@Builder | |
| 19 | +@NoArgsConstructor | |
| 20 | +@AllArgsConstructor | |
| 21 | +public class AttrKeyDO extends BaseDO { | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * 主键 | |
| 25 | + */ | |
| 26 | + @TableId | |
| 27 | + private Integer id; | |
| 28 | + /** | |
| 29 | + * 规格名称 | |
| 30 | + */ | |
| 31 | + private String attrName; | |
| 32 | + /** | |
| 33 | + * 状态: 1 开启 ,2 禁用 | |
| 34 | + */ | |
| 35 | + private Integer status; | |
| 36 | + | |
| 37 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/attrvalue/AttrValueDO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.dal.dataobject.attrvalue; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import com.baomidou.mybatisplus.annotation.*; | |
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 规格值 DO | |
| 10 | + * | |
| 11 | + * @author 芋道源码 | |
| 12 | + */ | |
| 13 | +@TableName("product_attr_value") | |
| 14 | +@KeySequence("product_attr_value_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 15 | +@Data | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +@Builder | |
| 19 | +@NoArgsConstructor | |
| 20 | +@AllArgsConstructor | |
| 21 | +public class AttrValueDO extends BaseDO { | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * 主键 | |
| 25 | + */ | |
| 26 | + @TableId | |
| 27 | + private Integer id; | |
| 28 | + /** | |
| 29 | + * 规格键id | |
| 30 | + */ | |
| 31 | + private String attrKeyId; | |
| 32 | + /** | |
| 33 | + * 规格值名字 | |
| 34 | + */ | |
| 35 | + private String attrValueName; | |
| 36 | + /** | |
| 37 | + * 状态: 1 开启 ,2 禁用 | |
| 38 | + */ | |
| 39 | + private Integer status; | |
| 40 | + | |
| 41 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/attrkey/AttrKeyMapper.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.dal.mysql.attrkey; | |
| 2 | + | |
| 3 | +import java.util.*; | |
| 4 | + | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 7 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 8 | +import cn.iocoder.yudao.module.product.dal.dataobject.attrkey.AttrKeyDO; | |
| 9 | +import org.apache.ibatis.annotations.Mapper; | |
| 10 | +import cn.iocoder.yudao.module.product.controller.admin.attrkey.vo.*; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 规格名称 Mapper | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@Mapper | |
| 18 | +public interface AttrKeyMapper extends BaseMapperX<AttrKeyDO> { | |
| 19 | + | |
| 20 | + default PageResult<AttrKeyDO> selectPage(AttrKeyPageReqVO reqVO) { | |
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<AttrKeyDO>() | |
| 22 | + .betweenIfPresent(AttrKeyDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 23 | + .likeIfPresent(AttrKeyDO::getAttrName, reqVO.getAttrName()) | |
| 24 | + .eqIfPresent(AttrKeyDO::getStatus, reqVO.getStatus()) | |
| 25 | + .orderByDesc(AttrKeyDO::getId)); | |
| 26 | + } | |
| 27 | + | |
| 28 | + default List<AttrKeyDO> selectList(AttrKeyExportReqVO reqVO) { | |
| 29 | + return selectList(new LambdaQueryWrapperX<AttrKeyDO>() | |
| 30 | + .betweenIfPresent(AttrKeyDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 31 | + .likeIfPresent(AttrKeyDO::getAttrName, reqVO.getAttrName()) | |
| 32 | + .eqIfPresent(AttrKeyDO::getStatus, reqVO.getStatus()) | |
| 33 | + .orderByDesc(AttrKeyDO::getId)); | |
| 34 | + } | |
| 35 | + | |
| 36 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/attrvalue/AttrValueMapper.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.dal.mysql.attrvalue; | |
| 2 | + | |
| 3 | +import java.util.*; | |
| 4 | + | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 7 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 8 | +import cn.iocoder.yudao.module.product.dal.dataobject.attrvalue.AttrValueDO; | |
| 9 | +import org.apache.ibatis.annotations.Mapper; | |
| 10 | +import cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo.*; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 规格值 Mapper | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@Mapper | |
| 18 | +public interface AttrValueMapper extends BaseMapperX<AttrValueDO> { | |
| 19 | + | |
| 20 | + default PageResult<AttrValueDO> selectPage(AttrValuePageReqVO reqVO) { | |
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<AttrValueDO>() | |
| 22 | + .betweenIfPresent(AttrValueDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 23 | + .eqIfPresent(AttrValueDO::getAttrKeyId, reqVO.getAttrKeyId()) | |
| 24 | + .likeIfPresent(AttrValueDO::getAttrValueName, reqVO.getAttrValueName()) | |
| 25 | + .eqIfPresent(AttrValueDO::getStatus, reqVO.getStatus()) | |
| 26 | + .orderByDesc(AttrValueDO::getId)); | |
| 27 | + } | |
| 28 | + | |
| 29 | + default List<AttrValueDO> selectList(AttrValueExportReqVO reqVO) { | |
| 30 | + return selectList(new LambdaQueryWrapperX<AttrValueDO>() | |
| 31 | + .betweenIfPresent(AttrValueDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 32 | + .eqIfPresent(AttrValueDO::getAttrKeyId, reqVO.getAttrKeyId()) | |
| 33 | + .likeIfPresent(AttrValueDO::getAttrValueName, reqVO.getAttrValueName()) | |
| 34 | + .eqIfPresent(AttrValueDO::getStatus, reqVO.getStatus()) | |
| 35 | + .orderByDesc(AttrValueDO::getId)); | |
| 36 | + } | |
| 37 | + | |
| 38 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/attrkey/AttrKeyService.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.service.attrkey; | |
| 2 | + | |
| 3 | +import java.util.*; | |
| 4 | +import javax.validation.*; | |
| 5 | +import cn.iocoder.yudao.module.product.controller.admin.attrkey.vo.*; | |
| 6 | +import cn.iocoder.yudao.module.product.dal.dataobject.attrkey.AttrKeyDO; | |
| 7 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 规格名称 Service 接口 | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +public interface AttrKeyService { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 创建规格名称 | |
| 18 | + * | |
| 19 | + * @param createReqVO 创建信息 | |
| 20 | + * @return 编号 | |
| 21 | + */ | |
| 22 | + Integer createAttrKey(@Valid AttrKeyCreateReqVO createReqVO); | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 更新规格名称 | |
| 26 | + * | |
| 27 | + * @param updateReqVO 更新信息 | |
| 28 | + */ | |
| 29 | + void updateAttrKey(@Valid AttrKeyUpdateReqVO updateReqVO); | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 删除规格名称 | |
| 33 | + * | |
| 34 | + * @param id 编号 | |
| 35 | + */ | |
| 36 | + void deleteAttrKey(Integer id); | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 获得规格名称 | |
| 40 | + * | |
| 41 | + * @param id 编号 | |
| 42 | + * @return 规格名称 | |
| 43 | + */ | |
| 44 | + AttrKeyDO getAttrKey(Integer id); | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 获得规格名称列表 | |
| 48 | + * | |
| 49 | + * @param ids 编号 | |
| 50 | + * @return 规格名称列表 | |
| 51 | + */ | |
| 52 | + List<AttrKeyDO> getAttrKeyList(Collection<Integer> ids); | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 获得规格名称分页 | |
| 56 | + * | |
| 57 | + * @param pageReqVO 分页查询 | |
| 58 | + * @return 规格名称分页 | |
| 59 | + */ | |
| 60 | + PageResult<AttrKeyDO> getAttrKeyPage(AttrKeyPageReqVO pageReqVO); | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * 获得规格名称列表, 用于 Excel 导出 | |
| 64 | + * | |
| 65 | + * @param exportReqVO 查询条件 | |
| 66 | + * @return 规格名称列表 | |
| 67 | + */ | |
| 68 | + List<AttrKeyDO> getAttrKeyList(AttrKeyExportReqVO exportReqVO); | |
| 69 | + | |
| 70 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/attrkey/AttrKeyServiceImpl.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.service.attrkey; | |
| 2 | + | |
| 3 | +import org.springframework.stereotype.Service; | |
| 4 | +import javax.annotation.Resource; | |
| 5 | +import org.springframework.validation.annotation.Validated; | |
| 6 | + | |
| 7 | +import java.util.*; | |
| 8 | +import cn.iocoder.yudao.module.product.controller.admin.attrkey.vo.*; | |
| 9 | +import cn.iocoder.yudao.module.product.dal.dataobject.attrkey.AttrKeyDO; | |
| 10 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 11 | + | |
| 12 | +import cn.iocoder.yudao.module.product.convert.attrkey.AttrKeyConvert; | |
| 13 | +import cn.iocoder.yudao.module.product.dal.mysql.attrkey.AttrKeyMapper; | |
| 14 | + | |
| 15 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 16 | +import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * 规格名称 Service 实现类 | |
| 20 | + * | |
| 21 | + * @author 芋道源码 | |
| 22 | + */ | |
| 23 | +@Service | |
| 24 | +@Validated | |
| 25 | +public class AttrKeyServiceImpl implements AttrKeyService { | |
| 26 | + | |
| 27 | + @Resource | |
| 28 | + private AttrKeyMapper attrKeyMapper; | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + public Integer createAttrKey(AttrKeyCreateReqVO createReqVO) { | |
| 32 | + // 插入 | |
| 33 | + AttrKeyDO attrKey = AttrKeyConvert.INSTANCE.convert(createReqVO); | |
| 34 | + attrKeyMapper.insert(attrKey); | |
| 35 | + // 返回 | |
| 36 | + return attrKey.getId(); | |
| 37 | + } | |
| 38 | + | |
| 39 | + @Override | |
| 40 | + public void updateAttrKey(AttrKeyUpdateReqVO updateReqVO) { | |
| 41 | + // 校验存在 | |
| 42 | + this.validateAttrKeyExists(updateReqVO.getId()); | |
| 43 | + // 更新 | |
| 44 | + AttrKeyDO updateObj = AttrKeyConvert.INSTANCE.convert(updateReqVO); | |
| 45 | + attrKeyMapper.updateById(updateObj); | |
| 46 | + } | |
| 47 | + | |
| 48 | + @Override | |
| 49 | + public void deleteAttrKey(Integer id) { | |
| 50 | + // 校验存在 | |
| 51 | + this.validateAttrKeyExists(id); | |
| 52 | + // 删除 | |
| 53 | + attrKeyMapper.deleteById(id); | |
| 54 | + } | |
| 55 | + | |
| 56 | + private void validateAttrKeyExists(Integer id) { | |
| 57 | + if (attrKeyMapper.selectById(id) == null) { | |
| 58 | + throw exception(ATTR_KEY_NOT_EXISTS); | |
| 59 | + } | |
| 60 | + } | |
| 61 | + | |
| 62 | + @Override | |
| 63 | + public AttrKeyDO getAttrKey(Integer id) { | |
| 64 | + return attrKeyMapper.selectById(id); | |
| 65 | + } | |
| 66 | + | |
| 67 | + @Override | |
| 68 | + public List<AttrKeyDO> getAttrKeyList(Collection<Integer> ids) { | |
| 69 | + return attrKeyMapper.selectBatchIds(ids); | |
| 70 | + } | |
| 71 | + | |
| 72 | + @Override | |
| 73 | + public PageResult<AttrKeyDO> getAttrKeyPage(AttrKeyPageReqVO pageReqVO) { | |
| 74 | + return attrKeyMapper.selectPage(pageReqVO); | |
| 75 | + } | |
| 76 | + | |
| 77 | + @Override | |
| 78 | + public List<AttrKeyDO> getAttrKeyList(AttrKeyExportReqVO exportReqVO) { | |
| 79 | + return attrKeyMapper.selectList(exportReqVO); | |
| 80 | + } | |
| 81 | + | |
| 82 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/attrvalue/AttrValueService.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.service.attrvalue; | |
| 2 | + | |
| 3 | +import java.util.*; | |
| 4 | +import javax.validation.*; | |
| 5 | +import cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo.*; | |
| 6 | +import cn.iocoder.yudao.module.product.dal.dataobject.attrvalue.AttrValueDO; | |
| 7 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 规格值 Service 接口 | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +public interface AttrValueService { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 创建规格值 | |
| 18 | + * | |
| 19 | + * @param createReqVO 创建信息 | |
| 20 | + * @return 编号 | |
| 21 | + */ | |
| 22 | + Integer createAttrValue(@Valid AttrValueCreateReqVO createReqVO); | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 更新规格值 | |
| 26 | + * | |
| 27 | + * @param updateReqVO 更新信息 | |
| 28 | + */ | |
| 29 | + void updateAttrValue(@Valid AttrValueUpdateReqVO updateReqVO); | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 删除规格值 | |
| 33 | + * | |
| 34 | + * @param id 编号 | |
| 35 | + */ | |
| 36 | + void deleteAttrValue(Integer id); | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 获得规格值 | |
| 40 | + * | |
| 41 | + * @param id 编号 | |
| 42 | + * @return 规格值 | |
| 43 | + */ | |
| 44 | + AttrValueDO getAttrValue(Integer id); | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 获得规格值列表 | |
| 48 | + * | |
| 49 | + * @param ids 编号 | |
| 50 | + * @return 规格值列表 | |
| 51 | + */ | |
| 52 | + List<AttrValueDO> getAttrValueList(Collection<Integer> ids); | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 获得规格值分页 | |
| 56 | + * | |
| 57 | + * @param pageReqVO 分页查询 | |
| 58 | + * @return 规格值分页 | |
| 59 | + */ | |
| 60 | + PageResult<AttrValueDO> getAttrValuePage(AttrValuePageReqVO pageReqVO); | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * 获得规格值列表, 用于 Excel 导出 | |
| 64 | + * | |
| 65 | + * @param exportReqVO 查询条件 | |
| 66 | + * @return 规格值列表 | |
| 67 | + */ | |
| 68 | + List<AttrValueDO> getAttrValueList(AttrValueExportReqVO exportReqVO); | |
| 69 | + | |
| 70 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/attrvalue/AttrValueServiceImpl.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.service.attrvalue; | |
| 2 | + | |
| 3 | +import org.springframework.stereotype.Service; | |
| 4 | +import javax.annotation.Resource; | |
| 5 | +import org.springframework.validation.annotation.Validated; | |
| 6 | + | |
| 7 | +import java.util.*; | |
| 8 | +import cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo.*; | |
| 9 | +import cn.iocoder.yudao.module.product.dal.dataobject.attrvalue.AttrValueDO; | |
| 10 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 11 | + | |
| 12 | +import cn.iocoder.yudao.module.product.convert.attrvalue.AttrValueConvert; | |
| 13 | +import cn.iocoder.yudao.module.product.dal.mysql.attrvalue.AttrValueMapper; | |
| 14 | + | |
| 15 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 16 | +import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * 规格值 Service 实现类 | |
| 20 | + * | |
| 21 | + * @author 芋道源码 | |
| 22 | + */ | |
| 23 | +@Service | |
| 24 | +@Validated | |
| 25 | +public class AttrValueServiceImpl implements AttrValueService { | |
| 26 | + | |
| 27 | + @Resource | |
| 28 | + private AttrValueMapper attrValueMapper; | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + public Integer createAttrValue(AttrValueCreateReqVO createReqVO) { | |
| 32 | + // 插入 | |
| 33 | + AttrValueDO attrValue = AttrValueConvert.INSTANCE.convert(createReqVO); | |
| 34 | + attrValueMapper.insert(attrValue); | |
| 35 | + // 返回 | |
| 36 | + return attrValue.getId(); | |
| 37 | + } | |
| 38 | + | |
| 39 | + @Override | |
| 40 | + public void updateAttrValue(AttrValueUpdateReqVO updateReqVO) { | |
| 41 | + // 校验存在 | |
| 42 | + this.validateAttrValueExists(updateReqVO.getId()); | |
| 43 | + // 更新 | |
| 44 | + AttrValueDO updateObj = AttrValueConvert.INSTANCE.convert(updateReqVO); | |
| 45 | + attrValueMapper.updateById(updateObj); | |
| 46 | + } | |
| 47 | + | |
| 48 | + @Override | |
| 49 | + public void deleteAttrValue(Integer id) { | |
| 50 | + // 校验存在 | |
| 51 | + this.validateAttrValueExists(id); | |
| 52 | + // 删除 | |
| 53 | + attrValueMapper.deleteById(id); | |
| 54 | + } | |
| 55 | + | |
| 56 | + private void validateAttrValueExists(Integer id) { | |
| 57 | + if (attrValueMapper.selectById(id) == null) { | |
| 58 | + throw exception(ATTR_VALUE_NOT_EXISTS); | |
| 59 | + } | |
| 60 | + } | |
| 61 | + | |
| 62 | + @Override | |
| 63 | + public AttrValueDO getAttrValue(Integer id) { | |
| 64 | + return attrValueMapper.selectById(id); | |
| 65 | + } | |
| 66 | + | |
| 67 | + @Override | |
| 68 | + public List<AttrValueDO> getAttrValueList(Collection<Integer> ids) { | |
| 69 | + return attrValueMapper.selectBatchIds(ids); | |
| 70 | + } | |
| 71 | + | |
| 72 | + @Override | |
| 73 | + public PageResult<AttrValueDO> getAttrValuePage(AttrValuePageReqVO pageReqVO) { | |
| 74 | + return attrValueMapper.selectPage(pageReqVO); | |
| 75 | + } | |
| 76 | + | |
| 77 | + @Override | |
| 78 | + public List<AttrValueDO> getAttrValueList(AttrValueExportReqVO exportReqVO) { | |
| 79 | + return attrValueMapper.selectList(exportReqVO); | |
| 80 | + } | |
| 81 | + | |
| 82 | +} | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/attrkey/AttrKeyServiceImplTest.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.product.service.attrkey; | |
| 2 | + | |
| 3 | +import org.junit.jupiter.api.Disabled; | |
| 4 | +import org.junit.jupiter.api.Test; | |
| 5 | +import org.springframework.boot.test.mock.mockito.MockBean; | |
| 6 | + | |
| 7 | +import javax.annotation.Resource; | |
| 8 | + | |
| 9 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 10 | + | |
| 11 | +import cn.iocoder.yudao.module.product.controller.admin.attrkey.vo.*; | |
| 12 | +import cn.iocoder.yudao.module.product.dal.dataobject.attrkey.AttrKeyDO; | |
| 13 | +import cn.iocoder.yudao.module.product.dal.mysql.attrkey.AttrKeyMapper; | |
| 14 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 15 | + | |
| 16 | +import javax.annotation.Resource; | |
| 17 | +import org.springframework.context.annotation.Import; | |
| 18 | +import java.util.*; | |
| 19 | + | |
| 20 | +import static cn.hutool.core.util.RandomUtil.*; | |
| 21 | +import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; | |
| 22 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; | |
| 23 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | |
| 24 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; | |
| 25 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; | |
| 26 | +import static org.junit.jupiter.api.Assertions.*; | |
| 27 | +import static org.mockito.Mockito.*; | |
| 28 | + | |
| 29 | +/** | |
| 30 | +* {@link AttrKeyServiceImpl} 的单元测试类 | |
| 31 | +* | |
| 32 | +* @author 芋道源码 | |
| 33 | +*/ | |
| 34 | +@Import(AttrKeyServiceImpl.class) | |
| 35 | +public class AttrKeyServiceImplTest extends BaseDbUnitTest { | |
| 36 | + | |
| 37 | + @Resource | |
| 38 | + private AttrKeyServiceImpl attrKeyService; | |
| 39 | + | |
| 40 | + @Resource | |
| 41 | + private AttrKeyMapper attrKeyMapper; | |
| 42 | + | |
| 43 | + @Test | |
| 44 | + public void testCreateAttrKey_success() { | |
| 45 | + // 准备参数 | |
| 46 | + AttrKeyCreateReqVO reqVO = randomPojo(AttrKeyCreateReqVO.class); | |
| 47 | + | |
| 48 | + // 调用 | |
| 49 | + Integer attrKeyId = attrKeyService.createAttrKey(reqVO); | |
| 50 | + // 断言 | |
| 51 | + assertNotNull(attrKeyId); | |
| 52 | + // 校验记录的属性是否正确 | |
| 53 | + AttrKeyDO attrKey = attrKeyMapper.selectById(attrKeyId); | |
| 54 | + assertPojoEquals(reqVO, attrKey); | |
| 55 | + } | |
| 56 | + | |
| 57 | + @Test | |
| 58 | + public void testUpdateAttrKey_success() { | |
| 59 | + // mock 数据 | |
| 60 | + AttrKeyDO dbAttrKey = randomPojo(AttrKeyDO.class); | |
| 61 | + attrKeyMapper.insert(dbAttrKey);// @Sql: 先插入出一条存在的数据 | |
| 62 | + // 准备参数 | |
| 63 | + AttrKeyUpdateReqVO reqVO = randomPojo(AttrKeyUpdateReqVO.class, o -> { | |
| 64 | + o.setId(dbAttrKey.getId()); // 设置更新的 ID | |
| 65 | + }); | |
| 66 | + | |
| 67 | + // 调用 | |
| 68 | + attrKeyService.updateAttrKey(reqVO); | |
| 69 | + // 校验是否更新正确 | |
| 70 | + AttrKeyDO attrKey = attrKeyMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 71 | + assertPojoEquals(reqVO, attrKey); | |
| 72 | + } | |
| 73 | + | |
| 74 | + @Test | |
| 75 | + public void testUpdateAttrKey_notExists() { | |
| 76 | + // 准备参数 | |
| 77 | + AttrKeyUpdateReqVO reqVO = randomPojo(AttrKeyUpdateReqVO.class); | |
| 78 | + | |
| 79 | + // 调用, 并断言异常 | |
| 80 | + assertServiceException(() -> attrKeyService.updateAttrKey(reqVO), ATTR_KEY_NOT_EXISTS); | |
| 81 | + } | |
| 82 | + | |
| 83 | + @Test | |
| 84 | + public void testDeleteAttrKey_success() { | |
| 85 | + // mock 数据 | |
| 86 | + AttrKeyDO dbAttrKey = randomPojo(AttrKeyDO.class); | |
| 87 | + attrKeyMapper.insert(dbAttrKey);// @Sql: 先插入出一条存在的数据 | |
| 88 | + // 准备参数 | |
| 89 | + Integer id = dbAttrKey.getId(); | |
| 90 | + | |
| 91 | + // 调用 | |
| 92 | + attrKeyService.deleteAttrKey(id); | |
| 93 | + // 校验数据不存在了 | |
| 94 | + assertNull(attrKeyMapper.selectById(id)); | |
| 95 | + } | |
| 96 | + | |
| 97 | + @Test | |
| 98 | + public void testDeleteAttrKey_notExists() { | |
| 99 | + // 准备参数 | |
| 100 | +// Integer id = randomIntegerId(); | |
| 101 | + Integer id = 1; | |
| 102 | + | |
| 103 | + // 调用, 并断言异常 | |
| 104 | + assertServiceException(() -> attrKeyService.deleteAttrKey(id), ATTR_KEY_NOT_EXISTS); | |
| 105 | + } | |
| 106 | + | |
| 107 | + @Test | |
| 108 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 109 | + public void testGetAttrKeyPage() { | |
| 110 | + // mock 数据 | |
| 111 | + AttrKeyDO dbAttrKey = randomPojo(AttrKeyDO.class, o -> { // 等会查询到 | |
| 112 | + o.setCreateTime(null); | |
| 113 | + o.setAttrName(null); | |
| 114 | + o.setStatus(null); | |
| 115 | + }); | |
| 116 | + attrKeyMapper.insert(dbAttrKey); | |
| 117 | + // 测试 createTime 不匹配 | |
| 118 | + attrKeyMapper.insert(cloneIgnoreId(dbAttrKey, o -> o.setCreateTime(null))); | |
| 119 | + // 测试 attrName 不匹配 | |
| 120 | + attrKeyMapper.insert(cloneIgnoreId(dbAttrKey, o -> o.setAttrName(null))); | |
| 121 | + // 测试 status 不匹配 | |
| 122 | + attrKeyMapper.insert(cloneIgnoreId(dbAttrKey, o -> o.setStatus(null))); | |
| 123 | + // 准备参数 | |
| 124 | + AttrKeyPageReqVO reqVO = new AttrKeyPageReqVO(); | |
| 125 | + reqVO.setBeginCreateTime(null); | |
| 126 | + reqVO.setEndCreateTime(null); | |
| 127 | + reqVO.setAttrName(null); | |
| 128 | + reqVO.setStatus(null); | |
| 129 | + | |
| 130 | + // 调用 | |
| 131 | + PageResult<AttrKeyDO> pageResult = attrKeyService.getAttrKeyPage(reqVO); | |
| 132 | + // 断言 | |
| 133 | + assertEquals(1, pageResult.getTotal()); | |
| 134 | + assertEquals(1, pageResult.getList().size()); | |
| 135 | + assertPojoEquals(dbAttrKey, pageResult.getList().get(0)); | |
| 136 | + } | |
| 137 | + | |
| 138 | + @Test | |
| 139 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 140 | + public void testGetAttrKeyList() { | |
| 141 | + // mock 数据 | |
| 142 | + AttrKeyDO dbAttrKey = randomPojo(AttrKeyDO.class, o -> { // 等会查询到 | |
| 143 | + o.setCreateTime(null); | |
| 144 | + o.setAttrName(null); | |
| 145 | + o.setStatus(null); | |
| 146 | + }); | |
| 147 | + attrKeyMapper.insert(dbAttrKey); | |
| 148 | + // 测试 createTime 不匹配 | |
| 149 | + attrKeyMapper.insert(cloneIgnoreId(dbAttrKey, o -> o.setCreateTime(null))); | |
| 150 | + // 测试 attrName 不匹配 | |
| 151 | + attrKeyMapper.insert(cloneIgnoreId(dbAttrKey, o -> o.setAttrName(null))); | |
| 152 | + // 测试 status 不匹配 | |
| 153 | + attrKeyMapper.insert(cloneIgnoreId(dbAttrKey, o -> o.setStatus(null))); | |
| 154 | + // 准备参数 | |
| 155 | + AttrKeyExportReqVO reqVO = new AttrKeyExportReqVO(); | |
| 156 | + reqVO.setBeginCreateTime(null); | |
| 157 | + reqVO.setEndCreateTime(null); | |
| 158 | + reqVO.setAttrName(null); | |
| 159 | + reqVO.setStatus(null); | |
| 160 | + | |
| 161 | + // 调用 | |
| 162 | + List<AttrKeyDO> list = attrKeyService.getAttrKeyList(reqVO); | |
| 163 | + // 断言 | |
| 164 | + assertEquals(1, list.size()); | |
| 165 | + assertPojoEquals(dbAttrKey, list.get(0)); | |
| 166 | + } | |
| 167 | + | |
| 168 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/UserController.java
| ... | ... | @@ -23,7 +23,7 @@ import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUti |
| 23 | 23 | */ |
| 24 | 24 | @Slf4j |
| 25 | 25 | @Api("用户管理") |
| 26 | -@RestController | |
| 26 | +@RestController(value = "memberUserController") | |
| 27 | 27 | @RequestMapping("/user") |
| 28 | 28 | public class UserController { |
| 29 | 29 | ... | ... |