diff --git a/src/main/java/com/cool/modules/product/controller/admin/AdminProductAttributeController.java b/src/main/java/com/cool/modules/product/controller/admin/AdminProductAttributeController.java new file mode 100644 index 0000000..fbd45be --- /dev/null +++ b/src/main/java/com/cool/modules/product/controller/admin/AdminProductAttributeController.java @@ -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 { + + @Override + protected void init(HttpServletRequest request, JSONObject requestParams) { + setPageOption(createOp()); + } +} diff --git a/src/main/java/com/cool/modules/product/controller/app/AppProductAttributeController.java b/src/main/java/com/cool/modules/product/controller/app/AppProductAttributeController.java new file mode 100644 index 0000000..98e08ca --- /dev/null +++ b/src/main/java/com/cool/modules/product/controller/app/AppProductAttributeController.java @@ -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)); + } +} diff --git a/src/main/java/com/cool/modules/product/entity/ProductAttributeEntity.java b/src/main/java/com/cool/modules/product/entity/ProductAttributeEntity.java new file mode 100644 index 0000000..9cd7818 --- /dev/null +++ b/src/main/java/com/cool/modules/product/entity/ProductAttributeEntity.java @@ -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 { + + @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; +} diff --git a/src/main/java/com/cool/modules/product/entity/ProductGoodsEntity.java b/src/main/java/com/cool/modules/product/entity/ProductGoodsEntity.java index 5f923f0..1db13ea 100644 --- a/src/main/java/com/cool/modules/product/entity/ProductGoodsEntity.java +++ b/src/main/java/com/cool/modules/product/entity/ProductGoodsEntity.java @@ -14,20 +14,17 @@ public class ProductGoodsEntity extends TenantEntity { @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; diff --git a/src/main/java/com/cool/modules/product/mapper/ProductAttributeMapper.java b/src/main/java/com/cool/modules/product/mapper/ProductAttributeMapper.java new file mode 100644 index 0000000..6a14ef4 --- /dev/null +++ b/src/main/java/com/cool/modules/product/mapper/ProductAttributeMapper.java @@ -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 { +} diff --git a/src/main/java/com/cool/modules/product/service/ProductAttributeService.java b/src/main/java/com/cool/modules/product/service/ProductAttributeService.java new file mode 100644 index 0000000..756538e --- /dev/null +++ b/src/main/java/com/cool/modules/product/service/ProductAttributeService.java @@ -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 { +} diff --git a/src/main/java/com/cool/modules/product/service/impl/ProductAttributeServiceImpl.java b/src/main/java/com/cool/modules/product/service/impl/ProductAttributeServiceImpl.java new file mode 100644 index 0000000..9bdf705 --- /dev/null +++ b/src/main/java/com/cool/modules/product/service/impl/ProductAttributeServiceImpl.java @@ -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 implements + ProductAttributeService { +}