重命名资源套餐相关结构体和数据库表,新增长效套餐类型
This commit is contained in:
355
web/queries/resource_long.gen.go
Normal file
355
web/queries/resource_long.gen.go
Normal file
@@ -0,0 +1,355 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newResourceLong(db *gorm.DB, opts ...gen.DOOption) resourceLong {
|
||||
_resourceLong := resourceLong{}
|
||||
|
||||
_resourceLong.resourceLongDo.UseDB(db, opts...)
|
||||
_resourceLong.resourceLongDo.UseModel(&models.ResourceLong{})
|
||||
|
||||
tableName := _resourceLong.resourceLongDo.TableName()
|
||||
_resourceLong.ALL = field.NewAsterisk(tableName)
|
||||
_resourceLong.ID = field.NewInt32(tableName, "id")
|
||||
_resourceLong.ResourceID = field.NewInt32(tableName, "resource_id")
|
||||
_resourceLong.Type = field.NewInt32(tableName, "type")
|
||||
_resourceLong.Live = field.NewInt32(tableName, "live")
|
||||
_resourceLong.Expire = field.NewField(tableName, "expire")
|
||||
_resourceLong.Quota = field.NewInt32(tableName, "quota")
|
||||
_resourceLong.Used = field.NewInt32(tableName, "used")
|
||||
_resourceLong.DailyLimit = field.NewInt32(tableName, "daily_limit")
|
||||
_resourceLong.DailyUsed = field.NewInt32(tableName, "daily_used")
|
||||
_resourceLong.DailyLast = field.NewField(tableName, "daily_last")
|
||||
|
||||
_resourceLong.fillFieldMap()
|
||||
|
||||
return _resourceLong
|
||||
}
|
||||
|
||||
type resourceLong struct {
|
||||
resourceLongDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // ID
|
||||
ResourceID field.Int32 // 套餐ID
|
||||
Type field.Int32 // 套餐类型:1-包时,2-包量
|
||||
Live field.Int32 // 可用时长(秒)
|
||||
Expire field.Field // 过期时间
|
||||
Quota field.Int32 // 配额数量
|
||||
Used field.Int32 // 已用数量
|
||||
DailyLimit field.Int32 // 每日限制
|
||||
DailyUsed field.Int32 // 今日已用数量
|
||||
DailyLast field.Field // 今日最后使用时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (r resourceLong) Table(newTableName string) *resourceLong {
|
||||
r.resourceLongDo.UseTable(newTableName)
|
||||
return r.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (r resourceLong) As(alias string) *resourceLong {
|
||||
r.resourceLongDo.DO = *(r.resourceLongDo.As(alias).(*gen.DO))
|
||||
return r.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (r *resourceLong) updateTableName(table string) *resourceLong {
|
||||
r.ALL = field.NewAsterisk(table)
|
||||
r.ID = field.NewInt32(table, "id")
|
||||
r.ResourceID = field.NewInt32(table, "resource_id")
|
||||
r.Type = field.NewInt32(table, "type")
|
||||
r.Live = field.NewInt32(table, "live")
|
||||
r.Expire = field.NewField(table, "expire")
|
||||
r.Quota = field.NewInt32(table, "quota")
|
||||
r.Used = field.NewInt32(table, "used")
|
||||
r.DailyLimit = field.NewInt32(table, "daily_limit")
|
||||
r.DailyUsed = field.NewInt32(table, "daily_used")
|
||||
r.DailyLast = field.NewField(table, "daily_last")
|
||||
|
||||
r.fillFieldMap()
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *resourceLong) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := r.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (r *resourceLong) fillFieldMap() {
|
||||
r.fieldMap = make(map[string]field.Expr, 10)
|
||||
r.fieldMap["id"] = r.ID
|
||||
r.fieldMap["resource_id"] = r.ResourceID
|
||||
r.fieldMap["type"] = r.Type
|
||||
r.fieldMap["live"] = r.Live
|
||||
r.fieldMap["expire"] = r.Expire
|
||||
r.fieldMap["quota"] = r.Quota
|
||||
r.fieldMap["used"] = r.Used
|
||||
r.fieldMap["daily_limit"] = r.DailyLimit
|
||||
r.fieldMap["daily_used"] = r.DailyUsed
|
||||
r.fieldMap["daily_last"] = r.DailyLast
|
||||
}
|
||||
|
||||
func (r resourceLong) clone(db *gorm.DB) resourceLong {
|
||||
r.resourceLongDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return r
|
||||
}
|
||||
|
||||
func (r resourceLong) replaceDB(db *gorm.DB) resourceLong {
|
||||
r.resourceLongDo.ReplaceDB(db)
|
||||
return r
|
||||
}
|
||||
|
||||
type resourceLongDo struct{ gen.DO }
|
||||
|
||||
func (r resourceLongDo) Debug() *resourceLongDo {
|
||||
return r.withDO(r.DO.Debug())
|
||||
}
|
||||
|
||||
func (r resourceLongDo) WithContext(ctx context.Context) *resourceLongDo {
|
||||
return r.withDO(r.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) ReadDB() *resourceLongDo {
|
||||
return r.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (r resourceLongDo) WriteDB() *resourceLongDo {
|
||||
return r.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Session(config *gorm.Session) *resourceLongDo {
|
||||
return r.withDO(r.DO.Session(config))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Clauses(conds ...clause.Expression) *resourceLongDo {
|
||||
return r.withDO(r.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Returning(value interface{}, columns ...string) *resourceLongDo {
|
||||
return r.withDO(r.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Not(conds ...gen.Condition) *resourceLongDo {
|
||||
return r.withDO(r.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Or(conds ...gen.Condition) *resourceLongDo {
|
||||
return r.withDO(r.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Select(conds ...field.Expr) *resourceLongDo {
|
||||
return r.withDO(r.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Where(conds ...gen.Condition) *resourceLongDo {
|
||||
return r.withDO(r.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Order(conds ...field.Expr) *resourceLongDo {
|
||||
return r.withDO(r.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Distinct(cols ...field.Expr) *resourceLongDo {
|
||||
return r.withDO(r.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Omit(cols ...field.Expr) *resourceLongDo {
|
||||
return r.withDO(r.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Join(table schema.Tabler, on ...field.Expr) *resourceLongDo {
|
||||
return r.withDO(r.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) LeftJoin(table schema.Tabler, on ...field.Expr) *resourceLongDo {
|
||||
return r.withDO(r.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) RightJoin(table schema.Tabler, on ...field.Expr) *resourceLongDo {
|
||||
return r.withDO(r.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Group(cols ...field.Expr) *resourceLongDo {
|
||||
return r.withDO(r.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Having(conds ...gen.Condition) *resourceLongDo {
|
||||
return r.withDO(r.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Limit(limit int) *resourceLongDo {
|
||||
return r.withDO(r.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Offset(offset int) *resourceLongDo {
|
||||
return r.withDO(r.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *resourceLongDo {
|
||||
return r.withDO(r.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Unscoped() *resourceLongDo {
|
||||
return r.withDO(r.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Create(values ...*models.ResourceLong) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Create(values)
|
||||
}
|
||||
|
||||
func (r resourceLongDo) CreateInBatches(values []*models.ResourceLong, batchSize int) error {
|
||||
return r.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (r resourceLongDo) Save(values ...*models.ResourceLong) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Save(values)
|
||||
}
|
||||
|
||||
func (r resourceLongDo) First() (*models.ResourceLong, error) {
|
||||
if result, err := r.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourceLong), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Take() (*models.ResourceLong, error) {
|
||||
if result, err := r.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourceLong), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Last() (*models.ResourceLong, error) {
|
||||
if result, err := r.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourceLong), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Find() ([]*models.ResourceLong, error) {
|
||||
result, err := r.DO.Find()
|
||||
return result.([]*models.ResourceLong), err
|
||||
}
|
||||
|
||||
func (r resourceLongDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.ResourceLong, err error) {
|
||||
buf := make([]*models.ResourceLong, 0, batchSize)
|
||||
err = r.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (r resourceLongDo) FindInBatches(result *[]*models.ResourceLong, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return r.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Attrs(attrs ...field.AssignExpr) *resourceLongDo {
|
||||
return r.withDO(r.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Assign(attrs ...field.AssignExpr) *resourceLongDo {
|
||||
return r.withDO(r.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Joins(fields ...field.RelationField) *resourceLongDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Joins(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Preload(fields ...field.RelationField) *resourceLongDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Preload(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r resourceLongDo) FirstOrInit() (*models.ResourceLong, error) {
|
||||
if result, err := r.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourceLong), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourceLongDo) FirstOrCreate() (*models.ResourceLong, error) {
|
||||
if result, err := r.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourceLong), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourceLongDo) FindByPage(offset int, limit int) (result []*models.ResourceLong, count int64, err error) {
|
||||
result, err = r.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = r.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (r resourceLongDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = r.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = r.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Scan(result interface{}) (err error) {
|
||||
return r.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (r resourceLongDo) Delete(models ...*models.ResourceLong) (result gen.ResultInfo, err error) {
|
||||
return r.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (r *resourceLongDo) withDO(do gen.Dao) *resourceLongDo {
|
||||
r.DO = *do.(*gen.DO)
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user