将 onemall 老代码,统一到归档目录,后续不断迁移移除

This commit is contained in:
YunaiV
2022-06-16 09:06:44 +08:00
parent 64c478a45b
commit 71930d492e
1095 changed files with 0 additions and 16 deletions

View File

@@ -0,0 +1,17 @@
package cn.iocoder.mall.productservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class ProductServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ProductServiceApplication.class, args);
}
}

View File

@@ -0,0 +1,12 @@
package cn.iocoder.mall.productservice.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
/**
* Spring Aop 配置类
*/
@Configuration
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
public class AopConfiguration {
}

View File

@@ -0,0 +1,28 @@
package cn.iocoder.mall.productservice.config;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@MapperScan("cn.iocoder.mall.productservice.dal.mysql.mapper") // 扫描对应的 Mapper 接口
@EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理。
public class DatabaseConfiguration {
// 数据库连接池 Druid
@Bean
public ISqlInjector sqlInjector() {
return new DefaultSqlInjector(); // MyBatis Plus 逻辑删除
}
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor(); // MyBatis Plus 分页插件
}
}

View File

@@ -0,0 +1,128 @@
package cn.iocoder.mall.productservice.controller;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.manager.attr.ProductAttrManager;
import cn.iocoder.mall.productservice.rpc.attr.dto.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@RestController
@RequestMapping("/product/attr")
@Api("商品属性")
public class ProductAttrController {
@Autowired
private ProductAttrManager productAttrManager;
@PostMapping("/createProductAttrKey")
@ApiOperation("创建商品规格键")
CommonResult<Integer> createProductAttrKey(@RequestBody ProductAttrKeyCreateReqDTO createDTO){
return success(productAttrManager.createProductAttrKey(createDTO));
}
/**
* 更新商品规格键
*
* @param updateDTO 更新商品规格键 DTO
*/
@PostMapping("/updateProductAttrKey")
@ApiOperation("更新商品规格键")
CommonResult<Boolean> updateProductAttrKey(@RequestBody ProductAttrKeyUpdateReqDTO updateDTO){
productAttrManager.updateProductAttrKey(updateDTO);
return success(true);
}
/**
* 获得商品规格键
*
* @param productAttrKeyId 商品规格键编号
* @return 商品规格键
*/
@GetMapping("/getProductAttrKey")
@ApiOperation("获得商品规格键")
CommonResult<ProductAttrKeyRespDTO> getProductAttrKey(@RequestParam("productAttrKeyId") Integer productAttrKeyId){
return success(productAttrManager.getProductAttrKey(productAttrKeyId));
}
/**
* 获得商品规格键列表
*
* @param productAttrKeyIds 商品规格键编号列表
* @return 商品规格键列表
*/
@GetMapping("/listProductAttrKeys")
@ApiOperation("获得商品规格键列表")
CommonResult<List<ProductAttrKeyRespDTO>> listProductAttrKeys(@RequestParam("productAttrKeyIds") List<Integer> productAttrKeyIds){
return success(productAttrManager.listProductAttrKeys(productAttrKeyIds));
}
/**
* 获得商品规格键分页
*
* @param pageDTO 商品规格键分页查询
* @return 商品规格键分页结果
*/
@PostMapping("/pageProductAttrKey")
@ApiOperation("获得商品规格键分页")
CommonResult<PageResult<ProductAttrKeyRespDTO>> pageProductAttrKey(@RequestBody ProductAttrKeyPageReqDTO pageDTO){
return success(productAttrManager.pageProductAttrKey(pageDTO));
}
/**
* 创建商品规格值
*
* @param createDTO 创建商品规格值 DTO
* @return 商品规格值编号
*/
@PostMapping("/createProductAttrValue")
@ApiOperation("创建商品规格值")
CommonResult<Integer> createProductAttrValue(@RequestBody ProductAttrValueCreateReqDTO createDTO){
return success(productAttrManager.createProductAttrValue(createDTO));
}
/**
* 更新商品规格值
*
* @param updateDTO 更新商品规格值 DTO
*/
@PostMapping("/updateProductAttrValue")
@ApiOperation("更新商品规格值")
CommonResult<Boolean> updateProductAttrValue(@RequestBody ProductAttrValueUpdateReqDTO updateDTO){
productAttrManager.updateProductAttrValue(updateDTO);
return success(true);
}
/**
* 获得商品规格值
*
* @param productAttrValueId 商品规格值编号
* @return 商品规格值
*/
@GetMapping("/getProductAttrValue")
@ApiOperation("获得商品规格值")
CommonResult<ProductAttrValueRespDTO> getProductAttrValue(@RequestParam("productAttrValueId") Integer productAttrValueId){
return success(productAttrManager.getProductAttrValue(productAttrValueId));
}
/**
* 获得商品规格值列表
*
* @param queryDTO 商品规格值的列表查询条件 DTO
* @return 商品规格值列表
*/
@PostMapping("/listProductAttrValues")
@ApiOperation("获得商品规格值列表")
CommonResult<List<ProductAttrValueRespDTO>> listProductAttrValues(@RequestBody ProductAttrValueListQueryReqDTO queryDTO){
return success(productAttrManager.listProductAttrValues(queryDTO));
}
}

View File

@@ -0,0 +1,98 @@
package cn.iocoder.mall.productservice.controller;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.manager.brand.ProductBrandManager;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandCreateReqDTO;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandPageReqDTO;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandUpdateReqDTO;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
* Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/7
*/
@RestController
@RequestMapping("/product/brand")
@Api("商品品牌")
public class ProductBrandController {
@Autowired
private ProductBrandManager productBrandManager;
/**
* 创建商品品牌
*
* @param createDTO 创建商品品牌 DTO
* @return 商品品牌编号
*/
@PostMapping("createProductBrand")
CommonResult<Integer> createProductBrand(@RequestBody ProductBrandCreateReqDTO createDTO){
return success(productBrandManager.createProductBrand(createDTO));
}
/**
* 更新商品品牌
*
* @param updateDTO 更新商品品牌 DTO
*/
@PostMapping("updateProductBrand")
CommonResult<Boolean> updateProductBrand(@RequestBody ProductBrandUpdateReqDTO updateDTO){
productBrandManager.updateProductBrand(updateDTO);
return success(true);
}
/**
* 删除商品品牌
*
* @param productBrandId 商品品牌编号
*/
@GetMapping("deleteProductBrand")
CommonResult<Boolean> deleteProductBrand(@RequestParam("productBrandId") Integer productBrandId){
productBrandManager.deleteProductBrand(productBrandId);
return success(true);
}
/**
* 获得商品品牌
*
* @param productBrandId 商品品牌编号
* @return 商品品牌
*/
@GetMapping("getProductBrand")
CommonResult<ProductBrandRespDTO> getProductBrand(@RequestParam("productBrandId")Integer productBrandId){
return success(productBrandManager.getProductBrand(productBrandId));
}
/**
* 获得商品品牌列表
*
* @param productBrandIds 商品品牌编号列表
* @return 商品品牌列表
*/
@GetMapping("listProductBrands")
CommonResult<List<ProductBrandRespDTO>> listProductBrands(@RequestParam("productBrandIds") List<Integer> productBrandIds){
return success(productBrandManager.listProductBrands(productBrandIds));
}
/**
* 获得商品品牌分页
*
* @param pageDTO 商品品牌分页查询
* @return 商品品牌分页结果
*/
@PostMapping("pageProductBrand")
CommonResult<PageResult<ProductBrandRespDTO>> pageProductBrand(@RequestBody ProductBrandPageReqDTO pageDTO){
return success(productBrandManager.pageProductBrand(pageDTO));
}
}

View File

@@ -0,0 +1,107 @@
package cn.iocoder.mall.productservice.controller;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.manager.brand.ProductBrandManager;
import cn.iocoder.mall.productservice.manager.category.ProductCategoryManager;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandCreateReqDTO;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandPageReqDTO;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandUpdateReqDTO;
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryCreateReqDTO;
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryListQueryReqDTO;
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO;
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryUpdateReqDTO;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
* Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/7
*/
@RestController
@RequestMapping("/product/category")
@Api("商品品牌")
public class ProductCategoryController {
@Autowired
private ProductCategoryManager productCategoryManager;
/**
* 创建商品分类
*
* @param createDTO 创建商品分类 DTO
* @return 商品分类编号
*/
@PostMapping("createProductCategory")
CommonResult<Integer> createProductCategory(@RequestBody ProductCategoryCreateReqDTO createDTO){
return success(productCategoryManager.createProductCategory(createDTO));
}
/**
* 更新商品分类
*
* @param updateDTO 更新商品分类 DTO
*/
@PostMapping("updateProductCategory")
CommonResult<Boolean> updateProductCategory(@RequestBody ProductCategoryUpdateReqDTO updateDTO){
productCategoryManager.updateProductCategory(updateDTO);
return success(true);
}
/**
* 删除商品分类
*
* @param productCategoryId 商品分类编号
*/
@GetMapping("deleteProductCategory")
CommonResult<Boolean> deleteProductCategory(@RequestParam("productCategoryId") Integer productCategoryId){
productCategoryManager.deleteProductCategory(productCategoryId);
return success(true);
}
/**
* 获得商品分类
*
* @param productCategoryId 商品分类编号
* @return 商品分类
*/
@GetMapping("getProductCategory")
CommonResult<ProductCategoryRespDTO> getProductCategory(@RequestParam("productCategoryId")Integer productCategoryId){
return success(productCategoryManager.getProductCategory(productCategoryId));
}
/**
* 获得商品分类列表
*
* @param productCategoryIds 商品分类编号列表
* @return 商品分类列表
*/
@GetMapping("listProductCategoriesByIds")
CommonResult<List<ProductCategoryRespDTO>> listProductCategoriesByIds(@RequestParam("productCategoryIds")Collection<Integer> productCategoryIds){
return success(productCategoryManager.listProductCategories(productCategoryIds));
}
/**
* 获得符合条件的商品分类列表
*
* @return 商品分类列表
*/
@PostMapping("listProductCategories")
CommonResult<List<ProductCategoryRespDTO>> listProductCategories(@RequestBody ProductCategoryListQueryReqDTO listQueryReqDTO){
return success(productCategoryManager.listProductCategories(listQueryReqDTO));
}
}

View File

@@ -0,0 +1,47 @@
package cn.iocoder.mall.productservice.controller;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.manager.attr.ProductAttrManager;
import cn.iocoder.mall.productservice.manager.sku.ProductSkuManager;
import cn.iocoder.mall.productservice.rpc.attr.dto.*;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@RestController
@RequestMapping("/product/sku")
@Api("商品sku")
public class ProductSkuController {
@Autowired
private ProductSkuManager productSkuManager;
/**
* 获得商品 SKU
*
* @param productSkuId 商品 SKU 编号
* @return 商品 SKU
*/
@GetMapping("getProductSku")
CommonResult<ProductSkuRespDTO> getProductSku(@RequestParam("productSkuId") Integer productSkuId){
return success(productSkuManager.getProductSku(productSkuId));
}
/**
* 获得商品 SKU 列表
*
* @param queryReqDTO 商品 SKU 列表的查询请求 DTO
* @return 商品 SKU 列表
*/
@PostMapping("listProductSkus")
CommonResult<List<ProductSkuRespDTO>> listProductSkus(@RequestBody ProductSkuListQueryReqDTO queryReqDTO){
return success(productSkuManager.listProductSkus(queryReqDTO));
}
}

View File

@@ -0,0 +1,13 @@
### /product/spu/get 获得商品 SPU
GET http://localhost:38082/product/spu/get?productSpuId=32
###
### /product/spu/get 获得商品 SPU
GET http://localhost:38082/product/spu/lislistProductSpuIdst?lastSpuId=30&limit=10
###
### /product/spu/get 获得商品 SPU
GET http://localhost:38082/product/spu/getProductSpuDetail?productSpuId=32&fields=attr,sku
###

View File

@@ -0,0 +1,91 @@
package cn.iocoder.mall.productservice.controller;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.manager.spu.ProductSpuManager;
import cn.iocoder.mall.productservice.rpc.spu.dto.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@RestController
@RequestMapping("/product/spu")
@Api("商品spu")
public class ProductSpuController {
@Autowired
private ProductSpuManager productSpuManager;
@GetMapping("/get")
@ApiOperation("获得商品 SPU")
@ApiImplicitParam(name = "productSpuId", value = "商品 SPU 编号", required = true)
public CommonResult<ProductSpuRespDTO> getProductSpu(@RequestParam(value="productSpuId") Integer productSpuId) {
return success(productSpuManager.getProductSpu(productSpuId));
}
/**
* 更新商品 SPU
*
* @param updateDTO 更新商品 SPU DTO
*/
@PostMapping("/update")
@ApiOperation("更新商品 SPU")
public CommonResult<Boolean> updateProductSpu(@Valid @RequestBody ProductSpuAndSkuUpdateReqDTO updateDTO) {
productSpuManager.updateProductSpu(updateDTO);
return success(true);
}
@PostMapping("/create")
@ApiOperation("创建商品 SPU")
public CommonResult<Integer> createProductSpu(@Valid @RequestBody ProductSpuAndSkuCreateReqDTO createDTO) {
return success(productSpuManager.createProductSpu(createDTO));
}
@GetMapping("/list")
@ApiOperation("获得商品 SPU 列表")
@ApiImplicitParam(name = "productSpuIds", value = "商品 SPU 编号列表", required = true)
public CommonResult<List<ProductSpuRespDTO>> listProductSpus(@RequestParam("productSpuIds") List<Integer> productSpuIds) {
return success(productSpuManager.listProductSpus(productSpuIds));
}
@PostMapping("/page")
@ApiOperation("获得商品 SPU 分页")
public CommonResult<PageResult<ProductSpuRespDTO>> pageProductSpu(@RequestBody ProductSpuPageReqDTO pageVO) {
// 全部:无搜索条件
// 在售中visible = true && hasQuantity = true
// 已售罄visible = true && hasQuantity = false
// 仓库中visible = false
return success(productSpuManager.pageProductSpu(pageVO));
}
/**
* 顺序获得商品 SPU 编号数组
*
* @param lastSpuId 最后一个商品 SPU 编号
* @param limit 数量
* @return 商品 SPU 编号数组
*/
@GetMapping("/lislistProductSpuIdst")
public CommonResult<List<Integer>> lislistProductSpuIdst(@RequestParam("lastSpuId")Integer lastSpuId, @RequestParam("limit")Integer limit) {
// 全部:无搜索条件
// 在售中visible = true && hasQuantity = true
// 已售罄visible = true && hasQuantity = false
// 仓库中visible = false
return success(productSpuManager.listProductSpuIds(lastSpuId, limit));
}
@GetMapping("/getProductSpuDetail")
public CommonResult<ProductSpuDetailRespDTO> getProductSpuDetail(@RequestParam("productSpuId") Integer productSpuId,@RequestParam("fields") Collection<String> fields) {
return success(productSpuManager.getProductSpuDetail(productSpuId,fields));
}
}

View File

@@ -0,0 +1,61 @@
package cn.iocoder.mall.productservice.convert.attr;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.attr.ProductAttrKeyDO;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.attr.ProductAttrValueDO;
import cn.iocoder.mall.productservice.rpc.attr.dto.*;
import cn.iocoder.mall.productservice.service.attr.bo.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface ProductAttrConvert {
ProductAttrConvert INSTANCE = Mappers.getMapper(ProductAttrConvert.class);
ProductAttrKeyDO convert(ProductAttrKeyCreateBO bean);
ProductAttrKeyBO convert(ProductAttrKeyDO bean);
ProductAttrKeyDO convert(ProductAttrKeyUpdateBO bean);
List<ProductAttrKeyBO> convertList(List<ProductAttrKeyDO> list);
@Mapping(source = "records", target = "list")
PageResult<ProductAttrKeyBO> convertPage(IPage<ProductAttrKeyDO> page);
ProductAttrKeyCreateBO convert(ProductAttrKeyCreateReqDTO bean);
ProductAttrKeyUpdateBO convert(ProductAttrKeyUpdateReqDTO bean);
ProductAttrKeyRespDTO convert(ProductAttrKeyBO bean);
List<ProductAttrKeyRespDTO> convertList02(List<ProductAttrKeyBO> list);
ProductAttrKeyPageBO convert(ProductAttrKeyPageReqDTO bean);
PageResult<ProductAttrKeyRespDTO> convertPage(PageResult<ProductAttrKeyBO> page);
ProductAttrValueDO convert(ProductAttrValueCreateBO bean);
ProductAttrValueBO convert(ProductAttrValueDO bean);
ProductAttrValueDO convert(ProductAttrValueUpdateBO bean);
List<ProductAttrValueBO> convertList03(List<ProductAttrValueDO> list);
ProductAttrValueCreateBO convert(ProductAttrValueCreateReqDTO bean);
ProductAttrValueUpdateBO convert(ProductAttrValueUpdateReqDTO bean);
ProductAttrValueRespDTO convert(ProductAttrValueBO bean);
List<ProductAttrValueRespDTO> convertList04(List<ProductAttrValueBO> list);
ProductAttrValueListQueryBO convert(ProductAttrValueListQueryReqDTO bean);
}

View File

@@ -0,0 +1,48 @@
package cn.iocoder.mall.productservice.convert.brand;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.brand.ProductBrandDO;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandCreateReqDTO;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandPageReqDTO;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandUpdateReqDTO;
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandBO;
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandCreateBO;
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandPageBO;
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandUpdateBO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface ProductBrandConvert {
ProductBrandConvert INSTANCE = Mappers.getMapper(ProductBrandConvert.class);
ProductBrandDO convert(ProductBrandCreateBO bean);
ProductBrandBO convert(ProductBrandDO bean);
ProductBrandDO convert(ProductBrandUpdateBO bean);
List<ProductBrandBO> convertList(List<ProductBrandDO> list);
@Mapping(source = "records", target = "list")
PageResult<ProductBrandBO> convertPage(IPage<ProductBrandDO> page);
ProductBrandCreateBO convert(ProductBrandCreateReqDTO bean);
ProductBrandUpdateBO convert(ProductBrandUpdateReqDTO bean);
ProductBrandRespDTO convert(ProductBrandBO bean);
List<ProductBrandRespDTO> convertList02(List<ProductBrandBO> list);
ProductBrandPageBO convert(ProductBrandPageReqDTO bean);
PageResult<ProductBrandRespDTO> convertPage(PageResult<ProductBrandBO> page);
}

