feat: 商品模块重构 - 区分实物/虚拟商品,新增属性管理

- ProductGoodsEntity: 删除price/unit/categoryId,新增type(商品类型)和extra(扩展属性JSON)
- ProductAttributeEntity: 新增属性管理实体(name/type/options/status)
- ProductAttributeMapper/Service/ServiceImpl: 属性CRUD
- AdminProductAttributeController: Admin端属性管理接口
- AppProductAttributeController: App端属性列表接口
This commit is contained in:
OpenCode
2026-07-28 11:36:28 +08:00
parent 7ab1c7590e
commit 24e18d9327
7 changed files with 103 additions and 8 deletions
@@ -0,0 +1,21 @@
package com.cool.modules.product.controller.admin;
import cn.hutool.json.JSONObject;
import com.cool.core.annotation.CoolRestController;
import com.cool.core.base.BaseController;
import com.cool.modules.product.entity.ProductAttributeEntity;
import com.cool.modules.product.service.ProductAttributeService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
@Tag(name = "商品属性管理", description = "商品属性管理")
@CoolRestController(api = {"add", "delete", "update", "page", "info"})
public class AdminProductAttributeController extends BaseController<ProductAttributeService, ProductAttributeEntity> {
@Override
protected void init(HttpServletRequest request, JSONObject requestParams) {
setPageOption(createOp());
}
}
@@ -0,0 +1,26 @@
package com.cool.modules.product.controller.app;
import cn.hutool.json.JSONObject;
import com.cool.core.annotation.CoolRestController;
import com.cool.core.request.R;
import com.cool.modules.product.entity.ProductAttributeEntity;
import com.cool.modules.product.service.ProductAttributeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
@RequiredArgsConstructor
@Tag(name = "商品属性", description = "App端商品属性")
@CoolRestController
public class AppProductAttributeController {
private final ProductAttributeService productAttributeService;
@Operation(summary = "属性列表")
@GetMapping("/list")
public R list(@RequestAttribute JSONObject requestParams) {
return R.ok(productAttributeService.list(requestParams, null));
}
}
@@ -0,0 +1,25 @@
package com.cool.modules.product.entity;
import com.cool.core.base.TenantEntity;
import com.mybatisflex.annotation.Table;
import com.cool.core.annotation.ColumnDefine;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Table(value = "product_attribute", comment = "商品属性表")
public class ProductAttributeEntity extends TenantEntity<ProductAttributeEntity> {
@ColumnDefine(comment = "属性名称", notNull = true)
private String name;
@ColumnDefine(comment = "值类型 0:文本 1:数字 2:选择 3:日期", defaultValue = "0")
private Integer type;
@ColumnDefine(comment = "选项值(type=2时存JSON)", type = "text")
private String options;
@ColumnDefine(comment = "状态 0:禁用 1:启用", defaultValue = "1")
private Integer status;
}
@@ -14,20 +14,17 @@ public class ProductGoodsEntity extends TenantEntity<ProductGoodsEntity> {
@ColumnDefine(comment = "商品名称", notNull = true)
private String name;
@ColumnDefine(comment = "价格")
private Double price;
@ColumnDefine(comment = "单位")
private String unit;
@ColumnDefine(comment = "图片")
private String image;
@ColumnDefine(comment = "描述", type = "text")
private String description;
@ColumnDefine(comment = "分类ID", type = "bigint")
private Long categoryId;
@ColumnDefine(comment = "商品类型 0:实物商品 1:虚拟商品", defaultValue = "0")
private Integer type;
@ColumnDefine(comment = "扩展属性", type = "text")
private String extra;
@ColumnDefine(comment = "状态 0:下架 1:上架", defaultValue = "1")
private Integer status;
@@ -0,0 +1,7 @@
package com.cool.modules.product.mapper;
import com.mybatisflex.core.BaseMapper;
import com.cool.modules.product.entity.ProductAttributeEntity;
public interface ProductAttributeMapper extends BaseMapper<ProductAttributeEntity> {
}
@@ -0,0 +1,7 @@
package com.cool.modules.product.service;
import com.cool.core.base.BaseService;
import com.cool.modules.product.entity.ProductAttributeEntity;
public interface ProductAttributeService extends BaseService<ProductAttributeEntity> {
}
@@ -0,0 +1,12 @@
package com.cool.modules.product.service.impl;
import com.cool.core.base.BaseServiceImpl;
import com.cool.modules.product.entity.ProductAttributeEntity;
import com.cool.modules.product.mapper.ProductAttributeMapper;
import com.cool.modules.product.service.ProductAttributeService;
import org.springframework.stereotype.Service;
@Service
public class ProductAttributeServiceImpl extends BaseServiceImpl<ProductAttributeMapper, ProductAttributeEntity> implements
ProductAttributeService {
}