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.
372 lines
10 KiB
Go
372 lines
10 KiB
Go
// 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 newUserBehavior(db *gorm.DB, opts ...gen.DOOption) userBehavior {
|
|
_userBehavior := userBehavior{}
|
|
|
|
_userBehavior.userBehaviorDo.UseDB(db, opts...)
|
|
_userBehavior.userBehaviorDo.UseModel(&model.UserBehavior{})
|
|
|
|
tableName := _userBehavior.userBehaviorDo.TableName()
|
|
_userBehavior.ALL = field.NewAsterisk(tableName)
|
|
_userBehavior.ID = field.NewInt64(tableName, "id")
|
|
_userBehavior.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
_userBehavior.APIURL = field.NewString(tableName, "api_url")
|
|
_userBehavior.Desc = field.NewString(tableName, "desc")
|
|
_userBehavior.CompanyID = field.NewInt64(tableName, "company_id")
|
|
_userBehavior.UserID = field.NewInt64(tableName, "user_id")
|
|
_userBehavior.ProjectID = field.NewString(tableName, "project_id")
|
|
_userBehavior.IP = field.NewString(tableName, "ip")
|
|
_userBehavior.UaData = field.NewString(tableName, "ua_data")
|
|
_userBehavior.Req = field.NewString(tableName, "req")
|
|
_userBehavior.Res = field.NewString(tableName, "res")
|
|
|
|
_userBehavior.fillFieldMap()
|
|
|
|
return _userBehavior
|
|
}
|
|
|
|
type userBehavior struct {
|
|
userBehaviorDo userBehaviorDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int64
|
|
CreatedAt field.Int64
|
|
APIURL field.String // 请求的接口
|
|
Desc field.String // 接口描述
|
|
CompanyID field.Int64 // 公司id
|
|
UserID field.Int64 // 用户id
|
|
ProjectID field.String // 项目hash_id
|
|
IP field.String // 操作ip
|
|
UaData field.String // 部分ua头数据
|
|
Req field.String // 请求数据
|
|
Res field.String // 操作结果
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (u userBehavior) Table(newTableName string) *userBehavior {
|
|
u.userBehaviorDo.UseTable(newTableName)
|
|
return u.updateTableName(newTableName)
|
|
}
|
|
|
|
func (u userBehavior) As(alias string) *userBehavior {
|
|
u.userBehaviorDo.DO = *(u.userBehaviorDo.As(alias).(*gen.DO))
|
|
return u.updateTableName(alias)
|
|
}
|
|
|
|
func (u *userBehavior) updateTableName(table string) *userBehavior {
|
|
u.ALL = field.NewAsterisk(table)
|
|
u.ID = field.NewInt64(table, "id")
|
|
u.CreatedAt = field.NewInt64(table, "created_at")
|
|
u.APIURL = field.NewString(table, "api_url")
|
|
u.Desc = field.NewString(table, "desc")
|
|
u.CompanyID = field.NewInt64(table, "company_id")
|
|
u.UserID = field.NewInt64(table, "user_id")
|
|
u.ProjectID = field.NewString(table, "project_id")
|
|
u.IP = field.NewString(table, "ip")
|
|
u.UaData = field.NewString(table, "ua_data")
|
|
u.Req = field.NewString(table, "req")
|
|
u.Res = field.NewString(table, "res")
|
|
|
|
u.fillFieldMap()
|
|
|
|
return u
|
|
}
|
|
|
|
func (u *userBehavior) WithContext(ctx context.Context) *userBehaviorDo {
|
|
return u.userBehaviorDo.WithContext(ctx)
|
|
}
|
|
|
|
func (u userBehavior) TableName() string { return u.userBehaviorDo.TableName() }
|
|
|
|
func (u userBehavior) Alias() string { return u.userBehaviorDo.Alias() }
|
|
|
|
func (u *userBehavior) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
_f, ok := u.fieldMap[fieldName]
|
|
if !ok || _f == nil {
|
|
return nil, false
|
|
}
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
return _oe, ok
|
|
}
|
|
|
|
func (u *userBehavior) fillFieldMap() {
|
|
u.fieldMap = make(map[string]field.Expr, 11)
|
|
u.fieldMap["id"] = u.ID
|
|
u.fieldMap["created_at"] = u.CreatedAt
|
|
u.fieldMap["api_url"] = u.APIURL
|
|
u.fieldMap["desc"] = u.Desc
|
|
u.fieldMap["company_id"] = u.CompanyID
|
|
u.fieldMap["user_id"] = u.UserID
|
|
u.fieldMap["project_id"] = u.ProjectID
|
|
u.fieldMap["ip"] = u.IP
|
|
u.fieldMap["ua_data"] = u.UaData
|
|
u.fieldMap["req"] = u.Req
|
|
u.fieldMap["res"] = u.Res
|
|
}
|
|
|
|
func (u userBehavior) clone(db *gorm.DB) userBehavior {
|
|
u.userBehaviorDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return u
|
|
}
|
|
|
|
func (u userBehavior) replaceDB(db *gorm.DB) userBehavior {
|
|
u.userBehaviorDo.ReplaceDB(db)
|
|
return u
|
|
}
|
|
|
|
type userBehaviorDo struct{ gen.DO }
|
|
|
|
func (u userBehaviorDo) Debug() *userBehaviorDo {
|
|
return u.withDO(u.DO.Debug())
|
|
}
|
|
|
|
func (u userBehaviorDo) WithContext(ctx context.Context) *userBehaviorDo {
|
|
return u.withDO(u.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (u userBehaviorDo) ReadDB() *userBehaviorDo {
|
|
return u.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (u userBehaviorDo) WriteDB() *userBehaviorDo {
|
|
return u.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (u userBehaviorDo) Session(config *gorm.Session) *userBehaviorDo {
|
|
return u.withDO(u.DO.Session(config))
|
|
}
|
|
|
|
func (u userBehaviorDo) Clauses(conds ...clause.Expression) *userBehaviorDo {
|
|
return u.withDO(u.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (u userBehaviorDo) Returning(value interface{}, columns ...string) *userBehaviorDo {
|
|
return u.withDO(u.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (u userBehaviorDo) Not(conds ...gen.Condition) *userBehaviorDo {
|
|
return u.withDO(u.DO.Not(conds...))
|
|
}
|
|
|
|
func (u userBehaviorDo) Or(conds ...gen.Condition) *userBehaviorDo {
|
|
return u.withDO(u.DO.Or(conds...))
|
|
}
|
|
|
|
func (u userBehaviorDo) Select(conds ...field.Expr) *userBehaviorDo {
|
|
return u.withDO(u.DO.Select(conds...))
|
|
}
|
|
|
|
func (u userBehaviorDo) Where(conds ...gen.Condition) *userBehaviorDo {
|
|
return u.withDO(u.DO.Where(conds...))
|
|
}
|
|
|
|
func (u userBehaviorDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *userBehaviorDo {
|
|
return u.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
}
|
|
|
|
func (u userBehaviorDo) Order(conds ...field.Expr) *userBehaviorDo {
|
|
return u.withDO(u.DO.Order(conds...))
|
|
}
|
|
|
|
func (u userBehaviorDo) Distinct(cols ...field.Expr) *userBehaviorDo {
|
|
return u.withDO(u.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (u userBehaviorDo) Omit(cols ...field.Expr) *userBehaviorDo {
|
|
return u.withDO(u.DO.Omit(cols...))
|
|
}
|
|
|
|
func (u userBehaviorDo) Join(table schema.Tabler, on ...field.Expr) *userBehaviorDo {
|
|
return u.withDO(u.DO.Join(table, on...))
|
|
}
|
|
|
|
func (u userBehaviorDo) LeftJoin(table schema.Tabler, on ...field.Expr) *userBehaviorDo {
|
|
return u.withDO(u.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (u userBehaviorDo) RightJoin(table schema.Tabler, on ...field.Expr) *userBehaviorDo {
|
|
return u.withDO(u.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (u userBehaviorDo) Group(cols ...field.Expr) *userBehaviorDo {
|
|
return u.withDO(u.DO.Group(cols...))
|
|
}
|
|
|
|
func (u userBehaviorDo) Having(conds ...gen.Condition) *userBehaviorDo {
|
|
return u.withDO(u.DO.Having(conds...))
|
|
}
|
|
|
|
func (u userBehaviorDo) Limit(limit int) *userBehaviorDo {
|
|
return u.withDO(u.DO.Limit(limit))
|
|
}
|
|
|
|
func (u userBehaviorDo) Offset(offset int) *userBehaviorDo {
|
|
return u.withDO(u.DO.Offset(offset))
|
|
}
|
|
|
|
func (u userBehaviorDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *userBehaviorDo {
|
|
return u.withDO(u.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (u userBehaviorDo) Unscoped() *userBehaviorDo {
|
|
return u.withDO(u.DO.Unscoped())
|
|
}
|
|
|
|
func (u userBehaviorDo) Create(values ...*model.UserBehavior) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return u.DO.Create(values)
|
|
}
|
|
|
|
func (u userBehaviorDo) CreateInBatches(values []*model.UserBehavior, batchSize int) error {
|
|
return u.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 (u userBehaviorDo) Save(values ...*model.UserBehavior) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return u.DO.Save(values)
|
|
}
|
|
|
|
func (u userBehaviorDo) First() (*model.UserBehavior, error) {
|
|
if result, err := u.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.UserBehavior), nil
|
|
}
|
|
}
|
|
|
|
func (u userBehaviorDo) Take() (*model.UserBehavior, error) {
|
|
if result, err := u.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.UserBehavior), nil
|
|
}
|
|
}
|
|
|
|
func (u userBehaviorDo) Last() (*model.UserBehavior, error) {
|
|
if result, err := u.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.UserBehavior), nil
|
|
}
|
|
}
|
|
|
|
func (u userBehaviorDo) Find() ([]*model.UserBehavior, error) {
|
|
result, err := u.DO.Find()
|
|
return result.([]*model.UserBehavior), err
|
|
}
|
|
|
|
func (u userBehaviorDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.UserBehavior, err error) {
|
|
buf := make([]*model.UserBehavior, 0, batchSize)
|
|
err = u.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 (u userBehaviorDo) FindInBatches(result *[]*model.UserBehavior, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return u.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (u userBehaviorDo) Attrs(attrs ...field.AssignExpr) *userBehaviorDo {
|
|
return u.withDO(u.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (u userBehaviorDo) Assign(attrs ...field.AssignExpr) *userBehaviorDo {
|
|
return u.withDO(u.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (u userBehaviorDo) Joins(fields ...field.RelationField) *userBehaviorDo {
|
|
for _, _f := range fields {
|
|
u = *u.withDO(u.DO.Joins(_f))
|
|
}
|
|
return &u
|
|
}
|
|
|
|
func (u userBehaviorDo) Preload(fields ...field.RelationField) *userBehaviorDo {
|
|
for _, _f := range fields {
|
|
u = *u.withDO(u.DO.Preload(_f))
|
|
}
|
|
return &u
|
|
}
|
|
|
|
func (u userBehaviorDo) FirstOrInit() (*model.UserBehavior, error) {
|
|
if result, err := u.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.UserBehavior), nil
|
|
}
|
|
}
|
|
|
|
func (u userBehaviorDo) FirstOrCreate() (*model.UserBehavior, error) {
|
|
if result, err := u.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.UserBehavior), nil
|
|
}
|
|
}
|
|
|
|
func (u userBehaviorDo) FindByPage(offset int, limit int) (result []*model.UserBehavior, count int64, err error) {
|
|
result, err = u.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 = u.Offset(-1).Limit(-1).Count()
|
|
return
|
|
}
|
|
|
|
func (u userBehaviorDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
count, err = u.Count()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = u.Offset(offset).Limit(limit).Scan(result)
|
|
return
|
|
}
|
|
|
|
func (u userBehaviorDo) Scan(result interface{}) (err error) {
|
|
return u.DO.Scan(result)
|
|
}
|
|
|
|
func (u userBehaviorDo) Delete(models ...*model.UserBehavior) (result gen.ResultInfo, err error) {
|
|
return u.DO.Delete(models)
|
|
}
|
|
|
|
func (u *userBehaviorDo) withDO(do gen.Dao) *userBehaviorDo {
|
|
u.DO = *do.(*gen.DO)
|
|
return u
|
|
}
|