View File

@@ -0,0 +1,40 @@
package cn.iocoder.mall.productservice.convert.category;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.category.ProductCategoryDO;
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryCreateReqDTO;
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryListQueryReqDTO;
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO;
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryUpdateReqDTO;
import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryBO;
import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryCreateBO;
import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryListQueryBO;
import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryUpdateBO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface ProductCategoryConvert {
ProductCategoryConvert INSTANCE = Mappers.getMapper(ProductCategoryConvert.class);
ProductCategoryDO convert(ProductCategoryCreateBO bean);
ProductCategoryBO convert(ProductCategoryDO bean);
List<ProductCategoryBO> convertList(List<ProductCategoryDO> list);
ProductCategoryDO convert(ProductCategoryUpdateBO bean);
ProductCategoryCreateBO convert(ProductCategoryCreateReqDTO bean);
ProductCategoryUpdateBO convert(ProductCategoryUpdateReqDTO bean);
ProductCategoryRespDTO convert(ProductCategoryBO bean);
List<ProductCategoryRespDTO> convertList02(List<ProductCategoryBO> list);
ProductCategoryListQueryBO convert(ProductCategoryListQueryReqDTO bean);
}

View File

@@ -0,0 +1,78 @@
package cn.iocoder.mall.productservice.convert.sku;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.util.StringUtils;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.sku.ProductSkuDO;
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrKeyValueRespDTO;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
import cn.iocoder.mall.productservice.service.attr.bo.ProductAttrKeyValueBO;
import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuBO;
import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuCreateOrUpdateBO;
import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuListQueryBO;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuBO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Mapper
public interface ProductSkuConvert {
ProductSkuConvert INSTANCE = Mappers.getMapper(ProductSkuConvert.class);
List<ProductSkuDO> convertList(List<ProductSkuCreateOrUpdateBO> list);
@Mapping(source = "attrValueIds", target = "attrs", qualifiedByName = "translatePicUrlsFromStringList")
ProductSkuDO convert(ProductSkuCreateOrUpdateBO bean);
@Mapping(source = "attrs", target = "attrValueIds", qualifiedByName = "translateAttrValueIdsFromString")
ProductSkuBO convert(ProductSkuDO bean);
List<ProductSkuBO> convertList02(List<ProductSkuDO> list);
ProductSkuRespDTO convert(ProductSkuBO bean);
ProductSkuListQueryBO convert(ProductSkuListQueryReqDTO bean);
ProductSpuRespDTO convert(ProductSpuBO bean);
ProductAttrKeyValueRespDTO convert(ProductAttrKeyValueBO bean);
default List<ProductSkuRespDTO> convertList(List<ProductSkuBO> skuBOs, List<ProductSpuBO> spuBOs,
List<ProductAttrKeyValueBO> attrBOs) {
// 创建 ProductAttrDetailBO 的映射。其中KEY 为 ProductAttrDetailBO.attrValueId ,即规格值的编号
Map<Integer, ProductAttrKeyValueBO> attrDetailBOMap = CollectionUtils.convertMap(attrBOs,
ProductAttrKeyValueBO::getAttrValueId);
// 构建 ProductSpuBO 的映射。
Map<Integer, ProductSpuBO> spuBOMap = CollectionUtils.convertMap(spuBOs, ProductSpuBO::getId);
// 拼接数据
List<ProductSkuRespDTO> skuRespDTOs = new ArrayList<>(skuBOs.size());
skuBOs.forEach(skuBO -> {
ProductSkuRespDTO skuRespDTO = convert(skuBO);
skuRespDTOs.add(skuRespDTO);
// 拼接商品 SPU
skuRespDTO.setSpu(convert(spuBOMap.get(skuBO.getSpuId())));
// 拼接商品 Attr
skuRespDTO.setAttrs(new ArrayList<>());
skuBO.getAttrValueIds().forEach(attrValueId -> skuRespDTO.getAttrs().add(convert(attrDetailBOMap.get(attrValueId))));
});
return skuRespDTOs;
}
@Named("translateAttrValueIdsFromString")
default List<Integer> translateAttrValueIdsFromString(String attrValueIdsStar) {
return StringUtils.splitToInt(attrValueIdsStar, ",");
}
@Named("translateAttrValueIdsFromList")
default String translateAttrValueIdsFromList(List<Integer> attrValueIds) {
return StringUtils.join(attrValueIds, ",");
}
}

View File

@@ -0,0 +1,99 @@
package cn.iocoder.mall.productservice.convert.spu;
import cn.iocoder.common.framework.util.StringUtils;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.spu.ProductSpuDO;
import cn.iocoder.mall.productservice.rpc.attr.dto.ProductAttrKeyValueRespDTO;
import cn.iocoder.mall.productservice.rpc.spu.dto.*;
import cn.iocoder.mall.productservice.service.attr.bo.ProductAttrKeyValueBO;
import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryBO;
import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuBO;
import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuCreateOrUpdateBO;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuBO;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuCreateBO;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuPageBO;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuUpdateBO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Mapper
public interface ProductSpuConvert {
ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class);
@Mapping(source = "picUrls", target = "picUrls", qualifiedByName = "translatePicUrlsFromStringList")
ProductSpuDO convert(ProductSpuCreateBO bean);
@Mapping(source = "picUrls", target = "picUrls", qualifiedByName = "translatePicUrlsFromString")
ProductSpuBO convert(ProductSpuDO bean);
@Mapping(source = "picUrls", target = "picUrls", qualifiedByName = "translatePicUrlsFromStringList")
ProductSpuDO convert(ProductSpuUpdateBO bean);
List<ProductSpuBO> convertList(List<ProductSpuDO> list);
@Mapping(source = "records", target = "list")
PageResult<ProductSpuBO> convertPage(IPage<ProductSpuDO> page);
ProductSpuCreateBO convert(ProductSpuAndSkuCreateReqDTO bean);
ProductSpuUpdateBO convert(ProductSpuAndSkuUpdateReqDTO bean);
ProductSpuRespDTO convert(ProductSpuBO bean);
ProductSpuDetailRespDTO convert2(ProductSpuBO bean);
List<ProductSpuRespDTO> convertList02(List<ProductSpuBO> list);
ProductSpuPageBO convert(ProductSpuPageReqDTO bean);
PageResult<ProductSpuRespDTO> convertPage(PageResult<ProductSpuBO> page);
List<ProductSkuCreateOrUpdateBO> convert(List<ProductSpuAndSkuCreateReqDTO.Sku> list);
List<ProductSkuCreateOrUpdateBO> convert02(List<ProductSpuAndSkuUpdateReqDTO.Sku> list);
ProductSpuDetailRespDTO.Sku convert(ProductSkuBO bean);
ProductAttrKeyValueRespDTO convert(ProductAttrKeyValueBO bean);
default ProductSpuDetailRespDTO convert(ProductSpuBO spuBO, List<ProductSkuBO> skuBOs,
List<ProductAttrKeyValueBO> attrBOs, ProductCategoryBO categoryBO) {
// 创建并转换 ProductSpuDetailBO 对象
ProductSpuDetailRespDTO spuDetailDTO = this.convert2(spuBO);
// 创建 ProductAttrDetailBO 的映射。其中KEY 为 ProductAttrDetailBO.attrValueId ,即规格值的编号
Map<Integer, ProductAttrKeyValueBO> attrDetailBOMap = attrBOs.stream().collect(
Collectors.toMap(ProductAttrKeyValueBO::getAttrValueId, attrBO -> attrBO));
// 创建并转换 ProductSpuDetailBO 数组
spuDetailDTO.setSkus(new ArrayList<>());
skuBOs.forEach(skuBO -> {
// 创建 ProductSpuDetailBO 对象
ProductSpuDetailRespDTO.Sku skuDetail = convert(skuBO).setAttrs(new ArrayList<>());
spuDetailDTO.getSkus().add(skuDetail);
// 设置 ProductSpuDetailBO 的 attrs 规格属性
skuBO.getAttrValueIds().forEach(attrValueId -> skuDetail.getAttrs().add(convert(attrDetailBOMap.get(attrValueId))));
});
// 设置分类名
spuDetailDTO.setCategoryName(categoryBO.getName());
// 返回
return spuDetailDTO;
}
@Named("translatePicUrlsFromString")
default List<String> translatePicUrlsFromList(String picUrls) {
return StringUtils.split(picUrls, ",");
}
@Named("translatePicUrlsFromStringList")
default String translatePicUrlsFromList(List<String> picUrls) {
return StringUtils.join(picUrls, ",");
}
}

View File

@@ -0,0 +1,34 @@
package cn.iocoder.mall.productservice.dal.mysql.dataobject.attr;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* Product 规格键 DO
*/
@TableName("product_attr_key")
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public class ProductAttrKeyDO extends DeletableDO {
/**
* 规格编号
*/
private Integer id;
/**
* 名称
*/
private String name;
/**
* 状态
*
* 枚举 {@link CommonStatusEnum}
*/
private Integer status;
}

View File

@@ -0,0 +1,40 @@
package cn.iocoder.mall.productservice.dal.mysql.dataobject.attr;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 商品规格值 DO
*/
@TableName("product_attr_value")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ProductAttrValueDO extends DeletableDO {
/**
* 规格值编号
*/
private Integer id;
/**
* 规格键编号
*
* 外键 {@link ProductAttrKeyDO#getId()}
*/
private Integer attrKeyId;
/**
* 规格值名字
*/
private String name;
/**
* 状态
*
* 枚举 {@link CommonStatusEnum}
*/
private Integer status;
}

View File

@@ -0,0 +1,41 @@
package cn.iocoder.mall.productservice.dal.mysql.dataobject.brand;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 商品品牌
*/
@TableName("product_brand")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ProductBrandDO extends DeletableDO {
/**
* 品牌编号(主键)
*/
@TableId
private Integer id;
/**
* 品牌名称
*/
private String name;
/**
* 品牌描述
*/
private String description;
/**
* 品牌名图片
*/
private String picUrl;
/**
* 状态
*/
private Integer status;
}

View File

@@ -0,0 +1,52 @@
package cn.iocoder.mall.productservice.dal.mysql.dataobject.category;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 商品分类 DO
*/
@TableName("product_category")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ProductCategoryDO extends DeletableDO {
/**
* 分类编号
*/
@TableId
private Integer id;
/**
* 父分类编号
*/
private Integer pid;
/**
* 分类名称
*/
private String name;
/**
* 分类描述
*/
private String description;
/**
* 分类图片
*/
private String picUrl;
/**
* 分类排序
*/
private Integer sort;
/**
* 状态
*
* 枚举 {@link CommonStatusEnum}
*/
private Integer status;
}

View File

@@ -0,0 +1,64 @@
package cn.iocoder.mall.productservice.dal.mysql.dataobject.sku;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.attr.ProductAttrValueDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 商品 SKU
*/
@TableName("product_sku")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ProductSkuDO extends DeletableDO {
/**
* sku 编号
*/
private Integer id;
/**
* 商品编号
*/
private Integer spuId;
// TODO 店铺编号
/**
* 状态
*
* 枚举 {@link CommonStatusEnum}
*/
private Integer status;
/**
* 图片地址
*/
private String picUrl;
/**
* 规格值({@link ProductAttrValueDO#getId()})数组
*
* 数组,以逗号分隔
*/
private String attrs;
/**
* 价格,单位:分
*/
private Integer price;
/**
* 库存数量
*/
private Integer quantity;
// /**
// * 商品在付款减库存的状态下该Sku上未付款的订单数量
// */
// private Integer withHoldQuantity;
// /**
// * 销量
// */
// private Integer soldNum;
}

View File

@@ -0,0 +1,82 @@
package cn.iocoder.mall.productservice.dal.mysql.dataobject.spu;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 商品 SPU
*
* TODO 芋艿,后面增加商品普通参数。例如说,正面材料,背面材料,屏幕尺寸。
*/
@TableName("product_spu")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ProductSpuDO extends DeletableDO {
/**
* SPU 编号
*/
private Integer id;
// TODO 店铺编号 先不考虑,因为第一个版本,不做 B2B2C
// ========== 基本信息 =========
/**
* SPU 名字
*/
private String name;
/**
* 卖点
*/
private String sellPoint;
/**
* 描述
*/
private String description;
/**
* 分类编号
*/
private Integer cid;
/**
* 商品主图地址
*
* 数组,以逗号分隔
*
* 建议尺寸800*800像素你可以拖拽图片调整顺序最多上传15张
*/
private String picUrls;
// TODO 运费信息
// ========== 其他信息 =========
/**
* 是否上架商品(是否可见)。
*
* true 为已上架
* false 为已下架
*/
private Boolean visible;
/**
* 排序字段
*/
private Integer sort;
// ========== Sku 相关字段 =========
/**
* 价格
*
* 目前的计算方式是,以 Sku 最小价格为准
*/
private Integer price;
/**
* 库存数量
*
* 目前的计算方式是,以 Sku 库存累加为准
*/
private Integer quantity;
}

View File

@@ -0,0 +1,25 @@
package cn.iocoder.mall.productservice.dal.mysql.mapper.attr;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.attr.ProductAttrKeyDO;
import cn.iocoder.mall.productservice.service.attr.bo.ProductAttrKeyPageBO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Repository;
@Repository
public interface ProductAttrKeyMapper extends BaseMapper<ProductAttrKeyDO> {
default IPage<ProductAttrKeyDO> selectPage(ProductAttrKeyPageBO pageBO) {
return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
new QueryWrapperX<ProductAttrKeyDO>().likeIfPresent("name", pageBO.getName())
.eqIfPresent("status", pageBO.getStatus()));
}
default ProductAttrKeyDO selectByName(String name) {
return selectOne(new QueryWrapper<ProductAttrKeyDO>().eq("name", name));
}
}

View File

@@ -0,0 +1,24 @@
package cn.iocoder.mall.productservice.dal.mysql.mapper.attr;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.attr.ProductAttrValueDO;
import cn.iocoder.mall.productservice.service.attr.bo.ProductAttrValueListQueryBO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ProductAttrValueMapper extends BaseMapper<ProductAttrValueDO> {
default ProductAttrValueDO selectByAttrKeyIdAndName(Integer attrKeyId, String name) {
return selectOne(new QueryWrapper<ProductAttrValueDO>().eq("attr_key_id", attrKeyId).eq("name", name));
}
default List<ProductAttrValueDO> selectList(ProductAttrValueListQueryBO queryBO) {
return selectList(new QueryWrapperX<ProductAttrValueDO>().inIfPresent("id", queryBO.getProductAttrValueIds())
.eqIfPresent("attr_key_id", queryBO.getProductAttrKeyId()));
}
}

View File

@@ -0,0 +1,25 @@
package cn.iocoder.mall.productservice.dal.mysql.mapper.brand;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.brand.ProductBrandDO;
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandPageBO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Repository;
@Repository
public interface ProductBrandMapper extends BaseMapper<ProductBrandDO> {
default IPage<ProductBrandDO> selectPage(ProductBrandPageBO pageBO) {
return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
new QueryWrapperX<ProductBrandDO>().likeIfPresent("name", pageBO.getName())
.eqIfPresent("status", pageBO.getStatus()));
}
default ProductBrandDO selectByName(String name) {
return selectOne(new QueryWrapper<ProductBrandDO>().eq("name", name));
}
}

View File

@@ -0,0 +1,24 @@
package cn.iocoder.mall.productservice.dal.mysql.mapper.category;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.category.ProductCategoryDO;
import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryListQueryBO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ProductCategoryMapper extends BaseMapper<ProductCategoryDO> {
default Integer selectCountByPid(Integer pid) {
return selectCount(new QueryWrapper<ProductCategoryDO>().eq("pid", pid));
}
default List<ProductCategoryDO> selectList(ProductCategoryListQueryBO listQueryBO) {
return selectList(new QueryWrapperX<ProductCategoryDO>().eqIfPresent("pid", listQueryBO.getPid())
.eqIfPresent("status", listQueryBO.getStatus()));
}
}

View File

@@ -0,0 +1,29 @@
package cn.iocoder.mall.productservice.dal.mysql.mapper.sku;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.sku.ProductSkuDO;
import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuListQueryBO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ProductSkuMapper extends BaseMapper<ProductSkuDO> {
default List<ProductSkuDO> selectListBySpuIdAndStatus(Integer spuId, Integer status) {
return selectList(new QueryWrapperX<ProductSkuDO>().eq("spu_id", spuId)
.eq("status", status));
}
void insertList(@Param("productSkuDOs") List<ProductSkuDO> productSkuDOs);
default List<ProductSkuDO> selectList(ProductSkuListQueryBO queryBO) {
return selectList(new QueryWrapperX<ProductSkuDO>().eqIfPresent("id", queryBO.getProductSkuId())
.inIfPresent("id", queryBO.getProductSkuIds())
.eqIfPresent("spu_id", queryBO.getProductSpuId())
.eqIfPresent("status", queryBO.getProductSkuStatus()));
}
}

View File

@@ -0,0 +1,35 @@
package cn.iocoder.mall.productservice.dal.mysql.mapper.spu;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.spu.ProductSpuDO;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuPageBO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ProductSpuMapper extends BaseMapper<ProductSpuDO> {
default IPage<ProductSpuDO> selectPage(ProductSpuPageBO pageBO) {
QueryWrapperX<ProductSpuDO> query = new QueryWrapperX<ProductSpuDO>().likeIfPresent("name", pageBO.getName())
.eqIfPresent("cid", pageBO.getCid()).eqIfPresent("visible", pageBO.getVisible());
// 库存过滤
if (pageBO.getHasQuantity() != null) {
if (pageBO.getHasQuantity()) {
query.gt("quantity", 0);
} else {
query.eq("quantity", 0);
}
}
return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()), query);
}
default List<ProductSpuDO> selectListByIdGt(Integer id, Integer limit) {
return selectList(new QueryWrapperX<ProductSpuDO>().gtIfPresent("id", id)
.orderByAsc("id").last("LIMIT " + limit));
}
}

