mirror of
https://ids-dev.idsbuybuybuy.com/ids-ecommerce/ids-svc-product.git
synced 2026-11-29 16:57:41 +08:00
feat: 统一商品、客户、活动页、商品分类页的状态与类型为数据库数值
This commit is contained in:
parent
d75d6e2112
commit
9e9c66fc42
@ -480,7 +480,7 @@ func (r *ProductRepository) UpdateCategoryTrees(ctx context.Context, updates []C
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if root.NodeType != 0 || root.Level != 1 || root.ParentID != "" {
|
||||
if root.NodeType != 1 || root.Level != 1 || root.ParentID != "" {
|
||||
return ErrCategoryTreeConflict
|
||||
}
|
||||
if tree.Category != nil {
|
||||
@ -496,7 +496,7 @@ func (r *ProductRepository) UpdateCategoryTrees(ctx context.Context, updates []C
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if current.NodeType != 0 || current.Level != 2 || current.ParentID != tree.CategoryID {
|
||||
if current.NodeType != 1 || current.Level != 2 || current.ParentID != tree.CategoryID {
|
||||
return ErrCategoryTreeConflict
|
||||
}
|
||||
if _, err := updateCategoryFields(ctx, tx, child); err != nil {
|
||||
@ -1652,7 +1652,7 @@ SELECT id,
|
||||
status,
|
||||
version
|
||||
FROM product.product_category
|
||||
WHERE node_type = 0
|
||||
WHERE node_type = 1
|
||||
AND ($1 = false OR status = 1)
|
||||
ORDER BY level ASC, sort_num ASC, id ASC
|
||||
`, onlyVisible)
|
||||
@ -1689,7 +1689,7 @@ SELECT id,
|
||||
status,
|
||||
version
|
||||
FROM product.product_category
|
||||
WHERE node_type = 1
|
||||
WHERE node_type = 2
|
||||
AND ($1 = false OR status = 1)
|
||||
ORDER BY sort_num ASC, id ASC
|
||||
`, onlyVisible)
|
||||
@ -2625,7 +2625,7 @@ func statusFromDB(status int16) productv1.ProductStatus {
|
||||
case 3:
|
||||
return productv1.ProductStatus_PRODUCT_STATUS_OFF_SALE
|
||||
default:
|
||||
return productv1.ProductStatus_PRODUCT_STATUS_UNSPECIFIED
|
||||
return productv1.ProductStatus_PRODUCT_STATUS_NOT_FOUND
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -32,8 +32,8 @@ const (
|
||||
defaultPageSize = int32(20)
|
||||
maxPageSize = int32(100)
|
||||
|
||||
categoryNodeType = int32(0)
|
||||
groupNodeType = int32(1)
|
||||
categoryNodeType = int32(1)
|
||||
groupNodeType = int32(2)
|
||||
|
||||
defaultNodeStatus = int32(1)
|
||||
maxNodeNameLength = 100
|
||||
@ -991,9 +991,6 @@ func productFromCreateRequest(req *productv1.CreateProductRequest) (repository.P
|
||||
}
|
||||
|
||||
statusValue := req.GetStatus()
|
||||
if statusValue == productv1.ProductStatus_PRODUCT_STATUS_UNSPECIFIED {
|
||||
statusValue = productv1.ProductStatus_PRODUCT_STATUS_INVENTORY
|
||||
}
|
||||
if statusValue != productv1.ProductStatus_PRODUCT_STATUS_INVENTORY &&
|
||||
statusValue != productv1.ProductStatus_PRODUCT_STATUS_ON_SALE &&
|
||||
statusValue != productv1.ProductStatus_PRODUCT_STATUS_OFF_SALE {
|
||||
@ -1266,9 +1263,6 @@ func skuFromCreateInput(sku *productv1.CreateProductSKU) (repository.SKURecord,
|
||||
name = derivedName
|
||||
}
|
||||
statusValue := sku.GetStatus()
|
||||
if statusValue == 0 {
|
||||
statusValue = 1
|
||||
}
|
||||
if statusValue < 0 || statusValue > 1 {
|
||||
return repository.SKURecord{}, errors.New("status must be 0 or 1")
|
||||
}
|
||||
@ -1348,7 +1342,7 @@ func crossBorderJSONFromProto(info *productv1.CrossBorderInfo) (string, error) {
|
||||
return "", errors.New("cross_border_info.logistics_mode is invalid")
|
||||
}
|
||||
|
||||
marshalOptions := protojson.MarshalOptions{UseProtoNames: true, EmitUnpopulated: true}
|
||||
marshalOptions := protojson.MarshalOptions{UseProtoNames: true, UseEnumNumbers: true, EmitUnpopulated: true}
|
||||
raw, err := marshalOptions.Marshal(info)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -1520,7 +1514,7 @@ func toProtoCartItemProduct(lineID string, record repository.CartItemProductReco
|
||||
LineId: lineID,
|
||||
ProductId: record.ProductID,
|
||||
SkuId: record.SKUID,
|
||||
SpuStatus: productv1.ProductStatus_PRODUCT_STATUS_UNSPECIFIED,
|
||||
SpuStatus: productv1.ProductStatus_PRODUCT_STATUS_NOT_FOUND,
|
||||
}
|
||||
if record.Product == nil {
|
||||
return result
|
||||
|
||||
@ -111,7 +111,7 @@ CREATE UNIQUE INDEX IF NOT EXISTS uq_products_spu_no
|
||||
|
||||
CREATE TABLE IF NOT EXISTS product.product_category (
|
||||
id BIGINT PRIMARY KEY,
|
||||
node_type SMALLINT NOT NULL DEFAULT 0,
|
||||
node_type SMALLINT NOT NULL DEFAULT 1,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
parent_id BIGINT REFERENCES product.product_category(id),
|
||||
level SMALLINT NOT NULL,
|
||||
@ -120,7 +120,7 @@ CREATE TABLE IF NOT EXISTS product.product_category (
|
||||
status SMALLINT NOT NULL DEFAULT 1,
|
||||
version INTEGER NOT NULL DEFAULT 0,
|
||||
CONSTRAINT chk_product_category_node_type
|
||||
CHECK (node_type IN (0, 1)),
|
||||
CHECK (node_type IN (1, 2)),
|
||||
CONSTRAINT chk_product_category_level
|
||||
CHECK (level > 0),
|
||||
CONSTRAINT chk_product_category_status
|
||||
@ -131,7 +131,7 @@ CREATE TABLE IF NOT EXISTS product.product_category (
|
||||
|
||||
COMMENT ON TABLE product.product_category IS '商品类别表:存储商品分类和商品分组,通过 node_type 区分分类或分组';
|
||||
COMMENT ON COLUMN product.product_category.id IS '类别/分组节点主键';
|
||||
COMMENT ON COLUMN product.product_category.node_type IS '节点类型:0 分类,1 分组';
|
||||
COMMENT ON COLUMN product.product_category.node_type IS '节点类型:1 分类,2 分组';
|
||||
COMMENT ON COLUMN product.product_category.name IS '节点展示名称';
|
||||
COMMENT ON COLUMN product.product_category.parent_id IS '上级节点 ID,顶级节点为空;子节点通过 parent_id 反向查询';
|
||||
COMMENT ON COLUMN product.product_category.level IS '节点层级,如 1、2、3';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user