Files
quyun-v2/backend/database/models/user_comment_actions.query.gen.go
2025-12-29 09:30:49 +08:00

478 lines
14 KiB
Go

// Code generated by go.ipao.vip/gen. DO NOT EDIT.
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
package models
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"go.ipao.vip/gen"
"go.ipao.vip/gen/field"
"gorm.io/plugin/dbresolver"
)
func newUserCommentAction(db *gorm.DB, opts ...gen.DOOption) userCommentActionQuery {
_userCommentActionQuery := userCommentActionQuery{}
_userCommentActionQuery.userCommentActionQueryDo.UseDB(db, opts...)
_userCommentActionQuery.userCommentActionQueryDo.UseModel(&UserCommentAction{})
tableName := _userCommentActionQuery.userCommentActionQueryDo.TableName()
_userCommentActionQuery.ALL = field.NewAsterisk(tableName)
_userCommentActionQuery.ID = field.NewInt64(tableName, "id")
_userCommentActionQuery.UserID = field.NewInt64(tableName, "user_id")
_userCommentActionQuery.CommentID = field.NewInt64(tableName, "comment_id")
_userCommentActionQuery.Type = field.NewString(tableName, "type")
_userCommentActionQuery.CreatedAt = field.NewTime(tableName, "created_at")
_userCommentActionQuery.fillFieldMap()
return _userCommentActionQuery
}
type userCommentActionQuery struct {
userCommentActionQueryDo userCommentActionQueryDo
ALL field.Asterisk
ID field.Int64
UserID field.Int64
CommentID field.Int64
Type field.String
CreatedAt field.Time
fieldMap map[string]field.Expr
}
func (u userCommentActionQuery) Table(newTableName string) *userCommentActionQuery {
u.userCommentActionQueryDo.UseTable(newTableName)
return u.updateTableName(newTableName)
}
func (u userCommentActionQuery) As(alias string) *userCommentActionQuery {
u.userCommentActionQueryDo.DO = *(u.userCommentActionQueryDo.As(alias).(*gen.DO))
return u.updateTableName(alias)
}
func (u *userCommentActionQuery) updateTableName(table string) *userCommentActionQuery {
u.ALL = field.NewAsterisk(table)
u.ID = field.NewInt64(table, "id")
u.UserID = field.NewInt64(table, "user_id")
u.CommentID = field.NewInt64(table, "comment_id")
u.Type = field.NewString(table, "type")
u.CreatedAt = field.NewTime(table, "created_at")
u.fillFieldMap()
return u
}
func (u *userCommentActionQuery) QueryContext(ctx context.Context) (*userCommentActionQuery, *userCommentActionQueryDo) {
return u, u.userCommentActionQueryDo.WithContext(ctx)
}
func (u *userCommentActionQuery) WithContext(ctx context.Context) *userCommentActionQueryDo {
return u.userCommentActionQueryDo.WithContext(ctx)
}
func (u userCommentActionQuery) TableName() string { return u.userCommentActionQueryDo.TableName() }
func (u userCommentActionQuery) Alias() string { return u.userCommentActionQueryDo.Alias() }
func (u userCommentActionQuery) Columns(cols ...field.Expr) gen.Columns {
return u.userCommentActionQueryDo.Columns(cols...)
}
func (u *userCommentActionQuery) 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 *userCommentActionQuery) fillFieldMap() {
u.fieldMap = make(map[string]field.Expr, 5)
u.fieldMap["id"] = u.ID
u.fieldMap["user_id"] = u.UserID
u.fieldMap["comment_id"] = u.CommentID
u.fieldMap["type"] = u.Type
u.fieldMap["created_at"] = u.CreatedAt
}
func (u userCommentActionQuery) clone(db *gorm.DB) userCommentActionQuery {
u.userCommentActionQueryDo.ReplaceConnPool(db.Statement.ConnPool)
return u
}
func (u userCommentActionQuery) replaceDB(db *gorm.DB) userCommentActionQuery {
u.userCommentActionQueryDo.ReplaceDB(db)
return u
}
type userCommentActionQueryDo struct{ gen.DO }
func (u userCommentActionQueryDo) Debug() *userCommentActionQueryDo {
return u.withDO(u.DO.Debug())
}
func (u userCommentActionQueryDo) WithContext(ctx context.Context) *userCommentActionQueryDo {
return u.withDO(u.DO.WithContext(ctx))
}
func (u userCommentActionQueryDo) ReadDB() *userCommentActionQueryDo {
return u.Clauses(dbresolver.Read)
}
func (u userCommentActionQueryDo) WriteDB() *userCommentActionQueryDo {
return u.Clauses(dbresolver.Write)
}
func (u userCommentActionQueryDo) Session(config *gorm.Session) *userCommentActionQueryDo {
return u.withDO(u.DO.Session(config))
}
func (u userCommentActionQueryDo) Clauses(conds ...clause.Expression) *userCommentActionQueryDo {
return u.withDO(u.DO.Clauses(conds...))
}
func (u userCommentActionQueryDo) Returning(value interface{}, columns ...string) *userCommentActionQueryDo {
return u.withDO(u.DO.Returning(value, columns...))
}
func (u userCommentActionQueryDo) Not(conds ...gen.Condition) *userCommentActionQueryDo {
return u.withDO(u.DO.Not(conds...))
}
func (u userCommentActionQueryDo) Or(conds ...gen.Condition) *userCommentActionQueryDo {
return u.withDO(u.DO.Or(conds...))
}
func (u userCommentActionQueryDo) Select(conds ...field.Expr) *userCommentActionQueryDo {
return u.withDO(u.DO.Select(conds...))
}
func (u userCommentActionQueryDo) Where(conds ...gen.Condition) *userCommentActionQueryDo {
return u.withDO(u.DO.Where(conds...))
}
func (u userCommentActionQueryDo) Order(conds ...field.Expr) *userCommentActionQueryDo {
return u.withDO(u.DO.Order(conds...))
}
func (u userCommentActionQueryDo) Distinct(cols ...field.Expr) *userCommentActionQueryDo {
return u.withDO(u.DO.Distinct(cols...))
}
func (u userCommentActionQueryDo) Omit(cols ...field.Expr) *userCommentActionQueryDo {
return u.withDO(u.DO.Omit(cols...))
}
func (u userCommentActionQueryDo) Join(table schema.Tabler, on ...field.Expr) *userCommentActionQueryDo {
return u.withDO(u.DO.Join(table, on...))
}
func (u userCommentActionQueryDo) LeftJoin(table schema.Tabler, on ...field.Expr) *userCommentActionQueryDo {
return u.withDO(u.DO.LeftJoin(table, on...))
}
func (u userCommentActionQueryDo) RightJoin(table schema.Tabler, on ...field.Expr) *userCommentActionQueryDo {
return u.withDO(u.DO.RightJoin(table, on...))
}
func (u userCommentActionQueryDo) Group(cols ...field.Expr) *userCommentActionQueryDo {
return u.withDO(u.DO.Group(cols...))
}
func (u userCommentActionQueryDo) Having(conds ...gen.Condition) *userCommentActionQueryDo {
return u.withDO(u.DO.Having(conds...))
}
func (u userCommentActionQueryDo) Limit(limit int) *userCommentActionQueryDo {
return u.withDO(u.DO.Limit(limit))
}
func (u userCommentActionQueryDo) Offset(offset int) *userCommentActionQueryDo {
return u.withDO(u.DO.Offset(offset))
}
func (u userCommentActionQueryDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *userCommentActionQueryDo {
return u.withDO(u.DO.Scopes(funcs...))
}
func (u userCommentActionQueryDo) Unscoped() *userCommentActionQueryDo {
return u.withDO(u.DO.Unscoped())
}
func (u userCommentActionQueryDo) Create(values ...*UserCommentAction) error {
if len(values) == 0 {
return nil
}
return u.DO.Create(values)
}
func (u userCommentActionQueryDo) CreateInBatches(values []*UserCommentAction, 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 userCommentActionQueryDo) Save(values ...*UserCommentAction) error {
if len(values) == 0 {
return nil
}
return u.DO.Save(values)
}
func (u userCommentActionQueryDo) First() (*UserCommentAction, error) {
if result, err := u.DO.First(); err != nil {
return nil, err
} else {
return result.(*UserCommentAction), nil
}
}
func (u userCommentActionQueryDo) Take() (*UserCommentAction, error) {
if result, err := u.DO.Take(); err != nil {
return nil, err
} else {
return result.(*UserCommentAction), nil
}
}
func (u userCommentActionQueryDo) Last() (*UserCommentAction, error) {
if result, err := u.DO.Last(); err != nil {
return nil, err
} else {
return result.(*UserCommentAction), nil
}
}
func (u userCommentActionQueryDo) Find() ([]*UserCommentAction, error) {
result, err := u.DO.Find()
return result.([]*UserCommentAction), err
}
func (u userCommentActionQueryDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*UserCommentAction, err error) {
buf := make([]*UserCommentAction, 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 userCommentActionQueryDo) FindInBatches(result *[]*UserCommentAction, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return u.DO.FindInBatches(result, batchSize, fc)
}
func (u userCommentActionQueryDo) Attrs(attrs ...field.AssignExpr) *userCommentActionQueryDo {
return u.withDO(u.DO.Attrs(attrs...))
}
func (u userCommentActionQueryDo) Assign(attrs ...field.AssignExpr) *userCommentActionQueryDo {
return u.withDO(u.DO.Assign(attrs...))
}
func (u userCommentActionQueryDo) Joins(fields ...field.RelationField) *userCommentActionQueryDo {
for _, _f := range fields {
u = *u.withDO(u.DO.Joins(_f))
}
return &u
}
func (u userCommentActionQueryDo) Preload(fields ...field.RelationField) *userCommentActionQueryDo {
for _, _f := range fields {
u = *u.withDO(u.DO.Preload(_f))
}
return &u
}
func (u userCommentActionQueryDo) FirstOrInit() (*UserCommentAction, error) {
if result, err := u.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*UserCommentAction), nil
}
}
func (u userCommentActionQueryDo) FirstOrCreate() (*UserCommentAction, error) {
if result, err := u.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*UserCommentAction), nil
}
}
func (u userCommentActionQueryDo) FindByPage(offset int, limit int) (result []*UserCommentAction, 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 userCommentActionQueryDo) 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 userCommentActionQueryDo) Scan(result interface{}) (err error) {
return u.DO.Scan(result)
}
func (u userCommentActionQueryDo) Delete(models ...*UserCommentAction) (result gen.ResultInfo, err error) {
return u.DO.Delete(models)
}
// ForceDelete performs a permanent delete (ignores soft-delete) for current scope.
func (u userCommentActionQueryDo) ForceDelete() (gen.ResultInfo, error) {
return u.Unscoped().Delete()
}
// Inc increases the given column by step for current scope.
func (u userCommentActionQueryDo) Inc(column field.Expr, step int64) (gen.ResultInfo, error) {
// column = column + step
e := field.NewUnsafeFieldRaw("?+?", column.RawExpr(), step)
return u.DO.UpdateColumn(column, e)
}
// Dec decreases the given column by step for current scope.
func (u userCommentActionQueryDo) Dec(column field.Expr, step int64) (gen.ResultInfo, error) {
// column = column - step
e := field.NewUnsafeFieldRaw("?-?", column.RawExpr(), step)
return u.DO.UpdateColumn(column, e)
}
// Sum returns SUM(column) for current scope.
func (u userCommentActionQueryDo) Sum(column field.Expr) (float64, error) {
var _v float64
agg := field.NewUnsafeFieldRaw("SUM(?)", column.RawExpr())
if err := u.Select(agg).Scan(&_v); err != nil {
return 0, err
}
return _v, nil
}
// Avg returns AVG(column) for current scope.
func (u userCommentActionQueryDo) Avg(column field.Expr) (float64, error) {
var _v float64
agg := field.NewUnsafeFieldRaw("AVG(?)", column.RawExpr())
if err := u.Select(agg).Scan(&_v); err != nil {
return 0, err
}
return _v, nil
}
// Min returns MIN(column) for current scope.
func (u userCommentActionQueryDo) Min(column field.Expr) (float64, error) {
var _v float64
agg := field.NewUnsafeFieldRaw("MIN(?)", column.RawExpr())
if err := u.Select(agg).Scan(&_v); err != nil {
return 0, err
}
return _v, nil
}
// Max returns MAX(column) for current scope.
func (u userCommentActionQueryDo) Max(column field.Expr) (float64, error) {
var _v float64
agg := field.NewUnsafeFieldRaw("MAX(?)", column.RawExpr())
if err := u.Select(agg).Scan(&_v); err != nil {
return 0, err
}
return _v, nil
}
// PluckMap returns a map[key]value for selected key/value expressions within current scope.
func (u userCommentActionQueryDo) PluckMap(key, val field.Expr) (map[interface{}]interface{}, error) {
do := u.Select(key, val)
rows, err := do.DO.Rows()
if err != nil {
return nil, err
}
defer rows.Close()
mm := make(map[interface{}]interface{})
for rows.Next() {
var k interface{}
var v interface{}
if err := rows.Scan(&k, &v); err != nil {
return nil, err
}
mm[k] = v
}
return mm, rows.Err()
}
// Exists returns true if any record matches the given conditions.
func (u userCommentActionQueryDo) Exists(conds ...gen.Condition) (bool, error) {
cnt, err := u.Where(conds...).Count()
if err != nil {
return false, err
}
return cnt > 0, nil
}
// PluckIDs returns all primary key values under current scope.
func (u userCommentActionQueryDo) PluckIDs() ([]int64, error) {
ids := make([]int64, 0, 16)
pk := field.NewInt64(u.TableName(), "id")
if err := u.DO.Pluck(pk, &ids); err != nil {
return nil, err
}
return ids, nil
}
// GetByID finds a single record by primary key.
func (u userCommentActionQueryDo) GetByID(id int64) (*UserCommentAction, error) {
pk := field.NewInt64(u.TableName(), "id")
return u.Where(pk.Eq(id)).First()
}
// GetByIDs finds records by primary key list.
func (u userCommentActionQueryDo) GetByIDs(ids ...int64) ([]*UserCommentAction, error) {
if len(ids) == 0 {
return []*UserCommentAction{}, nil
}
pk := field.NewInt64(u.TableName(), "id")
return u.Where(pk.In(ids...)).Find()
}
// DeleteByID deletes records by primary key.
func (u userCommentActionQueryDo) DeleteByID(id int64) (gen.ResultInfo, error) {
pk := field.NewInt64(u.TableName(), "id")
return u.Where(pk.Eq(id)).Delete()
}
// DeleteByIDs deletes records by a list of primary keys.
func (u userCommentActionQueryDo) DeleteByIDs(ids ...int64) (gen.ResultInfo, error) {
if len(ids) == 0 {
return gen.ResultInfo{RowsAffected: 0, Error: nil}, nil
}
pk := field.NewInt64(u.TableName(), "id")
return u.Where(pk.In(ids...)).Delete()
}
func (u *userCommentActionQueryDo) withDO(do gen.Dao) *userCommentActionQueryDo {
u.DO = *do.(*gen.DO)
return u
}