调整商品代码生成模块

This commit is contained in:
franky 2022-05-17 22:16:48 +08:00
parent 657e4d035b
commit 2bbfa40265
46 changed files with 770 additions and 949 deletions

View File

@ -112,36 +112,40 @@ CREATE TABLE `market_activity` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='促销活动';
-- 规格名称表
drop table if exists product_attr_key;
create table product_attr_key
drop table if exists product_property;
create table product_property
(
id int comment '主键',
create_time datetime default current_timestamp comment '创建时间',
update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
id bigint comment '主键',
name varchar(64) comment '规格名称',
status tinyint comment '状态 0 开启 1 禁用',
create_time datetime default current_timestamp comment '创建时间',
update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
creator varchar(64) comment '创建人',
updater varchar(64) comment '更新人',
tenant_id bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
deleted bit(1) comment '状态',
attr_name varchar(64) comment '规格名称',
status tinyint comment '状态 1 开启 2 禁用',
primary key (id),
key idx_name (attr_name(32)) comment '规格名称索引'
key idx_name (name(32)) comment '规格名称索引'
) comment '规格名称' character set utf8mb4
collate utf8mb4_general_ci;
-- 规格值表
drop table if exists product_attr_value;
create table product_attr_value
drop table if exists product_property_value;
create table product_property_value
(
id int comment '主键',
create_time datetime default current_timestamp comment '创建时间',
update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
creator varchar(64) comment '创建人',
updater varchar(64) comment '更新人',
deleted bit(1) comment '状态',
attr_key_id varchar(64) comment '规格键id',
attr_value_name varchar(128) comment '规格值名字',
status tinyint comment '状态 1 开启 2 禁用',
id int comment '主键',
property_id bigint comment '规格键id',
name varchar(128) comment '规格值名字',
status tinyint comment '状态 1 开启 2 禁用',
create_time datetime default current_timestamp comment '创建时间',
update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
creator varchar(64) comment '创建人',
updater varchar(64) comment '更新人',
tenant_id bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
deleted bit(1) comment '状态',
primary key (id)
) comment '规格值' character set utf8mb4
collate utf8mb4_general_ci;
@ -150,23 +154,23 @@ create table product_attr_value
drop table if exists product_spu;
create table product_spu
(
id int comment '主键',
create_time datetime default current_timestamp comment '创建时间',
update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
creator varchar(64) comment '创建人',
updater varchar(64) comment '更新人',
deleted bit(1) comment '状态',
name varchar(128) comment '商品名称',
visible bit(1) comment '上下架状态 true 上架false 下架',
sell_point varchar(128) not null comment '卖点',
description text not null comment '描述',
cid int not null comment '分类id',
list_pic_url varchar(128) comment '列表图',
pic_urls varchar(1024) not null default '' comment '商品主图地址, 数组以逗号分隔, 最多上传15张',
sort int not null default 0 comment '排序字段',
like_count int comment '点赞初始人数',
price int comment '价格',
quantity int comment '库存数量',
id int comment '主键',
name varchar(128) comment '商品名称',
sell_point varchar(128) not null comment '卖点',
description text not null comment '描述',
category_id bigint not null comment '分类id',
pic_urls varchar(1024) not null default '' comment '商品主图地址\n *\n * 数组以逗号分隔\n 最多上传15张',
sort int not null default 0 comment '排序字段',
like_count int comment '点赞初始人数',
price int comment '价格 单位使用',
quantity int comment '库存数量',
status bit(1) comment '上下架状态 0 上架开启 1 下架禁用',
create_time datetime default current_timestamp comment '创建时间',
update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
creator varchar(64) comment '创建人',
updater varchar(64) comment '更新人',
tenant_id bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
deleted bit(1) comment '状态',
primary key (id)
) comment '商品spu' character set utf8mb4
collate utf8mb4_general_ci;
@ -177,19 +181,22 @@ drop table if exists product_sku;
create table product_sku
(
id int comment '主键',
create_time datetime default current_timestamp comment '创建时间',
update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
creator varchar(64) comment '创建人',
updater varchar(64) comment '更新人',
deleted bit(1) comment '状态',
spu_id int not null comment 'spu编号',
sku_status tinyint comment '状态 1-正常 2-禁用',
attrs varchar(64) not null comment '规格值数组 以逗号隔开',
spu_id bigint not null comment 'spu编号',
properties varchar(64) not null comment '规格值数组-json格式 [{propertId: , valueId: }, {propertId: , valueId: }]',
price int not null DEFAULT -1 comment '销售价格单位',
original_price int not null DEFAULT -1 comment '原价 单位 ',
cost_price int not null DEFAULT -1 comment '成本价单位 ',
bar_code varchar(64) not null comment '条形码',
pic_url VARCHAR(128) not null comment '图片地址',
status tinyint comment '状态 0-正常 1-禁用',
create_time datetime default current_timestamp comment '创建时间',
update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
creator varchar(64) comment '创建人',
updater varchar(64) comment '更新人',
tenant_id bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
deleted bit(1) comment '状态',
primary key (id)
) comment '商品sku' character set utf8mb4
collate utf8mb4_general_ci;
collate utf8mb4_general_ci;

