Refactor order and tenant ledger models to use consts for Currency and Type fields; add new UserStatus values; implement comprehensive test cases for content, creator, order, super, and wallet services.
This commit is contained in:
@@ -30,10 +30,15 @@ func newContentAsset(db *gorm.DB, opts ...gen.DOOption) contentAssetQuery {
|
||||
_contentAssetQuery.UserID = field.NewInt64(tableName, "user_id")
|
||||
_contentAssetQuery.ContentID = field.NewInt64(tableName, "content_id")
|
||||
_contentAssetQuery.AssetID = field.NewInt64(tableName, "asset_id")
|
||||
_contentAssetQuery.Role = field.NewString(tableName, "role")
|
||||
_contentAssetQuery.Role = field.NewField(tableName, "role")
|
||||
_contentAssetQuery.Sort = field.NewInt32(tableName, "sort")
|
||||
_contentAssetQuery.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_contentAssetQuery.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_contentAssetQuery.Asset = contentAssetQueryBelongsToAsset{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Asset", "MediaAsset"),
|
||||
}
|
||||
|
||||
_contentAssetQuery.fillFieldMap()
|
||||
|
||||
@@ -49,10 +54,11 @@ type contentAssetQuery struct {
|
||||
UserID field.Int64
|
||||
ContentID field.Int64
|
||||
AssetID field.Int64
|
||||
Role field.String
|
||||
Role field.Field
|
||||
Sort field.Int32
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
Asset contentAssetQueryBelongsToAsset
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
@@ -74,7 +80,7 @@ func (c *contentAssetQuery) updateTableName(table string) *contentAssetQuery {
|
||||
c.UserID = field.NewInt64(table, "user_id")
|
||||
c.ContentID = field.NewInt64(table, "content_id")
|
||||
c.AssetID = field.NewInt64(table, "asset_id")
|
||||
c.Role = field.NewString(table, "role")
|
||||
c.Role = field.NewField(table, "role")
|
||||
c.Sort = field.NewInt32(table, "sort")
|
||||
c.CreatedAt = field.NewTime(table, "created_at")
|
||||
c.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
@@ -110,7 +116,7 @@ func (c *contentAssetQuery) GetFieldByName(fieldName string) (field.OrderExpr, b
|
||||
}
|
||||
|
||||
func (c *contentAssetQuery) fillFieldMap() {
|
||||
c.fieldMap = make(map[string]field.Expr, 9)
|
||||
c.fieldMap = make(map[string]field.Expr, 10)
|
||||
c.fieldMap["id"] = c.ID
|
||||
c.fieldMap["tenant_id"] = c.TenantID
|
||||
c.fieldMap["user_id"] = c.UserID
|
||||
@@ -120,18 +126,103 @@ func (c *contentAssetQuery) fillFieldMap() {
|
||||
c.fieldMap["sort"] = c.Sort
|
||||
c.fieldMap["created_at"] = c.CreatedAt
|
||||
c.fieldMap["updated_at"] = c.UpdatedAt
|
||||
|
||||
}
|
||||
|
||||
func (c contentAssetQuery) clone(db *gorm.DB) contentAssetQuery {
|
||||
c.contentAssetQueryDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
c.Asset.db = db.Session(&gorm.Session{Initialized: true})
|
||||
c.Asset.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
return c
|
||||
}
|
||||
|
||||
func (c contentAssetQuery) replaceDB(db *gorm.DB) contentAssetQuery {
|
||||
c.contentAssetQueryDo.ReplaceDB(db)
|
||||
c.Asset.db = db.Session(&gorm.Session{})
|
||||
return c
|
||||
}
|
||||
|
||||
type contentAssetQueryBelongsToAsset struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a contentAssetQueryBelongsToAsset) Where(conds ...field.Expr) *contentAssetQueryBelongsToAsset {
|
||||
if len(conds) == 0 {
|
||||
return &a
|
||||
}
|
||||
|
||||
exprs := make([]clause.Expression, 0, len(conds))
|
||||
for _, cond := range conds {
|
||||
exprs = append(exprs, cond.BeCond().(clause.Expression))
|
||||
}
|
||||
a.db = a.db.Clauses(clause.Where{Exprs: exprs})
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a contentAssetQueryBelongsToAsset) WithContext(ctx context.Context) *contentAssetQueryBelongsToAsset {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a contentAssetQueryBelongsToAsset) Session(session *gorm.Session) *contentAssetQueryBelongsToAsset {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a contentAssetQueryBelongsToAsset) Model(m *ContentAsset) *contentAssetQueryBelongsToAssetTx {
|
||||
return &contentAssetQueryBelongsToAssetTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a contentAssetQueryBelongsToAsset) Unscoped() *contentAssetQueryBelongsToAsset {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type contentAssetQueryBelongsToAssetTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a contentAssetQueryBelongsToAssetTx) Find() (result *MediaAsset, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a contentAssetQueryBelongsToAssetTx) Append(values ...*MediaAsset) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a contentAssetQueryBelongsToAssetTx) Replace(values ...*MediaAsset) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a contentAssetQueryBelongsToAssetTx) Delete(values ...*MediaAsset) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a contentAssetQueryBelongsToAssetTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a contentAssetQueryBelongsToAssetTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a contentAssetQueryBelongsToAssetTx) Unscoped() *contentAssetQueryBelongsToAssetTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type contentAssetQueryDo struct{ gen.DO }
|
||||
|
||||
func (c contentAssetQueryDo) Debug() *contentAssetQueryDo {
|
||||
|
||||
Reference in New Issue
Block a user