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