View File

@@ -0,0 +1,118 @@
package cn.iocoder.mall.productservice.manager.attr;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.convert.attr.ProductAttrConvert;
import cn.iocoder.mall.productservice.rpc.attr.dto.*;
import cn.iocoder.mall.productservice.service.attr.ProductAttrService;
import cn.iocoder.mall.productservice.service.attr.bo.ProductAttrKeyBO;
import cn.iocoder.mall.productservice.service.attr.bo.ProductAttrValueBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 商品规格 Manager
*/
@Service
public class ProductAttrManager {
@Autowired
private ProductAttrService productAttrService;
/**
* 创建商品规格键
*
* @param createDTO 创建商品规格键 DTO
* @return 商品规格键
*/
public Integer createProductAttrKey(ProductAttrKeyCreateReqDTO createDTO) {
ProductAttrKeyBO productAttrKeyBO = productAttrService.createProductAttrKey(ProductAttrConvert.INSTANCE.convert(createDTO));
return productAttrKeyBO.getId();
}
/**
* 更新商品规格键
*
* @param updateDTO 更新商品规格键 DTO
*/
public void updateProductAttrKey(ProductAttrKeyUpdateReqDTO updateDTO) {
productAttrService.updateProductAttrKey(ProductAttrConvert.INSTANCE.convert(updateDTO));
}
/**
* 获得商品规格键
*
* @param productAttrKeyId 商品规格键编号
* @return 商品规格键
*/
public ProductAttrKeyRespDTO getProductAttrKey(Integer productAttrKeyId) {
ProductAttrKeyBO productAttrKeyBO = productAttrService.getProductAttrKey(productAttrKeyId);
return ProductAttrConvert.INSTANCE.convert(productAttrKeyBO);
}
/**
* 获得商品规格键列表
*
* @param productAttrKeyIds 商品规格键编号列表
* @return 商品规格键列表
*/
public List<ProductAttrKeyRespDTO> listProductAttrKeys(List<Integer> productAttrKeyIds) {
List<ProductAttrKeyBO> productAttrKeyBOs = productAttrService.listProductAttrKeys(productAttrKeyIds);
return ProductAttrConvert.INSTANCE.convertList02(productAttrKeyBOs);
}
/**
* 获得商品规格键分页
*
* @param pageDTO 商品规格键分页查询
* @return 商品规格键分页结果
*/
public PageResult<ProductAttrKeyRespDTO> pageProductAttrKey(ProductAttrKeyPageReqDTO pageDTO) {
PageResult<ProductAttrKeyBO> pageResultBO = productAttrService.pageProductAttrKey(ProductAttrConvert.INSTANCE.convert(pageDTO));
return ProductAttrConvert.INSTANCE.convertPage(pageResultBO);
}
/**
* 创建商品规格值
*
* @param createDTO 创建商品规格值 DTO
* @return 商品规格值
*/
public Integer createProductAttrValue(ProductAttrValueCreateReqDTO createDTO) {
ProductAttrValueBO productAttrValueBO = productAttrService.createProductAttrValue(ProductAttrConvert.INSTANCE.convert(createDTO));
return productAttrValueBO.getId();
}
/**
* 更新商品规格值
*
* @param updateDTO 更新商品规格值 DTO
*/
public void updateProductAttrValue(ProductAttrValueUpdateReqDTO updateDTO) {
productAttrService.updateProductAttrValue(ProductAttrConvert.INSTANCE.convert(updateDTO));
}
/**
* 获得商品规格值
*
* @param productAttrValueId 商品规格值编号
* @return 商品规格值
*/
public ProductAttrValueRespDTO getProductAttrValue(Integer productAttrValueId) {
ProductAttrValueBO productAttrValueBO = productAttrService.getProductAttrValue(productAttrValueId);
return ProductAttrConvert.INSTANCE.convert(productAttrValueBO);
}
/**
* 获得商品规格值列表
*
* @param queryDTO 商品规格值的列表查询条件 DTO
* @return 商品规格值列表
*/
public List<ProductAttrValueRespDTO> listProductAttrValues(ProductAttrValueListQueryReqDTO queryDTO) {
List<ProductAttrValueBO> productAttrValueBOs = productAttrService.listProductAttrValues(ProductAttrConvert.INSTANCE.convert(queryDTO));
return ProductAttrConvert.INSTANCE.convertList04(productAttrValueBOs);
}
}

View File

@@ -0,0 +1,86 @@
package cn.iocoder.mall.productservice.manager.brand;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.convert.brand.ProductBrandConvert;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandCreateReqDTO;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandPageReqDTO;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandRespDTO;
import cn.iocoder.mall.productservice.rpc.brand.dto.ProductBrandUpdateReqDTO;
import cn.iocoder.mall.productservice.service.brand.ProductBrandService;
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 商品品牌 Manager
*/
@Service
public class ProductBrandManager {
@Autowired
private ProductBrandService productBrandService;
/**
* 创建商品品牌
*
* @param createDTO 创建商品品牌 DTO
* @return 商品品牌
*/
public Integer createProductBrand(ProductBrandCreateReqDTO createDTO) {
ProductBrandBO productBrandBO = productBrandService.createProductBrand(ProductBrandConvert.INSTANCE.convert(createDTO));
return productBrandBO.getId();
}
/**
* 更新商品品牌
*
* @param updateDTO 更新商品品牌 DTO
*/
public void updateProductBrand(ProductBrandUpdateReqDTO updateDTO) {
productBrandService.updateProductBrand(ProductBrandConvert.INSTANCE.convert(updateDTO));
}
/**
* 删除商品品牌
*
* @param productBrandId 商品品牌编号
*/
public void deleteProductBrand(Integer productBrandId) {
productBrandService.deleteProductBrand(productBrandId);
}
/**
* 获得商品品牌
*
* @param productBrandId 商品品牌编号
* @return 商品品牌
*/
public ProductBrandRespDTO getProductBrand(Integer productBrandId) {
ProductBrandBO productBrandBO = productBrandService.getProductBrand(productBrandId);
return ProductBrandConvert.INSTANCE.convert(productBrandBO);
}
/**
* 获得商品品牌列表
*
* @param productBrandIds 商品品牌编号列表
* @return 商品品牌列表
*/
public List<ProductBrandRespDTO> listProductBrands(List<Integer> productBrandIds) {
List<ProductBrandBO> productBrandBOs = productBrandService.listProductBrands(productBrandIds);
return ProductBrandConvert.INSTANCE.convertList02(productBrandBOs);
}
/**
* 获得商品品牌分页
*
* @param pageDTO 商品品牌分页查询
* @return 商品品牌分页结果
*/
public PageResult<ProductBrandRespDTO> pageProductBrand(ProductBrandPageReqDTO pageDTO) {
PageResult<ProductBrandBO> pageResultBO = productBrandService.pageProductBrand(ProductBrandConvert.INSTANCE.convert(pageDTO));
return ProductBrandConvert.INSTANCE.convertPage(pageResultBO);
}
}

View File

@@ -0,0 +1,87 @@
package cn.iocoder.mall.productservice.manager.category;
import cn.iocoder.mall.productservice.convert.category.ProductCategoryConvert;
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryCreateReqDTO;
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryListQueryReqDTO;
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO;
import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryUpdateReqDTO;
import cn.iocoder.mall.productservice.service.category.ProductCategoryService;
import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
/**
* 商品分类 Manager
*/
@Service
public class ProductCategoryManager {
@Autowired
private ProductCategoryService productCategoryService;
/**
* 创建商品分类
*
* @param createDTO 创建商品分类 DTO
* @return 商品分类
*/
public Integer createProductCategory(ProductCategoryCreateReqDTO createDTO) {
ProductCategoryBO productCategoryBO = productCategoryService.createProductCategory(ProductCategoryConvert.INSTANCE.convert(createDTO));
return productCategoryBO.getId();
}
/**
* 更新商品分类
*
* @param updateDTO 更新商品分类 DTO
*/
public void updateProductCategory(ProductCategoryUpdateReqDTO updateDTO) {
productCategoryService.updateProductCategory(ProductCategoryConvert.INSTANCE.convert(updateDTO));
}
/**
* 删除商品分类
*
* @param productCategoryId 商品分类编号
*/
public void deleteProductCategory(Integer productCategoryId) {
productCategoryService.deleteProductCategory(productCategoryId);
}
/**
* 获得商品分类
*
* @param productCategoryId 商品分类编号
* @return 商品分类
*/
public ProductCategoryRespDTO getProductCategory(Integer productCategoryId) {
ProductCategoryBO productCategoryBO = productCategoryService.getProductCategory(productCategoryId);
return ProductCategoryConvert.INSTANCE.convert(productCategoryBO);
}
/**
* 获得商品分类列表
*
* @param productCategoryIds 商品分类编号列表
* @return 商品分类列表
*/
public List<ProductCategoryRespDTO> listProductCategories(Collection<Integer> productCategoryIds) {
List<ProductCategoryBO> productCategoryBOs = productCategoryService.listProductCategories(productCategoryIds);
return ProductCategoryConvert.INSTANCE.convertList02(productCategoryBOs);
}
/**
* 获得商品分类全列表
*
* @return 商品分类全列表
*/
public List<ProductCategoryRespDTO> listProductCategories(ProductCategoryListQueryReqDTO listQueryReqDTO) {
List<ProductCategoryBO> productCategoryBOs = productCategoryService.listProductCategories(
ProductCategoryConvert.INSTANCE.convert(listQueryReqDTO));
return ProductCategoryConvert.INSTANCE.convertList02(productCategoryBOs);
}
}

View File

@@ -0,0 +1,76 @@
package cn.iocoder.mall.productservice.manager.sku;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.mall.productservice.convert.sku.ProductSkuConvert;
import cn.iocoder.mall.productservice.enums.sku.ProductSkuDetailFieldEnum;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
import cn.iocoder.mall.productservice.service.attr.ProductAttrService;
import cn.iocoder.mall.productservice.service.attr.bo.ProductAttrKeyValueBO;
import cn.iocoder.mall.productservice.service.sku.ProductSkuService;
import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuBO;
import cn.iocoder.mall.productservice.service.spu.ProductSpuService;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* 商品 SKU Manager
*/
@Service
public class ProductSkuManager {
@Autowired
private ProductSkuService productSkuService;
@Autowired
private ProductSpuService productSpuService;
@Autowired
private ProductAttrService productAttrService;
/**
* 获得商品 SKU
*
* @param productSkuId 商品 SKU编号
* @return 商品 SKU
*/
public ProductSkuRespDTO getProductSku(Integer productSkuId) {
ProductSkuBO productSkuBO = productSkuService.getProductSku(productSkuId);
return ProductSkuConvert.INSTANCE.convert(productSkuBO);
}
/**
* 获得商品 SKU 列表
*
* @param queryReqDTO 商品 SKU 列表的查询请求 DTO
* @return 商品 SKU列表
*/
public List<ProductSkuRespDTO> listProductSkus(ProductSkuListQueryReqDTO queryReqDTO) {
// 获得商品 SKU 列表
List<ProductSkuBO> skuBOs = productSkuService.listProductSkus(
ProductSkuConvert.INSTANCE.convert(queryReqDTO));
if (CollectionUtils.isEmpty(skuBOs)) {
return Collections.emptyList();
}
// 获得商品 SPU 列表
List<ProductSpuBO> spuBOs = Collections.emptyList();
if (queryReqDTO.getFields().contains(ProductSkuDetailFieldEnum.SPU.getField())) {
spuBOs = productSpuService.listProductSpus(
CollectionUtils.convertSet(skuBOs, ProductSkuBO::getSpuId));
}
// 获取商品 SKU 的规格数组
List<ProductAttrKeyValueBO> attrBOs = Collections.emptyList();
if (queryReqDTO.getFields().contains(ProductSkuDetailFieldEnum.ATTR.getField())) {
Set<Integer> attrValueIds = new HashSet<>();
skuBOs.forEach(sku -> attrValueIds.addAll(sku.getAttrValueIds()));
attrBOs = productAttrService.validProductAttr(attrValueIds, false); // 读取规格时,不考虑规格是否被禁用
}
// 拼接最终返回
return ProductSkuConvert.INSTANCE.convertList(skuBOs, spuBOs, attrBOs);
}
}

View File

@@ -0,0 +1,242 @@
package cn.iocoder.mall.productservice.manager.spu;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.convert.spu.ProductSpuConvert;
import cn.iocoder.mall.productservice.enums.category.ProductCategoryIdEnum;
import cn.iocoder.mall.productservice.enums.spu.ProductSpuDetailFieldEnum;
import cn.iocoder.mall.productservice.mq.producer.ProductMQProducer;
import cn.iocoder.mall.productservice.rpc.spu.dto.*;
import cn.iocoder.mall.productservice.service.attr.ProductAttrService;
import cn.iocoder.mall.productservice.service.attr.bo.ProductAttrKeyValueBO;
import cn.iocoder.mall.productservice.service.category.ProductCategoryService;
import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryBO;
import cn.iocoder.mall.productservice.service.sku.ProductSkuService;
import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuBO;
import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuCreateOrUpdateBO;
import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuListQueryBO;
import cn.iocoder.mall.productservice.service.spu.ProductSpuService;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuBO;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuCreateBO;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuUpdateBO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.mall.productservice.enums.ProductErrorCodeConstants.*;
/**
* 商品 SPU Manager
*/
@Service
@Slf4j
public class ProductSpuManager {
@Autowired
private ProductSpuService productSpuService;
@Autowired
private ProductSkuService productSkuService;
@Autowired
private ProductCategoryService productCategoryService;
@Autowired
private ProductAttrService productAttrService;
@Autowired
private ProductMQProducer productMQProducer;
private static ProductSpuManager self() {
return (ProductSpuManager) AopContext.currentProxy();
}
/**
* 创建商品 SPU 和 SKU
*
* @param createDTO 创建商品 SPU 和 SKU DTO
* @return 商品 SPU
*/
public Integer createProductSpu(ProductSpuAndSkuCreateReqDTO createDTO) {
// 创建商品 SPU 和 SKU。注意这里要调用 self() 方法,因为需要创建事务,否则会失效
Integer spuId = self().createProductSpu0(createDTO);
// 发送商品创建的 MQ 消息
productMQProducer.sendProductUpdateMessage(spuId);
return spuId;
}
@Transactional
public Integer createProductSpu0(ProductSpuAndSkuCreateReqDTO createDTO) {
// 校验商品分类是否合法
this.checkProductCategory(createDTO.getCid());
// 创建商品 SKU 对象,并进行校验
List<ProductSkuCreateOrUpdateBO> skuBOs = ProductSpuConvert.INSTANCE.convert(createDTO.getSkus());
this.checkProductAttr(skuBOs);
// 插入商品 SPU 记录
ProductSpuCreateBO spuCreateBO = ProductSpuConvert.INSTANCE.convert(createDTO).setSort(0);
spuCreateBO.setPrice(skuBOs.stream().min(Comparator.comparing(ProductSkuCreateOrUpdateBO::getPrice)).get().getPrice()); // 求最小价格
spuCreateBO.setQuantity(skuBOs.stream().mapToInt(ProductSkuCreateOrUpdateBO::getQuantity).sum()); // 求库存之和
ProductSpuBO spuBO = productSpuService.createProductSpu(spuCreateBO);
// 插入商品 SKU 记录
productSkuService.createProductSkus(spuBO.getId(), skuBOs);
return spuBO.getId();
}
/**
* 更新商品 SPU
*
* @param updateDTO 更新商品 SPU DTO
*/
public void updateProductSpu(ProductSpuAndSkuUpdateReqDTO updateDTO) {
// 更新商品 SPU 和 SKU。注意这里要调用 self() 方法,因为需要创建事务,否则会失效
self().updateProductSpu0(updateDTO);
// 发送商品创建的 MQ 消息
productMQProducer.sendProductUpdateMessage(updateDTO.getId());
}
@Transactional
public void updateProductSpu0(ProductSpuAndSkuUpdateReqDTO updateDTO) {
// 校验商品分类是否合法
this.checkProductCategory(updateDTO.getCid());
// 创建商品 SKU 对象,并进行校验
List<ProductSkuCreateOrUpdateBO> skuBOs = ProductSpuConvert.INSTANCE.convert02(updateDTO.getSkus());
this.checkProductAttr(skuBOs);
// 更新商品 SPU 记录
ProductSpuUpdateBO spuUpdateBO = ProductSpuConvert.INSTANCE.convert(updateDTO);
spuUpdateBO.setPrice(skuBOs.stream().min(Comparator.comparing(ProductSkuCreateOrUpdateBO::getPrice)).get().getPrice()); // 求最小价格
spuUpdateBO.setQuantity(skuBOs.stream().mapToInt(ProductSkuCreateOrUpdateBO::getQuantity).sum()); // 求库存之和
productSpuService.updateProductSpu(spuUpdateBO);
// 更新商品 SKU 记录
productSkuService.updateProductSkus(updateDTO.getId(), skuBOs);
}
/**
* 获得商品 SPU
*
* @param productSpuId 商品 SPU编号
* @return 商品 SPU
*/
public ProductSpuRespDTO getProductSpu(Integer productSpuId) {
ProductSpuBO productSpuBO = productSpuService.getProductSpu(productSpuId);
return ProductSpuConvert.INSTANCE.convert(productSpuBO);
}
/**
* 获得商品 SPU列表
*
* @param productSpuIds 商品 SPU编号列表
* @return 商品 SPU列表
*/
public List<ProductSpuRespDTO> listProductSpus(Collection<Integer> productSpuIds) {
List<ProductSpuBO> productSpuBOs = productSpuService.listProductSpus(productSpuIds);
return ProductSpuConvert.INSTANCE.convertList02(productSpuBOs);
}
/**
* 获得商品 SPU分页
*
* @param pageDTO 商品 SPU分页查询
* @return 商品 SPU分页结果
*/
public PageResult<ProductSpuRespDTO> pageProductSpu(ProductSpuPageReqDTO pageDTO) {
PageResult<ProductSpuBO> pageResultBO = productSpuService.pageProductSpu(ProductSpuConvert.INSTANCE.convert(pageDTO));
return ProductSpuConvert.INSTANCE.convertPage(pageResultBO);
}
/**
* 添加或修改商品 SPU 时,校验商品分类是否合法
*
* @param cid 商品分类编号
* @return 商品分类
*/
private ProductCategoryBO checkProductCategory(Integer cid) {
ProductCategoryBO categoryBO = productCategoryService.getProductCategory(cid);
if (categoryBO == null) {
// 不存在
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_NOT_EXISTS);
}
if (ProductCategoryIdEnum.ROOT.getId().equals(categoryBO.getPid())) {
// 商品只能添加到二级分类下
throw ServiceExceptionUtil.exception(PRODUCT_SPU_CATEGORY_MUST_BE_LEVEL2);
}
return categoryBO;
}
/**
* 顺序获得商品 SPU 编号数组
*
* @param lastSpuId 最后一个商品 SPU 编号
* @param limit 数量
* @return 商品 SPU 编号数组
*/
public List<Integer> listProductSpuIds(Integer lastSpuId, Integer limit) {
return productSpuService.listProductSpuIds(lastSpuId, limit);
}
private List<ProductAttrKeyValueBO> checkProductAttr(List<ProductSkuCreateOrUpdateBO> skuBOs) {
// 第一步,校验 SKU 使用到的规格是否存在
Set<Integer> attrValueIds = new HashSet<>();
skuBOs.forEach(sku -> attrValueIds.addAll(sku.getAttrValueIds()));
List<ProductAttrKeyValueBO> attrKeyValueBOs = productAttrService.validProductAttr(attrValueIds, true);
// 第二步,校验 SKU 设置的规格是否合法,例如说数量是否一致,是否重复等等
// 创建 ProductAttrDetailBO 的映射。其中KEY 为 ProductAttrDetailBO.attrValueId ,即规格值的编号
Map<Integer, ProductAttrKeyValueBO> productAttrDetailBOMap = attrKeyValueBOs.stream().collect(
Collectors.toMap(ProductAttrKeyValueBO::getAttrValueId, productAttrDetailBO -> productAttrDetailBO));
// 1. 先校验,一个 Sku 下,没有重复的规格。校验方式是,遍历每个 Sku ,看看是否有重复的规格 attrId
for (ProductSkuCreateOrUpdateBO sku : skuBOs) {
Set<Integer> attrIds = sku.getAttrValueIds().stream().map(attrValueId -> productAttrDetailBOMap.get(attrValueId).getAttrKeyId())
.collect(Collectors.toSet());
if (attrIds.size() != sku.getAttrValueIds().size()) {
throw ServiceExceptionUtil.exception(PRODUCT_SKU_ATTR_CANT_NOT_DUPLICATE);
}
}
// 2. 再校验,每个 Sku 的规格值的数量,是一致的。
int attrValueIdsSize = skuBOs.get(0).getAttrValueIds().size();
for (int i = 1; i < skuBOs.size(); i++) {
if (attrValueIdsSize != skuBOs.get(i).getAttrValueIds().size()) {
throw ServiceExceptionUtil.exception(PRODUCT_SPU_ATTR_NUMBERS_MUST_BE_EQUALS);
}
}
// 3. 最后校验,每个 Sku 之间不是重复的
Set<Set<Integer>> skuAttrValues = new HashSet<>(); // 每个元素,都是一个 Sku 的 attrValueId 集合。这样,通过最外层的 Set ,判断是否有重复的.
for (ProductSkuCreateOrUpdateBO sku : skuBOs) {
if (!skuAttrValues.add(new HashSet<>(sku.getAttrValueIds()))) { // 添加失败,说明重复
throw ServiceExceptionUtil.exception(PRODUCT_SPU_SKU_NOT_DUPLICATE);
}
}
return attrKeyValueBOs;
}
public ProductSpuDetailRespDTO getProductSpuDetail(Integer productSpuId, Collection<String> fields) {
// 获得商品 SPU 信息
ProductSpuBO spuBO = productSpuService.getProductSpu(productSpuId);
if (spuBO == null) {
throw ServiceExceptionUtil.exception(PRODUCT_SPU_NOT_EXISTS);
}
// 获取商品分类
ProductCategoryBO categoryBO = productCategoryService.getProductCategory(spuBO.getCid());
if (categoryBO == null) {
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_NOT_EXISTS);
}
// 获得商品 SKU 数组
List<ProductSkuBO> skuBOs = Collections.emptyList();
if (fields.contains(ProductSpuDetailFieldEnum.SKU.getField())) {
skuBOs = productSkuService.listProductSkus(new ProductSkuListQueryBO().setProductSpuId(productSpuId)
.setProductSkuStatus(CommonStatusEnum.ENABLE.getValue()));
}
// 获取商品 SKU 的规格数组
List<ProductAttrKeyValueBO> attrBOs = Collections.emptyList();
if (fields.contains(ProductSpuDetailFieldEnum.ATTR.getField()) && !CollectionUtils.isEmpty(skuBOs)) {
Set<Integer> attrValueIds = new HashSet<>();
skuBOs.forEach(sku -> attrValueIds.addAll(sku.getAttrValueIds()));
attrBOs = productAttrService.validProductAttr(attrValueIds, false); // 读取规格时,不考虑规格是否被禁用
}
// 拼接最终返回
return ProductSpuConvert.INSTANCE.convert(spuBO, skuBOs, attrBOs, categoryBO);
}
}

