You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

354 lines
8.7 KiB
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// 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 newTCoin(db *gorm.DB, opts ...gen.DOOption) tCoin {
_tCoin := tCoin{}
_tCoin.tCoinDo.UseDB(db, opts...)
_tCoin.tCoinDo.UseModel(&model.TCoin{})
tableName := _tCoin.tCoinDo.TableName()
_tCoin.ALL = field.NewAsterisk(tableName)
_tCoin.ID = field.NewInt64(tableName, "id")
_tCoin.CreatedAt = field.NewInt64(tableName, "created_at")
_tCoin.UpdatedAt = field.NewInt64(tableName, "updated_at")
_tCoin.ProjectID = field.NewInt64(tableName, "project_id")
_tCoin.Title = field.NewString(tableName, "title")
_tCoin.OpenPush = field.NewInt8(tableName, "open_push")
_tCoin.ExpSelect = field.NewString(tableName, "exp_select")
_tCoin.fillFieldMap()
return _tCoin
}
type tCoin struct {
tCoinDo tCoinDo
ALL field.Asterisk
ID field.Int64
CreatedAt field.Int64
UpdatedAt field.Int64
ProjectID field.Int64 // 项目id(project表)
Title field.String // 积分标题
OpenPush field.Int8 // 开启积分获得推送
ExpSelect field.String // 有效期选项
fieldMap map[string]field.Expr
}
func (t tCoin) Table(newTableName string) *tCoin {
t.tCoinDo.UseTable(newTableName)
return t.updateTableName(newTableName)
}
func (t tCoin) As(alias string) *tCoin {
t.tCoinDo.DO = *(t.tCoinDo.As(alias).(*gen.DO))
return t.updateTableName(alias)
}
func (t *tCoin) updateTableName(table string) *tCoin {
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.ProjectID = field.NewInt64(table, "project_id")
t.Title = field.NewString(table, "title")
t.OpenPush = field.NewInt8(table, "open_push")
t.ExpSelect = field.NewString(table, "exp_select")
t.fillFieldMap()
return t
}
func (t *tCoin) WithContext(ctx context.Context) *tCoinDo { return t.tCoinDo.WithContext(ctx) }
func (t tCoin) TableName() string { return t.tCoinDo.TableName() }
func (t tCoin) Alias() string { return t.tCoinDo.Alias() }
func (t *tCoin) 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 *tCoin) fillFieldMap() {
t.fieldMap = make(map[string]field.Expr, 7)
t.fieldMap["id"] = t.ID
t.fieldMap["created_at"] = t.CreatedAt
t.fieldMap["updated_at"] = t.UpdatedAt
t.fieldMap["project_id"] = t.ProjectID
t.fieldMap["title"] = t.Title
t.fieldMap["open_push"] = t.OpenPush
t.fieldMap["exp_select"] = t.ExpSelect
}
func (t tCoin) clone(db *gorm.DB) tCoin {
t.tCoinDo.ReplaceConnPool(db.Statement.ConnPool)
return t
}
func (t tCoin) replaceDB(db *gorm.DB) tCoin {
t.tCoinDo.ReplaceDB(db)
return t
}
type tCoinDo struct{ gen.DO }
func (t tCoinDo) Debug() *tCoinDo {
return t.withDO(t.DO.Debug())
}
func (t tCoinDo) WithContext(ctx context.Context) *tCoinDo {
return t.withDO(t.DO.WithContext(ctx))
}
func (t tCoinDo) ReadDB() *tCoinDo {
return t.Clauses(dbresolver.Read)
}
func (t tCoinDo) WriteDB() *tCoinDo {
return t.Clauses(dbresolver.Write)
}
func (t tCoinDo) Session(config *gorm.Session) *tCoinDo {
return t.withDO(t.DO.Session(config))
}
func (t tCoinDo) Clauses(conds ...clause.Expression) *tCoinDo {
return t.withDO(t.DO.Clauses(conds...))
}
func (t tCoinDo) Returning(value interface{}, columns ...string) *tCoinDo {
return t.withDO(t.DO.Returning(value, columns...))
}
func (t tCoinDo) Not(conds ...gen.Condition) *tCoinDo {
return t.withDO(t.DO.Not(conds...))
}
func (t tCoinDo) Or(conds ...gen.Condition) *tCoinDo {
return t.withDO(t.DO.Or(conds...))
}
func (t tCoinDo) Select(conds ...field.Expr) *tCoinDo {
return t.withDO(t.DO.Select(conds...))
}
func (t tCoinDo) Where(conds ...gen.Condition) *tCoinDo {
return t.withDO(t.DO.Where(conds...))
}
func (t tCoinDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *tCoinDo {
return t.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
}
func (t tCoinDo) Order(conds ...field.Expr) *tCoinDo {
return t.withDO(t.DO.Order(conds...))
}
func (t tCoinDo) Distinct(cols ...field.Expr) *tCoinDo {
return t.withDO(t.DO.Distinct(cols...))
}
func (t tCoinDo) Omit(cols ...field.Expr) *tCoinDo {
return t.withDO(t.DO.Omit(cols...))
}
func (t tCoinDo) Join(table schema.Tabler, on ...field.Expr) *tCoinDo {
return t.withDO(t.DO.Join(table, on...))
}
func (t tCoinDo) LeftJoin(table schema.Tabler, on ...field.Expr) *tCoinDo {
return t.withDO(t.DO.LeftJoin(table, on...))
}
func (t tCoinDo) RightJoin(table schema.Tabler, on ...field.Expr) *tCoinDo {
return t.withDO(t.DO.RightJoin(table, on...))
}
func (t tCoinDo) Group(cols ...field.Expr) *tCoinDo {
return t.withDO(t.DO.Group(cols...))
}
func (t tCoinDo) Having(conds ...gen.Condition) *tCoinDo {
return t.withDO(t.DO.Having(conds...))
}
func (t tCoinDo) Limit(limit int) *tCoinDo {
return t.withDO(t.DO.Limit(limit))
}
func (t tCoinDo) Offset(offset int) *tCoinDo {
return t.withDO(t.DO.Offset(offset))
}
func (t tCoinDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *tCoinDo {
return t.withDO(t.DO.Scopes(funcs...))
}
func (t tCoinDo) Unscoped() *tCoinDo {
return t.withDO(t.DO.Unscoped())
}
func (t tCoinDo) Create(values ...*model.TCoin) error {
if len(values) == 0 {
return nil
}
return t.DO.Create(values)
}
func (t tCoinDo) CreateInBatches(values []*model.TCoin, 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 tCoinDo) Save(values ...*model.TCoin) error {
if len(values) == 0 {
return nil
}
return t.DO.Save(values)
}
func (t tCoinDo) First() (*model.TCoin, error) {
if result, err := t.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.TCoin), nil
}
}
func (t tCoinDo) Take() (*model.TCoin, error) {
if result, err := t.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.TCoin), nil
}
}
func (t tCoinDo) Last() (*model.TCoin, error) {
if result, err := t.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.TCoin), nil
}
}
func (t tCoinDo) Find() ([]*model.TCoin, error) {
result, err := t.DO.Find()
return result.([]*model.TCoin), err
}
func (t tCoinDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TCoin, err error) {
buf := make([]*model.TCoin, 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 tCoinDo) FindInBatches(result *[]*model.TCoin, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return t.DO.FindInBatches(result, batchSize, fc)
}
func (t tCoinDo) Attrs(attrs ...field.AssignExpr) *tCoinDo {
return t.withDO(t.DO.Attrs(attrs...))
}
func (t tCoinDo) Assign(attrs ...field.AssignExpr) *tCoinDo {
return t.withDO(t.DO.Assign(attrs...))
}
func (t tCoinDo) Joins(fields ...field.RelationField) *tCoinDo {
for _, _f := range fields {
t = *t.withDO(t.DO.Joins(_f))
}
return &t
}
func (t tCoinDo) Preload(fields ...field.RelationField) *tCoinDo {
for _, _f := range fields {
t = *t.withDO(t.DO.Preload(_f))
}
return &t
}
func (t tCoinDo) FirstOrInit() (*model.TCoin, error) {
if result, err := t.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.TCoin), nil
}
}
func (t tCoinDo) FirstOrCreate() (*model.TCoin, error) {
if result, err := t.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.TCoin), nil
}
}
func (t tCoinDo) FindByPage(offset int, limit int) (result []*model.TCoin, 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 tCoinDo) 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 tCoinDo) Scan(result interface{}) (err error) {
return t.DO.Scan(result)
}
func (t tCoinDo) Delete(models ...*model.TCoin) (result gen.ResultInfo, err error) {
return t.DO.Delete(models)
}
func (t *tCoinDo) withDO(do gen.Dao) *tCoinDo {
t.DO = *do.(*gen.DO)
return t
}