mall:调整部分 SPU、SKU 的表设计

pull/2/head
YunaiV 2022-07-31 02:19:18 +08:00
parent fa9823161e
commit 2340f09c68
12 changed files with 89 additions and 120 deletions

View File

@ -71,24 +71,6 @@ INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, com
VALUES ('', 'product:property:export', 3, 5, @parentId, '', '', '', 0);
-- SQL
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', '', 2, 2, 2001, 'spu', '', 'mall/product/spu/index', 0);
-- ID
SELECT @parentId := LAST_INSERT_ID();
-- SQL
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'product:spu:query', 3, 1, @parentId, '', '', '', 0);
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'product:spu:create', 3, 2, @parentId, '', '', '', 0);
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'product:spu:update', 3, 3, @parentId, '', '', '', 0);
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'product:spu:delete', 3, 4, @parentId, '', '', '', 0);
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('', 'product:spu:export', 3, 5, @parentId, '', '', '', 0);
--
@ -127,54 +109,6 @@ create table product_property_value
) comment '' character set utf8mb4
collate utf8mb4_general_ci;
-- spu
drop table if exists product_spu;
create table product_spu
(
id bigint NOT NULL AUTO_INCREMENT 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) NOT NULL DEFAULT b'0' COMMENT '',
primary key (id)
) comment 'spu' character set utf8mb4
collate utf8mb4_general_ci;
-- sku
drop table if exists product_sku;
create table product_sku
(
id bigint NOT NULL AUTO_INCREMENT 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) NOT NULL DEFAULT b'0' COMMENT '',
primary key (id)
) comment 'sku' character set utf8mb4
collate utf8mb4_general_ci;
---Market-BannerSQL

View File

@ -6,7 +6,7 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*;
import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSkuDO;
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;

View File

@ -10,8 +10,7 @@ import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import org.springframework.util.StringUtils;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSkuDO;
/**
* sku Convert

View File

@ -1,18 +1,14 @@
package cn.iocoder.yudao.module.product.convert.spu;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*;
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO;
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
import org.springframework.util.StringUtils;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* spu Convert
@ -24,18 +20,12 @@ public interface ProductSpuConvert {
ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class);
@Mapping(source = "picUrls", target = "picUrls", qualifiedByName = "translatePicUrlsFromStringList")
ProductSpuDO convert(ProductSpuCreateReqVO bean);
@Mapping(source = "picUrls", target = "picUrls", qualifiedByName = "translatePicUrlsFromStringList")
ProductSpuDO convert(SpuUpdateReqVO bean);
@Mapping(source = "picUrls", target = "picUrls", qualifiedByName = "tokenizeToStringArray")
SpuRespVO convert(ProductSpuDO bean);
@Mapping(source = "picUrls", target = "picUrls", qualifiedByName = "tokenizeToStringArray")
SpuExcelVO convertToExcelVO(ProductSpuDO bean);
List<SpuRespVO> convertList(List<ProductSpuDO> list);
PageResult<SpuRespVO> convertPage(PageResult<ProductSpuDO> page);
@ -44,16 +34,6 @@ public interface ProductSpuConvert {
SpuPageReqVO convert(AppSpuPageReqVO bean);
@Mapping(source = "picUrls", target = "picUrls", qualifiedByName = "tokenizeToStringArray")
AppSpuPageRespVO convertAppResp(ProductSpuDO list);
@Named("tokenizeToStringArray")
default List<String> translatePicUrlsArrayFromString(String picUrls) {
return Arrays.asList(StringUtils.tokenizeToStringArray(picUrls, ","));
}
@Named("translatePicUrlsFromStringList")
default String translatePicUrlsFromList(List<String> picUrls) {
return StringUtils.collectionToCommaDelimitedString(picUrls);
}
}

View File

@ -0,0 +1,32 @@
package cn.iocoder.yudao.module.product.dal.dataobject.group;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
/**
* DO
*
* @author
*/
@TableName("product_group")
@KeySequence("product_group_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProductGroupDO extends BaseDO {
/**
*
*/
@TableId
private Long id;
// TODO 芋艿:字段补全
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.product.dal.dataobject.sku;
package cn.iocoder.yudao.module.product.dal.dataobject.spu;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;

View File

@ -1,13 +1,21 @@
package cn.iocoder.yudao.module.product.dal.dataobject.spu;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO;
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
import cn.iocoder.yudao.module.product.dal.dataobject.group.ProductGroupDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*;
import java.util.List;
/**
* spu DO
* SPU DO
*
* @author
*/
@ -22,7 +30,7 @@ import lombok.*;
public class ProductSpuDO extends BaseDO {
/**
*
* SPU
*/
@TableId
private Long id;
@ -31,41 +39,62 @@ public class ProductSpuDO extends BaseDO {
*/
private String name;
/**
*
*
*/
private String sellPoint;
/**
*
*
*/
private String description;
/**
* id
*
*
* {@link ProductCategoryDO#getId()}
*/
private Long categoryId;
/**
* ,* ,15
*
*
* {@link ProductBrandDO#getId()}
*/
// TODO frankyList<String>。可以参考别的模块,怎么处理这种类型的哈
private String picUrls;
private Long brandId;
/**
*
*
* {@link ProductGroupDO#getId()}
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List<Long> groupIds;
/**
*
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List<String> picUrls;
/**
*
*/
private Integer sort;
/**
*
*
*
* {@link CommonStatusEnum}
*/
private Integer likeCount;
private Integer status;
/**
* 使
* 使
*
* {@link ProductSkuDO#getPrice()}
*/
private Integer price;
/**
*
*
* {@link ProductSkuDO#getPrice()}
*/
private Integer quantity;
/**
* 0 1
*/
private Boolean status;
// TODO 芋艿:配送方式:商家配送、商家自提
// TODO 芋艿:运费设置;如果选择了 “商家配送” 配送方式,则选择「运费设置」编号
}

View File

@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuExportReqVO;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSkuDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;

View File

@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateR
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuExportReqVO;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuPageReqVO;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuUpdateReqVO;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSkuDO;
import javax.validation.Valid;
import java.util.Collection;

View File

@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPrope
import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.ProductPropertyValueRespVO;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*;
import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSkuDO;
import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper;
import cn.iocoder.yudao.module.product.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.product.service.property.ProductPropertyService;

View File

@ -12,7 +12,7 @@ import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageReqVO;
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppSpuPageRespVO;
import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert;
import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSkuDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper;
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;

View File

@ -2,29 +2,24 @@ package cn.iocoder.yudao.module.product.service.sku;
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.sku.vo.*;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSkuDO;
import cn.iocoder.yudao.module.product.dal.mysql.sku.ProductSkuMapper;
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 ProductSkuServiceImpl}