View File

@@ -0,0 +1,30 @@
package cn.iocoder.mall.productservice.mq.producer;
import cn.iocoder.mall.productservice.mq.producer.message.ProductUpdateMessage;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.client.producer.SendStatus;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class ProductMQProducer {
@Autowired
private RocketMQTemplate rocketMQTemplate;
public void sendProductUpdateMessage(Integer id) {
// TODO 芋艿:后续优化下,考虑下一致性
try {
SendResult sendResult = rocketMQTemplate.syncSend(ProductUpdateMessage.TOPIC, new ProductUpdateMessage().setId(id));
if (!SendStatus.SEND_OK.equals(sendResult.getSendStatus())) {
log.error("[sendProductUpdateMessage][product({}) 发送更新消息失败,结果为({})]", id, sendResult);
}
} catch (Throwable throwable) {
log.error("[sendProductUpdateMessage][product({}) 发送更新消息失败,发生异常]", id, throwable);
}
}
}

View File

@@ -0,0 +1,20 @@
package cn.iocoder.mall.productservice.mq.producer.message;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 商品更新(包括创建)消息
*/
@Data
@Accessors(chain = true)
public class ProductUpdateMessage {
public static final String TOPIC = "ProductUpdate";
/**
* 商品编号
*/
private Integer id;
}

View File

@@ -0,0 +1,211 @@
package cn.iocoder.mall.productservice.service.attr;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.convert.attr.ProductAttrConvert;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.attr.ProductAttrKeyDO;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.attr.ProductAttrValueDO;
import cn.iocoder.mall.productservice.dal.mysql.mapper.attr.ProductAttrKeyMapper;
import cn.iocoder.mall.productservice.dal.mysql.mapper.attr.ProductAttrValueMapper;
import cn.iocoder.mall.productservice.service.attr.bo.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static cn.iocoder.mall.productservice.enums.ProductErrorCodeConstants.*;
/**
* 商品规格 Service
*
* 包括商品键和值
*/
@Service
@Valid
public class ProductAttrService {
@Autowired
private ProductAttrKeyMapper productAttrKeyMapper;
@Autowired
private ProductAttrValueMapper productAttrValueMapper;
public List<ProductAttrKeyValueBO> validProductAttr(Set<Integer> productAttrValueIds, boolean validStatus) {
// 首先,校验规格 Value
List<ProductAttrValueDO> attrValues = productAttrValueMapper.selectBatchIds(productAttrValueIds);
if (attrValues.size() != productAttrValueIds.size()) {
throw ServiceExceptionUtil.exception(PRODUCT_ATTR_VALUE_NOT_EXIST);
}
if (validStatus) {
for (ProductAttrValueDO attrValue : attrValues) { // 同时,校验下状态
if (CommonStatusEnum.DISABLE.getValue().equals(attrValue.getStatus())) {
throw ServiceExceptionUtil.exception(PRODUCT_ATTR_VALUE_NOT_EXIST);
}
}
}
// 然后,校验规 Key
Set<Integer> attrKeyIds = CollectionUtils.convertSet(attrValues, ProductAttrValueDO::getAttrKeyId);
List<ProductAttrKeyDO> attrKeys = productAttrKeyMapper.selectBatchIds(attrKeyIds);
if (attrKeys.size() != attrKeyIds.size()) {
throw ServiceExceptionUtil.exception(PRODUCT_ATTR_KEY_NOT_EXIST);
}
if (validStatus) {
for (ProductAttrKeyDO attrKey : attrKeys) { // 同时,校验下状态
if (CommonStatusEnum.DISABLE.getValue().equals(attrKey.getStatus())) {
throw ServiceExceptionUtil.exception(PRODUCT_ATTR_KEY_NOT_EXIST);
}
}
}
// 返回成功
Map<Integer, ProductAttrKeyDO> attrKeyMap = CollectionUtils.convertMap(attrKeys,
ProductAttrKeyDO::getId, attrKeyDO -> attrKeyDO); // ProductAttrDO 的映射,方便查找。
return attrValues.stream().map(attrValueDO -> new ProductAttrKeyValueBO()
.setAttrKeyId(attrValueDO.getAttrKeyId()).setAttrKeyName(attrKeyMap.get(attrValueDO.getAttrKeyId()).getName())
.setAttrValueId(attrValueDO.getId()).setAttrValueName(attrValueDO.getName()))
.collect(Collectors.toList());
}
/**
* 创建商品规格键
*
* @param createBO 创建商品规格键 BO
* @return 商品规格键
*/
public ProductAttrKeyBO createProductAttrKey(@Valid ProductAttrKeyCreateBO createBO) {
// 校验规格键的名字是否重复
if (productAttrKeyMapper.selectByName(createBO.getName()) != null) {
throw ServiceExceptionUtil.exception(PRODUCT_ATTR_KEY_EXISTS);
}
// 插入到数据库
ProductAttrKeyDO productAttrKeyDO = ProductAttrConvert.INSTANCE.convert(createBO);
productAttrKeyMapper.insert(productAttrKeyDO);
// 返回
return ProductAttrConvert.INSTANCE.convert(productAttrKeyDO);
}
/**
* 更新商品规格键
*
* @param updateBO 更新商品规格键 BO
*/
public void updateProductAttrKey(@Valid ProductAttrKeyUpdateBO updateBO) {
// 校验规格键的名字是否重复
ProductAttrKeyDO attrKeyDOByName = productAttrKeyMapper.selectByName(updateBO.getName());
if (attrKeyDOByName != null && !attrKeyDOByName.getId().equals(updateBO.getId())) {
throw ServiceExceptionUtil.exception(PRODUCT_ATTR_KEY_EXISTS);
}
// 校验更新的商品规格键是否存在
if (productAttrKeyMapper.selectById(updateBO.getId()) == null) {
throw ServiceExceptionUtil.exception(PRODUCT_ATTR_KEY_NOT_EXIST);
}
// 更新到数据库
ProductAttrKeyDO updateObject = ProductAttrConvert.INSTANCE.convert(updateBO);
productAttrKeyMapper.updateById(updateObject);
}
/**
* 获得商品规格键
*
* @param productAttrKeyId 商品规格键编号
* @return 商品规格键
*/
public ProductAttrKeyBO getProductAttrKey(Integer productAttrKeyId) {
ProductAttrKeyDO productAttrKeyDO = productAttrKeyMapper.selectById(productAttrKeyId);
return ProductAttrConvert.INSTANCE.convert(productAttrKeyDO);
}
/**
* 获得商品规格键列表
*
* @param productAttrKeyIds 商品规格键编号列表
* @return 商品规格键列表
*/
public List<ProductAttrKeyBO> listProductAttrKeys(List<Integer> productAttrKeyIds) {
List<ProductAttrKeyDO> productAttrKeyDOs = productAttrKeyMapper.selectBatchIds(productAttrKeyIds);
return ProductAttrConvert.INSTANCE.convertList(productAttrKeyDOs);
}
/**
* 获得商品规格键分页
*
* @param pageBO 商品规格键分页查询
* @return 商品规格键分页结果
*/
public PageResult<ProductAttrKeyBO> pageProductAttrKey(ProductAttrKeyPageBO pageBO) {
IPage<ProductAttrKeyDO> productAttrKeyDOPage = productAttrKeyMapper.selectPage(pageBO);
return ProductAttrConvert.INSTANCE.convertPage(productAttrKeyDOPage);
}
/**
* 创建商品规格值
*
* @param createBO 创建商品规格值 BO
* @return 商品规格值
*/
public ProductAttrValueBO createProductAttrValue(@Valid ProductAttrValueCreateBO createBO) {
// 校验规格键是否存在
if (productAttrKeyMapper.selectById(createBO.getAttrKeyId()) == null) {
throw ServiceExceptionUtil.exception(PRODUCT_ATTR_KEY_NOT_EXIST);
}
// 校验规格值的名字是否重复
if (productAttrValueMapper.selectByAttrKeyIdAndName(createBO.getAttrKeyId(), createBO.getName()) != null) {
throw ServiceExceptionUtil.exception(PRODUCT_ATTR_VALUE_EXISTS);
}
// 插入到数据库
ProductAttrValueDO productAttrValueDO = ProductAttrConvert.INSTANCE.convert(createBO);
productAttrValueMapper.insert(productAttrValueDO);
// 返回
return ProductAttrConvert.INSTANCE.convert(productAttrValueDO);
}
/**
* 更新商品规格值
*
* @param updateBO 更新商品规格值 BO
*/
public void updateProductAttrValue(@Valid ProductAttrValueUpdateBO updateBO) {
// 校验更新的商品规格值是否存在
ProductAttrValueDO attrValueDO = productAttrValueMapper.selectById(updateBO.getId());
if (attrValueDO == null) {
throw ServiceExceptionUtil.exception(PRODUCT_ATTR_VALUE_NOT_EXIST);
}
// 校验规格值的名字是否重复
ProductAttrValueDO attrValueDOByName = productAttrValueMapper.selectByAttrKeyIdAndName(
attrValueDO.getAttrKeyId(), updateBO.getName());
if (attrValueDOByName != null && !attrValueDOByName.getId().equals(updateBO.getId())) {
throw ServiceExceptionUtil.exception(PRODUCT_ATTR_VALUE_EXISTS);
}
// 更新到数据库
ProductAttrValueDO updateObject = ProductAttrConvert.INSTANCE.convert(updateBO);
productAttrValueMapper.updateById(updateObject);
}
/**
* 获得商品规格值
*
* @param productAttrValueId 商品规格值编号
* @return 商品规格值
*/
public ProductAttrValueBO getProductAttrValue(Integer productAttrValueId) {
ProductAttrValueDO productAttrValueDO = productAttrValueMapper.selectById(productAttrValueId);
return ProductAttrConvert.INSTANCE.convert(productAttrValueDO);
}
/**
* 获得商品规格值列表
*
* @param queryBO 商品规格值的列表查询条件 BO
* @return 商品规格值列表
*/
public List<ProductAttrValueBO> listProductAttrValues(ProductAttrValueListQueryBO queryBO) {
List<ProductAttrValueDO> productAttrValueDOs = productAttrValueMapper.selectList(queryBO);
return ProductAttrConvert.INSTANCE.convertList03(productAttrValueDOs);
}
}

View File

