refactor: 重构资产实体和DTO结构类型
将gjson.Json类型替换为具体的结构体和map类型,修正DAO层链式调用,启用SKU元数据校验逻辑
This commit is contained in:
@@ -3,9 +3,9 @@ package entity
|
||||
import (
|
||||
consts "assets/consts/asset"
|
||||
"assets/consts/stock"
|
||||
"assets/model/config"
|
||||
|
||||
"gitea.com/red-future/common/beans"
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
@@ -59,29 +59,29 @@ var AssetCol = assetCol{
|
||||
type Asset struct {
|
||||
beans.SQLBaseDO `orm:",inherit"`
|
||||
// 基础信息
|
||||
Name string `orm:"name" json:"name" description:"资产名称"`
|
||||
Description string `orm:"description" json:"description" description:"资产描述"`
|
||||
Type consts.AssetType `orm:"type" json:"type" description:"资产类型:physical实物/virtual虚拟/service服务"`
|
||||
CategoryId int64 `orm:"category_id" json:"categoryId" description:"分类ID"`
|
||||
CategoryPath string `orm:"category_path" json:"categoryPath" description:"分类路径"`
|
||||
ImageURL string `orm:"image_url" json:"imageUrl" description:"主图URL"`
|
||||
Images []string `orm:"images" json:"images" description:"图片列表(JSONB)"`
|
||||
Status consts.AssetStatusType `orm:"status" json:"status" description:"资产状态:1启用/0停用"`
|
||||
BasePrice int `orm:"base_price" json:"basePrice" description:"基础价格(分为单位)"`
|
||||
Currency string `orm:"currency" json:"currency" description:"货币单位,默认CNY"`
|
||||
UnlimitedStock bool `orm:"unlimited_stock" json:"unlimitedStock" description:"是否无库存限制"`
|
||||
StockMode stock.StockMode `orm:"stock_mode" json:"stockMode" description:"库存管理模式:1-明细模式 2-批次模式"`
|
||||
OnlineTime *gtime.Time `orm:"online_time" json:"onlineTime,omitempty" description:"上线时间"` // 上线和下线时间配置(由定时任务处理资产状态)
|
||||
OfflineTime *gtime.Time `orm:"offline_time" json:"offlineTime,omitempty" description:"下线时间"` // 上线和下线时间配置(由定时任务处理资产状态)
|
||||
Name string `orm:"name" json:"name" description:"资产名称"`
|
||||
Description string `orm:"description" json:"description" description:"资产描述"`
|
||||
Type consts.AssetType `orm:"type" json:"type" description:"资产类型:physical实物/virtual虚拟/service服务"`
|
||||
CategoryId int64 `orm:"category_id" json:"categoryId,string" description:"分类ID"`
|
||||
CategoryPath string `orm:"category_path" json:"categoryPath" description:"分类路径"`
|
||||
ImageURL string `orm:"image_url" json:"imageUrl" description:"主图URL"`
|
||||
Images []string `orm:"images" json:"images" description:"图片列表(JSONB)"`
|
||||
Status consts.AssetStatus `orm:"status" json:"status" description:"资产状态:1启用/0停用"`
|
||||
BasePrice int `orm:"base_price" json:"basePrice" description:"基础价格(分为单位)"`
|
||||
Currency string `orm:"currency" json:"currency" description:"货币单位,默认CNY"`
|
||||
UnlimitedStock bool `orm:"unlimited_stock" json:"unlimitedStock" description:"是否无库存限制"`
|
||||
StockMode stock.StockMode `orm:"stock_mode" json:"stockMode" description:"库存管理模式:1-明细模式 2-批次模式"`
|
||||
OnlineTime *gtime.Time `orm:"online_time" json:"onlineTime,omitempty" description:"上线时间"` // 上线和下线时间配置(由定时任务处理资产状态)
|
||||
OfflineTime *gtime.Time `orm:"offline_time" json:"offlineTime,omitempty" description:"下线时间"` // 上线和下线时间配置(由定时任务处理资产状态)
|
||||
|
||||
// 类型专用配置 - 实物资产配置(JSONB)
|
||||
PhysicalAssetConfig *gjson.Json `orm:"physical_asset_config" json:"physicalAssetConfig" description:"实物资产配置(JSONB)"`
|
||||
PhysicalAssetConfig *config.PhysicalAssetConfig `orm:"physical_asset_config" json:"physicalAssetConfig" description:"实物资产配置(JSONB)"`
|
||||
// 类型专用配置 - 服务资产配置(JSONB)
|
||||
ServiceAssetConfig *gjson.Json `orm:"service_asset_config" json:"serviceAssetConfig" description:"服务资产配置(JSONB)"`
|
||||
ServiceAssetConfig *config.ServiceAssetConfig `orm:"service_asset_config" json:"serviceAssetConfig" description:"服务资产配置(JSONB)"`
|
||||
// 类型专用配置 - 虚拟资产配置(JSONB)
|
||||
VirtualAssetConfig *gjson.Json `orm:"virtual_asset_config" json:"virtualAssetConfig" description:"虚拟资产配置(JSONB)"`
|
||||
VirtualAssetConfig *config.VirtualAssetConfig `orm:"virtual_asset_config" json:"virtualAssetConfig" description:"虚拟资产配置(JSONB)"`
|
||||
// 扩展字段(JSONB)
|
||||
Metadata []gjson.Json `orm:"metadata" json:"metadata" description:"动态元数据(JSONB)"`
|
||||
Metadata []map[string]interface{} `orm:"metadata" json:"metadata" description:"动态元数据(JSONB)"`
|
||||
|
||||
TenantModuleType beans.TenantModuleType `orm:"tenant_module_type" json:"tenantModuleType" description:"租户模块类型"`
|
||||
}
|
||||
|
||||
@@ -3,77 +3,75 @@ package entity
|
||||
import (
|
||||
consts "assets/consts/asset"
|
||||
"assets/consts/stock"
|
||||
"assets/model/config"
|
||||
|
||||
"gitea.com/red-future/common/beans"
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
)
|
||||
|
||||
type assetSkuCol struct {
|
||||
beans.SQLBaseCol
|
||||
AssetId string
|
||||
AssetName string
|
||||
SkuName string
|
||||
ImageURL string
|
||||
SpecValues string
|
||||
Price string
|
||||
UnlimitedStock string
|
||||
Stock string
|
||||
SpecsCount string
|
||||
SpecsUnit string
|
||||
Sort string
|
||||
Status string
|
||||
StockMode string
|
||||
CategoryId string
|
||||
CategoryPath string
|
||||
CapacityUnitType string
|
||||
Capacity string
|
||||
AssetId string
|
||||
AssetName string
|
||||
SkuName string
|
||||
ImageURL string
|
||||
SpecValues string
|
||||
Price string
|
||||
UnlimitedStock string
|
||||
Stock string
|
||||
SpecsCount string
|
||||
SpecsUnit string
|
||||
Sort string
|
||||
Status string
|
||||
StockMode string
|
||||
CategoryId string
|
||||
CategoryPath string
|
||||
//CapacityUnitType string
|
||||
//Capacity string
|
||||
TenantModuleType string
|
||||
}
|
||||
|
||||
var AssetSkuCol = assetSkuCol{
|
||||
SQLBaseCol: beans.DefSQLBaseCol,
|
||||
AssetId: "asset_id",
|
||||
AssetName: "asset_name",
|
||||
SkuName: "sku_name",
|
||||
ImageURL: "image_url",
|
||||
SpecValues: "spec_values",
|
||||
Price: "price",
|
||||
UnlimitedStock: "unlimited_stock",
|
||||
Stock: "stock",
|
||||
SpecsCount: "specs_count",
|
||||
SpecsUnit: "specs_unit",
|
||||
Sort: "sort",
|
||||
Status: "status",
|
||||
StockMode: "stock_mode",
|
||||
CategoryId: "category_id",
|
||||
CategoryPath: "category_path",
|
||||
CapacityUnitType: "capacity_unit_type",
|
||||
Capacity: "capacity",
|
||||
SQLBaseCol: beans.DefSQLBaseCol,
|
||||
AssetId: "asset_id",
|
||||
AssetName: "asset_name",
|
||||
SkuName: "sku_name",
|
||||
ImageURL: "image_url",
|
||||
SpecValues: "spec_values",
|
||||
Price: "price",
|
||||
UnlimitedStock: "unlimited_stock",
|
||||
Stock: "stock",
|
||||
SpecsCount: "specs_count",
|
||||
SpecsUnit: "specs_unit",
|
||||
Sort: "sort",
|
||||
Status: "status",
|
||||
StockMode: "stock_mode",
|
||||
CategoryId: "category_id",
|
||||
CategoryPath: "category_path",
|
||||
//CapacityUnitType: "capacity_unit_type",
|
||||
//Capacity: "capacity",
|
||||
TenantModuleType: "tenant_module_type",
|
||||
}
|
||||
|
||||
// AssetSku 资产SKU实体
|
||||
type AssetSku struct {
|
||||
beans.SQLBaseDO `orm:",inherit"`
|
||||
AssetId int64 `orm:"asset_id" json:"assetId"` // 关联资产ID
|
||||
AssetName string `orm:"asset_name" json:"assetName"` // 资产名称
|
||||
SkuName string `orm:"sku_name" json:"skuName"` // SKU名称
|
||||
ImageURL string `orm:"image_url,omitempty" json:"imageUrl"` // SKU主图
|
||||
SpecValues []gjson.Json `orm:"spec_values" json:"specValues"` // 规格值:{"颜色":"红色","尺寸":"L","时长":"1个月","平台":"抖音"}
|
||||
Price int `orm:"price" json:"price"` // 价格(分为单位)
|
||||
UnlimitedStock bool `orm:"unlimited_stock" json:"unlimitedStock"` // 是否无库存限制
|
||||
Stock int `orm:"stock" json:"stock"` // 库存数量
|
||||
SpecsCount int `orm:"specs_count" json:"specsCount"` // 规格数量
|
||||
SpecsUnit *gjson.Json `orm:"specs_unit" json:"specsUnit"` // 规格单位 SpecsUnitKeyValue
|
||||
Sort int `orm:"sort" json:"sort"` // 排序
|
||||
Status consts.AssetSkuStatusType `orm:"status" json:"status"` // 状态:active/inactive/disabled
|
||||
StockMode stock.StockMode `orm:"stock_mode" json:"stockMode"` // 库存管理模式:1-明细模式 2-批次模式
|
||||
CategoryId int64 `orm:"category_id" json:"categoryId"` // 分类ID
|
||||
CategoryPath string `orm:"category_path" json:"categoryPath"` // 分类路径
|
||||
CapacityUnitType stock.CapacityUnitType `orm:"capacity_unit_type" json:"capacityUnitType"` // 容量单位类型
|
||||
Capacity config.Capacity `orm:"capacity" json:"capacity"` // 容量
|
||||
TenantModuleType beans.TenantModuleType `orm:"tenant_module_type" json:"tenantModuleType"` // 租户模块类型
|
||||
beans.SQLBaseDO `orm:",inherit"`
|
||||
AssetId int64 `orm:"asset_id" json:"assetId"` // 关联资产ID
|
||||
AssetName string `orm:"asset_name" json:"assetName"` // 资产名称
|
||||
SkuName string `orm:"sku_name" json:"skuName"` // SKU名称
|
||||
ImageURL string `orm:"image_url,omitempty" json:"imageUrl"` // SKU主图
|
||||
SpecValues []map[string]interface{} `orm:"spec_values" json:"specValues"` // 规格值:{"颜色":"红色","尺寸":"L","时长":"1个月","平台":"抖音"}
|
||||
Price int `orm:"price" json:"price"` // 价格(分为单位)
|
||||
UnlimitedStock bool `orm:"unlimited_stock" json:"unlimitedStock"` // 是否无库存限制
|
||||
Stock int `orm:"stock" json:"stock"` // 库存数量
|
||||
SpecsCount int `orm:"specs_count" json:"specsCount"` // 规格数量
|
||||
SpecsUnit *SpecsUnitKeyValue `orm:"specs_unit" json:"specsUnit"` // 规格单位 SpecsUnitKeyValue
|
||||
Sort int `orm:"sort" json:"sort"` // 排序
|
||||
Status consts.AssetSkuStatus `orm:"status" json:"status"` // 状态:active/inactive/disabled
|
||||
StockMode stock.StockMode `orm:"stock_mode" json:"stockMode"` // 库存管理模式:1-明细模式 2-批次模式
|
||||
CategoryId int64 `orm:"category_id" json:"categoryId"` // 分类ID
|
||||
CategoryPath string `orm:"category_path" json:"categoryPath"` // 分类路径
|
||||
//CapacityUnitType stock.CapacityUnitType `orm:"capacity_unit_type" json:"capacityUnitType"` // 容量单位类型
|
||||
//Capacity int `orm:"capacity" json:"capacity"` // 容量
|
||||
TenantModuleType beans.TenantModuleType `orm:"tenant_module_type" json:"tenantModuleType"` // 租户模块类型
|
||||
}
|
||||
|
||||
type SpecsUnitKeyValue struct {
|
||||
|
||||
@@ -35,15 +35,15 @@ var CategoryCol = categoryCol{
|
||||
// Category 分类实体
|
||||
type Category struct {
|
||||
beans.SQLBaseDO `orm:",inherit"`
|
||||
Name string `orm:"name" json:"name"` // 分类名称
|
||||
ParentId int64 `orm:"parent_id" json:"parentId"` // 父分类ID,为空表示根分类
|
||||
Path string `orm:"path" json:"path"` // 分类路径,如:/root/parent/child
|
||||
Level int `orm:"level" json:"level"` // 分类层级
|
||||
IsLeafNode *bool `orm:"is_leaf_node" json:"isLeafNode"` // 是叶子节点
|
||||
Sort int `orm:"sort" json:"sort"` // 排序
|
||||
Image string `orm:"image" json:"image"` // 分类图片
|
||||
Status consts.CategoryStatusType `orm:"status" json:"status"` // 状态:1启用/0禁用
|
||||
Attrs []CategoryAttr `orm:"attrs" json:"attrs,omitempty"` // 分类属性 CategoryAttr
|
||||
Name string `orm:"name" json:"name"` // 分类名称
|
||||
ParentId int64 `orm:"parent_id" json:"parentId"` // 父分类ID,为空表示根分类
|
||||
Path string `orm:"path" json:"path"` // 分类路径,如:/root/parent/child
|
||||
Level int `orm:"level" json:"level"` // 分类层级
|
||||
IsLeafNode *bool `orm:"is_leaf_node" json:"isLeafNode"` // 是叶子节点
|
||||
Sort int `orm:"sort" json:"sort"` // 排序
|
||||
Image string `orm:"image" json:"image"` // 分类图片
|
||||
Status consts.CategoryStatus `orm:"status" json:"status"` // 状态:1启用/0禁用
|
||||
Attrs []CategoryAttr `orm:"attrs" json:"attrs,omitempty"` // 分类属性 CategoryAttr
|
||||
// 使用场景说明:
|
||||
// 1. 商品分类属性:为该分类下的商品定义标准化的属性模板,如服装分类可定义尺寸、颜色、材质等属性
|
||||
// 2. 服务分类属性:为服务类目定义特性参数,如咨询服务可定义服务时长、服务方式、专业领域等
|
||||
|
||||
Reference in New Issue
Block a user