|
|
// 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 newProjectUser(db *gorm.DB, opts ...gen.DOOption) projectUser {
|
|
|
_projectUser := projectUser{}
|
|
|
|
|
|
_projectUser.projectUserDo.UseDB(db, opts...)
|
|
|
_projectUser.projectUserDo.UseModel(&model.ProjectUser{})
|
|
|
|
|
|
tableName := _projectUser.projectUserDo.TableName()
|
|
|
_projectUser.ALL = field.NewAsterisk(tableName)
|
|
|
_projectUser.ID = field.NewInt64(tableName, "id")
|
|
|
_projectUser.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_projectUser.ProjectID = field.NewInt64(tableName, "project_id")
|
|
|
_projectUser.UserID = field.NewString(tableName, "user_id")
|
|
|
|
|
|
_projectUser.fillFieldMap()
|
|
|
|
|
|
return _projectUser
|
|
|
}
|
|
|
|
|
|
type projectUser struct {
|
|
|
projectUserDo projectUserDo
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
ID field.Int64
|
|
|
CreatedAt field.Int64
|
|
|
ProjectID field.Int64 // 项目id(project表)
|
|
|
UserID field.String // 第三方的唯一用户id
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
}
|
|
|
|
|
|
func (p projectUser) Table(newTableName string) *projectUser {
|
|
|
p.projectUserDo.UseTable(newTableName)
|
|
|
return p.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (p projectUser) As(alias string) *projectUser {
|
|
|
p.projectUserDo.DO = *(p.projectUserDo.As(alias).(*gen.DO))
|
|
|
return p.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (p *projectUser) updateTableName(table string) *projectUser {
|
|
|
p.ALL = field.NewAsterisk(table)
|
|
|
p.ID = field.NewInt64(table, "id")
|
|
|
p.CreatedAt = field.NewInt64(table, "created_at")
|
|
|
p.ProjectID = field.NewInt64(table, "project_id")
|
|
|
p.UserID = field.NewString(table, "user_id")
|
|
|
|
|
|
p.fillFieldMap()
|
|
|
|
|
|
return p
|
|
|
}
|
|
|
|
|
|
func (p *projectUser) WithContext(ctx context.Context) *projectUserDo {
|
|
|
return p.projectUserDo.WithContext(ctx)
|
|
|
}
|
|
|
|
|
|
func (p projectUser) TableName() string { return p.projectUserDo.TableName() }
|
|
|
|
|
|
func (p projectUser) Alias() string { return p.projectUserDo.Alias() }
|
|
|
|
|
|
func (p *projectUser) 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 *projectUser) fillFieldMap() {
|
|
|
p.fieldMap = make(map[string]field.Expr, 4)
|
|
|
p.fieldMap["id"] = p.ID
|
|
|
p.fieldMap["created_at"] = p.CreatedAt
|
|
|
p.fieldMap["project_id"] = p.ProjectID
|
|
|
p.fieldMap["user_id"] = p.UserID
|
|
|
}
|
|
|
|
|
|
func (p projectUser) clone(db *gorm.DB) projectUser {
|
|
|
p.projectUserDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return p
|
|
|
}
|
|
|
|
|
|
func (p projectUser) replaceDB(db *gorm.DB) projectUser {
|
|
|
p.projectUserDo.ReplaceDB(db)
|
|
|
return p
|
|
|
}
|
|
|
|
|
|
type projectUserDo struct{ gen.DO }
|
|
|
|
|
|
func (p projectUserDo) Debug() *projectUserDo {
|
|
|
return p.withDO(p.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) WithContext(ctx context.Context) *projectUserDo {
|
|
|
return p.withDO(p.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) ReadDB() *projectUserDo {
|
|
|
return p.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) WriteDB() *projectUserDo {
|
|
|
return p.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Session(config *gorm.Session) *projectUserDo {
|
|
|
return p.withDO(p.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Clauses(conds ...clause.Expression) *projectUserDo {
|
|
|
return p.withDO(p.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Returning(value interface{}, columns ...string) *projectUserDo {
|
|
|
return p.withDO(p.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Not(conds ...gen.Condition) *projectUserDo {
|
|
|
return p.withDO(p.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Or(conds ...gen.Condition) *projectUserDo {
|
|
|
return p.withDO(p.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Select(conds ...field.Expr) *projectUserDo {
|
|
|
return p.withDO(p.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Where(conds ...gen.Condition) *projectUserDo {
|
|
|
return p.withDO(p.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *projectUserDo {
|
|
|
return p.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Order(conds ...field.Expr) *projectUserDo {
|
|
|
return p.withDO(p.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Distinct(cols ...field.Expr) *projectUserDo {
|
|
|
return p.withDO(p.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Omit(cols ...field.Expr) *projectUserDo {
|
|
|
return p.withDO(p.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Join(table schema.Tabler, on ...field.Expr) *projectUserDo {
|
|
|
return p.withDO(p.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) LeftJoin(table schema.Tabler, on ...field.Expr) *projectUserDo {
|
|
|
return p.withDO(p.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) RightJoin(table schema.Tabler, on ...field.Expr) *projectUserDo {
|
|
|
return p.withDO(p.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Group(cols ...field.Expr) *projectUserDo {
|
|
|
return p.withDO(p.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Having(conds ...gen.Condition) *projectUserDo {
|
|
|
return p.withDO(p.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Limit(limit int) *projectUserDo {
|
|
|
return p.withDO(p.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Offset(offset int) *projectUserDo {
|
|
|
return p.withDO(p.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *projectUserDo {
|
|
|
return p.withDO(p.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Unscoped() *projectUserDo {
|
|
|
return p.withDO(p.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Create(values ...*model.ProjectUser) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return p.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) CreateInBatches(values []*model.ProjectUser, 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 projectUserDo) Save(values ...*model.ProjectUser) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return p.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) First() (*model.ProjectUser, error) {
|
|
|
if result, err := p.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUser), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Take() (*model.ProjectUser, error) {
|
|
|
if result, err := p.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUser), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Last() (*model.ProjectUser, error) {
|
|
|
if result, err := p.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUser), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Find() ([]*model.ProjectUser, error) {
|
|
|
result, err := p.DO.Find()
|
|
|
return result.([]*model.ProjectUser), err
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectUser, err error) {
|
|
|
buf := make([]*model.ProjectUser, 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 projectUserDo) FindInBatches(result *[]*model.ProjectUser, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return p.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Attrs(attrs ...field.AssignExpr) *projectUserDo {
|
|
|
return p.withDO(p.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Assign(attrs ...field.AssignExpr) *projectUserDo {
|
|
|
return p.withDO(p.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Joins(fields ...field.RelationField) *projectUserDo {
|
|
|
for _, _f := range fields {
|
|
|
p = *p.withDO(p.DO.Joins(_f))
|
|
|
}
|
|
|
return &p
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Preload(fields ...field.RelationField) *projectUserDo {
|
|
|
for _, _f := range fields {
|
|
|
p = *p.withDO(p.DO.Preload(_f))
|
|
|
}
|
|
|
return &p
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) FirstOrInit() (*model.ProjectUser, error) {
|
|
|
if result, err := p.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUser), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) FirstOrCreate() (*model.ProjectUser, error) {
|
|
|
if result, err := p.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.ProjectUser), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) FindByPage(offset int, limit int) (result []*model.ProjectUser, 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 projectUserDo) 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 projectUserDo) Scan(result interface{}) (err error) {
|
|
|
return p.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (p projectUserDo) Delete(models ...*model.ProjectUser) (result gen.ResultInfo, err error) {
|
|
|
return p.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (p *projectUserDo) withDO(do gen.Dao) *projectUserDo {
|
|
|
p.DO = *do.(*gen.DO)
|
|
|
return p
|
|
|
}
|