View File

@ -18,10 +18,10 @@ public interface ErrorCodeConstants {
ErrorCode BRAND_NOT_EXISTS = new ErrorCode(1008002000, "品牌不存在");
// ========== 规格名称 1008003000 ==========
ErrorCode ATTR_KEY_NOT_EXISTS = new ErrorCode(1008003000, "规格名称不存在");
ErrorCode PROPERTY_NOT_EXISTS = new ErrorCode(1008003000, "规格名称不存在");
// ========== 规格值 1008004000 ==========
ErrorCode ATTR_VALUE_NOT_EXISTS = new ErrorCode(1008004000, "规格值不存在");
ErrorCode PROPERTY_VALUE_NOT_EXISTS = new ErrorCode(1008004000, "规格值不存在");
// ========== 商品spu 1008005000 ==========
ErrorCode SPU_NOT_EXISTS = new ErrorCode(1008005000, "商品spu不存在");

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.product.controller.admin.attrkey.vo;
package cn.iocoder.yudao.module.product.controller.admin.property.vo;
import lombok.*;
import java.util.*;
@ -9,6 +9,6 @@ import javax.validation.constraints.*;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class AttrKeyCreateReqVO extends AttrKeyBaseVO {
public class PropertyCreateReqVO extends PropertyBaseVO {
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.product.controller.admin.attrkey.vo;
package cn.iocoder.yudao.module.product.controller.admin.property.vo;
import lombok.*;
import java.util.*;
@ -12,18 +12,18 @@ import com.alibaba.excel.annotation.ExcelProperty;
* @author 芋道源码
*/
@Data
public class AttrKeyExcelVO {
public class PropertyExcelVO {
@ExcelProperty("主键")
private Integer id;
private Long id;
@ExcelProperty("规格名称")
private String name;
@ExcelProperty("状态: 0 开启 1 禁用")
private Integer status;
@ExcelProperty("创建时间")
private Date createTime;
@ExcelProperty("规格名称")
private String attrName;
@ExcelProperty("状态: 1 开启 2 禁用")
private Integer status;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.product.controller.admin.attrkey.vo;
package cn.iocoder.yudao.module.product.controller.admin.property.vo;
import lombok.*;
import java.util.*;
@ -8,9 +8,15 @@ import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel(value = "管理后台 - 规格名称 Excel 导出 Request VO", description = "参数和 AttrKeyPageReqVO 是一致的")
@ApiModel(value = "管理后台 - 规格名称 Excel 导出 Request VO", description = "参数和 PropertyPageReqVO 是一致的")
@Data
public class AttrKeyExportReqVO {
public class PropertyExportReqVO {
@ApiModelProperty(value = "规格名称")
private String name;
@ApiModelProperty(value = "状态: 0 开启 1 禁用")
private Integer status;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
@ -20,10 +26,4 @@ public class AttrKeyExportReqVO {
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
@ApiModelProperty(value = "规格名称")
private String attrName;
@ApiModelProperty(value = "状态: 1 开启 2 禁用")
private Integer status;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.product.controller.admin.attrkey.vo;
package cn.iocoder.yudao.module.product.controller.admin.property.vo;
import lombok.*;
import java.util.*;
@ -12,7 +12,13 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class AttrKeyPageReqVO extends PageParam {
public class PropertyPageReqVO extends PageParam {
@ApiModelProperty(value = "规格名称")
private String name;
@ApiModelProperty(value = "状态: 0 开启 1 禁用")
private Integer status;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
@ -22,10 +28,4 @@ public class AttrKeyPageReqVO extends PageParam {
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
@ApiModelProperty(value = "规格名称")
private String attrName;
@ApiModelProperty(value = "状态: 1 开启 2 禁用")
private Integer status;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.product.controller.admin.attrkey.vo;
package cn.iocoder.yudao.module.product.controller.admin.property.vo;
import lombok.*;
import java.util.*;
@ -8,10 +8,10 @@ import io.swagger.annotations.*;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class AttrKeyRespVO extends AttrKeyBaseVO {
public class PropertyRespVO extends PropertyBaseVO {
@ApiModelProperty(value = "主键", required = true)
private Integer id;
private Long id;
@ApiModelProperty(value = "创建时间")
private Date createTime;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.product.controller.admin.attrkey.vo;
package cn.iocoder.yudao.module.product.controller.admin.property.vo;
import lombok.*;
import java.util.*;
@ -9,10 +9,10 @@ import javax.validation.constraints.*;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class AttrKeyUpdateReqVO extends AttrKeyBaseVO {
public class PropertyUpdateReqVO extends PropertyBaseVO {
@ApiModelProperty(value = "主键", required = true)
@NotNull(message = "主键不能为空")
private Integer id;
private Long id;
}

View File

@ -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);
}
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo;
package cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo;
import lombok.*;
import java.util.*;
@ -10,13 +10,13 @@ import javax.validation.constraints.*;
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Data
public class AttrValueBaseVO {
public class PropertyValueBaseVO {
@ApiModelProperty(value = "规格键id")
private String attrKeyId;
private Long propertyId;
@ApiModelProperty(value = "规格值名字")
private String attrValueName;
private String name;
@ApiModelProperty(value = "状态: 1 开启 2 禁用")
private Integer status;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo;
package cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo;
import lombok.*;
import java.util.*;
@ -9,6 +9,6 @@ import javax.validation.constraints.*;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class AttrValueCreateReqVO extends AttrValueBaseVO {
public class PropertyValueCreateReqVO extends PropertyValueBaseVO {
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo;
package cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo;
import lombok.*;
import java.util.*;
@ -12,21 +12,21 @@ import com.alibaba.excel.annotation.ExcelProperty;
* @author 芋道源码
*/
@Data
public class AttrValueExcelVO {
public class PropertyValueExcelVO {
@ExcelProperty("主键")
private Integer id;
@ExcelProperty("创建时间")
private Date createTime;
@ExcelProperty("规格键id")
private String attrKeyId;
private Long propertyId;
@ExcelProperty("规格值名字")
private String attrValueName;
private String name;
@ExcelProperty("状态: 1 开启 2 禁用")
private Integer status;
@ExcelProperty("创建时间")
private Date createTime;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo;
package cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo;
import lombok.*;
import java.util.*;
@ -8,9 +8,18 @@ import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel(value = "管理后台 - 规格值 Excel 导出 Request VO", description = "参数和 AttrValuePageReqVO 是一致的")
@ApiModel(value = "管理后台 - 规格值 Excel 导出 Request VO", description = "参数和 PropertyValuePageReqVO 是一致的")
@Data
public class AttrValueExportReqVO {
public class PropertyValueExportReqVO {
@ApiModelProperty(value = "规格键id")
private Long propertyId;
@ApiModelProperty(value = "规格值名字")
private String name;
@ApiModelProperty(value = "状态: 1 开启 2 禁用")
private Integer status;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
@ -20,13 +29,4 @@ public class AttrValueExportReqVO {
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
@ApiModelProperty(value = "规格键id")
private String attrKeyId;
@ApiModelProperty(value = "规格值名字")
private String attrValueName;
@ApiModelProperty(value = "状态: 1 开启 2 禁用")
private Integer status;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo;
package cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo;
import lombok.*;
import java.util.*;
@ -12,7 +12,16 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class AttrValuePageReqVO extends PageParam {
public class PropertyValuePageReqVO extends PageParam {
@ApiModelProperty(value = "规格键id")
private Long propertyId;
@ApiModelProperty(value = "规格值名字")
private String name;
@ApiModelProperty(value = "状态: 1 开启 2 禁用")
private Integer status;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
@ -22,13 +31,4 @@ public class AttrValuePageReqVO extends PageParam {
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
@ApiModelProperty(value = "规格键id")
private String attrKeyId;
@ApiModelProperty(value = "规格值名字")
private String attrValueName;
@ApiModelProperty(value = "状态: 1 开启 2 禁用")
private Integer status;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo;
package cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo;
import lombok.*;
import java.util.*;
@ -8,7 +8,7 @@ import io.swagger.annotations.*;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class AttrValueRespVO extends AttrValueBaseVO {
public class PropertyValueRespVO extends PropertyValueBaseVO {
@ApiModelProperty(value = "主键", required = true)
private Integer id;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.product.controller.admin.attrvalue.vo;
package cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo;
import lombok.*;
import java.util.*;
@ -9,7 +9,7 @@ import javax.validation.constraints.*;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class AttrValueUpdateReqVO extends AttrValueBaseVO {
public class PropertyValueUpdateReqVO extends PropertyValueBaseVO {
@ApiModelProperty(value = "主键", required = true)
@NotNull(message = "主键不能为空")

View File

@ -14,14 +14,11 @@ public class SkuBaseVO {
@ApiModelProperty(value = "spu编号", required = true)
@NotNull(message = "spu编号不能为空")
private Integer spuId;
private Long spuId;
@ApiModelProperty(value = "状态: 1-正常 2-禁用")
private Integer skuStatus;
@ApiModelProperty(value = "规格值数组, 以逗号隔开", required = true)
@NotNull(message = "规格值数组, 以逗号隔开不能为空")
private String attrs;
@ApiModelProperty(value = "规格值数组-json格式 [{propertId: , valueId: }, {propertId: , valueId: }]", required = true)
@NotNull(message = "规格值数组-json格式 [{propertId: , valueId: }, {propertId: , valueId: }]不能为空")
private String properties;
@ApiModelProperty(value = "销售价格,单位:分", required = true)
@NotNull(message = "销售价格,单位:分不能为空")
@ -43,4 +40,7 @@ public class SkuBaseVO {
@NotNull(message = "图片地址不能为空")
private String picUrl;
@ApiModelProperty(value = "状态: 0-正常 1-禁用")
private Integer status;
}

View File

@ -17,17 +17,11 @@ public class SkuExcelVO {
@ExcelProperty("主键")
private Integer id;
@ExcelProperty("创建时间")
private Date createTime;
@ExcelProperty("spu编号")
private Integer spuId;
private Long spuId;
@ExcelProperty("状态: 1-正常 2-禁用")
private Integer skuStatus;
@ExcelProperty("规格值数组, 以逗号隔开")
private String attrs;
@ExcelProperty("规格值数组-json格式 [{propertId: , valueId: }, {propertId: , valueId: }]")
private String properties;
@ExcelProperty("销售价格,单位:分")
private Integer price;
@ -44,4 +38,10 @@ public class SkuExcelVO {
@ExcelProperty("图片地址")
private String picUrl;
@ExcelProperty("状态: 0-正常 1-禁用")
private Integer status;
@ExcelProperty("创建时间")
private Date createTime;
}

View File

@ -12,22 +12,11 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data
public class SkuExportReqVO {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
@ApiModelProperty(value = "spu编号")
private Integer spuId;
private Long spuId;
@ApiModelProperty(value = "状态: 1-正常 2-禁用")
private Integer skuStatus;
@ApiModelProperty(value = "规格值数组, 以逗号隔开")
private String attrs;
@ApiModelProperty(value = "规格值数组-json格式 [{propertId: , valueId: }, {propertId: , valueId: }]")
private String properties;
@ApiModelProperty(value = "销售价格,单位:分")
private Integer price;
@ -44,4 +33,15 @@ public class SkuExportReqVO {
@ApiModelProperty(value = "图片地址")
private String picUrl;
@ApiModelProperty(value = "状态: 0-正常 1-禁用")
private Integer status;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
}

View File

@ -14,22 +14,11 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true)
public class SkuPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
@ApiModelProperty(value = "spu编号")
private Integer spuId;
private Long spuId;
@ApiModelProperty(value = "状态: 1-正常 2-禁用")
private Integer skuStatus;
@ApiModelProperty(value = "规格值数组, 以逗号隔开")
private String attrs;
@ApiModelProperty(value = "规格值数组-json格式 [{propertId: , valueId: }, {propertId: , valueId: }]")
private String properties;
@ApiModelProperty(value = "销售价格,单位:分")
private Integer price;
@ -46,4 +35,15 @@ public class SkuPageReqVO extends PageParam {
@ApiModelProperty(value = "图片地址")
private String picUrl;
@ApiModelProperty(value = "状态: 0-正常 1-禁用")
private Integer status;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
}

View File

@ -15,9 +15,6 @@ public class SpuBaseVO {
@ApiModelProperty(value = "商品名称")
private String name;
@ApiModelProperty(value = "上下架状态: true 上架false 下架")
private Boolean visible;
@ApiModelProperty(value = "卖点", required = true)
@NotNull(message = "卖点不能为空")
private String sellPoint;
@ -28,13 +25,10 @@ public class SpuBaseVO {
@ApiModelProperty(value = "分类id", required = true)
@NotNull(message = "分类id不能为空")
private Integer cid;
private Long categoryId;
@ApiModelProperty(value = "列表图")
private String listPicUrl;
@ApiModelProperty(value = "商品主图地址, 数组,以逗号分隔, 最多上传15张", required = true)
@NotNull(message = "商品主图地址, 数组,以逗号分隔, 最多上传15张不能为空")
@ApiModelProperty(value = "商品主图地址,* 数组,以逗号分隔,最多上传15张", required = true)
@NotNull(message = "商品主图地址,* 数组,以逗号分隔,最多上传15张不能为空")
private String picUrls;
@ApiModelProperty(value = "排序字段", required = true)
@ -44,10 +38,13 @@ public class SpuBaseVO {
@ApiModelProperty(value = "点赞初始人数")
private Integer likeCount;
@ApiModelProperty(value = "价格")
@ApiModelProperty(value = "价格 单位使用:分")
private Integer price;
@ApiModelProperty(value = "库存数量")
private Integer quantity;
@ApiModelProperty(value = "上下架状态: 0 上架(开启) 1 下架(禁用)")
private Boolean status;
}

View File

@ -17,15 +17,9 @@ public class SpuExcelVO {
@ExcelProperty("主键")
private Integer id;
@ExcelProperty("创建时间")
private Date createTime;
@ExcelProperty("商品名称")
private String name;
@ExcelProperty("上下架状态: true 上架false 下架")
private Boolean visible;
@ExcelProperty("卖点")
private String sellPoint;
@ -33,12 +27,9 @@ public class SpuExcelVO {
private String description;
@ExcelProperty("分类id")
private Integer cid;
private Long categoryId;
@ExcelProperty("列表图")
private String listPicUrl;
@ExcelProperty("商品主图地址, 数组,以逗号分隔, 最多上传15张")
@ExcelProperty("商品主图地址,* 数组,以逗号分隔,最多上传15张")
private String picUrls;
@ExcelProperty("排序字段")
@ -47,10 +38,16 @@ public class SpuExcelVO {
@ExcelProperty("点赞初始人数")
private Integer likeCount;
@ExcelProperty("价格")
@ExcelProperty("价格 单位使用:分")
private Integer price;
@ExcelProperty("库存数量")
private Integer quantity;
@ExcelProperty("上下架状态: 0 上架(开启) 1 下架(禁用)")
private Boolean status;
@ExcelProperty("创建时间")
private Date createTime;
}

View File

@ -12,20 +12,9 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data
public class SpuExportReqVO {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
@ApiModelProperty(value = "商品名称")
private String name;
@ApiModelProperty(value = "上下架状态: true 上架false 下架")
private Boolean visible;
@ApiModelProperty(value = "卖点")
private String sellPoint;
@ -33,12 +22,9 @@ public class SpuExportReqVO {
private String description;
@ApiModelProperty(value = "分类id")
private Integer cid;
private Long categoryId;
@ApiModelProperty(value = "列表图")
private String listPicUrl;
@ApiModelProperty(value = "商品主图地址, 数组,以逗号分隔, 最多上传15张")
@ApiModelProperty(value = "商品主图地址,* 数组,以逗号分隔,最多上传15张")
private String picUrls;
@ApiModelProperty(value = "排序字段")
@ -47,10 +33,21 @@ public class SpuExportReqVO {
@ApiModelProperty(value = "点赞初始人数")
private Integer likeCount;
@ApiModelProperty(value = "价格")
@ApiModelProperty(value = "价格 单位使用:分")
private Integer price;
@ApiModelProperty(value = "库存数量")
private Integer quantity;
@ApiModelProperty(value = "上下架状态: 0 上架(开启) 1 下架(禁用)")
private Boolean status;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
}

View File

@ -14,20 +14,9 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true)
public class SpuPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
@ApiModelProperty(value = "商品名称")
private String name;
@ApiModelProperty(value = "上下架状态: true 上架false 下架")
private Boolean visible;
@ApiModelProperty(value = "卖点")
private String sellPoint;
@ -35,12 +24,9 @@ public class SpuPageReqVO extends PageParam {
private String description;
@ApiModelProperty(value = "分类id")
private Integer cid;
private Long categoryId;
@ApiModelProperty(value = "列表图")
private String listPicUrl;
@ApiModelProperty(value = "商品主图地址, 数组,以逗号分隔, 最多上传15张")
@ApiModelProperty(value = "商品主图地址,* 数组,以逗号分隔,最多上传15张")
private String picUrls;
@ApiModelProperty(value = "排序字段")
@ -49,10 +35,21 @@ public class SpuPageReqVO extends PageParam {
@ApiModelProperty(value = "点赞初始人数")
private Integer likeCount;
@ApiModelProperty(value = "价格")
@ApiModelProperty(value = "价格 单位使用:分")
private Integer price;
@ApiModelProperty(value = "库存数量")
private Integer quantity;
@ApiModelProperty(value = "上下架状态: 0 上架(开启) 1 下架(禁用)")
private Boolean status;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -28,15 +28,11 @@ public class SkuDO extends BaseDO {
/**
* spu编号
*/
private Integer spuId;
private Long spuId;
/**
* 状态 1-正常 2-禁用
* 规格值数组-json格式 [{propertId: , valueId: }, {propertId: , valueId: }]
*/
private Integer skuStatus;
/**
* 规格值数组 以逗号隔开
*/
private String attrs;
private String properties;
/**
* 销售价格单位
*/
@ -57,5 +53,9 @@ public class SkuDO extends BaseDO {
* 图片地址
*/
private String picUrl;
/**
* 状态 0-正常 1-禁用
*/
private Integer status;
}

View File

@ -29,10 +29,6 @@ public class SpuDO extends BaseDO {
* 商品名称
*/
private String name;
/**
* 上下架状态 true 上架false 下架
*/
private Boolean visible;
/**
* 卖点
*/
@ -44,13 +40,9 @@ public class SpuDO extends BaseDO {
/**
* 分类id
*/
private Integer cid;
private Long categoryId;
/**
* 列表图
*/
private String listPicUrl;
/**
* 商品主图地址, 数组以逗号分隔, 最多上传15张
* 商品主图地址,* 数组以逗号分隔,最多上传15张
*/
private String picUrls;
/**
@ -62,12 +54,16 @@ public class SpuDO extends BaseDO {
*/
private Integer likeCount;
/**
* 价格
* 价格 单位使用
*/
private Integer price;
/**
* 库存数量
*/
private Integer quantity;
/**
* 上下架状态 0 上架开启 1 下架禁用
*/
private Boolean status;
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -19,29 +19,29 @@ public interface SkuMapper extends BaseMapperX<SkuDO> {
default PageResult<SkuDO> selectPage(SkuPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<SkuDO>()
.betweenIfPresent(SkuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.eqIfPresent(SkuDO::getSpuId, reqVO.getSpuId())
.eqIfPresent(SkuDO::getSkuStatus, reqVO.getSkuStatus())
.eqIfPresent(SkuDO::getAttrs, reqVO.getAttrs())
.eqIfPresent(SkuDO::getProperties, reqVO.getProperties())
.eqIfPresent(SkuDO::getPrice, reqVO.getPrice())
.eqIfPresent(SkuDO::getOriginalPrice, reqVO.getOriginalPrice())
.eqIfPresent(SkuDO::getCostPrice, reqVO.getCostPrice())
.eqIfPresent(SkuDO::getBarCode, reqVO.getBarCode())
.eqIfPresent(SkuDO::getPicUrl, reqVO.getPicUrl())
.eqIfPresent(SkuDO::getStatus, reqVO.getStatus())
.betweenIfPresent(SkuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(SkuDO::getId));
}
default List<SkuDO> selectList(SkuExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<SkuDO>()
.betweenIfPresent(SkuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.eqIfPresent(SkuDO::getSpuId, reqVO.getSpuId())
.eqIfPresent(SkuDO::getSkuStatus, reqVO.getSkuStatus())
.eqIfPresent(SkuDO::getAttrs, reqVO.getAttrs())
.eqIfPresent(SkuDO::getProperties, reqVO.getProperties())
.eqIfPresent(SkuDO::getPrice, reqVO.getPrice())
.eqIfPresent(SkuDO::getOriginalPrice, reqVO.getOriginalPrice())
.eqIfPresent(SkuDO::getCostPrice, reqVO.getCostPrice())
.eqIfPresent(SkuDO::getBarCode, reqVO.getBarCode())
.eqIfPresent(SkuDO::getPicUrl, reqVO.getPicUrl())
.eqIfPresent(SkuDO::getStatus, reqVO.getStatus())
.betweenIfPresent(SkuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(SkuDO::getId));
}

View File

@ -19,35 +19,33 @@ public interface SpuMapper extends BaseMapperX<SpuDO> {
default PageResult<SpuDO> selectPage(SpuPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<SpuDO>()
.betweenIfPresent(SpuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.likeIfPresent(SpuDO::getName, reqVO.getName())
.eqIfPresent(SpuDO::getVisible, reqVO.getVisible())
.eqIfPresent(SpuDO::getSellPoint, reqVO.getSellPoint())
.eqIfPresent(SpuDO::getDescription, reqVO.getDescription())
.eqIfPresent(SpuDO::getCid, reqVO.getCid())
.eqIfPresent(SpuDO::getListPicUrl, reqVO.getListPicUrl())
.eqIfPresent(SpuDO::getCategoryId, reqVO.getCategoryId())
.eqIfPresent(SpuDO::getPicUrls, reqVO.getPicUrls())
.eqIfPresent(SpuDO::getSort, reqVO.getSort())
.eqIfPresent(SpuDO::getLikeCount, reqVO.getLikeCount())
.eqIfPresent(SpuDO::getPrice, reqVO.getPrice())
.eqIfPresent(SpuDO::getQuantity, reqVO.getQuantity())
.eqIfPresent(SpuDO::getStatus, reqVO.getStatus())
.betweenIfPresent(SpuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(SpuDO::getId));
}
default List<SpuDO> selectList(SpuExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<SpuDO>()
.betweenIfPresent(SpuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.likeIfPresent(SpuDO::getName, reqVO.getName())
.eqIfPresent(SpuDO::getVisible, reqVO.getVisible())
.eqIfPresent(SpuDO::getSellPoint, reqVO.getSellPoint())
.eqIfPresent(SpuDO::getDescription, reqVO.getDescription())
.eqIfPresent(SpuDO::getCid, reqVO.getCid())
.eqIfPresent(SpuDO::getListPicUrl, reqVO.getListPicUrl())
.eqIfPresent(SpuDO::getCategoryId, reqVO.getCategoryId())
.eqIfPresent(SpuDO::getPicUrls, reqVO.getPicUrls())
.eqIfPresent(SpuDO::getSort, reqVO.getSort())
.eqIfPresent(SpuDO::getLikeCount, reqVO.getLikeCount())
.eqIfPresent(SpuDO::getPrice, reqVO.getPrice())
.eqIfPresent(SpuDO::getQuantity, reqVO.getQuantity())
.eqIfPresent(SpuDO::getStatus, reqVO.getStatus())
.betweenIfPresent(SpuDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(SpuDO::getId));
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -1,9 +1,9 @@
package cn.iocoder.yudao.module.product.service.attrkey;
package cn.iocoder.yudao.module.product.service.property;
import java.util.*;
import javax.validation.*;
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.controller.admin.property.vo.*;
import cn.iocoder.yudao.module.product.dal.dataobject.property.PropertyDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
/**
@ -11,7 +11,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
*
* @author 芋道源码
*/
public interface AttrKeyService {
public interface PropertyService {
/**
* 创建规格名称
@ -19,21 +19,21 @@ public interface AttrKeyService {
* @param createReqVO 创建信息
* @return 编号
*/
Integer createAttrKey(@Valid AttrKeyCreateReqVO createReqVO);
Long createProperty(@Valid PropertyCreateReqVO createReqVO);
/**
* 更新规格名称
*
* @param updateReqVO 更新信息
*/
void updateAttrKey(@Valid AttrKeyUpdateReqVO updateReqVO);
void updateProperty(@Valid PropertyUpdateReqVO updateReqVO);
/**
* 删除规格名称
*
* @param id 编号
*/
void deleteAttrKey(Integer id);
void deleteProperty(Long id);
/**
* 获得规格名称
@ -41,7 +41,7 @@ public interface AttrKeyService {
* @param id 编号
* @return 规格名称
*/
AttrKeyDO getAttrKey(Integer id);
PropertyDO getProperty(Long id);
/**
* 获得规格名称列表
@ -49,7 +49,7 @@ public interface AttrKeyService {
* @param ids 编号
* @return 规格名称列表
*/
List<AttrKeyDO> getAttrKeyList(Collection<Integer> ids);
List<PropertyDO> getPropertyList(Collection<Long> ids);
/**
* 获得规格名称分页
@ -57,7 +57,7 @@ public interface AttrKeyService {
* @param pageReqVO 分页查询
* @return 规格名称分页
*/
PageResult<AttrKeyDO> getAttrKeyPage(AttrKeyPageReqVO pageReqVO);
PageResult<PropertyDO> getPropertyPage(PropertyPageReqVO pageReqVO);
/**
* 获得规格名称列表, 用于 Excel 导出
@ -65,6 +65,6 @@ public interface AttrKeyService {
* @param exportReqVO 查询条件
* @return 规格名称列表
*/
List<AttrKeyDO> getAttrKeyList(AttrKeyExportReqVO exportReqVO);
List<PropertyDO> getPropertyList(PropertyExportReqVO exportReqVO);
}

View File

@ -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);
}
}

View File

@ -1,9 +1,9 @@
package cn.iocoder.yudao.module.product.service.attrvalue;
package cn.iocoder.yudao.module.product.service.propertyvalue;
import java.util.*;
import javax.validation.*;
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.controller.admin.propertyvalue.vo.*;
import cn.iocoder.yudao.module.product.dal.dataobject.propertyvalue.PropertyValueDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
/**
@ -11,7 +11,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
*
* @author 芋道源码
*/
public interface AttrValueService {
public interface PropertyValueService {
/**
* 创建规格值
@ -19,21 +19,21 @@ public interface AttrValueService {
* @param createReqVO 创建信息
* @return 编号
*/
Integer createAttrValue(@Valid AttrValueCreateReqVO createReqVO);
Integer createPropertyValue(@Valid PropertyValueCreateReqVO createReqVO);
/**
* 更新规格值
*
* @param updateReqVO 更新信息
*/
void updateAttrValue(@Valid AttrValueUpdateReqVO updateReqVO);
void updatePropertyValue(@Valid PropertyValueUpdateReqVO updateReqVO);
/**
* 删除规格值
*
* @param id 编号
*/
void deleteAttrValue(Integer id);
void deletePropertyValue(Integer id);
/**
* 获得规格值
@ -41,7 +41,7 @@ public interface AttrValueService {
* @param id 编号
* @return 规格值
*/
AttrValueDO getAttrValue(Integer id);
PropertyValueDO getPropertyValue(Integer id);
/**
* 获得规格值列表
@ -49,7 +49,7 @@ public interface AttrValueService {
* @param ids 编号
* @return 规格值列表
*/
List<AttrValueDO> getAttrValueList(Collection<Integer> ids);
List<PropertyValueDO> getPropertyValueList(Collection<Integer> ids);
/**
* 获得规格值分页
@ -57,7 +57,7 @@ public interface AttrValueService {
* @param pageReqVO 分页查询
* @return 规格值分页
*/
PageResult<AttrValueDO> getAttrValuePage(AttrValuePageReqVO pageReqVO);
PageResult<PropertyValueDO> getPropertyValuePage(PropertyValuePageReqVO pageReqVO);
/**
* 获得规格值列表, 用于 Excel 导出
@ -65,6 +65,6 @@ public interface AttrValueService {
* @param exportReqVO 查询条件
* @return 规格值列表
*/
List<AttrValueDO> getAttrValueList(AttrValueExportReqVO exportReqVO);
List<PropertyValueDO> getPropertyValueList(PropertyValueExportReqVO exportReqVO);
}

View File

@ -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);
}
}

View File

@ -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));
}
}