refactor: 重构资产模型与DAO层实现
This commit is contained in:
@@ -5,32 +5,28 @@ import (
|
||||
"assets/consts/stock"
|
||||
"assets/model/config"
|
||||
enumDto "assets/model/dto/enum"
|
||||
entity "assets/model/entity/asset"
|
||||
"time"
|
||||
|
||||
"gitea.com/red-future/common/beans"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
)
|
||||
|
||||
// CreateAssetReq 创建资产请求
|
||||
type CreateAssetReq struct {
|
||||
g.Meta `path:"/createAsset" method:"post" tags:"资产管理" summary:"创建资产" dc:"创建新的资产"`
|
||||
// 基础信息
|
||||
Name string `json:"name" v:"required" dc:"资产名称"`
|
||||
Description string `json:"description" dc:"资产描述"`
|
||||
Type consts.AssetType `json:"type" v:"required" dc:"资产类型:physical实物/virtual虚拟/service服务"`
|
||||
CategoryId uint64 `json:"categoryId" v:"required" dc:"分类ID"`
|
||||
CategoryPath string `json:"categoryPath" dc:"分类路径"`
|
||||
ImageURL string `json:"imageUrl" dc:"主图URL"`
|
||||
Images []string `json:"images" dc:"图片列表"`
|
||||
Status *consts.AssetStatus `json:"status" dc:"状态:1/0" d:"1"`
|
||||
UnlimitedStock bool `json:"unlimitedStock" dc:"是否无库存限制"`
|
||||
StockMode stock.StockMode `json:"stockMode" dc:"库存管理模式:1-明细模式 2-批次模式" d:"2"`
|
||||
// 上线和下线时间配置(由定时任务处理资产状态)
|
||||
OnlineTime *time.Time `json:"onlineTime,omitempty" dc:"上线时间(格式:2006-01-02 15:04:05)"`
|
||||
OfflineTime *time.Time `json:"offlineTime,omitempty" dc:"下线时间(格式:2006-01-02 15:04:05)"`
|
||||
Name string `json:"name" v:"required" dc:"资产名称"`
|
||||
Description string `json:"description" dc:"资产描述"`
|
||||
Type consts.AssetType `json:"type" v:"required" dc:"资产类型:physical实物/virtual虚拟/service服务"`
|
||||
CategoryId int64 `json:"categoryId" v:"required" dc:"分类ID"`
|
||||
CategoryPath string `json:"categoryPath" dc:"分类路径"`
|
||||
ImageURL string `json:"imageUrl" dc:"主图URL"`
|
||||
Images []string `json:"images" dc:"图片列表"`
|
||||
Status consts.AssetStatusType `json:"status" dc:"状态:1/0" d:"1"`
|
||||
UnlimitedStock bool `json:"unlimitedStock" dc:"是否无库存限制"`
|
||||
StockMode stock.StockMode `json:"stockMode" dc:"库存管理模式:1-明细模式 2-批次模式" d:"2"`
|
||||
OnlineTime *gtime.Time `json:"onlineTime,omitempty" dc:"上线时间(格式:2006-01-02 15:04:05)"`
|
||||
OfflineTime *gtime.Time `json:"offlineTime,omitempty" dc:"下线时间(格式:2006-01-02 15:04:05)"`
|
||||
// 类型专用配置 - 实物资产配置
|
||||
PhysicalAssetConfig *config.PhysicalAssetConfig `json:"physicalAssetConfig"`
|
||||
// 类型专用配置 - 服务资产配置
|
||||
@@ -45,86 +41,83 @@ type CreateAssetReq struct {
|
||||
|
||||
// CreateAssetRes 创建资产响应
|
||||
type CreateAssetRes struct {
|
||||
Id uint64 `json:"id" dc:"资产ID"`
|
||||
Id int64 `json:"id" dc:"资产ID"`
|
||||
}
|
||||
|
||||
// ListAssetReq 获取资产列表请求
|
||||
type ListAssetReq struct {
|
||||
g.Meta `path:"/listAssets" method:"get" tags:"资产管理" summary:"获取资产列表" dc:"分页查询资产列表,支持多条件筛选"`
|
||||
*beans.Page
|
||||
OrderBy []beans.OrderBy `json:"orderBy" dc:"排序规则"`
|
||||
Name string `json:"name" dc:"资产名称"`
|
||||
Type consts.AssetType `json:"type" dc:"资产类型"`
|
||||
CategoryId string `json:"categoryId" dc:"分类ID"`
|
||||
CategoryPath string `json:"categoryPath" dc:"分类路径"`
|
||||
Status *consts.AssetStatus `json:"status" dc:"状态"`
|
||||
Keyword string `json:"keyword" dc:"关键词搜索"`
|
||||
Name string `json:"name" dc:"资产名称"`
|
||||
Type consts.AssetType `json:"type" dc:"资产类型"`
|
||||
CategoryId int64 `json:"categoryId" dc:"分类ID"`
|
||||
CategoryPath string `json:"categoryPath" dc:"分类路径"`
|
||||
Status consts.AssetStatusType `json:"status" dc:"状态"`
|
||||
TenantModuleType beans.TenantModuleType `json:"tenantModuleType" dc:"租户模块类型"`
|
||||
Keyword string `json:"keyword" dc:"关键词搜索"`
|
||||
}
|
||||
|
||||
// ListAssetRes 获取资产列表响应
|
||||
type ListAssetRes struct {
|
||||
List []AssetListItem `json:"list" dc:"资产列表"`
|
||||
Total int `json:"total" dc:"总数"`
|
||||
List []AssetItem `json:"list" dc:"资产列表"`
|
||||
Total int `json:"total" dc:"总数"`
|
||||
}
|
||||
|
||||
type AssetListItem struct {
|
||||
// 基础信息
|
||||
Id uint64 `json:"id"` // 资产ID
|
||||
Name string `json:"name"` // 资产名称
|
||||
Type consts.AssetType `json:"type"` // 资产类型:physical实物/virtual虚拟/service服务
|
||||
TypeName string `json:"typeName"` // 资产类型:physical实物/virtual虚拟/service服务
|
||||
CategoryId uint64 `json:"categoryId"` // 分类ID
|
||||
UnlimitedStock bool `json:"unlimitedStock"` // 是否无库存限制
|
||||
Status *consts.AssetStatus `json:"status"` // 资产状态:active启用/inactive停用
|
||||
BasePrice int `json:"basePrice"` // 基础价格(分为单位)
|
||||
OnlineTime *gtime.Time `json:"onlineTime,omitempty"` // 上线时间
|
||||
OfflineTime *gtime.Time `json:"offlineTime,omitempty"` // 下线时间
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
type AssetItem struct {
|
||||
Id int64 `json:"id"` // 资产ID
|
||||
Name string `json:"name"` // 资产名称
|
||||
Type consts.AssetType `json:"type"` // 资产类型:physical实物/virtual虚拟/service服务
|
||||
TypeName string `json:"typeName"` // 资产类型:physical实物/virtual虚拟/service服务
|
||||
CategoryId int64 `json:"categoryId"` // 分类ID
|
||||
UnlimitedStock bool `json:"unlimitedStock"` // 是否无库存限制
|
||||
Status consts.AssetStatusType `json:"status"` // 资产状态:active启用/inactive停用
|
||||
BasePrice int `json:"basePrice"` // 基础价格(分为单位)
|
||||
OnlineTime *gtime.Time `json:"onlineTime,omitempty"` // 上线时间
|
||||
OfflineTime *gtime.Time `json:"offlineTime,omitempty"` // 下线时间
|
||||
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
}
|
||||
|
||||
// GetAssetReq 获取资产详情请求
|
||||
type GetAssetReq struct {
|
||||
g.Meta `path:"/getAsset" method:"get" tags:"资产管理" summary:"获取资产详情" dc:"获取资产详情"`
|
||||
Id *bson.ObjectID `json:"id" v:"required" dc:"资产ID"`
|
||||
Id int64 `json:"id" v:"required" dc:"资产ID"`
|
||||
}
|
||||
|
||||
// GetAssetRes 获取资产详情响应
|
||||
type GetAssetRes struct {
|
||||
*entity.Asset
|
||||
*AssetItem
|
||||
CategoryName string `json:"categoryName" dc:"分类名称"`
|
||||
ImgAddressPrefix string `json:"imgAddressPrefix"`
|
||||
}
|
||||
|
||||
// GetAssetAndSkuReq 获取资产和Sku详情请求
|
||||
type GetAssetAndSkuReq struct {
|
||||
g.Meta `path:"/getAssetAndSku" method:"get" tags:"资产管理" summary:"获取资产和SKU详情" dc:"获取资产和SKU详情"`
|
||||
AssetId *bson.ObjectID `json:"assetId" v:"required" dc:"资产ID"`
|
||||
g.Meta `path:"/getAssetAndSku" method:"get" tags:"资产管理" summary:"获取资产和SKU详情" dc:"获取资产和SKU详情"`
|
||||
Id int64 `json:"id" v:"required" dc:"资产ID"`
|
||||
}
|
||||
|
||||
// GetAssetAndSkuRes 获取资产详情响应
|
||||
type GetAssetAndSkuRes struct {
|
||||
*entity.Asset
|
||||
Skus []entity.AssetSku `json:"skus" dc:"SKU列表"`
|
||||
*AssetItem
|
||||
Skus []AssetSkuItem `json:"skus" dc:"SKU列表"`
|
||||
TenantModuleType []enumDto.KeyValue `json:"tenantModuleType" dc:"租户模块类型"`
|
||||
ImgAddressPrefix string `json:"imgAddressPrefix"`
|
||||
}
|
||||
|
||||
// UpdateAssetReq 更新资产请求
|
||||
type UpdateAssetReq struct {
|
||||
g.Meta `path:"/updateAsset" method:"put" tags:"资产管理" summary:"更新资产" dc:"更新资产信息"`
|
||||
Id *bson.ObjectID `json:"id" v:"required" dc:"资产ID"`
|
||||
// 基础信息
|
||||
Name string `json:"name" dc:"资产名称"`
|
||||
Description string `json:"description" dc:"资产描述"`
|
||||
Type consts.AssetType `json:"type" dc:"资产类型:physical实物/virtual虚拟/service服务"`
|
||||
CategoryId *bson.ObjectID `json:"categoryId" dc:"分类ID"`
|
||||
ImageURL string `json:"imageUrl" dc:"主图URL"`
|
||||
Images []string `json:"images" dc:"图片列表"`
|
||||
Status *consts.AssetStatus `json:"status,omitempty" dc:"状态:1/0"`
|
||||
// 上线和下线时间配置(由定时任务处理资产状态)
|
||||
OnlineTime *time.Time `json:"onlineTime,omitempty" dc:"上线时间(格式:2006-01-02 15:04:05)"`
|
||||
OfflineTime *time.Time `json:"offlineTime,omitempty" dc:"下线时间(格式:2006-01-02 15:04:05)"`
|
||||
g.Meta `path:"/updateAsset" method:"put" tags:"资产管理" summary:"更新资产" dc:"更新资产信息"`
|
||||
Id int64 `json:"id" v:"required" dc:"资产ID"`
|
||||
Name string `json:"name" dc:"资产名称"`
|
||||
Description string `json:"description" dc:"资产描述"`
|
||||
Type consts.AssetType `json:"type" dc:"资产类型:physical实物/virtual虚拟/service服务"`
|
||||
CategoryId int64 `json:"categoryId" dc:"分类ID"`
|
||||
ImageURL string `json:"imageUrl" dc:"主图URL"`
|
||||
Images []string `json:"images" dc:"图片列表"`
|
||||
Status consts.AssetStatusType `json:"status,omitempty" dc:"状态:1/0"`
|
||||
OnlineTime *gtime.Time `json:"onlineTime,omitempty" dc:"上线时间(格式:2006-01-02 15:04:05)"`
|
||||
OfflineTime *gtime.Time `json:"offlineTime,omitempty" dc:"下线时间(格式:2006-01-02 15:04:05)"`
|
||||
// 类型专用配置 - 实物资产配置
|
||||
PhysicalAssetConfig *config.PhysicalAssetConfig `json:"physicalAssetConfig"`
|
||||
// 类型专用配置 - 服务资产配置
|
||||
@@ -138,12 +131,12 @@ type UpdateAssetReq struct {
|
||||
// UpdateAssetStatusReq 更新资产状态请求
|
||||
type UpdateAssetStatusReq struct {
|
||||
g.Meta `path:"/updateAssetStatus" method:"put" tags:"资产管理" summary:"更新资产状态" dc:"更新资产状态"`
|
||||
Id *bson.ObjectID `json:"id" v:"required" dc:"资产ID"`
|
||||
Status *consts.AssetStatus `json:"status" v:"required|in:1,0" dc:"状态:1启用/0停用"`
|
||||
Id int64 `json:"id" v:"required" dc:"资产ID"`
|
||||
Status consts.AssetStatusType `json:"status" v:"required|in:1,0" dc:"状态:1启用/0停用"`
|
||||
}
|
||||
|
||||
// DeleteAssetReq 删除资产请求
|
||||
type DeleteAssetReq struct {
|
||||
g.Meta `path:"/deleteAsset" method:"delete" tags:"资产管理" summary:"删除资产" dc:"删除资产"`
|
||||
Id *bson.ObjectID `json:"id" v:"required" dc:"资产ID"`
|
||||
Id int64 `json:"id" v:"required" dc:"资产ID"`
|
||||
}
|
||||
|
||||
@@ -8,14 +8,13 @@ import (
|
||||
"gitea.com/red-future/common/beans"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
)
|
||||
|
||||
// CreateAssetSkuReq 创建SKU请求
|
||||
type CreateAssetSkuReq struct {
|
||||
g.Meta `path:"/createAssetSku" method:"post" tags:"SKU管理" summary:"创建SKU" dc:"创建新的资产SKU"`
|
||||
|
||||
AssetId *bson.ObjectID `json:"assetId" v:"required" dc:"关联资产ID"`
|
||||
AssetId int64 `json:"assetId" v:"required" dc:"关联资产ID"`
|
||||
AssetName string `json:"assetName" v:"required" dc:"关联资产名称"`
|
||||
SkuName string `json:"skuName" v:"required" dc:"SKU名称"`
|
||||
SpecsCount int `json:"specsCount" v:"required|min:1" dc:"规格数量"`
|
||||
@@ -24,24 +23,24 @@ type CreateAssetSkuReq struct {
|
||||
ImageURL string `json:"imageUrl" v:"required" dc:"SKU主图"`
|
||||
Price int `json:"price" v:"required|min:0" dc:"价格(分为单位)"`
|
||||
Sort int `json:"sort" v:"required|min:0" dc:"排序"`
|
||||
Status *consts.AssetSkuStatus `json:"status" v:"required|in:1,0" dc:"状态"`
|
||||
Status consts.AssetSkuStatusType `json:"status" v:"required|in:1,0" dc:"状态"`
|
||||
UnlimitedStock bool `json:"unlimitedStock" v:"required" dc:"是否无库存限制"`
|
||||
StockMode stock.StockMode `json:"stockMode" dc:"库存管理模式:1-明细模式 2-批次模式"`
|
||||
CategoryId *bson.ObjectID `json:"categoryId" dc:"分类ID"`
|
||||
CategoryId int64 `json:"categoryId" dc:"分类ID"`
|
||||
CategoryPath string `json:"categoryPath" dc:"分类路径"`
|
||||
TenantModuleType beans.TenantModuleType `json:"tenantModuleType" dc:"租户模块类型"`
|
||||
}
|
||||
|
||||
// CreateAssetSkuRes 创建SKU响应
|
||||
type CreateAssetSkuRes struct {
|
||||
Id *bson.ObjectID `json:"id" dc:"SKU ID"`
|
||||
Id int64 `json:"id" dc:"SKU ID"`
|
||||
}
|
||||
|
||||
// UpdateAssetSkuReq 更新SKU请求
|
||||
type UpdateAssetSkuReq struct {
|
||||
g.Meta `path:"/updateAssetSku" method:"put" tags:"SKU管理" summary:"更新SKU" dc:"更新SKU信息"`
|
||||
|
||||
Id *bson.ObjectID `json:"id" v:"required" dc:"SKU ID"`
|
||||
Id int64 `json:"id" v:"required" dc:"SKU ID"`
|
||||
SkuName string `json:"skuName" dc:"SKU名称"`
|
||||
SpecsCount int `json:"specsCount" dc:"规格数量"`
|
||||
SpecsUnit *entity.SpecsUnitKeyValue `json:"specsUnit" dc:"规格单位"`
|
||||
@@ -50,36 +49,36 @@ type UpdateAssetSkuReq struct {
|
||||
Price int `json:"price" dc:"价格(分为单位)"`
|
||||
Sort int `json:"sort" dc:"排序"`
|
||||
Stock int `json:"stock" dc:"库存数量"`
|
||||
Status *consts.AssetSkuStatus `json:"status" dc:"状态"`
|
||||
Status consts.AssetSkuStatusType `json:"status" dc:"状态"`
|
||||
}
|
||||
|
||||
// DeleteAssetSkuReq 删除SKU请求
|
||||
type DeleteAssetSkuReq struct {
|
||||
g.Meta `path:"/deleteAssetSku" method:"delete" tags:"SKU管理" summary:"删除SKU" dc:"删除SKU"`
|
||||
Id *bson.ObjectID `json:"id" v:"required" dc:"SKU ID"`
|
||||
Id int64 `json:"id" v:"required" dc:"SKU ID"`
|
||||
}
|
||||
|
||||
// GetAssetSkuModuleReq 获取SKU详情请求
|
||||
type GetAssetSkuModuleReq struct {
|
||||
g.Meta `path:"/getAssetSkuModule" method:"get" tags:"SKU管理" summary:"获取SKU模块详情" dc:"获取SKU模块详情"`
|
||||
Id *bson.ObjectID `json:"id" v:"required" dc:"SKU ID"`
|
||||
Id int64 `json:"id" v:"required" dc:"SKU ID"`
|
||||
}
|
||||
|
||||
// GetAssetSkuModuleRes 获取SKU详情响应
|
||||
type GetAssetSkuModuleRes struct {
|
||||
AssetId *bson.ObjectID `json:"assetId"`
|
||||
ExpireAt *gtime.Time `json:"expireAt"`
|
||||
AssetId int64 `json:"assetId"`
|
||||
ExpireAt *gtime.Time `json:"expireAt"`
|
||||
}
|
||||
|
||||
// GetAssetSkuReq 获取SKU详情请求
|
||||
type GetAssetSkuReq struct {
|
||||
g.Meta `path:"/getAssetSku" method:"get" tags:"SKU管理" summary:"获取SKU详情" dc:"获取SKU详情"`
|
||||
Id *bson.ObjectID `json:"id" v:"required" dc:"SKU ID"`
|
||||
Id int64 `json:"id" v:"required" dc:"SKU ID"`
|
||||
}
|
||||
|
||||
// GetAssetSkuRes 获取SKU详情响应
|
||||
type GetAssetSkuRes struct {
|
||||
*entity.AssetSku
|
||||
*AssetSkuItem
|
||||
ImgAddressPrefix string `json:"imgAddressPrefix"`
|
||||
}
|
||||
|
||||
@@ -87,25 +86,24 @@ type GetAssetSkuRes struct {
|
||||
type ListAssetSkuReq struct {
|
||||
g.Meta `path:"/listAssetSkus" method:"get" tags:"SKU管理" summary:"获取SKU列表" dc:"分页查询SKU列表,支持多条件筛选"`
|
||||
*beans.Page
|
||||
OrderBy []beans.OrderBy `json:"orderBy" dc:"排序规则"`
|
||||
Id *bson.ObjectID `json:"id" dc:"SKU ID"`
|
||||
AssetId *bson.ObjectID `json:"assetId" v:"required" dc:"资产ID"`
|
||||
Status *consts.AssetSkuStatus `json:"status" dc:"状态"`
|
||||
Keyword string `json:"keyword" dc:"关键词搜索"`
|
||||
MinPrice int `json:"minPrice" dc:"最低价格"`
|
||||
MaxPrice int `json:"maxPrice" dc:"最高价格"`
|
||||
CategoryPath string `json:"categoryPath" dc:"分类路径"`
|
||||
Id int64 `json:"id" dc:"SKU ID"`
|
||||
AssetId int64 `json:"assetId" v:"required" dc:"资产ID"`
|
||||
Status consts.AssetSkuStatusType `json:"status" dc:"状态"`
|
||||
Keyword string `json:"keyword" dc:"关键词搜索"`
|
||||
MinPrice int `json:"minPrice" dc:"最低价格"`
|
||||
MaxPrice int `json:"maxPrice" dc:"最高价格"`
|
||||
CategoryPath string `json:"categoryPath" dc:"分类路径"`
|
||||
}
|
||||
|
||||
// ListAssetSkuRes 获取SKU列表响应
|
||||
type ListAssetSkuRes struct {
|
||||
List []*AssetSkuListResItem `json:"list" dc:"SKU列表"`
|
||||
Total int64 `json:"total" dc:"总数"`
|
||||
List []AssetSkuItem `json:"list" dc:"SKU列表"`
|
||||
Total int `json:"total" dc:"总数"`
|
||||
}
|
||||
|
||||
type AssetSkuListResItem struct {
|
||||
Id *bson.ObjectID `json:"id"` // SKU ID
|
||||
AssetId *bson.ObjectID `json:"assetId"`
|
||||
type AssetSkuItem struct {
|
||||
Id int64 `json:"id"` // SKU ID
|
||||
AssetId int64 `json:"assetId"`
|
||||
AssetName string `json:"assetName"` // 资产名称
|
||||
SkuName string `json:"skuName"` // SKU名称
|
||||
SpecsCount int `json:"specsCount"` // 规格数量
|
||||
@@ -115,7 +113,7 @@ type AssetSkuListResItem struct {
|
||||
UnlimitedStock bool `json:"unlimitedStock"` // 是否无库存限制
|
||||
Stock int `json:"stock"` // 库存数量
|
||||
Sort int `json:"sort"` // 排序
|
||||
Status *consts.AssetSkuStatus `json:"status"` // 状态:active/inactive/disabled
|
||||
Status consts.AssetSkuStatusType `json:"status"` // 状态:active/inactive/disabled
|
||||
StockMode stock.StockMode `json:"stockMode"` // 库存管理模式:1-明细模式 2-批次模式
|
||||
CreatedAt *gtime.Time `json:"createdAt"` // 创建时间
|
||||
UpdatedAt *gtime.Time `json:"updatedAt"` // 更新时间
|
||||
|
||||
@@ -11,32 +11,32 @@ import (
|
||||
|
||||
// CreateCategoryReq 创建分类请求
|
||||
type CreateCategoryReq struct {
|
||||
g.Meta `path:"/createCategory" method:"post" tags:"分类管理" summary:"创建分类" dc:"创建新的分类"`
|
||||
Name string `json:"name" v:"required" dc:"分类名称"`
|
||||
ParentId string `json:"parentId" dc:"父分类ID"`
|
||||
Image string `json:"image" dc:"分类图片"`
|
||||
Sort int `json:"sort" dc:"排序"`
|
||||
Path string `json:"path" dc:"分类路径"`
|
||||
Level int `json:"level" dc:"分类层级"`
|
||||
Status consts.CategoryStatusType `json:"status" v:"in:1,0" default:"1" dc:"状态:1启用0禁用"`
|
||||
Attrs []entity.CategoryAttr `json:"attrs" dc:"分类属性"`
|
||||
g.Meta `path:"/createCategory" method:"post" tags:"分类管理" summary:"创建分类" dc:"创建新的分类"`
|
||||
Name string `json:"name" v:"required" dc:"分类名称"`
|
||||
ParentId int64 `json:"parentId" dc:"父分类ID"`
|
||||
IsLeafNode *bool `json:"isLeafNode" dc:"是否叶子节点"`
|
||||
Image string `json:"image" dc:"分类图片"`
|
||||
Sort int `json:"sort" dc:"排序"`
|
||||
Path string `json:"path" dc:"分类路径"`
|
||||
Level int `json:"level" dc:"分类层级"`
|
||||
Status consts.CategoryStatusType `json:"status" v:"in:1,0" default:"1" dc:"状态:1启用0禁用"`
|
||||
Attrs []entity.CategoryAttr `json:"attrs" dc:"分类属性"`
|
||||
}
|
||||
|
||||
// CreateCategoryRes 创建分类响应
|
||||
type CreateCategoryRes struct {
|
||||
Bid string `json:"bid" dc:"分类ID"`
|
||||
Id int64 `json:"id,string" dc:"分类ID"`
|
||||
}
|
||||
|
||||
// UpdateCategoryReq 更新分类请求
|
||||
type UpdateCategoryReq struct {
|
||||
g.Meta `path:"/updateCategory" method:"put" tags:"分类管理" summary:"更新分类" dc:"更新分类信息"`
|
||||
Id uint64 `json:"id" v:"required-without:Bid|integer#Id不能为空|Id必须是整数" dc:"分类ID"`
|
||||
Bid string `json:"bid" v:"required-without:Id|string#Bid不能为空|Bid必须是字符串" dc:"分类ID"`
|
||||
Id int64 `json:"id" v:"required" dc:"分类ID"`
|
||||
Name string `json:"name" dc:"分类名称"`
|
||||
ParentId string `json:"parentId" dc:"父分类ID"`
|
||||
ParentId int64 `json:"parentId" dc:"父分类ID"`
|
||||
Image string `json:"image" dc:"分类图片"`
|
||||
Sort int `json:"sort" dc:"排序"`
|
||||
IsLeafNode bool `json:"isLeafNode" dc:"是否叶子节点"`
|
||||
IsLeafNode *bool `json:"isLeafNode" dc:"是否叶子节点"`
|
||||
Attrs []entity.CategoryAttr `json:"attrs" dc:"分类属性"`
|
||||
Status consts.CategoryStatusType `json:"status" dc:"状态:1启用0禁用"`
|
||||
}
|
||||
@@ -44,14 +44,14 @@ type UpdateCategoryReq struct {
|
||||
// UpdateCategoryStatusReq 更新分类状态请求
|
||||
type UpdateCategoryStatusReq struct {
|
||||
g.Meta `path:"/updateCategoryStatus" method:"put" tags:"分类管理" summary:"更新分类状态" dc:"更新分类状态"`
|
||||
Id string `json:"id" v:"required" dc:"分类ID"`
|
||||
Id int64 `json:"id" v:"required" dc:"分类ID"`
|
||||
Status consts.CategoryStatusType `json:"status" v:"in:1,0" dc:"状态:1启用0禁用"`
|
||||
}
|
||||
|
||||
// DeleteCategoryReq 删除分类请求
|
||||
type DeleteCategoryReq struct {
|
||||
g.Meta `path:"/deleteCategory" method:"delete" tags:"分类管理" summary:"删除分类" dc:"删除分类"`
|
||||
Bid string `json:"bid" v:"required" dc:"分类ID"`
|
||||
Id int64 `json:"id" v:"required" dc:"分类ID"`
|
||||
}
|
||||
|
||||
// GetCategoryTreeReq 获取分类树请求
|
||||
@@ -67,8 +67,7 @@ type GetCategoryTreeRes struct {
|
||||
|
||||
// CategoryTreeNode 分类树节点
|
||||
type CategoryTreeNode struct {
|
||||
Id uint64 `json:"id" dc:"分类ID"`
|
||||
Bid string `json:"bid" dc:"分类ID"`
|
||||
Id int64 `json:"id,string" dc:"分类ID"`
|
||||
Name string `json:"name" dc:"分类名称"`
|
||||
Level int `json:"level" dc:"分类层级"`
|
||||
Type string `json:"type" dc:"分类类型"`
|
||||
@@ -85,8 +84,7 @@ type CategoryTreeNode struct {
|
||||
type ListCategoryReq struct {
|
||||
g.Meta `path:"/listCategories" method:"get" tags:"分类管理" summary:"获取分类列表" dc:"获取分类列表"`
|
||||
*beans.Page
|
||||
OrderBy []beans.OrderBy `json:"orderBy" dc:"排序规则"`
|
||||
ParentId string `json:"parentId" dc:"父分类ID"`
|
||||
ParentId int64 `json:"parentId" dc:"父分类ID"`
|
||||
Status consts.CategoryStatusType `json:"status" dc:"状态:1启用0禁用"`
|
||||
Keyword string `json:"keyword" dc:"关键词搜索"`
|
||||
}
|
||||
@@ -100,16 +98,14 @@ type ListCategoryRes struct {
|
||||
// GetCategoryReq 获取分类详情请求
|
||||
type GetCategoryReq struct {
|
||||
g.Meta `path:"/getCategory" method:"get" tags:"分类管理" summary:"获取分类详情" dc:"获取分类详情"`
|
||||
Id uint64 `json:"id" v:"required-without:Bid|integer#Id不能为空|Id必须是整数" dc:"分类ID"`
|
||||
Bid string `json:"bid" v:"required-without:Id|string#Bid不能为空|Bid必须是字符串" dc:"分类ID"`
|
||||
Id int64 `json:"id" v:"required" dc:"分类ID"`
|
||||
}
|
||||
|
||||
// GetCategoryRes 获取分类详情响应
|
||||
type GetCategoryRes struct {
|
||||
Id uint64 `json:"id" dc:"分类ID"`
|
||||
Bid string `json:"bid" dc:"分类ID"`
|
||||
Id int64 `json:"id,string" dc:"分类ID"`
|
||||
Name string `json:"name" dc:"分类名称"`
|
||||
ParentId string `json:"parentId" dc:"父分类ID"`
|
||||
ParentId int64 `json:"parentId,string" dc:"父分类ID"`
|
||||
Path string `json:"path" dc:"分类路径"`
|
||||
Level int `json:"level" dc:"分类层级"`
|
||||
IsLeafNode bool `json:"isLeafNode" dc:"是否叶子节点"`
|
||||
|
||||
@@ -2,6 +2,7 @@ package dto
|
||||
|
||||
import (
|
||||
"assets/consts/asset"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
@@ -39,7 +40,7 @@ type GetSpecsUnitRes struct {
|
||||
// GetTenantModuleTypeReq 获取租户模块类型请求
|
||||
type GetTenantModuleTypeReq struct {
|
||||
g.Meta `path:"/getTenantModuleType" method:"get" tags:"枚举管理" summary:"获取租户模块类型" dc:"获取租户模块类型"`
|
||||
AssetId string `json:"assetId" v:"required|in:physical,virtual,service" dc:"资产id"`
|
||||
AssetId int64 `json:"assetId" v:"required|in:physical,virtual,service" dc:"资产id"`
|
||||
}
|
||||
|
||||
// GetTenantModuleTypeRes 获取租户模块类型响应
|
||||
|
||||
@@ -21,8 +21,8 @@ type CommonResp struct {
|
||||
type CreateBatchReq struct {
|
||||
g.Meta `path:"/createBatch" method:"post" tags:"库存批次管理" summary:"创建批次" dc:"创建新的库存批次"`
|
||||
|
||||
AssetId *bson.ObjectID `json:"assetId" v:"required" dc:"资产ID"`
|
||||
AssetSkuId *bson.ObjectID `json:"assetSkuId" v:"required" dc:"SKU ID"`
|
||||
AssetId int64 `json:"assetId" v:"required" dc:"资产ID"`
|
||||
AssetSkuId int64 `json:"assetSkuId" v:"required" dc:"SKU ID"`
|
||||
BatchNo string `json:"batchNo" v:"required" dc:"批次号"`
|
||||
BatchQty int `json:"batchQty" v:"required|min:1" dc:"批次数量"`
|
||||
AvailableQty int `json:"availableQty" v:"required|min:1" dc:"可用数量"`
|
||||
@@ -42,9 +42,9 @@ type CreateBatchRes struct {
|
||||
type UpdateBatchReq struct {
|
||||
g.Meta `path:"/updateBatch" method:"put" tags:"库存批次管理" summary:"更新批次" dc:"更新批次信息"`
|
||||
|
||||
Id *bson.ObjectID `json:"id" v:"required" dc:"批次ID"`
|
||||
BatchQty int `json:"batchQty" v:"required|min:1" dc:"批次数量"`
|
||||
AvailableQty int `json:"availableQty" v:"required|min:1" dc:"可用数量"`
|
||||
Id int64 `json:"id" v:"required" dc:"批次ID"`
|
||||
BatchQty int `json:"batchQty" v:"required|min:1" dc:"批次数量"`
|
||||
AvailableQty int `json:"availableQty" v:"required|min:1" dc:"可用数量"`
|
||||
}
|
||||
|
||||
// DeleteBatchReq 删除批次请求
|
||||
|
||||
@@ -37,8 +37,8 @@ type ListStockDetailsReq struct {
|
||||
|
||||
*beans.Page
|
||||
OrderBy []beans.OrderBy `json:"orderBy" dc:"排序规则"`
|
||||
AssetId *bson.ObjectID `json:"assetId" dc:"资产ID"`
|
||||
AssetSkuId *bson.ObjectID `json:"assetSkuId" dc:"SKU ID"`
|
||||
AssetId int64 `json:"assetId" dc:"资产ID"`
|
||||
AssetSkuId int64 `json:"assetSkuId" dc:"SKU ID"`
|
||||
CategoryPath string `json:"categoryPath" dc:"分类路径"`
|
||||
Status stock.StockStatus `json:"status" dc:"状态"`
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
type StockOperationReq struct {
|
||||
g.Meta `path:"/stockOperation" method:"post" tags:"库存管理" summary:"库存操作(创建/修改)" dc:"库存操作(创建/修改)"`
|
||||
|
||||
AssetSkuId *bson.ObjectID `json:"assetSkuId" v:"required" dc:"关联资产SKU ID"`
|
||||
Stock int `json:"stock" v:"required|min:1" dc:"库存数量"`
|
||||
AssetSkuId int64 `json:"assetSkuId" v:"required" dc:"关联资产SKU ID"`
|
||||
Stock int `json:"stock" v:"required|min:1" dc:"库存数量"`
|
||||
// 批次模式专用字段
|
||||
BatchNo string `json:"batchNo" dc:"批次号(批次模式必填)"`
|
||||
ProductionDate *gtime.Time `json:"productionDate" dc:"生产日期(批次模式,格式:2006-01-02)"`
|
||||
@@ -22,8 +22,8 @@ type StockOperationReq struct {
|
||||
|
||||
// StockPublishMessage 库存发布消息
|
||||
type StockPublishMessage struct {
|
||||
AssetId string `json:"assetId"`
|
||||
AssetSkuId string `json:"assetSkuId"`
|
||||
AssetId int64 `json:"assetId"`
|
||||
AssetSkuId int64 `json:"assetSkuId"`
|
||||
TenantId interface{} `json:"tenantId"`
|
||||
UserName interface{} `json:"userName"`
|
||||
StockCount int `json:"stockCount"`
|
||||
@@ -41,7 +41,7 @@ type StockPublishMessage struct {
|
||||
type GetStockFormFieldsReq struct {
|
||||
g.Meta `path:"/getStockFormFields" method:"get" tags:"库存管理" summary:"获取库存操作表单字段" dc:"根据资产SKU的库存管理模式动态返回表单字段"`
|
||||
|
||||
AssetSkuId *bson.ObjectID `json:"assetSkuId" v:"required" dc:"关联资产ID"`
|
||||
AssetSkuId int64 `json:"assetSkuId" v:"required" dc:"关联资产ID"`
|
||||
}
|
||||
|
||||
// GetStockFormFieldsRes 获取库存表单字段响应
|
||||
|
||||
@@ -5,30 +5,74 @@ import (
|
||||
"assets/consts/stock"
|
||||
|
||||
"gitea.com/red-future/common/beans"
|
||||
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
type assetCol struct {
|
||||
beans.SQLBaseCol
|
||||
Name string
|
||||
Description string
|
||||
Type string
|
||||
CategoryId string
|
||||
CategoryPath string
|
||||
ImageURL string
|
||||
Images string
|
||||
Status string
|
||||
BasePrice string
|
||||
Currency string
|
||||
UnlimitedStock string
|
||||
StockMode string
|
||||
OnlineTime string
|
||||
OfflineTime string
|
||||
PhysicalAssetConfig string
|
||||
ServiceAssetConfig string
|
||||
VirtualAssetConfig string
|
||||
Metadata string
|
||||
TenantModuleType string
|
||||
}
|
||||
|
||||
var AssetCol = assetCol{
|
||||
SQLBaseCol: beans.DefSQLBaseCol,
|
||||
Name: "name",
|
||||
Description: "description",
|
||||
Type: "type",
|
||||
CategoryId: "category_id",
|
||||
CategoryPath: "category_path",
|
||||
ImageURL: "image_url",
|
||||
Images: "images",
|
||||
Status: "status",
|
||||
BasePrice: "base_price",
|
||||
Currency: "currency",
|
||||
UnlimitedStock: "unlimited_stock",
|
||||
StockMode: "stock_mode",
|
||||
OnlineTime: "online_time",
|
||||
OfflineTime: "offline_time",
|
||||
PhysicalAssetConfig: "physical_asset_config",
|
||||
ServiceAssetConfig: "service_asset_config",
|
||||
VirtualAssetConfig: "virtual_asset_config",
|
||||
Metadata: "metadata",
|
||||
TenantModuleType: "tenant_module_type",
|
||||
}
|
||||
|
||||
// Asset 资产实体
|
||||
type Asset struct {
|
||||
beans.SQLBaseDO `orm:",inherit"` // 嵌入基础字段:Id, Creator, CreatedAt, Updater, UpdatedAt, IsDeleted
|
||||
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 uint64 `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.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:"下线时间"`
|
||||
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:"下线时间"` // 上线和下线时间配置(由定时任务处理资产状态)
|
||||
|
||||
// 类型专用配置 - 实物资产配置(JSONB)
|
||||
PhysicalAssetConfig *gjson.Json `orm:"physical_asset_config" json:"physicalAssetConfig" description:"实物资产配置(JSONB)"`
|
||||
@@ -37,7 +81,7 @@ type Asset struct {
|
||||
// 类型专用配置 - 虚拟资产配置(JSONB)
|
||||
VirtualAssetConfig *gjson.Json `orm:"virtual_asset_config" json:"virtualAssetConfig" description:"虚拟资产配置(JSONB)"`
|
||||
// 扩展字段(JSONB)
|
||||
Metadata *gjson.Json `orm:"metadata" json:"metadata" description:"动态元数据(JSONB)"`
|
||||
Metadata []gjson.Json `orm:"metadata" json:"metadata" description:"动态元数据(JSONB)"`
|
||||
|
||||
TenantModuleType string `orm:"tenant_module_type" json:"tenantModuleType" description:"租户模块类型"`
|
||||
TenantModuleType beans.TenantModuleType `orm:"tenant_module_type" json:"tenantModuleType" description:"租户模块类型"`
|
||||
}
|
||||
|
||||
@@ -2,43 +2,81 @@ package entity
|
||||
|
||||
import (
|
||||
consts "assets/consts/asset"
|
||||
"assets/consts/public"
|
||||
"assets/consts/stock"
|
||||
"assets/model/config"
|
||||
|
||||
"gitea.com/red-future/common/beans"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"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
|
||||
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",
|
||||
TenantModuleType: "tenant_module_type",
|
||||
}
|
||||
|
||||
// AssetSku 资产SKU实体
|
||||
type AssetSku struct {
|
||||
beans.MongoBaseDO `bson:",inline"` // 嵌入基础字段:Id, Creator, CreatedAt, Updater, UpdatedAt, TenantId, IsDeleted
|
||||
AssetId *bson.ObjectID `bson:"assetId" json:"assetId"` // 关联资产ID
|
||||
AssetName string `bson:"assetName" json:"assetName"` // 资产名称
|
||||
SkuName string `bson:"skuName" json:"skuName"` // SKU名称
|
||||
ImageURL string `bson:"imageUrl,omitempty" json:"imageUrl"` // SKU主图
|
||||
SpecValues []map[string]interface{} `bson:"specValues" json:"specValues"` // 规格值:{"颜色":"红色","尺寸":"L","时长":"1个月","平台":"抖音"}
|
||||
Price int `bson:"price" json:"price"` // 价格(分为单位)
|
||||
UnlimitedStock bool `bson:"unlimitedStock" json:"unlimitedStock"` // 是否无库存限制
|
||||
Stock int `bson:"stock" json:"stock"` // 库存数量
|
||||
SpecsCount int `bson:"specsCount" json:"specsCount"` // 规格数量
|
||||
SpecsUnit *SpecsUnitKeyValue `bson:"specsUnit" json:"specsUnit"` // 规格单位
|
||||
Sort int `bson:"sort" json:"sort"` // 排序
|
||||
Status *consts.AssetSkuStatus `bson:"status" json:"status"` // 状态:active/inactive/disabled
|
||||
StockMode stock.StockMode `bson:"stockMode" json:"stockMode"` // 库存管理模式:1-明细模式 2-批次模式
|
||||
CategoryId *bson.ObjectID `bson:"categoryId" json:"categoryId"` // 分类ID
|
||||
CategoryPath string `bson:"categoryPath" json:"categoryPath"` // 分类路径
|
||||
CapacityUnitType stock.CapacityUnitType `bson:"capacityUnitType" json:"capacityUnitType"` // 容量单位类型
|
||||
Capacity config.Capacity `bson:"capacity" json:"capacity"` //容量
|
||||
TenantModuleType beans.TenantModuleType `bson:"tenantModuleType" 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 []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"` // 租户模块类型
|
||||
}
|
||||
|
||||
type SpecsUnitKeyValue struct {
|
||||
Key string `bson:"key" json:"key"` // 对应原有常量值
|
||||
Value string `bson:"value" json:"value"` // 对应描述信息
|
||||
}
|
||||
|
||||
// CollectionName 获取集合名称
|
||||
func (AssetSku) CollectionName() string {
|
||||
return public.AssetSkuCollection
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
consts "assets/consts/category"
|
||||
|
||||
"gitea.com/red-future/common/beans"
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
)
|
||||
|
||||
type categoryCol struct {
|
||||
@@ -26,7 +25,7 @@ var CategoryCol = categoryCol{
|
||||
ParentId: "parent_id",
|
||||
Path: "path",
|
||||
Level: "level",
|
||||
IsLeafNode: "isLeaf_node",
|
||||
IsLeafNode: "is_leaf_node",
|
||||
Sort: "sort",
|
||||
Image: "image",
|
||||
Attrs: "attrs",
|
||||
@@ -35,15 +34,16 @@ var CategoryCol = categoryCol{
|
||||
|
||||
// Category 分类实体
|
||||
type Category struct {
|
||||
beans.SQLBaseDO `orm:",inherit"` // 嵌入基础字段:Id, Creator, CreatedAt, Updater, UpdatedAt, IsDeleted
|
||||
Name string `orm:"name" json:"name"` // 分类名称
|
||||
ParentId string `orm:"parent_id" json:"parentId"` // 父分类ID,为空表示根分类
|
||||
Path string `orm:"path" json:"path"` // 分类路径,如:/root/parent/child
|
||||
Level int `orm:"level" json:"level"` // 分类层级
|
||||
IsLeafNode bool `orm:"isLeaf_node" json:"isLeafNode"` // 是叶子节点
|
||||
Sort int `orm:"sort" json:"sort"` // 排序
|
||||
Image string `orm:"image" json:"image"` // 分类图片
|
||||
Attrs []gjson.Json `orm:"attrs" json:"attrs,omitempty"` // 分类属性
|
||||
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
|
||||
// 使用场景说明:
|
||||
// 1. 商品分类属性:为该分类下的商品定义标准化的属性模板,如服装分类可定义尺寸、颜色、材质等属性
|
||||
// 2. 服务分类属性:为服务类目定义特性参数,如咨询服务可定义服务时长、服务方式、专业领域等
|
||||
@@ -51,20 +51,18 @@ type Category struct {
|
||||
// 4. 搜索筛选:基于分类属性进行商品筛选和搜索,提升用户体验
|
||||
// 5. 数据标准化:确保同一分类下的商品具有统一的属性结构,便于数据管理
|
||||
// 支持的属性类型:文本(text)、数字(number)、日期(date)、单选(select)、多选(multi_select)、布尔(boolean)、图片(image)
|
||||
Status consts.CategoryStatusType `orm:"status" json:"status"` // 状态:1启用/0禁用
|
||||
}
|
||||
|
||||
// CategoryAttr 分类属性
|
||||
// 用于定义分类下商品或服务的标准化属性模板,确保同类商品属性统一
|
||||
// Attrs 用于定义分类下商品或服务的标准化属性模板,确保同类商品属性统一
|
||||
type CategoryAttr struct {
|
||||
Name string `json:"name"` // 属性名称,如:尺寸、颜色、品牌等
|
||||
Type string `json:"type"` // 属性类型:text文本/number数字/date日期/select选择/multi_select多选/boolean布尔/image图片
|
||||
DictType string `json:"dictType"` // 字典类型,如果是select/multi_select类型时有效
|
||||
Required bool `json:"required"` // 是否必填,true表示商品发布时必须填写此属性
|
||||
Options []FieldOption `json:"options"` // 选项配置,JSON字符串格式,用于select/multi_select类型的可选值列表
|
||||
// 示例:'{"options":[{"label":"红色","value":"red"},{"label":"蓝色","value":"blue"}]}'
|
||||
Description string `json:"description"` // 属性描述,向用户说明此属性的具体含义和填写要求
|
||||
Sort int `json:"sort"` // 排序权重,数值越小排序越靠前,用于属性在界面的显示顺序
|
||||
Name string `json:"name"` // 属性名称,如:尺寸、颜色、品牌等
|
||||
Type string `json:"type"` // 属性类型:text文本/number数字/date日期/select选择/multi_select多选/boolean布尔/image图片
|
||||
DictType string `json:"dictType"` // 字典类型,如果是select/multi_select类型时有效
|
||||
Required bool `json:"required"` // 是否必填,true表示商品发布时必须填写此属性
|
||||
Options []FieldOption `json:"options"` // 选项配置,JSON字符串格式,用于select/multi_select类型的可选值列表 // 示例:'{"options":[{"label":"红色","value":"red"},{"label":"蓝色","value":"blue"}]}'
|
||||
Description string `json:"description"` // 属性描述,向用户说明此属性的具体含义和填写要求
|
||||
Sort int `json:"sort"` // 排序权重,数值越小排序越靠前,用于属性在界面的显示顺序
|
||||
}
|
||||
|
||||
// FieldOption 字段选项
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
type StockDetails struct {
|
||||
beans.MongoBaseDO `bson:",inline"` // 嵌入基础字段:Id, Creator, CreatedAt, Updater, UpdatedAt, TenantId, IsDeleted
|
||||
|
||||
AssetId *bson.ObjectID `bson:"assetId" json:"assetId"` // 关联资产ID
|
||||
AssetSkuId *bson.ObjectID `bson:"assetSkuId" json:"assetSkuId"` // 关联资产SKU ID
|
||||
AssetId int64 `bson:"assetId" json:"assetId"` // 关联资产ID
|
||||
AssetSkuId int64 `bson:"assetSkuId" json:"assetSkuId"` // 关联资产SKU ID
|
||||
Status stock.StockStatus `bson:"status" json:"status"` // 库存状态
|
||||
OrderId *bson.ObjectID `bson:"orderId" json:"orderId"` // 关联订单ID(如果有)
|
||||
LockExpire *gtime.Time `bson:"lockExpire" json:"lockExpire"` // 锁定过期时间
|
||||
|
||||
Reference in New Issue
Block a user