diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductCategoryController.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductCategoryController.java index c49f29834..e13957856 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductCategoryController.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductCategoryController.java @@ -8,8 +8,8 @@ import cn.iocoder.mall.product.api.constant.ProductCategoryConstants; import cn.iocoder.mall.product.api.dto.ProductCategoryAddDTO; import cn.iocoder.mall.product.api.dto.ProductCategoryUpdateDTO; import cn.iocoder.mall.product.application.convert.ProductCategoryConvert; -import cn.iocoder.mall.product.application.vo.ProductCategoryTreeNodeVO; -import cn.iocoder.mall.product.application.vo.ProductCategoryVO; +import cn.iocoder.mall.product.application.vo.admins.AdminProductCategoryTreeNodeVO; +import cn.iocoder.mall.product.application.vo.admins.AdminsProductCategoryVO; import com.alibaba.dubbo.config.annotation.Reference; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -33,16 +33,16 @@ public class AdminsProductCategoryController { @GetMapping("/tree") @ApiOperation("获得分类树结构") - public CommonResult> tree() { + public CommonResult> tree() { List productCategories = productCategoryService.getAll().getData(); // 创建 ProductCategoryTreeNodeVO Map - Map treeNodeMap = productCategories.stream().collect(Collectors.toMap(ProductCategoryBO::getId, ProductCategoryConvert.INSTANCE::convert)); + Map treeNodeMap = productCategories.stream().collect(Collectors.toMap(ProductCategoryBO::getId, ProductCategoryConvert.INSTANCE::convert)); // 处理父子关系 treeNodeMap.values().stream() .filter(node -> !node.getPid().equals(ProductCategoryConstants.PID_ROOT)) .forEach((childNode) -> { // 获得父节点 - ProductCategoryTreeNodeVO parentNode = treeNodeMap.get(childNode.getPid()); + AdminProductCategoryTreeNodeVO parentNode = treeNodeMap.get(childNode.getPid()); if (parentNode.getChildren() == null) { // 初始化 children 数组 parentNode.setChildren(new ArrayList<>()); } @@ -50,9 +50,9 @@ public class AdminsProductCategoryController { parentNode.getChildren().add(childNode); }); // 获得到所有的根节点 - List rootNodes = treeNodeMap.values().stream() + List rootNodes = treeNodeMap.values().stream() .filter(node -> node.getPid().equals(ProductCategoryConstants.PID_ROOT)) - .sorted(Comparator.comparing(ProductCategoryTreeNodeVO::getSort)) + .sorted(Comparator.comparing(AdminProductCategoryTreeNodeVO::getSort)) .collect(Collectors.toList()); return CommonResult.success(rootNodes); } @@ -66,11 +66,11 @@ public class AdminsProductCategoryController { @ApiImplicitParam(name = "picUrl", value = "分类图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg/"), @ApiImplicitParam(name = "sort", value = "排序", required = true, example = "1"), }) - public CommonResult add(@RequestParam("pid") Integer pid, - @RequestParam("name") String name, - @RequestParam("description") String description, - @RequestParam(value = "picUrl", required = false) String picUrl, - @RequestParam("sort") Integer sort) { + public CommonResult add(@RequestParam("pid") Integer pid, + @RequestParam("name") String name, + @RequestParam("description") String description, + @RequestParam(value = "picUrl", required = false) String picUrl, + @RequestParam("sort") Integer sort) { // 创建 ProductCategoryAddDTO 对象 ProductCategoryAddDTO productCategoryAddDTO = new ProductCategoryAddDTO().setPid(pid).setName(name) .setDescription(description).setPicUrl(picUrl).setSort(sort); diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductSpuController.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductSpuController.java new file mode 100644 index 000000000..4308f0698 --- /dev/null +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/admins/AdminsProductSpuController.java @@ -0,0 +1,101 @@ +package cn.iocoder.mall.product.application.controller.admins; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder; +import cn.iocoder.mall.product.api.ProductSpuService; +import cn.iocoder.mall.product.api.bo.ProductSpuDetailBO; +import cn.iocoder.mall.product.api.dto.ProductSkuAddDTO; +import cn.iocoder.mall.product.api.dto.ProductSkuUpdateDTO; +import cn.iocoder.mall.product.api.dto.ProductSpuAddDTO; +import cn.iocoder.mall.product.api.dto.ProductSpuUpdateDTO; +import cn.iocoder.mall.product.application.convert.ProductSpuConvert; +import cn.iocoder.mall.product.application.vo.admins.AdminsProductSpuDetailVO; +import cn.iocoder.mall.product.application.vo.admins.AdminsProductSpuPageVO; +import com.alibaba.dubbo.config.annotation.Reference; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +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.io.IOException; +import java.util.List; + +@RestController +@RequestMapping("admins") +@Api("商品 SPU + SKU") +public class AdminsProductSpuController { + + @Reference(validation = "true") + private ProductSpuService productSpuService; + + @Autowired + private ObjectMapper objectMapper; // jackson 解析 + + @PostMapping("/spu/add") + @ApiOperation("创建商品") + public CommonResult add(@RequestParam("name") String name, + @RequestParam("sellPoint") String sellPoint, + @RequestParam("description") String description, + @RequestParam("cid") Integer cid, + @RequestParam("picURLs") List picUrls, + @RequestParam("visible") Boolean visible, + @RequestParam("skuStr") String skuStr) { // TODO 芋艿,因为考虑不使用 json 接受参数,所以这里手动转。 + // 创建 ProductSpuAddDTO 对象 + ProductSpuAddDTO productSpuAddDTO = new ProductSpuAddDTO().setName(name).setSellPoint(sellPoint) + .setDescription(description).setCid(cid).setPicUrls(picUrls).setVisible(visible) + .setSkus(parseSkus(skuStr, ProductSkuAddDTO.class)); + // 保存商品 + CommonResult result = productSpuService.addProductSpu(AdminSecurityContextHolder.getContext().getAdminId(), productSpuAddDTO); + // 返回结果 + return ProductSpuConvert.INSTANCE.convert(result); + } + + @PostMapping("/spu/update") + @ApiOperation("更新商品") + public CommonResult update(@RequestParam("id") Integer id, + @RequestParam("name") String name, + @RequestParam("sellPoint") String sellPoint, + @RequestParam("description") String description, + @RequestParam("cid") Integer cid, + @RequestParam("picURLs") List picUrls, + @RequestParam("visible") Boolean visible, + @RequestParam("skuStr") String skuStr) { // TODO 芋艿,因为考虑不使用 json 接受参数,所以这里手动转。 + // 创建 ProductSpuUpdateDTO 对象 + ProductSpuUpdateDTO productSpuUpdateDTO = new ProductSpuUpdateDTO().setId(id).setName(name).setSellPoint(sellPoint) + .setDescription(description).setCid(cid).setPicUrls(picUrls).setVisible(visible) + .setSkus(parseSkus(skuStr, ProductSkuUpdateDTO.class)); + // 更新商品 + return productSpuService.updateProductSpu(AdminSecurityContextHolder.getContext().getAdminId(), productSpuUpdateDTO); + } + + @PostMapping("/spu/update_sort") + @ApiOperation("更新商品的排序") + public CommonResult updateSort(@RequestParam("id") Integer id, + @RequestParam("sort") Integer sort) { + return null; + } + + @GetMapping("/spu/page") + @ApiOperation("商品 SPU 分页列表") + public CommonResult spuPage() { + return null; + } + + @GetMapping("/spu/info") + @ApiOperation("商品 SPU 明细") + public CommonResult info() { + return null; + } + + private List parseSkus(String skuStr, Class clazz) { + JavaType type = objectMapper.getTypeFactory().constructParametricType(List.class, clazz); + try { + return objectMapper.readValue(skuStr, type); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + +} \ No newline at end of file diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/ProductCategoryController.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/ProductCategoryController.java index b7857d249..b925258d6 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/ProductCategoryController.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/controller/users/ProductCategoryController.java @@ -3,7 +3,7 @@ package cn.iocoder.mall.product.application.controller.users; import cn.iocoder.mall.product.api.ProductCategoryService; import cn.iocoder.mall.product.api.bo.ProductCategoryBO; import cn.iocoder.mall.product.application.convert.ProductCategoryConvert; -import cn.iocoder.mall.product.application.vo.ProductCategorySimpleVO; +import cn.iocoder.mall.product.application.vo.users.UsersProductCategoryVO; import com.alibaba.dubbo.config.annotation.Reference; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -26,7 +26,7 @@ public class ProductCategoryController { @GetMapping @ApiOperation("获得指定编号下的子分类的数组") @ApiImplicitParam(name = "pid", value = "指定分类编号", required = true, example = "0") - public List list(@RequestParam("pid") Integer pid) { + public List list(@RequestParam("pid") Integer pid) { List result = productCategoryService.getListByPid(pid); return ProductCategoryConvert.INSTANCE.convertToVO(result); } diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductCategoryConvert.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductCategoryConvert.java index 5c6efb1b8..f0602a9f9 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductCategoryConvert.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductCategoryConvert.java @@ -2,9 +2,9 @@ package cn.iocoder.mall.product.application.convert; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.product.api.bo.ProductCategoryBO; -import cn.iocoder.mall.product.application.vo.ProductCategorySimpleVO; -import cn.iocoder.mall.product.application.vo.ProductCategoryTreeNodeVO; -import cn.iocoder.mall.product.application.vo.ProductCategoryVO; +import cn.iocoder.mall.product.application.vo.users.UsersProductCategoryVO; +import cn.iocoder.mall.product.application.vo.admins.AdminProductCategoryTreeNodeVO; +import cn.iocoder.mall.product.application.vo.admins.AdminsProductCategoryVO; import org.mapstruct.Mapper; import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; @@ -17,12 +17,12 @@ public interface ProductCategoryConvert { ProductCategoryConvert INSTANCE = Mappers.getMapper(ProductCategoryConvert.class); @Mappings({}) - ProductCategorySimpleVO convertToVO(ProductCategoryBO category); + UsersProductCategoryVO convertToVO(ProductCategoryBO category); - List convertToVO(List categoryList); + List convertToVO(List categoryList); - ProductCategoryTreeNodeVO convert(ProductCategoryBO category); + AdminProductCategoryTreeNodeVO convert(ProductCategoryBO category); - CommonResult convert(CommonResult result); + CommonResult convert(CommonResult result); } \ No newline at end of file diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductSpuConvert.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductSpuConvert.java new file mode 100644 index 000000000..d734a1aa3 --- /dev/null +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/convert/ProductSpuConvert.java @@ -0,0 +1,21 @@ +package cn.iocoder.mall.product.application.convert; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.product.api.bo.ProductSpuDetailBO; +import cn.iocoder.mall.product.application.vo.admins.AdminsProductSpuDetailVO; +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface ProductSpuConvert { + + ProductSpuConvert INSTANCE = Mappers.getMapper(ProductSpuConvert.class); + + @Mappings({}) + AdminsProductSpuDetailVO convert(ProductSpuDetailBO productSpuDetailBO); + + @Mappings({}) + CommonResult convert(CommonResult result); + +} \ No newline at end of file diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductCategoryTreeNodeVO.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminProductCategoryTreeNodeVO.java similarity index 72% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductCategoryTreeNodeVO.java rename to product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminProductCategoryTreeNodeVO.java index 4cbeb167a..15807ae1f 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductCategoryTreeNodeVO.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminProductCategoryTreeNodeVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.product.application.vo; +package cn.iocoder.mall.product.application.vo.admins; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -7,7 +7,7 @@ import java.util.Date; import java.util.List; @ApiModel("产品分类树节点 VO") -public class ProductCategoryTreeNodeVO { +public class AdminProductCategoryTreeNodeVO { @ApiModelProperty(value = "分类编号", required = true, example = "1") private Integer id; @@ -26,13 +26,13 @@ public class ProductCategoryTreeNodeVO { @ApiModelProperty(value = "创建时间", required = true, example = "时间戳") private Date createTime; @ApiModelProperty(value = "子节点数组") - private List children; + private List children; public Integer getId() { return id; } - public ProductCategoryTreeNodeVO setId(Integer id) { + public AdminProductCategoryTreeNodeVO setId(Integer id) { this.id = id; return this; } @@ -41,7 +41,7 @@ public class ProductCategoryTreeNodeVO { return pid; } - public ProductCategoryTreeNodeVO setPid(Integer pid) { + public AdminProductCategoryTreeNodeVO setPid(Integer pid) { this.pid = pid; return this; } @@ -50,7 +50,7 @@ public class ProductCategoryTreeNodeVO { return name; } - public ProductCategoryTreeNodeVO setName(String name) { + public AdminProductCategoryTreeNodeVO setName(String name) { this.name = name; return this; } @@ -59,7 +59,7 @@ public class ProductCategoryTreeNodeVO { return description; } - public ProductCategoryTreeNodeVO setDescription(String description) { + public AdminProductCategoryTreeNodeVO setDescription(String description) { this.description = description; return this; } @@ -68,7 +68,7 @@ public class ProductCategoryTreeNodeVO { return picUrl; } - public ProductCategoryTreeNodeVO setPicUrl(String picUrl) { + public AdminProductCategoryTreeNodeVO setPicUrl(String picUrl) { this.picUrl = picUrl; return this; } @@ -77,7 +77,7 @@ public class ProductCategoryTreeNodeVO { return sort; } - public ProductCategoryTreeNodeVO setSort(Integer sort) { + public AdminProductCategoryTreeNodeVO setSort(Integer sort) { this.sort = sort; return this; } @@ -86,7 +86,7 @@ public class ProductCategoryTreeNodeVO { return status; } - public ProductCategoryTreeNodeVO setStatus(Integer status) { + public AdminProductCategoryTreeNodeVO setStatus(Integer status) { this.status = status; return this; } @@ -95,16 +95,16 @@ public class ProductCategoryTreeNodeVO { return createTime; } - public ProductCategoryTreeNodeVO setCreateTime(Date createTime) { + public AdminProductCategoryTreeNodeVO setCreateTime(Date createTime) { this.createTime = createTime; return this; } - public List getChildren() { + public List getChildren() { return children; } - public ProductCategoryTreeNodeVO setChildren(List children) { + public AdminProductCategoryTreeNodeVO setChildren(List children) { this.children = children; return this; } diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductCategoryVO.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductCategoryVO.java similarity index 78% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductCategoryVO.java rename to product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductCategoryVO.java index b848a5ec7..4a309b383 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductCategoryVO.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductCategoryVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.product.application.vo; +package cn.iocoder.mall.product.application.vo.admins; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -6,7 +6,7 @@ import io.swagger.annotations.ApiModelProperty; import java.util.Date; @ApiModel("产品分类 VO") -public class ProductCategoryVO { +public class AdminsProductCategoryVO { @ApiModelProperty(value = "分类编号", required = true, example = "1") private Integer id; @@ -29,7 +29,7 @@ public class ProductCategoryVO { return id; } - public ProductCategoryVO setId(Integer id) { + public AdminsProductCategoryVO setId(Integer id) { this.id = id; return this; } @@ -38,7 +38,7 @@ public class ProductCategoryVO { return pid; } - public ProductCategoryVO setPid(Integer pid) { + public AdminsProductCategoryVO setPid(Integer pid) { this.pid = pid; return this; } @@ -47,7 +47,7 @@ public class ProductCategoryVO { return name; } - public ProductCategoryVO setName(String name) { + public AdminsProductCategoryVO setName(String name) { this.name = name; return this; } @@ -56,7 +56,7 @@ public class ProductCategoryVO { return description; } - public ProductCategoryVO setDescription(String description) { + public AdminsProductCategoryVO setDescription(String description) { this.description = description; return this; } @@ -65,7 +65,7 @@ public class ProductCategoryVO { return picUrl; } - public ProductCategoryVO setPicUrl(String picUrl) { + public AdminsProductCategoryVO setPicUrl(String picUrl) { this.picUrl = picUrl; return this; } @@ -74,7 +74,7 @@ public class ProductCategoryVO { return sort; } - public ProductCategoryVO setSort(Integer sort) { + public AdminsProductCategoryVO setSort(Integer sort) { this.sort = sort; return this; } @@ -83,7 +83,7 @@ public class ProductCategoryVO { return status; } - public ProductCategoryVO setStatus(Integer status) { + public AdminsProductCategoryVO setStatus(Integer status) { this.status = status; return this; } @@ -92,7 +92,7 @@ public class ProductCategoryVO { return createTime; } - public ProductCategoryVO setCreateTime(Date createTime) { + public AdminsProductCategoryVO setCreateTime(Date createTime) { this.createTime = createTime; return this; } diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuDetailVO.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuDetailVO.java new file mode 100644 index 000000000..aebbbcc23 --- /dev/null +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuDetailVO.java @@ -0,0 +1,10 @@ +package cn.iocoder.mall.product.application.vo.admins; + +import io.swagger.annotations.ApiModel; + +@ApiModel(value = "商品 SPU 详细 VO", description = "包括 SKU 信息 VO") +public class AdminsProductSpuDetailVO { + + + +} diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuPageVO.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuPageVO.java new file mode 100644 index 000000000..0f9569375 --- /dev/null +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuPageVO.java @@ -0,0 +1,37 @@ +package cn.iocoder.mall.product.application.vo.admins; + +import io.swagger.annotations.ApiModel; + +import java.util.List; + +@ApiModel("商品 SPU 分页 VO") +public class AdminsProductSpuPageVO { + + /** + * spu 数组 + */ + private List spus; + /** + * 总数 + */ + private Integer count; + + public List getSpus() { + return spus; + } + + public AdminsProductSpuPageVO setSpus(List spus) { + this.spus = spus; + return this; + } + + public Integer getCount() { + return count; + } + + public AdminsProductSpuPageVO setCount(Integer count) { + this.count = count; + return this; + } + +} \ No newline at end of file diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuVO.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuVO.java new file mode 100644 index 000000000..b36f6b789 --- /dev/null +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/admins/AdminsProductSpuVO.java @@ -0,0 +1,10 @@ +package cn.iocoder.mall.product.application.vo.admins; + +import io.swagger.annotations.ApiModel; + +@ApiModel(value = "商品 SPU VO", description = "不包括 SKU 信息 VO") +public class AdminsProductSpuVO { + + + +} \ No newline at end of file diff --git a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductCategorySimpleVO.java b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductCategoryVO.java similarity index 90% rename from product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductCategorySimpleVO.java rename to product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductCategoryVO.java index 49d4cf801..d32304b64 100644 --- a/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/ProductCategorySimpleVO.java +++ b/product/product-application/src/main/java/cn/iocoder/mall/product/application/vo/users/UsersProductCategoryVO.java @@ -1,10 +1,10 @@ -package cn.iocoder.mall.product.application.vo; +package cn.iocoder.mall.product.application.vo.users; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @ApiModel("商品分类(简单)") -public class ProductCategorySimpleVO { +public class UsersProductCategoryVO { @ApiModelProperty(value = "分类编号", required = true, example = "1") private Integer id; diff --git a/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/ProductSpuService.java b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/ProductSpuService.java index b2fc9aa43..047c3b788 100644 --- a/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/ProductSpuService.java +++ b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/ProductSpuService.java @@ -1,9 +1,17 @@ package cn.iocoder.mall.product.api; +import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.product.api.bo.ProductSpuBO; +import cn.iocoder.mall.product.api.bo.ProductSpuDetailBO; +import cn.iocoder.mall.product.api.dto.ProductSpuAddDTO; +import cn.iocoder.mall.product.api.dto.ProductSpuUpdateDTO; public interface ProductSpuService { ProductSpuBO getProductSpu(Integer id); + CommonResult addProductSpu(Integer adminId, ProductSpuAddDTO productSpuAddDTO); + + CommonResult updateProductSpu(Integer adminId, ProductSpuUpdateDTO productSpuUpdateDTO); + } diff --git a/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductAttrBO.java b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductAttrBO.java new file mode 100644 index 000000000..766c44006 --- /dev/null +++ b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductAttrBO.java @@ -0,0 +1,61 @@ +package cn.iocoder.mall.product.api.bo; + +/** + * 商品规格 BO + */ +public class ProductAttrBO { + + /** + * 规格编号 + */ + private Integer attrId; + /** + * 规格名 + */ + private String attrName; + /** + * 规格值 + */ + private Integer attrValueId; + /** + * 规格值名 + */ + private String attrValueName; + + public Integer getAttrId() { + return attrId; + } + + public ProductAttrBO setAttrId(Integer attrId) { + this.attrId = attrId; + return this; + } + + public String getAttrName() { + return attrName; + } + + public ProductAttrBO setAttrName(String attrName) { + this.attrName = attrName; + return this; + } + + public Integer getAttrValueId() { + return attrValueId; + } + + public ProductAttrBO setAttrValueId(Integer attrValueId) { + this.attrValueId = attrValueId; + return this; + } + + public String getAttrValueName() { + return attrValueName; + } + + public ProductAttrBO setAttrValueName(String attrValueName) { + this.attrValueName = attrValueName; + return this; + } + +} \ No newline at end of file diff --git a/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductSkuDetailBO.java b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductSkuDetailBO.java new file mode 100644 index 000000000..806320c2c --- /dev/null +++ b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductSkuDetailBO.java @@ -0,0 +1,45 @@ +package cn.iocoder.mall.product.api.bo; + +import java.util.List; + +/** + * 商品 Sku 明细 BO + */ +public class ProductSkuDetailBO { + + /** + * sku 编号 + */ + private Integer id; + /** + * 商品编号 + */ + private Integer itemId; + + // TODO 店铺编号 + + /** + * 状态 + * + * 1-正常 + * 2-禁用 + */ + private Integer status; + /** + * 图片地址 + */ + private String picURL; + /** + * 规格值数组 + */ + private List attrs; + /** + * 价格,单位:分 + */ + private Integer price; + /** + * 库存数量 + */ + private Integer quantity; + +} \ No newline at end of file diff --git a/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductSpuDetailBO.java b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductSpuDetailBO.java new file mode 100644 index 000000000..22631318d --- /dev/null +++ b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/bo/ProductSpuDetailBO.java @@ -0,0 +1,65 @@ +package cn.iocoder.mall.product.api.bo; + +import cn.iocoder.mall.product.api.dto.ProductSkuAddDTO; + +import java.util.List; + +/** + * 商品 Spu 明细 BO(包括 Sku 明细) + */ +public class ProductSpuDetailBO { + + /** + * SPU 编号 + */ + private Integer id; + + // ========== 基本信息 ========= + /** + * SPU 名字 + */ + private String name; + /** + * 卖点 + */ + private String sellPoint; + /** + * 描述 + */ + private String description; + /** + * 分类编号 + */ + private Integer cid; + /** + * 商品主图地址 + * + * 数组,以逗号分隔 + * + * 建议尺寸:800*800像素,你可以拖拽图片调整顺序,最多上传15张 + */ + private List picUrls; + + // ========== 其他信息 ========= + /** + * 是否上架商品(是否可见)。 + * + * true 为已上架 + * false 为已下架 + */ + private Boolean visible; + /** + * 排序字段 + */ + private Integer order; + + // + + // ========== SKU ========= + + /** + * SKU 数组 + */ + private List skus; + +} \ No newline at end of file diff --git a/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/dto/ProductSkuAddDTO.java b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/dto/ProductSkuAddDTO.java new file mode 100644 index 000000000..d3986ccac --- /dev/null +++ b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/dto/ProductSkuAddDTO.java @@ -0,0 +1,50 @@ +package cn.iocoder.mall.product.api.dto; + +import java.util.List; + +/** + * 商品 Sku 添加 DTO + */ +public class ProductSkuAddDTO { + + /** + * 规格值数组 + */ + private List attrs; + /** + * 价格,单位:分 + */ + private Integer price; + /** + * 库存数量 + */ + private Integer quantity; + + public List getAttrs() { + return attrs; + } + + public ProductSkuAddDTO setAttrs(List attrs) { + this.attrs = attrs; + return this; + } + + public Integer getPrice() { + return price; + } + + public ProductSkuAddDTO setPrice(Integer price) { + this.price = price; + return this; + } + + public Integer getQuantity() { + return quantity; + } + + public ProductSkuAddDTO setQuantity(Integer quantity) { + this.quantity = quantity; + return this; + } + +} \ No newline at end of file diff --git a/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/dto/ProductSkuUpdateDTO.java b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/dto/ProductSkuUpdateDTO.java new file mode 100644 index 000000000..f11ad3707 --- /dev/null +++ b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/dto/ProductSkuUpdateDTO.java @@ -0,0 +1,50 @@ +package cn.iocoder.mall.product.api.dto; + +import java.util.List; + +/** + * 商品 Sku 更新 DTO + */ +public class ProductSkuUpdateDTO { + + /** + * 规格值数组 + */ + private List attrs; + /** + * 价格,单位:分 + */ + private Integer price; + /** + * 库存数量 + */ + private Integer quantity; + + public List getAttrs() { + return attrs; + } + + public ProductSkuUpdateDTO setAttrs(List attrs) { + this.attrs = attrs; + return this; + } + + public Integer getPrice() { + return price; + } + + public ProductSkuUpdateDTO setPrice(Integer price) { + this.price = price; + return this; + } + + public Integer getQuantity() { + return quantity; + } + + public ProductSkuUpdateDTO setQuantity(Integer quantity) { + this.quantity = quantity; + return this; + } + +} \ No newline at end of file diff --git a/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/dto/ProductSpuAddDTO.java b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/dto/ProductSpuAddDTO.java new file mode 100644 index 000000000..a2e25fc22 --- /dev/null +++ b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/dto/ProductSpuAddDTO.java @@ -0,0 +1,120 @@ +package cn.iocoder.mall.product.api.dto; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * 商品 SPU + SKU 添加 DTO + */ +public class ProductSpuAddDTO { + + // ========== 基本信息 ========= + /** + * SPU 名字 + */ + @NotEmpty(message = "SPU 名字不能为空") + private String name; + /** + * 卖点 + */ + @NotEmpty(message = "卖点不能为空") + private String sellPoint; + /** + * 描述 + */ + @NotEmpty(message = "描述不能为空") + private String description; + /** + * 分类编号 + */ + @NotEmpty(message = "分类不能为空") + private Integer cid; + /** + * 商品主图地址 + */ + @NotNull(message = "商品主图不能为空") + private List picUrls; + + // ========== 其他信息 ========= + /** + * 是否上架商品(是否可见)。 + * + * true 为已上架 + * false 为已下架 + */ + @NotNull(message = "是否上架不能为空") + private Boolean visible; + + // ========== SKU ========= + + /** + * SKU 数组 + */ + @NotNull(message = "SKU 不能为空") + private List skus; + + public String getName() { + return name; + } + + public ProductSpuAddDTO setName(String name) { + this.name = name; + return this; + } + + public String getSellPoint() { + return sellPoint; + } + + public ProductSpuAddDTO setSellPoint(String sellPoint) { + this.sellPoint = sellPoint; + return this; + } + + public String getDescription() { + return description; + } + + public ProductSpuAddDTO setDescription(String description) { + this.description = description; + return this; + } + + public Integer getCid() { + return cid; + } + + public ProductSpuAddDTO setCid(Integer cid) { + this.cid = cid; + return this; + } + + public List getPicUrls() { + return picUrls; + } + + public ProductSpuAddDTO setPicUrls(List picUrls) { + this.picUrls = picUrls; + return this; + } + + public Boolean getVisible() { + return visible; + } + + public ProductSpuAddDTO setVisible(Boolean visible) { + this.visible = visible; + return this; + } + + public List getSkus() { + return skus; + } + + public ProductSpuAddDTO setSkus(List skus) { + this.skus = skus; + return this; + } + +} \ No newline at end of file diff --git a/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/dto/ProductSpuUpdateDTO.java b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/dto/ProductSpuUpdateDTO.java new file mode 100644 index 000000000..07566ae2d --- /dev/null +++ b/product/product-service-api/src/main/java/cn/iocoder/mall/product/api/dto/ProductSpuUpdateDTO.java @@ -0,0 +1,134 @@ +package cn.iocoder.mall.product.api.dto; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * 商品 SPU + SKU 更新 DTO + */ +public class ProductSpuUpdateDTO { + + /** + * Spu 编号 + */ + @NotNull(message = "SPU 编号不能为空") + private Integer id; + + // ========== 基本信息 ========= + /** + * SPU 名字 + */ + @NotEmpty(message = "SPU 名字不能为空") + private String name; + /** + * 卖点 + */ + @NotEmpty(message = "卖点不能为空") + private String sellPoint; + /** + * 描述 + */ + @NotEmpty(message = "描述不能为空") + private String description; + /** + * 分类编号 + */ + @NotEmpty(message = "分类不能为空") + private Integer cid; + /** + * 商品主图地址 + */ + @NotNull(message = "商品主图不能为空") + private List picUrls; + + // ========== 其他信息 ========= + /** + * 是否上架商品(是否可见)。 + * + * true 为已上架 + * false 为已下架 + */ + @NotNull(message = "是否上架不能为空") + private Boolean visible; + + // ========== SKU ========= + + /** + * SKU 数组 + */ + @NotNull(message = "SKU 不能为空") + private List skus; + + public String getName() { + return name; + } + + public ProductSpuUpdateDTO setName(String name) { + this.name = name; + return this; + } + + public String getSellPoint() { + return sellPoint; + } + + public ProductSpuUpdateDTO setSellPoint(String sellPoint) { + this.sellPoint = sellPoint; + return this; + } + + public String getDescription() { + return description; + } + + public ProductSpuUpdateDTO setDescription(String description) { + this.description = description; + return this; + } + + public Integer getCid() { + return cid; + } + + public ProductSpuUpdateDTO setCid(Integer cid) { + this.cid = cid; + return this; + } + + public List getPicUrls() { + return picUrls; + } + + public ProductSpuUpdateDTO setPicUrls(List picUrls) { + this.picUrls = picUrls; + return this; + } + + public Boolean getVisible() { + return visible; + } + + public ProductSpuUpdateDTO setVisible(Boolean visible) { + this.visible = visible; + return this; + } + + public List getSkus() { + return skus; + } + + public ProductSpuUpdateDTO setSkus(List skus) { + this.skus = skus; + return this; + } + + public Integer getId() { + return id; + } + + public ProductSpuUpdateDTO setId(Integer id) { + this.id = id; + return this; + } +} \ No newline at end of file diff --git a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSkuDO.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSkuDO.java index 737c0eaf6..a3f3b4f09 100644 --- a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSkuDO.java +++ b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSkuDO.java @@ -1,11 +1,11 @@ package cn.iocoder.mall.product.dataobject; -import java.util.Date; +import cn.iocoder.common.framework.dataobject.BaseDO; /** * 商品 SKU */ -public class ProductSkuDO { +public class ProductSkuDO extends BaseDO { /** * sku 编号 @@ -22,7 +22,7 @@ public class ProductSkuDO { * 状态 * * 1-正常 - * 2-删除 + * 2-禁用 */ private Integer status; /** @@ -36,24 +36,20 @@ public class ProductSkuDO { */ private String attrs; /** - * 价格,单位分 + * 价格,单位:分 */ private Integer price; /** - * 商品在付款减库存的状态下,该Sku上未付款的订单数量 + * 库存数量 */ - private Integer withHoldQuantity; - /** - * 销量 - */ - private Integer soldNum; - /** - * 创建时间 - */ - private Date createTime; - /** - * 更新时间 - */ - private Date updateTime; + private Integer quantity; + // /** +// * 商品在付款减库存的状态下,该Sku上未付款的订单数量 +// */ +// private Integer withHoldQuantity; +// /** +// * 销量 +// */ +// private Integer soldNum; } \ No newline at end of file diff --git a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSpuDO.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSpuDO.java index f406b7f8b..621baaf59 100644 --- a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSpuDO.java +++ b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductSpuDO.java @@ -1,36 +1,18 @@ package cn.iocoder.mall.product.dataobject; -import java.util.Date; +import cn.iocoder.common.framework.dataobject.BaseDO; /** * 商品 SPU */ -public class ProductSpuDO { - - // ========== 基础字段 ========= +public class ProductSpuDO extends BaseDO { /** * SPU 编号 */ private Integer id; - // TODO 店铺编号 - - /** - * 创建时间 - */ - private Date createTime; - /** - * 最后更新时间 - */ - private Date updateTime; - /** - * 状态 - * - * 1-正常 - * 2-删除 - */ - private Integer status; + // TODO 店铺编号 先不考虑,因为第一个版本,不做 B2B2C // ========== 基本信息 ========= /** @@ -38,9 +20,13 @@ public class ProductSpuDO { */ private String name; /** - * SPU 描述 + * 卖点 */ - private String descrption; + private String sellPoint; + /** + * 描述 + */ + private String description; /** * 分类编号 */ @@ -52,7 +38,7 @@ public class ProductSpuDO { * * 建议尺寸:800*800像素,你可以拖拽图片调整顺序,最多上传15张 */ - private String picURLs; + private String picUrls; // TODO 价格库存 @@ -79,4 +65,66 @@ public class ProductSpuDO { this.id = id; } + public String getName() { + return name; + } + + public ProductSpuDO setName(String name) { + this.name = name; + return this; + } + + public String getSellPoint() { + return sellPoint; + } + + public ProductSpuDO setSellPoint(String sellPoint) { + this.sellPoint = sellPoint; + return this; + } + + public String getDescription() { + return description; + } + + public ProductSpuDO setDescription(String description) { + this.description = description; + return this; + } + + public Integer getCid() { + return cid; + } + + public ProductSpuDO setCid(Integer cid) { + this.cid = cid; + return this; + } + + public String getPicUrls() { + return picUrls; + } + + public ProductSpuDO setPicUrls(String picUrls) { + this.picUrls = picUrls; + return this; + } + + public Boolean getVisible() { + return visible; + } + + public ProductSpuDO setVisible(Boolean visible) { + this.visible = visible; + return this; + } + + public Integer getOrder() { + return order; + } + + public ProductSpuDO setOrder(Integer order) { + this.order = order; + return this; + } } \ No newline at end of file diff --git a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductStockDO.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductStockDO.java index ff1e814ae..21043fcaa 100644 --- a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductStockDO.java +++ b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/dataobject/ProductStockDO.java @@ -5,6 +5,7 @@ import java.util.Date; /** * Product 库存 */ +@Deprecated // TODO 芋艿,咱暂时不加库存表和库存服务 public class ProductStockDO { /** diff --git a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductSpuServiceImpl.java b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductSpuServiceImpl.java index 3cc508617..21ec281a3 100644 --- a/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductSpuServiceImpl.java +++ b/product/product-service-impl/src/main/java/cn/iocoder/mall/product/service/ProductSpuServiceImpl.java @@ -1,7 +1,11 @@ package cn.iocoder.mall.product.service; +import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.product.api.ProductSpuService; import cn.iocoder.mall.product.api.bo.ProductSpuBO; +import cn.iocoder.mall.product.api.bo.ProductSpuDetailBO; +import cn.iocoder.mall.product.api.dto.ProductSpuAddDTO; +import cn.iocoder.mall.product.api.dto.ProductSpuUpdateDTO; import cn.iocoder.mall.product.convert.ProductSpuConvert; import cn.iocoder.mall.product.dao.ProductSpuMapper; import cn.iocoder.mall.product.dataobject.ProductSpuDO; @@ -22,4 +26,14 @@ public class ProductSpuServiceImpl implements ProductSpuService { return ProductSpuConvert.INSTANCE.convert(productSpuDO); } + @Override + public CommonResult addProductSpu(Integer adminId, ProductSpuAddDTO productSpuAddDTO) { + return null; + } + + @Override + public CommonResult updateProductSpu(Integer adminId, ProductSpuUpdateDTO productSpuUpdateDTO) { + return null; + } + } \ No newline at end of file