Files
quyun-v2/backend/database/models/notification_templates.query.gen.go

496 lines
16 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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 newNotificationTemplate(db *gorm.DB, opts ...gen.DOOption) notificationTemplateQuery {
_notificationTemplateQuery := notificationTemplateQuery{}
_notificationTemplateQuery.notificationTemplateQueryDo.UseDB(db, opts...)
_notificationTemplateQuery.notificationTemplateQueryDo.UseModel(&NotificationTemplate{})
tableName := _notificationTemplateQuery.notificationTemplateQueryDo.TableName()
_notificationTemplateQuery.ALL = field.NewAsterisk(tableName)
_notificationTemplateQuery.ID = field.NewInt64(tableName, "id")
_notificationTemplateQuery.TenantID = field.NewInt64(tableName, "tenant_id")
_notificationTemplateQuery.Name = field.NewString(tableName, "name")
_notificationTemplateQuery.Type = field.NewField(tableName, "type")
_notificationTemplateQuery.Title = field.NewString(tableName, "title")
_notificationTemplateQuery.Content = field.NewString(tableName, "content")
_notificationTemplateQuery.IsActive = field.NewBool(tableName, "is_active")
_notificationTemplateQuery.CreatedAt = field.NewTime(tableName, "created_at")
_notificationTemplateQuery.UpdatedAt = field.NewTime(tableName, "updated_at")
_notificationTemplateQuery.fillFieldMap()
return _notificationTemplateQuery
}
type notificationTemplateQuery struct {
notificationTemplateQueryDo notificationTemplateQueryDo
ALL field.Asterisk
ID field.Int64 // 模板主键ID用于后台检索与引用。
TenantID field.Int64 // 归属租户ID0 表示平台级模板);用于限制模板适用范围。
Name field.String // 模板名称,用于后台识别用途(如“提现提醒”“内容审核通过”),不直接下发给用户。
Type field.Field // 通知类型system/order/audit/interaction需与前端枚举一致用于分类与筛选。
Title field.String // 通知标题,直接展示给用户的标题文本。
Content field.String // 通知内容,直接展示给用户的正文,可包含简要说明与行动提示。
IsActive field.Bool // 是否启用;禁用模板不可用于发送,便于临时下架或停用。
CreatedAt field.Time // 创建时间,按时间排序与审计使用。
UpdatedAt field.Time // 更新时间,记录最近一次编辑时间。
fieldMap map[string]field.Expr
}
func (n notificationTemplateQuery) Table(newTableName string) *notificationTemplateQuery {
n.notificationTemplateQueryDo.UseTable(newTableName)
return n.updateTableName(newTableName)
}
func (n notificationTemplateQuery) As(alias string) *notificationTemplateQuery {
n.notificationTemplateQueryDo.DO = *(n.notificationTemplateQueryDo.As(alias).(*gen.DO))
return n.updateTableName(alias)
}
func (n *notificationTemplateQuery) updateTableName(table string) *notificationTemplateQuery {
n.ALL = field.NewAsterisk(table)
n.ID = field.NewInt64(table, "id")
n.TenantID = field.NewInt64(table, "tenant_id")
n.Name = field.NewString(table, "name")
n.Type = field.NewField(table, "type")
n.Title = field.NewString(table, "title")
n.Content = field.NewString(table, "content")
n.IsActive = field.NewBool(table, "is_active")
n.CreatedAt = field.NewTime(table, "created_at")
n.UpdatedAt = field.NewTime(table, "updated_at")
n.fillFieldMap()
return n
}
func (n *notificationTemplateQuery) QueryContext(ctx context.Context) (*notificationTemplateQuery, *notificationTemplateQueryDo) {
return n, n.notificationTemplateQueryDo.WithContext(ctx)
}
func (n *notificationTemplateQuery) WithContext(ctx context.Context) *notificationTemplateQueryDo {
return n.notificationTemplateQueryDo.WithContext(ctx)
}
func (n notificationTemplateQuery) TableName() string {
return n.notificationTemplateQueryDo.TableName()
}
func (n notificationTemplateQuery) Alias() string { return n.notificationTemplateQueryDo.Alias() }
func (n notificationTemplateQuery) Columns(cols ...field.Expr) gen.Columns {
return n.notificationTemplateQueryDo.Columns(cols...)
}
func (n *notificationTemplateQuery) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := n.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (n *notificationTemplateQuery) fillFieldMap() {
n.fieldMap = make(map[string]field.Expr, 9)
n.fieldMap["id"] = n.ID
n.fieldMap["tenant_id"] = n.TenantID
n.fieldMap["name"] = n.Name
n.fieldMap["type"] = n.Type
n.fieldMap["title"] = n.Title
n.fieldMap["content"] = n.Content
n.fieldMap["is_active"] = n.IsActive
n.fieldMap["created_at"] = n.CreatedAt
n.fieldMap["updated_at"] = n.UpdatedAt
}
func (n notificationTemplateQuery) clone(db *gorm.DB) notificationTemplateQuery {
n.notificationTemplateQueryDo.ReplaceConnPool(db.Statement.ConnPool)
return n
}
func (n notificationTemplateQuery) replaceDB(db *gorm.DB) notificationTemplateQuery {
n.notificationTemplateQueryDo.ReplaceDB(db)
return n
}
type notificationTemplateQueryDo struct{ gen.DO }
func (n notificationTemplateQueryDo) Debug() *notificationTemplateQueryDo {
return n.withDO(n.DO.Debug())
}
func (n notificationTemplateQueryDo) WithContext(ctx context.Context) *notificationTemplateQueryDo {
return n.withDO(n.DO.WithContext(ctx))
}
func (n notificationTemplateQueryDo) ReadDB() *notificationTemplateQueryDo {
return n.Clauses(dbresolver.Read)
}
func (n notificationTemplateQueryDo) WriteDB() *notificationTemplateQueryDo {
return n.Clauses(dbresolver.Write)
}
func (n notificationTemplateQueryDo) Session(config *gorm.Session) *notificationTemplateQueryDo {
return n.withDO(n.DO.Session(config))
}
func (n notificationTemplateQueryDo) Clauses(conds ...clause.Expression) *notificationTemplateQueryDo {
return n.withDO(n.DO.Clauses(conds...))
}
func (n notificationTemplateQueryDo) Returning(value interface{}, columns ...string) *notificationTemplateQueryDo {
return n.withDO(n.DO.Returning(value, columns...))
}
func (n notificationTemplateQueryDo) Not(conds ...gen.Condition) *notificationTemplateQueryDo {
return n.withDO(n.DO.Not(conds...))
}
func (n notificationTemplateQueryDo) Or(conds ...gen.Condition) *notificationTemplateQueryDo {
return n.withDO(n.DO.Or(conds...))
}
func (n notificationTemplateQueryDo) Select(conds ...field.Expr) *notificationTemplateQueryDo {
return n.withDO(n.DO.Select(conds...))
}
func (n notificationTemplateQueryDo) Where(conds ...gen.Condition) *notificationTemplateQueryDo {
return n.withDO(n.DO.Where(conds...))
}
func (n notificationTemplateQueryDo) Order(conds ...field.Expr) *notificationTemplateQueryDo {
return n.withDO(n.DO.Order(conds...))
}
func (n notificationTemplateQueryDo) Distinct(cols ...field.Expr) *notificationTemplateQueryDo {
return n.withDO(n.DO.Distinct(cols...))
}
func (n notificationTemplateQueryDo) Omit(cols ...field.Expr) *notificationTemplateQueryDo {
return n.withDO(n.DO.Omit(cols...))
}
func (n notificationTemplateQueryDo) Join(table schema.Tabler, on ...field.Expr) *notificationTemplateQueryDo {
return n.withDO(n.DO.Join(table, on...))
}
func (n notificationTemplateQueryDo) LeftJoin(table schema.Tabler, on ...field.Expr) *notificationTemplateQueryDo {
return n.withDO(n.DO.LeftJoin(table, on...))
}
func (n notificationTemplateQueryDo) RightJoin(table schema.Tabler, on ...field.Expr) *notificationTemplateQueryDo {
return n.withDO(n.DO.RightJoin(table, on...))
}
func (n notificationTemplateQueryDo) Group(cols ...field.Expr) *notificationTemplateQueryDo {
return n.withDO(n.DO.Group(cols...))
}
func (n notificationTemplateQueryDo) Having(conds ...gen.Condition) *notificationTemplateQueryDo {
return n.withDO(n.DO.Having(conds...))
}
func (n notificationTemplateQueryDo) Limit(limit int) *notificationTemplateQueryDo {
return n.withDO(n.DO.Limit(limit))
}
func (n notificationTemplateQueryDo) Offset(offset int) *notificationTemplateQueryDo {
return n.withDO(n.DO.Offset(offset))
}
func (n notificationTemplateQueryDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *notificationTemplateQueryDo {
return n.withDO(n.DO.Scopes(funcs...))
}
func (n notificationTemplateQueryDo) Unscoped() *notificationTemplateQueryDo {
return n.withDO(n.DO.Unscoped())
}
func (n notificationTemplateQueryDo) Create(values ...*NotificationTemplate) error {
if len(values) == 0 {
return nil
}
return n.DO.Create(values)
}
func (n notificationTemplateQueryDo) CreateInBatches(values []*NotificationTemplate, batchSize int) error {
return n.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 (n notificationTemplateQueryDo) Save(values ...*NotificationTemplate) error {
if len(values) == 0 {
return nil
}
return n.DO.Save(values)
}
func (n notificationTemplateQueryDo) First() (*NotificationTemplate, error) {
if result, err := n.DO.First(); err != nil {
return nil, err
} else {
return result.(*NotificationTemplate), nil
}
}
func (n notificationTemplateQueryDo) Take() (*NotificationTemplate, error) {
if result, err := n.DO.Take(); err != nil {
return nil, err
} else {
return result.(*NotificationTemplate), nil
}
}
func (n notificationTemplateQueryDo) Last() (*NotificationTemplate, error) {
if result, err := n.DO.Last(); err != nil {
return nil, err
} else {
return result.(*NotificationTemplate), nil
}
}
func (n notificationTemplateQueryDo) Find() ([]*NotificationTemplate, error) {
result, err := n.DO.Find()
return result.([]*NotificationTemplate), err
}
func (n notificationTemplateQueryDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*NotificationTemplate, err error) {
buf := make([]*NotificationTemplate, 0, batchSize)
err = n.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 (n notificationTemplateQueryDo) FindInBatches(result *[]*NotificationTemplate, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return n.DO.FindInBatches(result, batchSize, fc)
}
func (n notificationTemplateQueryDo) Attrs(attrs ...field.AssignExpr) *notificationTemplateQueryDo {
return n.withDO(n.DO.Attrs(attrs...))
}
func (n notificationTemplateQueryDo) Assign(attrs ...field.AssignExpr) *notificationTemplateQueryDo {
return n.withDO(n.DO.Assign(attrs...))
}
func (n notificationTemplateQueryDo) Joins(fields ...field.RelationField) *notificationTemplateQueryDo {
for _, _f := range fields {
n = *n.withDO(n.DO.Joins(_f))
}
return &n
}
func (n notificationTemplateQueryDo) Preload(fields ...field.RelationField) *notificationTemplateQueryDo {
for _, _f := range fields {
n = *n.withDO(n.DO.Preload(_f))
}
return &n
}
func (n notificationTemplateQueryDo) FirstOrInit() (*NotificationTemplate, error) {
if result, err := n.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*NotificationTemplate), nil
}
}
func (n notificationTemplateQueryDo) FirstOrCreate() (*NotificationTemplate, error) {
if result, err := n.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*NotificationTemplate), nil
}
}
func (n notificationTemplateQueryDo) FindByPage(offset int, limit int) (result []*NotificationTemplate, count int64, err error) {
result, err = n.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 = n.Offset(-1).Limit(-1).Count()
return
}
func (n notificationTemplateQueryDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = n.Count()
if err != nil {
return
}
err = n.Offset(offset).Limit(limit).Scan(result)
return
}
func (n notificationTemplateQueryDo) Scan(result interface{}) (err error) {
return n.DO.Scan(result)
}
func (n notificationTemplateQueryDo) Delete(models ...*NotificationTemplate) (result gen.ResultInfo, err error) {
return n.DO.Delete(models)
}
// ForceDelete performs a permanent delete (ignores soft-delete) for current scope.
func (n notificationTemplateQueryDo) ForceDelete() (gen.ResultInfo, error) {
return n.Unscoped().Delete()
}
// Inc increases the given column by step for current scope.
func (n notificationTemplateQueryDo) Inc(column field.Expr, step int64) (gen.ResultInfo, error) {
// column = column + step
e := field.NewUnsafeFieldRaw("?+?", column.RawExpr(), step)
return n.DO.UpdateColumn(column, e)
}
// Dec decreases the given column by step for current scope.
func (n notificationTemplateQueryDo) Dec(column field.Expr, step int64) (gen.ResultInfo, error) {
// column = column - step
e := field.NewUnsafeFieldRaw("?-?", column.RawExpr(), step)
return n.DO.UpdateColumn(column, e)
}
// Sum returns SUM(column) for current scope.
func (n notificationTemplateQueryDo) Sum(column field.Expr) (float64, error) {
var _v float64
agg := field.NewUnsafeFieldRaw("SUM(?)", column.RawExpr())
if err := n.Select(agg).Scan(&_v); err != nil {
return 0, err
}
return _v, nil
}
// Avg returns AVG(column) for current scope.
func (n notificationTemplateQueryDo) Avg(column field.Expr) (float64, error) {
var _v float64
agg := field.NewUnsafeFieldRaw("AVG(?)", column.RawExpr())
if err := n.Select(agg).Scan(&_v); err != nil {
return 0, err
}
return _v, nil
}
// Min returns MIN(column) for current scope.
func (n notificationTemplateQueryDo) Min(column field.Expr) (float64, error) {
var _v float64
agg := field.NewUnsafeFieldRaw("MIN(?)", column.RawExpr())
if err := n.Select(agg).Scan(&_v); err != nil {
return 0, err
}
return _v, nil
}
// Max returns MAX(column) for current scope.
func (n notificationTemplateQueryDo) Max(column field.Expr) (float64, error) {
var _v float64
agg := field.NewUnsafeFieldRaw("MAX(?)", column.RawExpr())
if err := n.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 (n notificationTemplateQueryDo) PluckMap(key, val field.Expr) (map[interface{}]interface{}, error) {
do := n.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 (n notificationTemplateQueryDo) Exists(conds ...gen.Condition) (bool, error) {
cnt, err := n.Where(conds...).Count()
if err != nil {
return false, err
}
return cnt > 0, nil
}
// PluckIDs returns all primary key values under current scope.
func (n notificationTemplateQueryDo) PluckIDs() ([]int64, error) {
ids := make([]int64, 0, 16)
pk := field.NewInt64(n.TableName(), "id")
if err := n.DO.Pluck(pk, &ids); err != nil {
return nil, err
}
return ids, nil
}
// GetByID finds a single record by primary key.
func (n notificationTemplateQueryDo) GetByID(id int64) (*NotificationTemplate, error) {
pk := field.NewInt64(n.TableName(), "id")
return n.Where(pk.Eq(id)).First()
}
// GetByIDs finds records by primary key list.
func (n notificationTemplateQueryDo) GetByIDs(ids ...int64) ([]*NotificationTemplate, error) {
if len(ids) == 0 {
return []*NotificationTemplate{}, nil
}
pk := field.NewInt64(n.TableName(), "id")
return n.Where(pk.In(ids...)).Find()
}
// DeleteByID deletes records by primary key.
func (n notificationTemplateQueryDo) DeleteByID(id int64) (gen.ResultInfo, error) {
pk := field.NewInt64(n.TableName(), "id")
return n.Where(pk.Eq(id)).Delete()
}
// DeleteByIDs deletes records by a list of primary keys.
func (n notificationTemplateQueryDo) DeleteByIDs(ids ...int64) (gen.ResultInfo, error) {
if len(ids) == 0 {
return gen.ResultInfo{RowsAffected: 0, Error: nil}, nil
}
pk := field.NewInt64(n.TableName(), "id")
return n.Where(pk.In(ids...)).Delete()
}
func (n *notificationTemplateQueryDo) withDO(do gen.Dao) *notificationTemplateQueryDo {
n.DO = *do.(*gen.DO)
return n
}