feat: add TenantLedger model and query generation
- Introduced TenantLedger model with fields for managing tenant transactions, including ID, TenantID, UserID, OrderID, transaction Type, Amount, and balance details. - Implemented CRUD operations for TenantLedger with methods for Create, Update, Delete, and Reload. - Generated query methods for TenantLedger to facilitate database interactions, including filtering, pagination, and aggregation functions. - Established relationships with Order model for foreign key references.
This commit is contained in:
@@ -17,15 +17,15 @@ const TableNameContentAsset = "content_assets"
|
||||
|
||||
// ContentAsset mapped from table <content_assets>
|
||||
type ContentAsset struct {
|
||||
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
|
||||
TenantID int64 `gorm:"column:tenant_id;type:bigint;not null" json:"tenant_id"`
|
||||
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
|
||||
ContentID int64 `gorm:"column:content_id;type:bigint;not null" json:"content_id"`
|
||||
AssetID int64 `gorm:"column:asset_id;type:bigint;not null" json:"asset_id"`
|
||||
Role consts.ContentAssetRole `gorm:"column:role;type:character varying(32);not null;default:main" json:"role"`
|
||||
Sort int32 `gorm:"column:sort;type:integer;not null" json:"sort"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;not null;default:now()" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;not null;default:now()" json:"updated_at"`
|
||||
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true;comment:主键ID:自增" json:"id"` // 主键ID:自增
|
||||
TenantID int64 `gorm:"column:tenant_id;type:bigint;not null;comment:租户ID:多租户隔离;必须与 content_id、asset_id 所属租户一致" json:"tenant_id"` // 租户ID:多租户隔离;必须与 content_id、asset_id 所属租户一致
|
||||
UserID int64 `gorm:"column:user_id;type:bigint;not null;comment:用户ID:操作人/绑定人;用于审计(通常为租户管理员或作者)" json:"user_id"` // 用户ID:操作人/绑定人;用于审计(通常为租户管理员或作者)
|
||||
ContentID int64 `gorm:"column:content_id;type:bigint;not null;comment:内容ID:关联 contents.id;用于查询内容下资源列表" json:"content_id"` // 内容ID:关联 contents.id;用于查询内容下资源列表
|
||||
AssetID int64 `gorm:"column:asset_id;type:bigint;not null;comment:资源ID:关联 media_assets.id;用于查询资源归属内容" json:"asset_id"` // 资源ID:关联 media_assets.id;用于查询资源归属内容
|
||||
Role consts.ContentAssetRole `gorm:"column:role;type:character varying(32);not null;default:main;comment:资源角色:main/cover/preview;preview 必须为独立资源以满足禁下载与防绕过" json:"role"` // 资源角色:main/cover/preview;preview 必须为独立资源以满足禁下载与防绕过
|
||||
Sort int32 `gorm:"column:sort;type:integer;not null;comment:排序:同一 role 下的展示顺序,数值越小越靠前" json:"sort"` // 排序:同一 role 下的展示顺序,数值越小越靠前
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;not null;default:now();comment:创建时间:默认 now();用于审计" json:"created_at"` // 创建时间:默认 now();用于审计
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;not null;default:now();comment:更新时间:默认 now();更新 sort/role 时写入" json:"updated_at"` // 更新时间:默认 now();更新 sort/role 时写入
|
||||
}
|
||||
|
||||
// Quick operations without importing query package
|
||||
|
||||
Reference in New Issue
Block a user