|
|
// 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 newFissionPointsLog(db *gorm.DB, opts ...gen.DOOption) fissionPointsLog {
|
|
|
_fissionPointsLog := fissionPointsLog{}
|
|
|
|
|
|
_fissionPointsLog.fissionPointsLogDo.UseDB(db, opts...)
|
|
|
_fissionPointsLog.fissionPointsLogDo.UseModel(&model.FissionPointsLog{})
|
|
|
|
|
|
tableName := _fissionPointsLog.fissionPointsLogDo.TableName()
|
|
|
_fissionPointsLog.ALL = field.NewAsterisk(tableName)
|
|
|
_fissionPointsLog.ID = field.NewInt64(tableName, "id")
|
|
|
_fissionPointsLog.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_fissionPointsLog.UpdatedAt = field.NewInt64(tableName, "updated_at")
|
|
|
_fissionPointsLog.CampaignID = field.NewInt64(tableName, "campaign_id")
|
|
|
_fissionPointsLog.UserID = field.NewInt64(tableName, "user_id")
|
|
|
_fissionPointsLog.State = field.NewString(tableName, "state")
|
|
|
_fissionPointsLog.Num = field.NewInt32(tableName, "num")
|
|
|
_fissionPointsLog.Source = field.NewString(tableName, "source")
|
|
|
_fissionPointsLog.ReqURL = field.NewString(tableName, "req_url")
|
|
|
_fissionPointsLog.Req = field.NewString(tableName, "req")
|
|
|
_fissionPointsLog.Resp = field.NewString(tableName, "resp")
|
|
|
_fissionPointsLog.RespCode = field.NewInt32(tableName, "resp_code")
|
|
|
_fissionPointsLog.ReqTime = field.NewInt64(tableName, "req_time")
|
|
|
_fissionPointsLog.ErrMsg = field.NewString(tableName, "err_msg")
|
|
|
_fissionPointsLog.OtherData = field.NewString(tableName, "other_data")
|
|
|
_fissionPointsLog.Token = field.NewString(tableName, "token")
|
|
|
_fissionPointsLog.ReqHeader = field.NewString(tableName, "req_header")
|
|
|
|
|
|
_fissionPointsLog.fillFieldMap()
|
|
|
|
|
|
return _fissionPointsLog
|
|
|
}
|
|
|
|
|
|
type fissionPointsLog struct {
|
|
|
fissionPointsLogDo fissionPointsLogDo
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
ID field.Int64
|
|
|
CreatedAt field.Int64
|
|
|
UpdatedAt field.Int64
|
|
|
CampaignID field.Int64 // 活动id(fission_campaign表)
|
|
|
UserID field.Int64 // 用户id(fission_user表)
|
|
|
State field.String // 类型(deduct - 扣除, gain - 获得)
|
|
|
Num field.Int32 // 数量
|
|
|
Source field.String // 来源标识
|
|
|
ReqURL field.String // 请求地址
|
|
|
Req field.String // 请求数据
|
|
|
Resp field.String // 返回数据
|
|
|
RespCode field.Int32 // 返回状态码
|
|
|
ReqTime field.Int64 // 请求时长(单位:ms)
|
|
|
ErrMsg field.String // 错误信息
|
|
|
OtherData field.String // 其他数据信息
|
|
|
Token field.String // 请求token
|
|
|
ReqHeader field.String // 请求头数据
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLog) Table(newTableName string) *fissionPointsLog {
|
|
|
f.fissionPointsLogDo.UseTable(newTableName)
|
|
|
return f.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLog) As(alias string) *fissionPointsLog {
|
|
|
f.fissionPointsLogDo.DO = *(f.fissionPointsLogDo.As(alias).(*gen.DO))
|
|
|
return f.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (f *fissionPointsLog) updateTableName(table string) *fissionPointsLog {
|
|
|
f.ALL = field.NewAsterisk(table)
|
|
|
f.ID = field.NewInt64(table, "id")
|
|
|
f.CreatedAt = field.NewInt64(table, "created_at")
|
|
|
f.UpdatedAt = field.NewInt64(table, "updated_at")
|
|
|
f.CampaignID = field.NewInt64(table, "campaign_id")
|
|
|
f.UserID = field.NewInt64(table, "user_id")
|
|
|
f.State = field.NewString(table, "state")
|
|
|
f.Num = field.NewInt32(table, "num")
|
|
|
f.Source = field.NewString(table, "source")
|
|
|
f.ReqURL = field.NewString(table, "req_url")
|
|
|
f.Req = field.NewString(table, "req")
|
|
|
f.Resp = field.NewString(table, "resp")
|
|
|
f.RespCode = field.NewInt32(table, "resp_code")
|
|
|
f.ReqTime = field.NewInt64(table, "req_time")
|
|
|
f.ErrMsg = field.NewString(table, "err_msg")
|
|
|
f.OtherData = field.NewString(table, "other_data")
|
|
|
f.Token = field.NewString(table, "token")
|
|
|
f.ReqHeader = field.NewString(table, "req_header")
|
|
|
|
|
|
f.fillFieldMap()
|
|
|
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f *fissionPointsLog) WithContext(ctx context.Context) *fissionPointsLogDo {
|
|
|
return f.fissionPointsLogDo.WithContext(ctx)
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLog) TableName() string { return f.fissionPointsLogDo.TableName() }
|
|
|
|
|
|
func (f fissionPointsLog) Alias() string { return f.fissionPointsLogDo.Alias() }
|
|
|
|
|
|
func (f *fissionPointsLog) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
|
_f, ok := f.fieldMap[fieldName]
|
|
|
if !ok || _f == nil {
|
|
|
return nil, false
|
|
|
}
|
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
|
return _oe, ok
|
|
|
}
|
|
|
|
|
|
func (f *fissionPointsLog) fillFieldMap() {
|
|
|
f.fieldMap = make(map[string]field.Expr, 17)
|
|
|
f.fieldMap["id"] = f.ID
|
|
|
f.fieldMap["created_at"] = f.CreatedAt
|
|
|
f.fieldMap["updated_at"] = f.UpdatedAt
|
|
|
f.fieldMap["campaign_id"] = f.CampaignID
|
|
|
f.fieldMap["user_id"] = f.UserID
|
|
|
f.fieldMap["state"] = f.State
|
|
|
f.fieldMap["num"] = f.Num
|
|
|
f.fieldMap["source"] = f.Source
|
|
|
f.fieldMap["req_url"] = f.ReqURL
|
|
|
f.fieldMap["req"] = f.Req
|
|
|
f.fieldMap["resp"] = f.Resp
|
|
|
f.fieldMap["resp_code"] = f.RespCode
|
|
|
f.fieldMap["req_time"] = f.ReqTime
|
|
|
f.fieldMap["err_msg"] = f.ErrMsg
|
|
|
f.fieldMap["other_data"] = f.OtherData
|
|
|
f.fieldMap["token"] = f.Token
|
|
|
f.fieldMap["req_header"] = f.ReqHeader
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLog) clone(db *gorm.DB) fissionPointsLog {
|
|
|
f.fissionPointsLogDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLog) replaceDB(db *gorm.DB) fissionPointsLog {
|
|
|
f.fissionPointsLogDo.ReplaceDB(db)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
type fissionPointsLogDo struct{ gen.DO }
|
|
|
|
|
|
func (f fissionPointsLogDo) Debug() *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) WithContext(ctx context.Context) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) ReadDB() *fissionPointsLogDo {
|
|
|
return f.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) WriteDB() *fissionPointsLogDo {
|
|
|
return f.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Session(config *gorm.Session) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Clauses(conds ...clause.Expression) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Returning(value interface{}, columns ...string) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Not(conds ...gen.Condition) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Or(conds ...gen.Condition) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Select(conds ...field.Expr) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Where(conds ...gen.Condition) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *fissionPointsLogDo {
|
|
|
return f.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Order(conds ...field.Expr) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Distinct(cols ...field.Expr) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Omit(cols ...field.Expr) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Join(table schema.Tabler, on ...field.Expr) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) LeftJoin(table schema.Tabler, on ...field.Expr) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) RightJoin(table schema.Tabler, on ...field.Expr) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Group(cols ...field.Expr) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Having(conds ...gen.Condition) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Limit(limit int) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Offset(offset int) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Unscoped() *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Create(values ...*model.FissionPointsLog) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) CreateInBatches(values []*model.FissionPointsLog, batchSize int) error {
|
|
|
return f.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 (f fissionPointsLogDo) Save(values ...*model.FissionPointsLog) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) First() (*model.FissionPointsLog, error) {
|
|
|
if result, err := f.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionPointsLog), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Take() (*model.FissionPointsLog, error) {
|
|
|
if result, err := f.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionPointsLog), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Last() (*model.FissionPointsLog, error) {
|
|
|
if result, err := f.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionPointsLog), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Find() ([]*model.FissionPointsLog, error) {
|
|
|
result, err := f.DO.Find()
|
|
|
return result.([]*model.FissionPointsLog), err
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.FissionPointsLog, err error) {
|
|
|
buf := make([]*model.FissionPointsLog, 0, batchSize)
|
|
|
err = f.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 (f fissionPointsLogDo) FindInBatches(result *[]*model.FissionPointsLog, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return f.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Attrs(attrs ...field.AssignExpr) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Assign(attrs ...field.AssignExpr) *fissionPointsLogDo {
|
|
|
return f.withDO(f.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Joins(fields ...field.RelationField) *fissionPointsLogDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Joins(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Preload(fields ...field.RelationField) *fissionPointsLogDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Preload(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) FirstOrInit() (*model.FissionPointsLog, error) {
|
|
|
if result, err := f.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionPointsLog), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) FirstOrCreate() (*model.FissionPointsLog, error) {
|
|
|
if result, err := f.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionPointsLog), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) FindByPage(offset int, limit int) (result []*model.FissionPointsLog, count int64, err error) {
|
|
|
result, err = f.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 = f.Offset(-1).Limit(-1).Count()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
|
count, err = f.Count()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
err = f.Offset(offset).Limit(limit).Scan(result)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Scan(result interface{}) (err error) {
|
|
|
return f.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (f fissionPointsLogDo) Delete(models ...*model.FissionPointsLog) (result gen.ResultInfo, err error) {
|
|
|
return f.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (f *fissionPointsLogDo) withDO(do gen.Dao) *fissionPointsLogDo {
|
|
|
f.DO = *do.(*gen.DO)
|
|
|
return f
|
|
|
}
|