@@ -0,0 +1,32 @@
package cn.iocoder.mall.productservice.service.attr.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 商品规格键 BO
*/
@Data
@Accessors(chain = true)
public class ProductAttrKeyBO {
/**
* 规格键编号
*/
private Integer id;
/**
* 规格键名称
*/
private String name;
/**
* 状态
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
}

View File

@@ -0,0 +1,30 @@
package cn.iocoder.mall.productservice.service.attr.bo;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 商品规格键创建 BO
*/
@Data
@Accessors(chain = true)
public class ProductAttrKeyCreateBO {
/**
* 规格键名称
*/
@NotEmpty(message = "规格键名称不能为空")
private String name;
/**
* 状态
*/
@NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
}

View File

@@ -0,0 +1,25 @@
package cn.iocoder.mall.productservice.service.attr.bo;
import cn.iocoder.common.framework.vo.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 商品规格键分页 BO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ProductAttrKeyPageBO extends PageParam {
/**
* 规格键名称,模糊匹配
*/
private String name;
/**
* 状态
*/
private Integer status;
}

View File

@@ -0,0 +1,35 @@
package cn.iocoder.mall.productservice.service.attr.bo;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 商品规格键更新 BO
*/
@Data
@Accessors(chain = true)
public class ProductAttrKeyUpdateBO {
/**
* 规格键编号
*/
@NotNull(message = "规格键编号不能为空")
private Integer id;
/**
* 规格键名称
*/
@NotEmpty(message = "规格键名称不能为空")
private String name;
/**
* 状态
*/
@NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
}

View File

@@ -0,0 +1,32 @@
package cn.iocoder.mall.productservice.service.attr.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* 商品规格键值对 BO
*/
@Data
@Accessors(chain = true)
public class ProductAttrKeyValueBO implements Serializable {
/**
* 规格 Key 编号
*/
private Integer attrKeyId;
/**
* 规格 Key 名字
*/
private String attrKeyName;
/**
* 规格 Value 编号
*/
private Integer attrValueId;
/**
* 规格 Value 名字
*/
private String attrValueName;
}

View File

@@ -0,0 +1,36 @@
package cn.iocoder.mall.productservice.service.attr.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 商品规格值 BO
*/
@Data
@Accessors(chain = true)
public class ProductAttrValueBO {
/**
* 规格值编号
*/
private Integer id;
/**
* 规格键编号
*/
private Integer attrKeyId;
/**
* 规格值名字
*/
private String name;
/**
* 状态
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
}

View File

@@ -0,0 +1,35 @@
package cn.iocoder.mall.productservice.service.attr.bo;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 商品规格值创建 BO
*/
@Data
@Accessors(chain = true)
public class ProductAttrValueCreateBO {
/**
* 规格键编号
*/
@NotNull(message = "规格键编号不能为空")
private Integer attrKeyId;
/**
* 规格值名字
*/
@NotEmpty(message = "规格值名字不能为空")
private String name;
/**
* 状态
*/
@NotNull(message = "状态")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
}

View File

@@ -0,0 +1,25 @@
package cn.iocoder.mall.productservice.service.attr.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 商品规格值的列表查询条件 BO
*/
@Data
@Accessors(chain = true)
public class ProductAttrValueListQueryBO {
/**
* 商品规格值编号列表
*/
private List<Integer> productAttrValueIds;
/**
* 商品规格键编号
*/
private Integer productAttrKeyId;
}

View File

@@ -0,0 +1,41 @@
package cn.iocoder.mall.productservice.service.attr.bo;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 商品规格值更新 BO
*/
@Data
@Accessors(chain = true)
public class ProductAttrValueUpdateBO {
/**
* 规格值编号
*/
@NotNull(message = "规格值编号不能为空")
private Integer id;
/**
* 规格键编号
*/
@NotNull(message = "规格键编号不能为空")
private Integer attrKeyId;
/**
* 规格值名字
*/
@NotEmpty(message = "规格值名字不能为空")
private String name;
/**
* 状态
*/
@NotNull(message = "状态")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
}

View File

@@ -0,0 +1,119 @@
package cn.iocoder.mall.productservice.service.brand;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.convert.brand.ProductBrandConvert;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.brand.ProductBrandDO;
import cn.iocoder.mall.productservice.dal.mysql.mapper.brand.ProductBrandMapper;
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandBO;
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandCreateBO;
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandPageBO;
import cn.iocoder.mall.productservice.service.brand.bo.ProductBrandUpdateBO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import java.util.List;
import static cn.iocoder.mall.productservice.enums.ProductErrorCodeConstants.PRODUCT_BRAND_NAME_EXIST;
import static cn.iocoder.mall.productservice.enums.ProductErrorCodeConstants.PRODUCT_BRAND_NOT_FOUND;
/**
* 商品品牌 Service
*/
@Service
@Validated
public class ProductBrandService {
@Autowired
private ProductBrandMapper productBrandMapper;
/**
* 创建商品品牌
*
* @param createBO 创建商品品牌 BO
* @return 商品品牌
*/
public ProductBrandBO createProductBrand(@Valid ProductBrandCreateBO createBO) {
// 校验商品品牌的名字是否已经使用
if (productBrandMapper.selectByName(createBO.getName()) != null) {
throw ServiceExceptionUtil.exception(PRODUCT_BRAND_NAME_EXIST);
}
// 插入到数据库
ProductBrandDO productBrandDO = ProductBrandConvert.INSTANCE.convert(createBO);
productBrandMapper.insert(productBrandDO);
// 返回
return ProductBrandConvert.INSTANCE.convert(productBrandDO);
}
/**
* 更新商品品牌
*
* @param updateBO 更新商品品牌 BO
*/
public void updateProductBrand(@Valid ProductBrandUpdateBO updateBO) {
// 校验更新的商品品牌是否存在
if (productBrandMapper.selectById(updateBO.getId()) == null) {
throw ServiceExceptionUtil.exception(PRODUCT_BRAND_NOT_FOUND);
}
// 校验商品品牌的名字是否已经使用
ProductBrandDO productBrandDOByName = productBrandMapper.selectByName(updateBO.getName());
if (productBrandDOByName != null && !updateBO.getId().equals(productBrandDOByName.getId())) {
throw ServiceExceptionUtil.exception(PRODUCT_BRAND_NAME_EXIST);
}
// 更新到数据库
ProductBrandDO updateObject = ProductBrandConvert.INSTANCE.convert(updateBO);
productBrandMapper.updateById(updateObject);
}
/**
* 删除商品品牌
*
* @param productBrandId 商品品牌编号
*/
public void deleteProductBrand(Integer productBrandId) {
// 校验删除的商品品牌是否存在
if (productBrandMapper.selectById(productBrandId) == null) {
throw ServiceExceptionUtil.exception(PRODUCT_BRAND_NOT_FOUND);
}
// TODO 功能点:需要品牌下没有分类
// 标记删除
productBrandMapper.deleteById(productBrandId);
}
/**
* 获得商品品牌
*
* @param productBrandId 商品品牌编号
* @return 商品品牌
*/
public ProductBrandBO getProductBrand(Integer productBrandId) {
ProductBrandDO productBrandDO = productBrandMapper.selectById(productBrandId);
return ProductBrandConvert.INSTANCE.convert(productBrandDO);
}
/**
* 获得商品品牌列表
*
* @param productBrandIds 商品品牌编号列表
* @return 商品品牌列表
*/
public List<ProductBrandBO> listProductBrands(List<Integer> productBrandIds) {
List<ProductBrandDO> productBrandDOs = productBrandMapper.selectBatchIds(productBrandIds);
return ProductBrandConvert.INSTANCE.convertList(productBrandDOs);
}
/**
* 获得商品品牌分页
*
* @param pageBO 商品品牌分页查询
* @return 商品品牌分页结果
*/
public PageResult<ProductBrandBO> pageProductBrand(ProductBrandPageBO pageBO) {
IPage<ProductBrandDO> productBrandDOPage = productBrandMapper.selectPage(pageBO);
return ProductBrandConvert.INSTANCE.convertPage(productBrandDOPage);
}
}

View File

@@ -0,0 +1,40 @@
package cn.iocoder.mall.productservice.service.brand.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 商品品牌 BO
*/
@Data
@Accessors(chain = true)
public class ProductBrandBO {
/**
* 品牌编号(主键)
*/
private Integer id;
/**
* 品牌名称
*/
private String name;
/**
* 品牌描述
*/
private String description;
/**
* 品牌名图片
*/
private String picUrl;
/**
* 状态
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
}

View File

@@ -0,0 +1,38 @@
package cn.iocoder.mall.productservice.service.brand.bo;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 商品品牌创建 BO
*/
@Data
@Accessors(chain = true)
public class ProductBrandCreateBO {
/**
* 品牌名称
*/
@NotEmpty(message = "品牌名称不能为空")
private String name;
/**
* 品牌描述
*/
private String description;
/**
* 品牌名图片
*/
private String picUrl;
/**
* 状态
*/
@NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
}

View File

@@ -0,0 +1,27 @@
package cn.iocoder.mall.productservice.service.brand.bo;
import cn.iocoder.common.framework.vo.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 商品品牌分页 BO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ProductBrandPageBO extends PageParam {
/**
* 品牌名称
*
* 模糊匹配
*/
private String name;
/**
* 状态
*/
private Integer status;
}

View File

@@ -0,0 +1,43 @@
package cn.iocoder.mall.productservice.service.brand.bo;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 商品品牌更新 BO
*/
@Data
@Accessors(chain = true)
public class ProductBrandUpdateBO {
/**
* 品牌编号(主键)
*/
@NotNull(message = "品牌编号(主键)不能为空")
private Integer id;
/**
* 品牌名称
*/
@NotEmpty(message = "品牌名称不能为空")
private String name;
/**
* 品牌描述
*/
private String description;
/**
* 品牌名图片
*/
private String picUrl;
/**
* 状态
*/
@NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
}

View File

@@ -0,0 +1,135 @@
package cn.iocoder.mall.productservice.service.category;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.mall.productservice.convert.category.ProductCategoryConvert;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.category.ProductCategoryDO;
import cn.iocoder.mall.productservice.dal.mysql.mapper.category.ProductCategoryMapper;
import cn.iocoder.mall.productservice.enums.category.ProductCategoryIdEnum;
import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryBO;
import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryCreateBO;
import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryListQueryBO;
import cn.iocoder.mall.productservice.service.category.bo.ProductCategoryUpdateBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.mall.productservice.enums.ProductErrorCodeConstants.*;
/**
* 商品分类 Service
*/
@Service
@Validated
public class ProductCategoryService {
@Autowired
private ProductCategoryMapper productCategoryMapper;
/**
* 创建商品分类
*
* @param createBO 创建商品分类 BO
* @return 商品分类
*/
public ProductCategoryBO createProductCategory(@Valid ProductCategoryCreateBO createBO) {
// 校验父分类
validParent(createBO.getPid());
// 插入到数据库
ProductCategoryDO productCategoryDO = ProductCategoryConvert.INSTANCE.convert(createBO);
productCategoryMapper.insert(productCategoryDO);
// 返回
return ProductCategoryConvert.INSTANCE.convert(productCategoryDO);
}
/**
* 更新商品分类
*
* @param updateBO 更新商品分类 BO
*/
public void updateProductCategory(@Valid ProductCategoryUpdateBO updateBO) {
// 校验父分类
validParent(updateBO.getPid());
// 校验不能设置自己为父分类
if (updateBO.getId().equals(updateBO.getPid())) {
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_PARENT_NOT_SELF);
}
// 校验更新的商品分类是否存在
if (productCategoryMapper.selectById(updateBO.getId()) == null) {
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_NOT_EXISTS);
}
// 更新到数据库
ProductCategoryDO updateObject = ProductCategoryConvert.INSTANCE.convert(updateBO);
productCategoryMapper.updateById(updateObject);
}
/**
* 删除商品分类
*
* @param productCategoryId 商品分类编号
*/
public void deleteProductCategory(Integer productCategoryId) {
// 校验删除的商品分类是否存在
if (productCategoryMapper.selectById(productCategoryId) == null) {
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_NOT_EXISTS);
}
// 只有不存在子分类才可以删除
Integer childCount = productCategoryMapper.selectCountByPid(productCategoryId);
if (childCount > 0) {
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_DELETE_ONLY_NO_CHILD);
}
// TODO 芋艿 补充只有不存在商品才可以删除
// 标记删除
productCategoryMapper.deleteById(productCategoryId);
}
/**
* 获得商品分类
*
* @param productCategoryId 商品分类编号
* @return 商品分类
*/
public ProductCategoryBO getProductCategory(Integer productCategoryId) {
ProductCategoryDO productCategoryDO = productCategoryMapper.selectById(productCategoryId);
return ProductCategoryConvert.INSTANCE.convert(productCategoryDO);
}
/**
* 获得商品分类列表
*
* @param productCategoryIds 商品分类编号列表
* @return 商品分类列表
*/
public List<ProductCategoryBO> listProductCategories(Collection<Integer> productCategoryIds) {
List<ProductCategoryDO> productCategoryDOs = productCategoryMapper.selectBatchIds(productCategoryIds);
return ProductCategoryConvert.INSTANCE.convertList(productCategoryDOs);
}
/**
* 获得商品分类全列表
*
* @return 商品分类全列表
*/
public List<ProductCategoryBO> listProductCategories(ProductCategoryListQueryBO listQueryBO) {
List<ProductCategoryDO> resourceDOs = productCategoryMapper.selectList(listQueryBO);
return ProductCategoryConvert.INSTANCE.convertList(resourceDOs);
}
private void validParent(Integer pid) {
if (!ProductCategoryIdEnum.ROOT.getId().equals(pid)) {
ProductCategoryDO parentCategory = productCategoryMapper.selectById(pid);
// 校验父分类是否存在
if (parentCategory == null) {
throw ServiceExceptionUtil.exception(PRODUCT_CATEGORY_PARENT_NOT_EXISTS);
}
// 父分类必须是一级分类
if (!ProductCategoryIdEnum.ROOT.getId().equals(parentCategory.getPid())) {
throw ServiceExceptionUtil.exception((PRODUCT_CATEGORY_PARENT_CAN_NOT_BE_LEVEL2));
}
}
}
}

View File

