|
|
// 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 dao
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
|
|
|
"gorm.io/gorm"
|
|
|
"gorm.io/gorm/clause"
|
|
|
"gorm.io/gorm/schema"
|
|
|
|
|
|
"gorm.io/gen"
|
|
|
"gorm.io/gen/field"
|
|
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
|
|
"joybuywork/internal/repository/model"
|
|
|
)
|
|
|
|
|
|
func newTCoinLang(db *gorm.DB, opts ...gen.DOOption) tCoinLang {
|
|
|
_tCoinLang := tCoinLang{}
|
|
|
|
|
|
_tCoinLang.tCoinLangDo.UseDB(db, opts...)
|
|
|
_tCoinLang.tCoinLangDo.UseModel(&model.TCoinLang{})
|
|
|
|
|
|
tableName := _tCoinLang.tCoinLangDo.TableName()
|
|
|
_tCoinLang.ALL = field.NewAsterisk(tableName)
|
|
|
_tCoinLang.ID = field.NewInt64(tableName, "id")
|
|
|
_tCoinLang.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_tCoinLang.UpdatedAt = field.NewInt64(tableName, "updated_at")
|
|
|
_tCoinLang.TCoinID = field.NewInt64(tableName, "t_coin_id")
|
|
|
_tCoinLang.LangMark = field.NewString(tableName, "lang_mark")
|
|
|
_tCoinLang.Title = field.NewString(tableName, "title")
|
|
|
_tCoinLang.ImgURL = field.NewString(tableName, "img_url")
|
|
|
_tCoinLang.Rule = field.NewString(tableName, "rule")
|
|
|
_tCoinLang.IsDefault = field.NewInt8(tableName, "is_default")
|
|
|
|
|
|
_tCoinLang.fillFieldMap()
|
|
|
|
|
|
return _tCoinLang
|
|
|
}
|
|
|
|
|
|
type tCoinLang struct {
|
|
|
tCoinLangDo tCoinLangDo
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
ID field.Int64
|
|
|
CreatedAt field.Int64
|
|
|
UpdatedAt field.Int64
|
|
|
TCoinID field.Int64 // 积分配置id(t_coin表)
|
|
|
LangMark field.String // 语言标识
|
|
|
Title field.String // 积分标题
|
|
|
ImgURL field.String // 积分图片
|
|
|
Rule field.String // 积分规则
|
|
|
IsDefault field.Int8 // 是否默认
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
}
|
|
|
|
|
|
func (t tCoinLang) Table(newTableName string) *tCoinLang {
|
|
|
t.tCoinLangDo.UseTable(newTableName)
|
|
|
return t.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (t tCoinLang) As(alias string) *tCoinLang {
|
|
|
t.tCoinLangDo.DO = *(t.tCoinLangDo.As(alias).(*gen.DO))
|
|
|
return t.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (t *tCoinLang) updateTableName(table string) *tCoinLang {
|
|
|
t.ALL = field.NewAsterisk(table)
|
|
|
t.ID = field.NewInt64(table, "id")
|
|
|
t.CreatedAt = field.NewInt64(table, "created_at")
|
|
|
t.UpdatedAt = field.NewInt64(table, "updated_at")
|
|
|
t.TCoinID = field.NewInt64(table, "t_coin_id")
|
|
|
t.LangMark = field.NewString(table, "lang_mark")
|
|
|
t.Title = field.NewString(table, "title")
|
|
|
t.ImgURL = field.NewString(table, "img_url")
|
|
|
t.Rule = field.NewString(table, "rule")
|
|
|
t.IsDefault = field.NewInt8(table, "is_default")
|
|
|
|
|
|
t.fillFieldMap()
|
|
|
|
|
|
return t
|
|
|
}
|
|
|
|
|
|
func (t *tCoinLang) WithContext(ctx context.Context) *tCoinLangDo {
|
|
|
return t.tCoinLangDo.WithContext(ctx)
|
|
|
}
|
|
|
|
|
|
func (t tCoinLang) TableName() string { return t.tCoinLangDo.TableName() }
|
|
|
|
|
|
func (t tCoinLang) Alias() string { return t.tCoinLangDo.Alias() }
|
|
|
|
|
|
func (t *tCoinLang) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
|
_f, ok := t.fieldMap[fieldName]
|
|
|
if !ok || _f == nil {
|
|
|
return nil, false
|
|
|
}
|
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
|
return _oe, ok
|
|
|
}
|
|
|
|
|
|
func (t *tCoinLang) fillFieldMap() {
|
|
|
t.fieldMap = make(map[string]field.Expr, 9)
|
|
|
t.fieldMap["id"] = t.ID
|
|
|
t.fieldMap["created_at"] = t.CreatedAt
|
|
|
t.fieldMap["updated_at"] = t.UpdatedAt
|
|
|
t.fieldMap["t_coin_id"] = t.TCoinID
|
|
|
t.fieldMap["lang_mark"] = t.LangMark
|
|
|
t.fieldMap["title"] = t.Title
|
|
|
t.fieldMap["img_url"] = t.ImgURL
|
|
|
t.fieldMap["rule"] = t.Rule
|
|
|
t.fieldMap["is_default"] = t.IsDefault
|
|
|
}
|
|
|
|
|
|
func (t tCoinLang) clone(db *gorm.DB) tCoinLang {
|
|
|
t.tCoinLangDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return t
|
|
|
}
|
|
|
|
|
|
func (t tCoinLang) replaceDB(db *gorm.DB) tCoinLang {
|
|
|
t.tCoinLangDo.ReplaceDB(db)
|
|
|
return t
|
|
|
}
|
|
|
|
|
|
type tCoinLangDo struct{ gen.DO }
|
|
|
|
|
|
func (t tCoinLangDo) Debug() *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) WithContext(ctx context.Context) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) ReadDB() *tCoinLangDo {
|
|
|
return t.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) WriteDB() *tCoinLangDo {
|
|
|
return t.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Session(config *gorm.Session) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Clauses(conds ...clause.Expression) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Returning(value interface{}, columns ...string) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Not(conds ...gen.Condition) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Or(conds ...gen.Condition) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Select(conds ...field.Expr) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Where(conds ...gen.Condition) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *tCoinLangDo {
|
|
|
return t.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Order(conds ...field.Expr) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Distinct(cols ...field.Expr) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Omit(cols ...field.Expr) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Join(table schema.Tabler, on ...field.Expr) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) LeftJoin(table schema.Tabler, on ...field.Expr) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) RightJoin(table schema.Tabler, on ...field.Expr) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Group(cols ...field.Expr) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Having(conds ...gen.Condition) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Limit(limit int) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Offset(offset int) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Unscoped() *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Create(values ...*model.TCoinLang) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return t.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) CreateInBatches(values []*model.TCoinLang, batchSize int) error {
|
|
|
return t.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 (t tCoinLangDo) Save(values ...*model.TCoinLang) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return t.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) First() (*model.TCoinLang, error) {
|
|
|
if result, err := t.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.TCoinLang), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Take() (*model.TCoinLang, error) {
|
|
|
if result, err := t.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.TCoinLang), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Last() (*model.TCoinLang, error) {
|
|
|
if result, err := t.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.TCoinLang), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Find() ([]*model.TCoinLang, error) {
|
|
|
result, err := t.DO.Find()
|
|
|
return result.([]*model.TCoinLang), err
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TCoinLang, err error) {
|
|
|
buf := make([]*model.TCoinLang, 0, batchSize)
|
|
|
err = t.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 (t tCoinLangDo) FindInBatches(result *[]*model.TCoinLang, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return t.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Attrs(attrs ...field.AssignExpr) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Assign(attrs ...field.AssignExpr) *tCoinLangDo {
|
|
|
return t.withDO(t.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Joins(fields ...field.RelationField) *tCoinLangDo {
|
|
|
for _, _f := range fields {
|
|
|
t = *t.withDO(t.DO.Joins(_f))
|
|
|
}
|
|
|
return &t
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Preload(fields ...field.RelationField) *tCoinLangDo {
|
|
|
for _, _f := range fields {
|
|
|
t = *t.withDO(t.DO.Preload(_f))
|
|
|
}
|
|
|
return &t
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) FirstOrInit() (*model.TCoinLang, error) {
|
|
|
if result, err := t.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.TCoinLang), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) FirstOrCreate() (*model.TCoinLang, error) {
|
|
|
if result, err := t.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.TCoinLang), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) FindByPage(offset int, limit int) (result []*model.TCoinLang, count int64, err error) {
|
|
|
result, err = t.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 = t.Offset(-1).Limit(-1).Count()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
|
count, err = t.Count()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
err = t.Offset(offset).Limit(limit).Scan(result)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Scan(result interface{}) (err error) {
|
|
|
return t.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (t tCoinLangDo) Delete(models ...*model.TCoinLang) (result gen.ResultInfo, err error) {
|
|
|
return t.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (t *tCoinLangDo) withDO(do gen.Dao) *tCoinLangDo {
|
|
|
t.DO = *do.(*gen.DO)
|
|
|
return t
|
|
|
}
|