@@ -0,0 +1,48 @@
package cn.iocoder.mall.productservice.service.category.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 商品分类 BO
*/
@Data
@Accessors(chain = true)
public class ProductCategoryBO {
/**
* 分类编号
*/
private Integer id;
/**
* 父分类编号
*/
private Integer pid;
/**
* 分类名称
*/
private String name;
/**
* 分类描述
*/
private String description;
/**
* 分类图片
*/
private String picUrl;
/**
* 分类排序
*/
private Integer sort;
/**
* 状态
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
}

View File

@@ -0,0 +1,48 @@
package cn.iocoder.mall.productservice.service.category.bo;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 商品分类创建 BO
*/
@Data
@Accessors(chain = true)
public class ProductCategoryCreateBO {
/**
* 父分类编号
*/
@NotNull(message = "父分类编号不能为空")
private Integer pid;
/**
* 分类名称
*/
@NotEmpty(message = "分类名称不能为空")
private String name;
/**
* 分类描述
*/
private String description;
/**
* 分类图片
*/
private String picUrl;
/**
* 分类排序
*/
@NotNull(message = "分类排序不能为空")
private Integer sort;
/**
* 状态
*/
@NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
}

View File

@@ -0,0 +1,25 @@
package cn.iocoder.mall.productservice.service.category.bo;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 商品分类列表查询 BO
*/
@Data
@Accessors(chain = true)
public class ProductCategoryListQueryBO {
/**
* 父编号
*/
private Integer pid;
/**
* 状态
*/
@InEnum(value = CommonStatusEnum.class, message = "状态必须是 {value}")
private Integer status;
}

View File

@@ -0,0 +1,53 @@
package cn.iocoder.mall.productservice.service.category.bo;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 商品分类更新 BO
*/
@Data
@Accessors(chain = true)
public class ProductCategoryUpdateBO {
/**
* 分类编号
*/
@NotNull(message = "分类编号不能为空")
private Integer id;
/**
* 父分类编号
*/
@NotNull(message = "父分类编号不能为空")
private Integer pid;
/**
* 分类名称
*/
@NotEmpty(message = "分类名称不能为空")
private String name;
/**
* 分类描述
*/
private String description;
/**
* 分类图片
*/
private String picUrl;
/**
* 分类排序
*/
@NotNull(message = "分类排序不能为空")
private Integer sort;
/**
* 状态
*/
@NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
}

View File

@@ -0,0 +1,118 @@
package cn.iocoder.mall.productservice.service.sku;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.util.StringUtils;
import cn.iocoder.mall.productservice.convert.sku.ProductSkuConvert;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.sku.ProductSkuDO;
import cn.iocoder.mall.productservice.dal.mysql.mapper.sku.ProductSkuMapper;
import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuBO;
import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuCreateOrUpdateBO;
import cn.iocoder.mall.productservice.service.sku.bo.ProductSkuListQueryBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class ProductSkuService {
@Autowired
private ProductSkuMapper productSkuMapper;
public void createProductSkus(Integer spuId, List<ProductSkuCreateOrUpdateBO> createSkuBOs) {
List<ProductSkuDO> skus = ProductSkuConvert.INSTANCE.convertList(createSkuBOs);
skus.forEach(sku -> {
sku.setStatus(CommonStatusEnum.ENABLE.getValue());
sku.setSpuId(spuId);
});
productSkuMapper.insertList(skus);
}
@Transactional
public void updateProductSkus(Integer spuId, List<ProductSkuCreateOrUpdateBO> skuUpdateBOs) {
List<ProductSkuDO> existsSkus = productSkuMapper.selectListBySpuIdAndStatus(spuId,
CommonStatusEnum.ENABLE.getValue());
List<ProductSkuDO> insertSkus = new ArrayList<>(); // 1、找不到进行插入
List<Integer> deleteSkus = new ArrayList<>(); // 2、多余的删除
List<ProductSkuDO> updateSkus = new ArrayList<>(); // 3、找的到进行更新。
for (ProductSkuCreateOrUpdateBO skuUpdateDTO : skuUpdateBOs) {
ProductSkuDO existsSku = findProductSku(skuUpdateDTO.getAttrValueIds(), existsSkus);
// 3、找的到进行更新。
if (existsSku != null) {
// 移除
existsSkus.remove(existsSku);
// 创建 ProductSkuDO
updateSkus.add(ProductSkuConvert.INSTANCE.convert(skuUpdateDTO).setId(existsSku.getId()));
continue;
}
// 1、找不到进行插入
ProductSkuDO insertSku = ProductSkuConvert.INSTANCE.convert(skuUpdateDTO)
.setSpuId(spuId).setStatus(CommonStatusEnum.ENABLE.getValue());
insertSkus.add(insertSku);
}
// 2、多余的删除
if (!existsSkus.isEmpty()) {
deleteSkus.addAll(existsSkus.stream().map(ProductSkuDO::getId).collect(Collectors.toList()));
}
// 执行修改 Sku
if (!insertSkus.isEmpty()) {
productSkuMapper.insertList(insertSkus);
}
if (!updateSkus.isEmpty()) {
updateSkus.forEach(productSkuDO -> productSkuMapper.updateById(productSkuDO));
}
if (!deleteSkus.isEmpty()) {
productSkuMapper.deleteBatchIds(deleteSkus);
}
}
/**
* 获得 sku 数组中,指定规格的 sku
*
* @param attrValueIds 指定规格 Value 的编号数组
* @param skus sku 数组
* @return 符合条件的 sku
*/
private ProductSkuDO findProductSku(Collection<Integer> attrValueIds, List<ProductSkuDO> skus) {
if (CollectionUtils.isEmpty(skus)) {
return null;
}
// 创建成 Set ,方便后面比较
attrValueIds = new HashSet<>(attrValueIds);
for (ProductSkuDO sku : skus) {
Set<Integer> skuAttrValueIds = StringUtils.split(sku.getAttrs(), ",")
.stream().map(Integer::parseInt).collect(Collectors.toSet());
if (attrValueIds.equals(skuAttrValueIds)) {
return sku;
}
}
return null;
}
/**
* 获得商品 SKU
*
* @param productSkuId 商品 SKU 编号
* @return 商品 SKU
*/
public ProductSkuBO getProductSku(Integer productSkuId) {
ProductSkuDO productSkuDO = productSkuMapper.selectById(productSkuId);
return ProductSkuConvert.INSTANCE.convert(productSkuDO);
}
/**
* 获得商品 SKU 列表
*
* @param queryBO 商品 SKU 列表查询条件 BO
* @return 商品 SKU 列表
*/
public List<ProductSkuBO> listProductSkus(ProductSkuListQueryBO queryBO) {
// TODO FROM 芋艿:可能要考虑下,是不是要必须传递条件
List<ProductSkuDO> productSkuDOs = productSkuMapper.selectList(queryBO);
return ProductSkuConvert.INSTANCE.convertList02(productSkuDOs);
}
}

View File

@@ -0,0 +1,60 @@
package cn.iocoder.mall.productservice.service.sku.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
/**
* 商品 SKU BO
*/
@Data
@Accessors(chain = true)
public class ProductSkuBO {
/**
* sku 编号
*/
private Integer id;
/**
* 商品编号
*/
private Integer spuId;
/**
* 状态
*
* 1-正常
* 2-禁用
*/
private Integer status;
/**
* 图片地址
*/
private String picUrl;
/**
* 规格值编号数组
*/
private List<Integer> attrValueIds;
/**
* 价格,单位:分
*/
private Integer price;
/**
* 库存数量
*/
private Integer quantity;
/**
* 创建时间
*/
private Date createTime;
/**
* 最后更新时间
*/
private Date updateTime;
/**
* 是否删除
*/
private Integer deleted;
}

View File

@@ -0,0 +1,37 @@
package cn.iocoder.mall.productservice.service.sku.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 商品 SKU 创建或者修改 BO
*
* 注意,目前该对象是搭配 {@link}
*/
@Data
@Accessors(chain = true)
public class ProductSkuCreateOrUpdateBO {
/**
* 规格值数组
*/
@NotNull(message = "规格值数组不能为空")
private List<Integer> attrValueIds;
/**
* 价格,单位:分
*/
@NotNull(message = "价格不能为空")
@Min(value = 1L, message = "最小价格为 1")
private Integer price;
/**
* 库存数量
*/
@NotNull(message = "库存数量不能为空")
@Min(value = 1L, message = "最小库存为 1")
private Integer quantity;
}

View File

@@ -0,0 +1,32 @@
package cn.iocoder.mall.productservice.service.sku.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Collection;
/**
* 商品 SKU 列表查询 BO
*/
@Data
@Accessors(chain = true)
public class ProductSkuListQueryBO {
/**
* 商品 SKU 编号
*/
private Integer productSkuId;
/**
* 商品 SKU 编号数组
*/
private Collection<Integer> productSkuIds;
/**
* 商品 SPU 编号
*/
private Integer productSpuId;
/**
* 商品 SKU 状态
*/
private Integer productSkuStatus;
}

View File

@@ -0,0 +1,110 @@
package cn.iocoder.mall.productservice.service.spu;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.convert.spu.ProductSpuConvert;
import cn.iocoder.mall.productservice.dal.mysql.dataobject.spu.ProductSpuDO;
import cn.iocoder.mall.productservice.dal.mysql.mapper.spu.ProductSpuMapper;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuBO;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuCreateBO;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuPageBO;
import cn.iocoder.mall.productservice.service.spu.bo.ProductSpuUpdateBO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.mall.productservice.enums.ProductErrorCodeConstants.PRODUCT_SPU_NOT_EXISTS;
/**
* 商品 SPU Service
*/
@Service
@Validated
public class ProductSpuService {
@Autowired
private ProductSpuMapper productSpuMapper;
/**
* 创建商品 SPU
*
* @param createBO 创建商品 SPU BO
* @return 商品 SPU
*/
public ProductSpuBO createProductSpu(@Valid ProductSpuCreateBO createBO) {
// 插入到数据库
ProductSpuDO productSpuDO = ProductSpuConvert.INSTANCE.convert(createBO);
productSpuMapper.insert(productSpuDO);
// 返回
return ProductSpuConvert.INSTANCE.convert(productSpuDO);
}
/**
* 更新商品 SPU
*
* @param updateBO 更新商品 SPU BO
*/
public void updateProductSpu(@Valid ProductSpuUpdateBO updateBO) {
// 校验更新的商品 SPU是否存在
if (productSpuMapper.selectById(updateBO.getId()) == null) {
throw ServiceExceptionUtil.exception(PRODUCT_SPU_NOT_EXISTS);
}
// 更新到数据库
ProductSpuDO updateObject = ProductSpuConvert.INSTANCE.convert(updateBO);
productSpuMapper.updateById(updateObject);
}
/**
* 获得商品 SPU
*
* @param productSpuId 商品 SPU编号
* @return 商品 SPU
*/
public ProductSpuBO getProductSpu(Integer productSpuId) {
ProductSpuDO productSpuDO = productSpuMapper.selectById(productSpuId);
return ProductSpuConvert.INSTANCE.convert(productSpuDO);
}
/**
* 获得商品 SPU列表
*
* @param productSpuIds 商品 SPU编号列表
* @return 商品 SPU列表
*/
public List<ProductSpuBO> listProductSpus(Collection<Integer> productSpuIds) {
List<ProductSpuDO> productSpuDOs = productSpuMapper.selectBatchIds(productSpuIds);
return ProductSpuConvert.INSTANCE.convertList(productSpuDOs);
}
/**
* 获得商品 SPU分页
*
* @param pageBO 商品 SPU分页查询
* @return 商品 SPU分页结果
*/
public PageResult<ProductSpuBO> pageProductSpu(ProductSpuPageBO pageBO) {
IPage<ProductSpuDO> productSpuDOPage = productSpuMapper.selectPage(pageBO);
return ProductSpuConvert.INSTANCE.convertPage(productSpuDOPage);
}
/**
* 顺序获得商品 SPU 编号数组
*
* 一般情况下,该接口我们用于提供顺序的 SPU 编号数组,以便调用方进一步根据自己需要获取商品信息
* 例如说,搜索服务会不断获取商品编号,重建该商品编号的索引
*
* @param lastSpuId 最后一个商品 SPU 编号
* @param limit 数量
* @return 商品 SPU 编号数组
*/
public List<Integer> listProductSpuIds(Integer lastSpuId, Integer limit) {
return CollectionUtils.convertList(productSpuMapper.selectListByIdGt(lastSpuId, limit), ProductSpuDO::getId);
}
}

View File

@@ -0,0 +1,61 @@
package cn.iocoder.mall.productservice.service.spu.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
/**
* 商品 SPU 信息 BO
*/
@Data
@Accessors(chain = true)
public class ProductSpuBO {
/**
* 商品 SPU 编号
*/
private Integer id;
/**
* SPU 名字
*/
private String name;
/**
* 卖点
*/
private String sellPoint;
/**
* 描述
*/
private String description;
/**
* 分类编号
*/
private Integer cid;
/**
* 商品主图地址
*/
private List<String> picUrls;
/**
* 是否上架商品
*/
private Boolean visible;
/**
* 排序字段
*/
private Integer sort;
/**
* 价格
*/
private Integer price;
/**
* 库存数量
*/
private Integer quantity;
/**
* 创建时间
*/
private Date createTime;
}

View File

@@ -0,0 +1,63 @@
package cn.iocoder.mall.productservice.service.spu.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 商品 SPU 创建 BO
*/
@Data
@Accessors(chain = true)
public class ProductSpuCreateBO {
/**
* SPU 名字
*/
@NotEmpty(message = "SPU 名字不能为空")
private String name;
/**
* 卖点
*/
@NotEmpty(message = "卖点不能为空")
private String sellPoint;
/**
* 描述
*/
@NotEmpty(message = "描述不能为空")
private String description;
/**
* 分类编号
*/
@NotNull(message = "分类编号不能为空")
private Integer cid;
/**
* 商品主图地址
*/
@NotEmpty(message = "商品主图地址不能为空")
private List<String> picUrls;
/**
* 是否上架商品
*/
@NotNull(message = "是否上架商品不能为空")
private Boolean visible;
/**
* 排序字段
*/
@NotNull(message = "排序字段不能为空")
private Integer sort;
/**
* 价格
*/
@NotNull(message = "价格不能为空")
private Integer price;
/**
* 库存数量
*/
@NotNull(message = "库存数量不能为空")
private Integer quantity;
}

View File

@@ -0,0 +1,33 @@
package cn.iocoder.mall.productservice.service.spu.bo;
import cn.iocoder.common.framework.vo.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 商品 SPU 分页 BO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ProductSpuPageBO extends PageParam {
/**
* SPU 名字
*/
private String name;
/**
* 分类编号
*/
private Integer cid;
/**
* 是否可见
*/
private Boolean visible;
/**
* 是否有库存
*/
private Boolean hasQuantity;
}

View File

@@ -0,0 +1,67 @@
package cn.iocoder.mall.productservice.service.spu.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 商品 SPU 更新 BO
*/
@Data
@Accessors(chain = true)
public class ProductSpuUpdateBO {
/**
* 商品 SPU 编号
*/
@NotNull(message = "商品 SPU 编号不能为空")
private Integer id;
/**
* SPU 名字
*/
@NotEmpty(message = "SPU 名字不能为空")
private String name;
/**
* 卖点
*/
@NotEmpty(message = "卖点不能为空")
private String sellPoint;
/**
* 描述
*/
@NotEmpty(message = "描述不能为空")
private String description;
/**
* 分类编号
*/
@NotNull(message = "分类编号不能为空")
private Integer cid;
/**
* 商品主图地址
*/
@NotEmpty(message = "商品主图地址不能为空")
private List<String> picUrls;
/**
* 是否上架商品
*/
@NotNull(message = "是否上架商品不能为空")
private Boolean visible;
/**
* 排序字段
*/
private Integer sort;
/**
* 价格
*/
@NotNull(message = "价格不能为空")
private Integer price;
/**
* 库存数量
*/
@NotNull(message = "库存数量不能为空")
private Integer quantity;
}

View File

@@ -0,0 +1,21 @@
spring:
# 数据源配置项
datasource:
url: jdbc:mysql://localhost:3306/mall_product?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
password: zhuyang
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
# address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址

View File

@@ -0,0 +1,24 @@
spring:
# 数据源配置项
datasource:
url: jdbc:mysql://localhost:3306/mall_product?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
driver-class-name: com.mysql.jdbc.Driver
username: root
password: zhuyang
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
server-addr: localhost:8848 # Nacos 服务器地址
namespace: dev # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
# address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址
address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址
# Dubbo 服务提供者的配置
provider:
tag: ${DUBBO_TAG} # Dubbo 路由分组

View File

@@ -0,0 +1,60 @@
spring:
# Application 的配置项
application:
name: product-service
# Profile 的配置项
profiles:
active: local
# MyBatis Plus 配置项
mybatis-plus:
configuration:
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
global-config:
db-config:
id-type: auto
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
mapper-locations: classpath*:mapper/*.xml
type-aliases-package: cn.iocoder.mall.productservice.dal.mysql.dataobject
# Dubbo 配置项
dubbo:
# Spring Cloud Alibaba Dubbo 专属配置
cloud:
subscribed-services: '' # 设置订阅的应用列表,默认为 * 订阅所有应用
# Dubbo 提供者的协议
protocol:
name: dubbo
port: -1
# Dubbo 提供服务的扫描基础包
scan:
base-packages: cn.iocoder.mall.productservice.rpc
# Dubbo 服务提供者的配置
provider:
filter: -exception
validation: true # 开启 Provider 参数校验
version: 1.0.0 # 服务的版本号
# Dubbo 服务消费者的配置
consumer:
ErrorCodeRpc:
version: 1.0.0
# RocketMQ 配置项
rocketmq:
name-server: localhost:9876
producer:
group: ${spring.application.name}-producer-group
# Actuator 监控配置项
management:
server.port: 38082 # 独立端口,避免被暴露出去
endpoints.web.exposure.include: '*' # 暴露所有监控端点
server.port: ${management.server.port} # 设置使用 Actuator 的服务器端口,因为 RPC 服务不需要 Web 端口
# Mall 配置项
mall:
# 错误码配置项对应 ErrorCodeProperties 配置类
error-code:
group: ${spring.application.name}
constants-class: cn.iocoder.mall.productservice.enums.ProductErrorCodeConstants

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.productservice.dal.mysql.mapper.sku.ProductSkuMapper">
<insert id="insertList" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO product_sku (
spu_id, status, pic_url, attrs, price,
quantity
) VALUES
<foreach collection="productSkuDOs" item="productSkuDO" separator=",">
(#{productSkuDO.spuId}, #{productSkuDO.status}, #{productSkuDO.picUrl}, #{productSkuDO.attrs}, #{productSkuDO.price},
#{productSkuDO.quantity}
)
</foreach>
</insert>
</mapper>

View File

@@ -0,0 +1,216 @@
-- ----------------------------
-- Table structure for product_spu
-- ----------------------------
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (7, '测试商品', '又大又长', '厮大牛逼', 791, 'https://img2.woyaogexing.com/2019/03/15/5d4374f27d078462!400x400_big.jpg', 1, 0, 7, 10, '2019-03-05 02:45:44', '2019-04-24 11:47:20', b'1');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (8, '测试商品', '又大又长', '厮大牛逼', 791, 'https://img2.woyaogexing.com/2019/03/15/52c349020e992e04!400x400_big.jpg', 1, 0, 8, 20, '2019-03-05 02:48:52', '2019-04-24 11:47:22', b'1');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (9, '测试商品', '又大又长', '厮大牛逼', 791, 'https://img2.woyaogexing.com/2019/03/15/4ba4264eb3416283!400x400_big.jpg', 1, 0, 9, 30, '2019-03-05 02:51:22', '2019-04-24 11:47:23', b'1');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (10, '测试商品', '又大又长', '厮大牛逼', 791, 'https://img2.woyaogexing.com/2019/03/15/b258b691c543172d!400x400_big.jpg', 1, 0, 10, 40, '2019-03-05 02:52:25', '2019-04-24 11:47:25', b'1');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (11, '测试商品', '又大又长', '厮大牛逼', 791, 'https://img2.woyaogexing.com/2019/03/15/976d2210182f6816!400x400_big.jpg', 1, 0, 11, 50, '2019-03-05 03:21:46', '2019-04-24 11:47:47', b'1');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (28, '测试商品', '又大又长', '<p>厮大牛逼</p>', 638, 'https://user-gold-cdn.xitu.io/2019/4/1/169d694b02ef0df7?imageView2/0/w/1280/h/960/format/jpeg/ignore-error/1,http://static.shop.iocoder.cn/49ace70a-bebc-4d1c-b4e7-2115cedbf2a8', 1, 1, 100, 300, '2019-03-07 01:34:15', '2019-05-13 14:48:36', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (29, 'kafka 实战第一版', '最强', '<p>我是一个骚气的描述</p>', 637, 'https://user-gold-cdn.xitu.io/2019/4/1/169d694ae392047b?imageView2/0/w/1280/h/960/format/jpeg/ignore-error/1,http://static.shop.iocoder.cn/ab34d8e5-3b28-4f74-bafa-48aa66b4cf58', 1, 2, 10000000, 60, '2019-03-18 17:50:00', '2019-05-06 15:31:21', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (32, '农夫山泉', '有点甜', '<p>我就是一个水</p>', 637, 'https://img.1000.com/qm-a-img/prod/000000/68635d48f57444c8a5ffd47a257dc3d7.jpg', 1, 1, 125000000, 50, '2019-04-16 13:45:13', '2019-09-06 10:58:36', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (33, 'Kafka 书籍汇总', '分布式发布订阅消息系统', 'kafka是一种高吞吐量的分布式发布订阅消息系统她有如下特性\n\n通过O(1)的磁盘数据结构提供消息的持久化这种结构对于即使数以TB的消息存储也能够保持长时间的稳定性能。\n\n高吞吐量即使是非常普通的硬件kafka也可以支持每秒数十万的消息。\n\n支持通过kafka服务器和消费机集群来分区消息。\n\n支持Hadoop并行数据加载。\n\n卡夫卡的目的是提供一个发布订阅解决方案它可以处理消费者规模的网站中的所有动作流数据。 这种动作(网页浏览,搜索和其他用户的行动)是在现代网络上的许多社会功能的一个关键因素。 这些数据通常是由于吞吐量的要求而通过处理日志和日志聚合来解决。 对于像Hadoop的一样的日志数据和离线分析系统但又要求实时处理的限制这是一个可行的解决方案。kafka的目的是通过Hadoop的并行加载机制来统一线上和离线的消息处理也是为了通过集群机来提供实时的消费。', 783, 'http://static.iocoder.cn/kafka.png', 1, 0, 10000, 120, '2019-04-22 13:08:27', '2019-04-22 13:08:26', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (34, 'MySQL', '数据库服务器', 'MySQL是一个开放源码的小型关联式数据库管理系统开发者为瑞典MySQL AB公司。目前MySQL被广泛地应用在Internet上的中小型网站中。由于其体积小、速度快、总体拥有成本低尤其是开放源码这一特点许多中小型网站为了降低网站总体拥有成本而选择了MySQL作为网站数据库。', 579, 'https://static.oschina.net/img/logo/mysql.png', 1, 0, 2000, 300, '2019-04-22 13:11:56', '2019-04-22 13:11:55', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (35, 'Oracle', '数据库服务器', '<p>Oracle是一个面向Internet计算环境的数据库。它是在数据库领域一直处于领先地位的Oracle即甲骨文公司的产品。可以说Oracle 关系数据库系统是目前世界上流行的关系数据库管理系统,系统可移植性好、使用方便、功能强,适用于各类大、中、小、微机环境。它是一种高效率、可靠性好的 适应高吞吐量的数据库解决方案。</p>', 639, 'https://static.oschina.net/img/logo/oracle.gif', 1, 0, 200000, 33, '2019-04-22 13:14:33', '2019-08-12 23:38:32', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (36, 'Java', '编程语言', 'Java是由Sun Microsystems公司于1995年5月推出的Java程序设计语言和Java平台的总称最初推出的时候提出 “Write Once, Run Anywhere” 的理想愿景。\n\n 用 Java 实现的 HotJava 浏览器支持Java applet显示了 Java 的魅力跨平台、动态的Web、Internet计算。从此Java被广泛接受并推动了Web的迅速发展常用的浏览器现在均支持Java applet。', 639, 'https://static.oschina.net/img/logo/java.png', 1, 0, 2100, 33, '2019-04-22 13:15:15', '2019-04-22 13:15:14', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (37, '狼哥很骚', '骚气十足', '狼哥,死于 JVM 之手', 637, 'https://img.1000.com/qm-a-img/prod/000000/68635d48f57444c8a5ffd47a257dc3d7.jpg', 1, 0, 2000, 90, '2019-04-25 15:42:36', '2019-04-25 15:42:35', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (38, '天天吃饭', '不吃不行', '美团外卖饿了么外卖', 783, 'https://static.oschina.net/img/logo/mysql.png', 1, 0, 1000, 20, '2019-04-25 15:44:56', '2019-04-25 15:44:56', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (39, 'admin-server', '测试卖点', '30', 637, 'http://static.shop.iocoder.cn/8702680d-9145-490c-9bc1-13ed3337c4d1', 1, 0, 1000, 20, '2019-05-02 02:20:50', '2019-05-02 02:20:49', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (40, '测试多规格商品', '我是多规格', 'nice', 637, 'http://static.shop.iocoder.cn/d434dc76-3766-4d82-bdb7-229d1db4749c', 1, 0, 1000, 60, '2019-05-02 12:38:00', '2019-05-02 12:37:59', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (41, 'kafka 实战', '很吊', '厮大牛逼', 637, 'https://user-gold-cdn.xitu.io/2019/4/1/169d694ae392047b?imageView2/0/w/1280/h/960/format/jpeg/ignore-error/1', 1, 0, 1000, 0, '2019-05-02 17:44:05', '2019-05-06 13:27:22', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (42, '我和僵尸有个约会', '有点甜', '我就是描述', 637, 'http://static.shop.iocoder.cn/e3904ca3-d37c-47ae-b53f-3b46c5916e41', 0, 0, 1000, 60, '2019-05-02 22:17:01', '2019-05-06 13:27:05', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (43, '111', '111', '<p>123</p><div class=\"media-wrap image-wrap align-center\" style=\"text-align:center\"><img src=\"http://static.shop.iocoder.cn/57aa3c2a-56d7-4491-92b4-61c2461b3412\"/></div><p></p>', 784, 'http://static.shop.iocoder.cn/f97c1bce-48ff-4b26-8d34-d38137a306dd', 1, 0, 111100, 2222, '2019-07-02 11:36:25', '2019-07-02 11:36:24', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (44, '111', '111', '<p>123</p><div class=\"media-wrap image-wrap align-center\" style=\"text-align:center\"><img src=\"http://static.shop.iocoder.cn/57aa3c2a-56d7-4491-92b4-61c2461b3412\"/></div><p></p>', 784, 'http://static.shop.iocoder.cn/f97c1bce-48ff-4b26-8d34-d38137a306dd', 1, 0, 111100, 2222, '2019-07-02 11:36:39', '2019-07-02 11:36:38', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (45, '111', '111', '<p>123</p><div class=\"media-wrap image-wrap align-center\" style=\"text-align:center\"><img src=\"http://static.shop.iocoder.cn/57aa3c2a-56d7-4491-92b4-61c2461b3412\"/></div><p></p>', 784, 'http://static.shop.iocoder.cn/f97c1bce-48ff-4b26-8d34-d38137a306dd', 1, 0, 11100, 222, '2019-07-02 11:37:53', '2019-07-02 11:37:52', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (46, 'aaaa', 'a', '<p>111111111111111111111111</p>', 784, 'http://static.shop.iocoder.cn/c7f1a2c8-4015-4c28-bc64-a92ad72fbe12', 1, 0, 1100, 1222, '2019-07-05 15:41:02', '2019-07-05 15:41:01', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (47, '测试', '测试', '<p>21121212121</p>', 784, 'http://static.shop.iocoder.cn/1b4195db-93b9-4f8d-b8bb-3a88df28459d', 1, 0, 21213300, 23123, '2019-07-09 20:29:30', '2019-07-09 20:29:30', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (48, '测试', '测试', '<p>21121212121</p>', 784, 'http://static.shop.iocoder.cn/1b4195db-93b9-4f8d-b8bb-3a88df28459d', 1, 0, 21213300, 23123, '2019-07-09 20:29:40', '2019-07-09 20:29:40', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (49, '测试', '测试', '<p>21121212121</p>', 784, 'http://static.shop.iocoder.cn/124519dc-5b11-4bf1-96e3-ac29d18a603b', 1, 0, 21213300, 23123, '2019-07-09 20:32:27', '2019-07-09 20:32:26', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (50, '<script>alert(1111)</script>', '123', '<p>123123321</p><div class=\"media-wrap image-wrap\"><img src=\"http://static.shop.iocoder.cn/45bae085-0f13-42c8-a048-296ecc2dba2c\"/></div><p></p>', 784, 'http://static.shop.iocoder.cn/a7c70291-3d6e-46c2-90b8-f2b43f134b2b', 1, 0, 1200, 2, '2019-08-12 18:48:58', '2019-08-12 18:48:58', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (51, '<script>alert(1111)</script>', '123', '<p>123123321</p><div class=\"media-wrap image-wrap\"><img src=\"http://static.shop.iocoder.cn/45bae085-0f13-42c8-a048-296ecc2dba2c\"/></div><p></p>', 784, 'http://static.shop.iocoder.cn/a7c70291-3d6e-46c2-90b8-f2b43f134b2b', 1, 0, 1200, 2, '2019-08-12 18:49:03', '2019-08-12 18:49:02', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (52, '<script>alert(1111)</script>', '123', '<p>123123321</p><div class=\"media-wrap image-wrap\"><img src=\"http://static.shop.iocoder.cn/45bae085-0f13-42c8-a048-296ecc2dba2c\"/></div><p></p>', 784, 'http://static.shop.iocoder.cn/a7c70291-3d6e-46c2-90b8-f2b43f134b2b', 1, 0, 1200, 2, '2019-08-12 18:49:19', '2019-08-12 18:49:19', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (53, '<script>alert(1111)</script>', '123', '<p>123123321</p><div class=\"media-wrap image-wrap\"><img src=\"http://static.shop.iocoder.cn/45bae085-0f13-42c8-a048-296ecc2dba2c\"/></div><p></p>', 784, 'http://static.shop.iocoder.cn/a7c70291-3d6e-46c2-90b8-f2b43f134b2b', 1, 0, 1200, 2, '2019-08-12 18:50:48', '2019-08-12 18:50:48', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (54, 'Hadoop', '有点小贵', '<p>好看的不得了</p><div class=\"media-wrap image-wrap\"><img src=\"http://static.shop.iocoder.cn/d5dccd13-1f82-483e-bb87-fc47e14cb19f\"/></div><p></p>', 794, 'http://static.shop.iocoder.cn/4870d103-1c00-42e1-8eb7-177e227d5e03', 1, 0, 10000, 100, '2019-08-12 23:46:12', '2019-08-12 23:46:11', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (55, '金坷垃', '农民伯伯都爱它', '<p>金坷拉</p>', 783, 'http://static.shop.iocoder.cn/8fb41fd6-2ace-4e66-870d-28cff91084ae', 1, 0, 10000, 0, '2019-09-05 10:41:24', '2020-07-27 14:12:59', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (58, '测试商品标题', '', '测试商品描述', 637, '1,2,3', 1, 0, 1, 150, '2020-07-27 23:22:56', '2020-07-27 23:22:56', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (59, '测试商品标题', '', '测试商品描述', 637, '1,2,3', 1, 0, 1, 150, '2020-07-28 11:38:43', '2020-07-28 11:38:43', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (60, '测试商品标题', '', '测试商品描述', 637, '1,2,3', 1, 0, 1, 150, '2020-07-28 13:08:35', '2020-07-28 13:08:35', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (61, '测试商品标题', '', '测试商品描述', 637, '1,2,3', 1, 0, 1, 150, '2020-07-30 16:25:47', '2020-07-30 16:25:47', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (62, '测试商品标题', '', '测试商品描述', 637, '1,2,3', 1, 0, 1, 150, '2020-07-30 16:26:02', '2020-07-30 16:26:02', b'0');
INSERT INTO `mall_product`.`product_spu`(`id`, `name`, `sell_point`, `description`, `cid`, `pic_urls`, `visible`, `sort`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (63, '测试商品标题', '', '测试商品描述', 637, '1,2,3', 1, 0, 1, 150, '2020-07-30 16:26:13', '2020-07-30 16:26:13', b'0');
-- ----------------------------
-- Table structure for product_sku
-- ----------------------------
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (3, 8, 1, NULL, '1', 1, 100, '2019-03-05 02:48:52', '2019-03-05 16:48:52', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (4, 8, 1, NULL, '2', 1, 100, '2019-03-05 02:48:52', '2019-03-05 16:48:52', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (5, 9, 1, NULL, '1', 1, 100, '2019-03-05 02:51:22', '2019-03-05 16:51:21', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (6, 9, 1, NULL, '2', 1, 100, '2019-03-05 02:51:22', '2019-03-05 16:51:21', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (7, 10, 1, NULL, '1', 1, 100, '2019-03-05 02:52:25', '2019-03-05 16:52:25', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (8, 10, 1, NULL, '2', 1, 100, '2019-03-05 02:52:25', '2019-03-05 16:52:25', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (9, 13, 1, NULL, '1', 1, 100, '2019-03-05 03:22:24', '2019-03-05 17:22:26', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (10, 13, 1, NULL, '2', 1, 100, '2019-03-05 03:22:24', '2019-03-05 17:22:26', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (11, 14, 1, NULL, '1', 1, 100, '2019-03-05 03:22:33', '2019-03-05 17:22:40', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (12, 14, 1, NULL, '2', 1, 100, '2019-03-05 03:22:33', '2019-03-05 17:22:40', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (13, 20, 1, NULL, '1,3', 1, 100, '2019-03-05 03:25:39', '2019-03-05 17:25:39', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (14, 20, 1, NULL, '1,4', 1, 100, '2019-03-05 03:25:39', '2019-03-05 17:25:39', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (15, 21, 1, NULL, '1,3', 1, 100, '2019-03-05 03:34:07', '2019-03-05 17:34:06', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (16, 21, 1, NULL, '1,4', 1, 100, '2019-03-05 03:34:07', '2019-03-05 17:34:06', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (17, 22, 1, NULL, '1,3', 1, 100, '2019-03-05 03:34:50', '2019-03-05 17:34:49', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (18, 22, 1, NULL, '1,4', 1, 100, '2019-03-05 03:34:50', '2019-03-05 17:34:49', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (19, 23, 1, NULL, '1,3', 1, 1, '2019-03-05 03:37:03', '2019-03-26 23:51:23', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (20, 23, 1, NULL, '1,4', 2, 10, '2019-03-05 03:37:03', '2019-03-26 23:51:25', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (23, 25, 1, NULL, '1,3', 1, 100, '2019-03-05 03:43:30', '2019-03-05 17:43:30', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (24, 25, 1, NULL, '1,4', 1, 100, '2019-03-05 03:43:30', '2019-03-05 17:43:30', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (25, 26, 1, NULL, '1', 1, 100, '2019-03-05 07:00:38', '2019-03-05 21:00:38', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (26, 27, 1, NULL, '1', 1, 100, '2019-03-05 07:01:33', '2019-03-05 21:10:52', b'1');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (27, 27, 1, NULL, '2', 21, 200, '2019-03-05 07:01:33', '2019-03-05 21:10:52', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (30, 27, 1, NULL, '3', 3, 300, '2019-03-05 07:10:52', '2019-03-05 21:10:52', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (31, 28, 1, NULL, '1', 100, 100, '2019-03-07 01:34:15', '2019-05-13 14:48:36', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (32, 28, 1, NULL, '2', 200, 200, '2019-03-07 01:34:15', '2019-05-13 14:48:36', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (33, 29, 1, NULL, '1', 10000000, 20, '2019-03-18 17:50:01', '2019-05-05 23:48:10', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (34, 32, 1, NULL, '1,3', 125000000, 20, '2019-04-16 13:45:13', '2019-05-09 10:43:55', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (35, 32, 1, NULL, '1,4', 1410065408, 30, '2019-04-16 13:45:13', '2019-05-09 10:43:55', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (36, 33, 1, NULL, '3', 10000, 100, '2019-04-22 13:08:27', '2019-04-22 13:08:26', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (37, 33, 1, NULL, '4', 20000, 20, '2019-04-22 13:08:27', '2019-04-22 13:08:26', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (38, 34, 1, NULL, '1', 2000, 100, '2019-04-22 13:11:56', '2019-04-22 13:11:55', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (39, 34, 1, NULL, '2', 3000, 200, '2019-04-22 13:11:56', '2019-04-22 13:11:55', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (40, 35, 1, NULL, '3', 500000, 11, '2019-04-22 13:14:33', '2019-08-12 23:38:32', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (41, 35, 1, NULL, '4', 200000, 22, '2019-04-22 13:14:33', '2019-08-12 23:38:33', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (42, 36, 1, NULL, '3', 5100, 11, '2019-04-22 13:15:15', '2019-04-22 13:15:14', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (43, 36, 1, NULL, '4', 2100, 22, '2019-04-22 13:15:15', '2019-04-22 13:15:14', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (44, 37, 1, NULL, '3,2', 2000, 40, '2019-04-25 15:42:36', '2019-04-25 15:42:35', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (45, 37, 1, NULL, '4,2', 3000, 50, '2019-04-25 15:42:36', '2019-04-25 15:42:35', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (46, 38, 1, NULL, '2', 1000, 20, '2019-04-25 15:44:56', '2019-04-25 15:44:56', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (47, 39, 1, NULL, '1,3', 1000, 20, '2019-05-02 02:20:50', '2019-05-02 02:20:49', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (48, 40, 1, NULL, '1', 1000, 20, '2019-05-02 12:38:00', '2019-05-02 12:37:59', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (49, 40, 1, NULL, '2', 3000, 40, '2019-05-02 12:38:00', '2019-05-02 12:37:59', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (50, 41, 1, NULL, '1', 1000, 20, '2019-05-02 17:44:05', '2019-05-02 17:44:05', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (51, 29, 1, NULL, '2', 30000000, 40, '2019-05-02 18:19:15', '2019-05-05 23:48:10', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (54, 42, 1, NULL, '2', 3000, 40, '2019-05-02 22:25:19', '2019-05-02 22:54:16', b'1');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (55, 42, 1, NULL, '28', 1000, 20, '2019-05-02 22:54:17', '2019-05-02 22:54:16', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (56, 42, 1, NULL, '35', 3000, 40, '2019-05-02 23:01:17', '2019-05-02 23:01:17', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (57, 43, 1, NULL, '1,3', 111100, 1111, '2019-07-02 11:36:25', '2019-07-02 11:36:25', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (58, 43, 1, NULL, '2,3', 111100, 1111, '2019-07-02 11:36:25', '2019-07-02 11:36:25', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (59, 44, 1, NULL, '1,3', 111100, 1111, '2019-07-02 11:36:39', '2019-07-02 11:36:38', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (60, 44, 1, NULL, '2,3', 111100, 1111, '2019-07-02 11:36:39', '2019-07-02 11:36:38', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (61, 45, 1, NULL, '1,3,6', 11100, 111, '2019-07-02 11:37:53', '2019-07-02 11:37:52', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (62, 45, 1, NULL, '2,3,6', 11100, 111, '2019-07-02 11:37:53', '2019-07-02 11:37:52', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (63, 46, 1, NULL, '46', 1100, 1111, '2019-07-05 15:41:02', '2019-07-05 15:41:01', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (64, 46, 1, NULL, '4', 1100, 111, '2019-07-05 15:41:02', '2019-07-05 15:41:01', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (65, 47, 1, NULL, '3', 21213300, 23123, '2019-07-09 20:29:31', '2019-07-09 20:29:30', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (66, 48, 1, NULL, '3', 21213300, 23123, '2019-07-09 20:29:40', '2019-07-09 20:29:40', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (67, 49, 1, NULL, '3', 21213300, 23123, '2019-07-09 20:32:27', '2019-07-09 20:32:27', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (68, 50, 1, NULL, '47,48', 1200, 2, '2019-08-12 18:48:58', '2019-08-12 18:48:58', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (69, 51, 1, NULL, '47,48', 1200, 2, '2019-08-12 18:49:03', '2019-08-12 18:49:02', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (70, 52, 1, NULL, '47,48', 1200, 2, '2019-08-12 18:49:19', '2019-08-12 18:49:19', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (71, 53, 1, NULL, '47,48', 1200, 2, '2019-08-12 18:50:48', '2019-08-12 18:50:48', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (72, 54, 1, NULL, '1', 10000, 100, '2019-08-12 23:46:12', '2019-08-12 23:46:11', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (73, 55, 1, NULL, '49,50', 10000, 100, '2019-09-05 10:41:24', '2019-09-05 10:41:24', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (76, 58, 1, NULL, '1,3', 1, 100, '2020-07-27 23:22:56', '2020-07-27 23:22:56', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (77, 58, 1, NULL, '2,4', 2, 50, '2020-07-27 23:22:56', '2020-07-27 23:22:56', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (78, 59, 1, NULL, '1,3', 1, 100, '2020-07-28 11:38:43', '2020-07-28 11:38:43', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (79, 59, 1, NULL, '2,4', 2, 50, '2020-07-28 11:38:43', '2020-07-28 11:38:43', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (80, 60, 1, NULL, '1,3', 1, 100, '2020-07-28 13:08:35', '2020-07-28 13:08:35', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (81, 60, 1, NULL, '2,4', 2, 50, '2020-07-28 13:08:35', '2020-07-28 13:08:35', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (82, 61, 1, NULL, '1,3', 1, 100, '2020-07-30 16:25:47', '2020-07-30 16:25:47', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (83, 61, 1, NULL, '2,4', 2, 50, '2020-07-30 16:25:47', '2020-07-30 16:25:47', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (84, 62, 1, NULL, '1,3', 1, 100, '2020-07-30 16:26:02', '2020-07-30 16:26:02', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (85, 62, 1, NULL, '2,4', 2, 50, '2020-07-30 16:26:02', '2020-07-30 16:26:02', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (86, 63, 1, NULL, '1,3', 1, 100, '2020-07-30 16:26:13', '2020-07-30 16:26:13', b'0');
INSERT INTO `mall_product`.`product_sku`(`id`, `spu_id`, `status`, `pic_url`, `attrs`, `price`, `quantity`, `create_time`, `update_time`, `deleted`) VALUES (87, 63, 1, NULL, '2,4', 2, 50, '2020-07-30 16:26:13', '2020-07-30 16:26:13', b'0');
-- ----------------------------
-- Table structure for product_attr_key
-- ----------------------------
INSERT INTO `mall_product`.`product_attr_key`(`id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (1, '颜色', 1, '2019-03-05 15:40:56', '2019-03-05 15:40:58', b'0');
INSERT INTO `mall_product`.`product_attr_key`(`id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (2, '尺寸', 1, '2019-03-05 17:23:07', '2019-03-05 17:23:07', b'0');
INSERT INTO `mall_product`.`product_attr_key`(`id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (3, '测试规格1', 1, '2019-03-06 10:29:58', '2020-07-29 11:13:41', b'0');
INSERT INTO `mall_product`.`product_attr_key`(`id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (4, '厮大牛逼规格', 1, '2019-03-06 10:31:01', '2019-03-07 00:33:53', b'0');
INSERT INTO `mall_product`.`product_attr_key`(`id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (5, '狼哥规格', 2, '2019-03-06 10:31:47', '2019-03-07 00:34:27', b'0');
INSERT INTO `mall_product`.`product_attr_key`(`id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (6, '老徐规格', 1, '2019-03-06 10:48:42', '2019-03-07 00:48:41', b'0');
INSERT INTO `mall_product`.`product_attr_key`(`id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (7, '徐妈规格', 1, '2019-03-06 10:53:37', '2019-03-07 00:53:37', b'0');
INSERT INTO `mall_product`.`product_attr_key`(`id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (8, '粉色', 1, '2019-05-02 22:05:21', '2019-05-02 22:05:21', b'0');
INSERT INTO `mall_product`.`product_attr_key`(`id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (9, 'test', 1, '2020-07-29 11:04:26', '2020-07-29 11:04:26', b'0');
INSERT INTO `mall_product`.`product_attr_key`(`id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (10, 'test02', 1, '2020-07-29 11:13:48', '2020-07-29 11:13:48', b'0');
INSERT INTO `mall_product`.`product_attr_key`(`id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (11, '电视剧', 1, '2020-07-30 00:37:52', '2020-07-30 00:37:52', b'0');
-- ----------------------------
-- Table structure for product_attr_value
-- ----------------------------
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (1, 1, '蓝色', 1, '2019-03-05 15:41:09', '2019-03-05 15:41:09', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (2, 1, '绿色', 1, '2019-03-05 15:41:14', '2019-03-05 15:42:58', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (3, 2, 'XL', 1, '2019-03-05 17:23:19', '2019-03-05 17:23:19', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (4, 2, 'L', 1, '2019-03-05 17:23:25', '2019-03-05 17:23:25', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (5, 1, '红色', 1, '2019-03-05 20:59:48', '2019-03-05 20:59:48', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (6, 4, '狼哥规格', 1, '2019-03-06 19:55:38', '2019-03-07 09:55:38', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (7, 4, '狼哥规格1', 1, '2019-03-06 19:56:26', '2019-03-07 09:56:25', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (8, 4, '狼哥规格2', 1, '2019-03-06 19:57:19', '2019-03-07 09:57:19', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (9, 4, '狼哥规格345', 1, '2019-03-06 20:00:02', '2019-03-07 10:01:18', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (10, 9, '狼哥规格34', 2, '2019-03-06 20:00:59', '2019-03-07 10:02:43', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (11, 1, '粉色', 1, '2019-05-02 22:08:22', '2019-05-02 22:08:21', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (12, 1, '黄色', 1, '2019-05-02 22:10:30', '2019-05-02 22:10:30', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (13, 1, '橙色', 1, '2019-05-02 22:12:20', '2019-05-02 22:12:19', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (14, 1, '青色', 1, '2019-05-02 22:13:12', '2019-05-02 22:13:11', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (15, 1, '海蓝色', 1, '2019-05-02 22:15:47', '2019-05-02 22:15:47', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (16, 1, '浅蓝色', 1, '2019-05-02 22:16:25', '2019-05-02 22:16:25', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (17, 1, '天蓝色', 1, '2019-05-02 22:17:36', '2019-05-02 22:17:35', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (18, 9, '不破不灭', 1, '2019-05-02 22:18:24', '2019-05-02 22:30:29', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (19, 9, '各种浪', 1, '2019-05-02 22:19:17', '2019-05-02 22:30:27', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (20, 9, '测试01', 1, '2019-05-02 22:21:21', '2019-05-02 22:30:27', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (21, 9, '测试02', 1, '2019-05-02 22:23:17', '2019-05-02 22:30:25', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (22, 9, '测试03', 1, '2019-05-02 22:24:13', '2019-05-02 22:30:24', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (23, 9, 'biubiubiu', 1, '2019-05-02 22:24:42', '2019-05-02 22:30:23', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (24, 9, '特特', 1, '2019-05-02 22:35:35', '2019-05-02 22:35:42', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (25, 9, '01', 1, '2019-05-02 22:37:24', '2019-05-02 22:37:56', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (26, 9, 'liubi', 1, '2019-05-02 22:38:02', '2019-05-02 22:38:14', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (27, 9, 'zei6', 1, '2019-05-02 22:38:33', '2019-05-02 22:39:52', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (28, 3, 'niubi', 1, '2019-05-02 22:52:03', '2019-05-02 22:52:03', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (29, 3, 'wocao', 1, '2019-05-02 22:52:27', '2019-05-02 22:52:27', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (30, 3, '666', 1, '2019-05-02 22:54:44', '2019-05-02 22:54:43', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (31, 3, 'gouwazi', 1, '2019-05-02 22:58:52', '2019-05-02 22:58:51', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (32, 3, 'abc', 1, '2019-05-02 22:59:46', '2019-05-02 22:59:46', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (33, 3, 'qilin', 1, '2019-05-02 23:00:06', '2019-05-02 23:00:05', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (34, 3, 'xigua', 1, '2019-05-02 23:00:43', '2019-05-02 23:00:43', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (35, 3, 'zhanxiaolang', 1, '2019-05-02 23:01:07', '2019-05-02 23:01:07', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (36, 1, '粉绿色', 1, '2019-05-02 23:33:55', '2020-07-30 00:59:01', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (37, 6, '111', 1, '2019-05-31 18:55:56', '2019-05-31 18:55:55', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (38, 3, '22', 1, '2019-05-31 18:55:59', '2019-05-31 18:55:58', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (39, 2, '112', 1, '2019-05-31 18:56:06', '2019-05-31 18:56:05', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (40, 7, 'kk', 1, '2019-05-31 19:53:01', '2019-05-31 19:53:00', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (41, 7, 'nm', 1, '2019-05-31 19:53:05', '2019-05-31 19:53:04', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (42, 6, 'sss', 1, '2019-06-02 12:22:44', '2019-06-02 12:22:43', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (43, 6, 'sds', 1, '2019-06-02 12:22:46', '2019-06-02 12:22:45', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (44, 2, '3333', 1, '2019-07-02 11:19:32', '2019-07-02 11:19:32', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (45, 2, '123', 1, '2019-07-02 11:33:15', '2019-07-02 11:33:15', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (46, 2, 'a', 1, '2019-07-05 15:40:51', '2019-07-05 15:40:51', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (47, 2, '12312', 1, '2019-08-12 18:48:48', '2019-08-12 18:48:47', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (48, 3, '222', 1, '2019-08-12 18:48:54', '2019-08-12 18:48:53', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (49, 1, '金色', 1, '2019-09-05 10:38:55', '2019-09-05 10:38:55', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (50, 2, '一克拉', 1, '2019-09-05 10:39:05', '2019-09-05 10:39:04', b'0');
INSERT INTO `mall_product`.`product_attr_value`(`id`, `attr_key_id`, `name`, `status`, `create_time`, `update_time`, `deleted`) VALUES (51, 1, '花色', 1, '2020-07-30 01:00:22', '2020-07-30 01:00:22', b'0');
-- ----------------------------
-- Table structure for product_category
-- ----------------------------
INSERT INTO `mall_product`.`product_category`(`id`, `pid`, `name`, `description`, `pic_url`, `sort`, `status`, `create_time`, `update_time`, `deleted`) VALUES (90, 0, '电视影音', NULL, NULL, 0, 1, '2019-02-21 18:35:00', '2019-03-03 20:42:01', b'0');
INSERT INTO `mall_product`.`product_category`(`id`, `pid`, `name`, `description`, `pic_url`, `sort`, `status`, `create_time`, `update_time`, `deleted`) VALUES (579, 0, '手机电脑', NULL, NULL, 0, 1, '2019-02-21 18:33:26', '2019-03-03 20:42:03', b'0');
INSERT INTO `mall_product`.`product_category`(`id`, `pid`, `name`, `description`, `pic_url`, `sort`, `status`, `create_time`, `update_time`, `deleted`) VALUES (637, 90, '32-40英寸', NULL, 'https://shop.io.mi-img.com/app/shop/img?id=shop_904483f8aa3bbaaa9f53e4aae2382275.jpeg', 1, 1, '2019-02-21 18:35:20', '2019-03-03 20:42:05', b'0');
INSERT INTO `mall_product`.`product_category`(`id`, `pid`, `name`, `description`, `pic_url`, `sort`, `status`, `create_time`, `update_time`, `deleted`) VALUES (638, 90, '43英寸', NULL, 'https://shop.io.mi-img.com/app/shop/img?id=shop_0f26088b420afbe2c63df02246b94a34.jpeg', 2, 1, '2019-02-21 18:35:41', '2019-03-03 20:42:07', b'0');
INSERT INTO `mall_product`.`product_category`(`id`, `pid`, `name`, `description`, `pic_url`, `sort`, `status`, `create_time`, `update_time`, `deleted`) VALUES (639, 90, '49-50英寸', NULL, 'https://shop.io.mi-img.com/app/shop/img?id=shop_c2c741283b2ce1c4bc8b0abe9ea4f65e.jpeg', 3, 1, '2019-02-21 18:36:01', '2019-03-03 20:42:10', b'0');
INSERT INTO `mall_product`.`product_category`(`id`, `pid`, `name`, `description`, `pic_url`, `sort`, `status`, `create_time`, `update_time`, `deleted`) VALUES (783, 579, '小米系列', NULL, 'https://shop.io.mi-img.com/app/shop/img?id=shop_af3ae1e1444bc54af8b2251dd14aaa6b.jpeg', 1, 1, '2019-02-21 18:33:56', '2019-03-03 20:42:12', b'0');
INSERT INTO `mall_product`.`product_category`(`id`, `pid`, `name`, `description`, `pic_url`, `sort`, `status`, `create_time`, `update_time`, `deleted`) VALUES (784, 579, '红米系列', NULL, 'https://shop.io.mi-img.com/app/shop/img?id=shop_72605808146ee82c9961f9e3be6d8696.jpeg', 2, 1, '2019-02-21 18:34:29', '2019-03-03 20:42:14', b'0');
INSERT INTO `mall_product`.`product_category`(`id`, `pid`, `name`, `description`, `pic_url`, `sort`, `status`, `create_time`, `update_time`, `deleted`) VALUES (793, 0, '图书', '书是个好东西,可惜看的少。', NULL, 3, 1, '2019-05-05 16:12:39', '2019-05-05 16:12:39', b'0');
INSERT INTO `mall_product`.`product_category`(`id`, `pid`, `name`, `description`, `pic_url`, `sort`, `status`, `create_time`, `update_time`, `deleted`) VALUES (794, 793, 'Java', '半年一更,妥妥的', 'http://static.shop.iocoder.cn/5fd5709e-988d-4efd-b5d8-54a599ca538f', 1, 1, '2019-05-05 16:35:03', '2019-05-06 23:05:53', b'0');
INSERT INTO `mall_product`.`product_category`(`id`, `pid`, `name`, `description`, `pic_url`, `sort`, `status`, `create_time`, `update_time`, `deleted`) VALUES (796, 579, '订单系统设计', 'sss', 'http://static.shop.iocoder.cn/3fd98e94-ad50-415a-8f17-8bd8a998e508', 5, 1, '2019-06-26 20:28:35', '2019-06-26 20:28:34', b'0');
INSERT INTO `mall_product`.`product_category`(`id`, `pid`, `name`, `description`, `pic_url`, `sort`, `status`, `create_time`, `update_time`, `deleted`) VALUES (797, 0, '测试分类', NULL, NULL, 1, 1, '2020-07-25 19:16:24', '2020-07-25 19:16:24', b'0');
-- ----------------------------
-- Table structure for product_brand
-- ----------------------------
INSERT INTO `mall_product`.`product_brand`(`id`, `name`, `description`, `pic_url`, `status`, `create_time`, `update_time`, `deleted`) VALUES (1, '安踏更新', '安踏拖鞋更新', 'https://pic.17qq.com/uploads/hddeefhgbz.jpeg', 1, '2019-05-30 13:43:44', '2020-07-26 00:27:23', b'0');
INSERT INTO `mall_product`.`product_brand`(`id`, `name`, `description`, `pic_url`, `status`, `create_time`, `update_time`, `deleted`) VALUES (2, '特步', '特步描述', 'https://www.mask9.com/re/wp-content/uploads/2020/02/87285695_2755663391137244_8679130282952782166_n.jpg', 1, '2019-05-31 13:42:22', '2020-07-26 00:27:40', b'0');

View File

@@ -0,0 +1,103 @@
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for product_spu
-- ----------------------------
CREATE TABLE `product_spu` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'SPU 编号',
`name` varchar(50) NOT NULL DEFAULT '' COMMENT 'SPU 名字',
`sell_point` varchar(50) NOT NULL DEFAULT '' COMMENT '卖点',
`description` text NOT NULL COMMENT '描述',
`cid` int(11) NOT NULL DEFAULT '-1' COMMENT '分类编号',
`pic_urls` varchar(1024) NOT NULL DEFAULT '' COMMENT '商品主图地址\n *\n * 数组,以逗号分隔\n *\n * 建议尺寸800*800像素你可以拖拽图片调整顺序最多上传15张',
`visible` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否上架商品(是否可见)。\n *\n * true 为已上架\n * false 为已下架',
`sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序字段',
`price` int(11) NOT NULL COMMENT '价格',
`quantity` int(11) NOT NULL COMMENT '库存数量',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=68 DEFAULT CHARSET=utf8mb4 COMMENT='商品 SPU';
-- ----------------------------
-- Table structure for product_sku
-- ----------------------------
CREATE TABLE `product_sku` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'sku 编号',
`spu_id` int(11) NOT NULL DEFAULT '-1' COMMENT '商品编号',
`status` int(11) NOT NULL DEFAULT '-1' COMMENT '状态\n *\n * 1-正常\n * 2-禁用',
`pic_url` varchar(50) DEFAULT '' COMMENT '图片地址',
`attrs` varchar(50) NOT NULL DEFAULT '' COMMENT '规格值({@link ProductAttrDO})数组\n *\n * 数组,以逗号分隔',
`price` int(11) NOT NULL DEFAULT '-1' COMMENT '价格,单位:分',
`quantity` int(11) NOT NULL DEFAULT '-1' COMMENT '库存数量',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=utf8mb4 COMMENT='商品 SKU';
-- ----------------------------
-- Table structure for product_attr_key
-- ----------------------------
CREATE TABLE `product_attr_key` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '规格键编号',
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '规格键名称',
`status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态\n *\n * 1-开启\n * 2-禁用',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COMMENT='商品规格键';
-- ----------------------------
-- Table structure for product_attr_value
-- ----------------------------
CREATE TABLE `product_attr_value` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '规格值编号',
`attr_key_id` int(11) NOT NULL COMMENT '规格键编号',
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '规格值名字',
`status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态\n *\n * 1-开启\n * 2-禁用',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=52 DEFAULT CHARSET=utf8mb4 COMMENT='商品规格值';
-- ----------------------------
-- Table structure for product_category
-- ----------------------------
CREATE TABLE `product_category` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '分类编号',
`pid` int(11) NOT NULL COMMENT '父分类编号',
`name` varchar(16) NOT NULL COMMENT '分类名称',
`description` varchar(255) DEFAULT NULL COMMENT '分类描述',
`pic_url` varchar(255) DEFAULT NULL COMMENT '分类图片',
`sort` int(11) NOT NULL COMMENT '分类排序',
`status` tinyint(4) NOT NULL COMMENT '状态',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=801 DEFAULT CHARSET=utf8mb4 COMMENT='商品分类表';
-- ----------------------------
-- Table structure for product_brand
-- ----------------------------
CREATE TABLE `product_brand` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '品牌编号',
`name` varchar(50) NOT NULL COMMENT '品牌名称',
`description` varchar(255) DEFAULT NULL COMMENT '品牌描述',
`pic_url` varchar(1024) DEFAULT NULL COMMENT '品牌名图片',
`status` tinyint(4) NOT NULL COMMENT '状态 1开启 2禁用',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COMMENT='商品品牌';

View File

@@ -0,0 +1,34 @@
package cn.iocoder.mall.productservice.manager.spu;
import cn.iocoder.mall.productservice.enums.sku.ProductSkuDetailFieldEnum;
import cn.iocoder.mall.productservice.manager.sku.ProductSkuManager;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO;
import cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.Arrays;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
@Slf4j
public class ProductSkuManagerTest {
@Autowired
private ProductSkuManager productSkuManager;
@Test
public void testListProductSkus() {
List<ProductSkuRespDTO> skuRespDTOs = productSkuManager.listProductSkus(
new ProductSkuListQueryReqDTO().setProductSkuIds(Arrays.asList(3, 4))
.setFields(Arrays.asList(ProductSkuDetailFieldEnum.SPU.getField(),
ProductSkuDetailFieldEnum.ATTR.getField())));
log.info("结果:{}", skuRespDTOs);
}
}

View File

@@ -0,0 +1 @@
package cn.iocoder.mall.productservice;