feat: add superadmin assets and notifications
This commit is contained in:
@@ -52,6 +52,8 @@ field_type:
|
||||
type: consts.CouponType
|
||||
user_coupons:
|
||||
status: consts.UserCouponStatus
|
||||
notification_templates:
|
||||
type: consts.NotificationType
|
||||
field_relate:
|
||||
contents:
|
||||
Author:
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE IF NOT EXISTS notification_templates (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
tenant_id BIGINT NOT NULL DEFAULT 0,
|
||||
name VARCHAR(128) NOT NULL,
|
||||
type VARCHAR(32) NOT NULL,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
COMMENT ON TABLE notification_templates IS '通知模板:用于超管/运营预置通知内容,便于批量触达与统一管理。';
|
||||
COMMENT ON COLUMN notification_templates.id IS '模板主键ID,用于后台检索与引用。';
|
||||
COMMENT ON COLUMN notification_templates.tenant_id IS '归属租户ID(0 表示平台级模板);用于限制模板适用范围。';
|
||||
COMMENT ON COLUMN notification_templates.name IS '模板名称,用于后台识别用途(如“提现提醒”“内容审核通过”),不直接下发给用户。';
|
||||
COMMENT ON COLUMN notification_templates.type IS '通知类型(system/order/audit/interaction),需与前端枚举一致,用于分类与筛选。';
|
||||
COMMENT ON COLUMN notification_templates.title IS '通知标题,直接展示给用户的标题文本。';
|
||||
COMMENT ON COLUMN notification_templates.content IS '通知内容,直接展示给用户的正文,可包含简要说明与行动提示。';
|
||||
COMMENT ON COLUMN notification_templates.is_active IS '是否启用;禁用模板不可用于发送,便于临时下架或停用。';
|
||||
COMMENT ON COLUMN notification_templates.created_at IS '创建时间,按时间排序与审计使用。';
|
||||
COMMENT ON COLUMN notification_templates.updated_at IS '更新时间,记录最近一次编辑时间。';
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE IF EXISTS notification_templates;
|
||||
@@ -40,9 +40,9 @@ type Content struct {
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:timestamp with time zone" json:"deleted_at"`
|
||||
Key string `gorm:"column:key;type:character varying(32);comment:Musical key/tone" json:"key"` // Musical key/tone
|
||||
IsPinned bool `gorm:"column:is_pinned;type:boolean;comment:Whether content is pinned/featured" json:"is_pinned"` // Whether content is pinned/featured
|
||||
Comments []*Comment `gorm:"foreignKey:ContentID;references:ID" json:"comments,omitempty"`
|
||||
Author *User `gorm:"foreignKey:UserID;references:ID" json:"author,omitempty"`
|
||||
ContentAssets []*ContentAsset `gorm:"foreignKey:ContentID;references:ID" json:"content_assets,omitempty"`
|
||||
Comments []*Comment `gorm:"foreignKey:ContentID;references:ID" json:"comments,omitempty"`
|
||||
}
|
||||
|
||||
// Quick operations without importing query package
|
||||
|
||||
@@ -46,12 +46,6 @@ func newContent(db *gorm.DB, opts ...gen.DOOption) contentQuery {
|
||||
_contentQuery.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_contentQuery.Key = field.NewString(tableName, "key")
|
||||
_contentQuery.IsPinned = field.NewBool(tableName, "is_pinned")
|
||||
_contentQuery.Comments = contentQueryHasManyComments{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Comments", "Comment"),
|
||||
}
|
||||
|
||||
_contentQuery.Author = contentQueryBelongsToAuthor{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
@@ -64,6 +58,12 @@ func newContent(db *gorm.DB, opts ...gen.DOOption) contentQuery {
|
||||
RelationField: field.NewRelation("ContentAssets", "ContentAsset"),
|
||||
}
|
||||
|
||||
_contentQuery.Comments = contentQueryHasManyComments{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Comments", "Comment"),
|
||||
}
|
||||
|
||||
_contentQuery.fillFieldMap()
|
||||
|
||||
return _contentQuery
|
||||
@@ -94,12 +94,12 @@ type contentQuery struct {
|
||||
DeletedAt field.Field
|
||||
Key field.String // Musical key/tone
|
||||
IsPinned field.Bool // Whether content is pinned/featured
|
||||
Comments contentQueryHasManyComments
|
||||
|
||||
Author contentQueryBelongsToAuthor
|
||||
Author contentQueryBelongsToAuthor
|
||||
|
||||
ContentAssets contentQueryHasManyContentAssets
|
||||
|
||||
Comments contentQueryHasManyComments
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
@@ -195,104 +195,23 @@ func (c *contentQuery) fillFieldMap() {
|
||||
|
||||
func (c contentQuery) clone(db *gorm.DB) contentQuery {
|
||||
c.contentQueryDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
c.Comments.db = db.Session(&gorm.Session{Initialized: true})
|
||||
c.Comments.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
c.Author.db = db.Session(&gorm.Session{Initialized: true})
|
||||
c.Author.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
c.ContentAssets.db = db.Session(&gorm.Session{Initialized: true})
|
||||
c.ContentAssets.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
c.Comments.db = db.Session(&gorm.Session{Initialized: true})
|
||||
c.Comments.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
return c
|
||||
}
|
||||
|
||||
func (c contentQuery) replaceDB(db *gorm.DB) contentQuery {
|
||||
c.contentQueryDo.ReplaceDB(db)
|
||||
c.Comments.db = db.Session(&gorm.Session{})
|
||||
c.Author.db = db.Session(&gorm.Session{})
|
||||
c.ContentAssets.db = db.Session(&gorm.Session{})
|
||||
c.Comments.db = db.Session(&gorm.Session{})
|
||||
return c
|
||||
}
|
||||
|
||||
type contentQueryHasManyComments struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyComments) Where(conds ...field.Expr) *contentQueryHasManyComments {
|
||||
if len(conds) == 0 {
|
||||
return &a
|
||||
}
|
||||
|
||||
exprs := make([]clause.Expression, 0, len(conds))
|
||||
for _, cond := range conds {
|
||||
exprs = append(exprs, cond.BeCond().(clause.Expression))
|
||||
}
|
||||
a.db = a.db.Clauses(clause.Where{Exprs: exprs})
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyComments) WithContext(ctx context.Context) *contentQueryHasManyComments {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyComments) Session(session *gorm.Session) *contentQueryHasManyComments {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyComments) Model(m *Content) *contentQueryHasManyCommentsTx {
|
||||
return &contentQueryHasManyCommentsTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyComments) Unscoped() *contentQueryHasManyComments {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type contentQueryHasManyCommentsTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a contentQueryHasManyCommentsTx) Find() (result []*Comment, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyCommentsTx) Append(values ...*Comment) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyCommentsTx) Replace(values ...*Comment) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyCommentsTx) Delete(values ...*Comment) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyCommentsTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyCommentsTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyCommentsTx) Unscoped() *contentQueryHasManyCommentsTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type contentQueryBelongsToAuthor struct {
|
||||
db *gorm.DB
|
||||
|
||||
@@ -455,6 +374,87 @@ func (a contentQueryHasManyContentAssetsTx) Unscoped() *contentQueryHasManyConte
|
||||
return &a
|
||||
}
|
||||
|
||||
type contentQueryHasManyComments struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyComments) Where(conds ...field.Expr) *contentQueryHasManyComments {
|
||||
if len(conds) == 0 {
|
||||
return &a
|
||||
}
|
||||
|
||||
exprs := make([]clause.Expression, 0, len(conds))
|
||||
for _, cond := range conds {
|
||||
exprs = append(exprs, cond.BeCond().(clause.Expression))
|
||||
}
|
||||
a.db = a.db.Clauses(clause.Where{Exprs: exprs})
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyComments) WithContext(ctx context.Context) *contentQueryHasManyComments {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyComments) Session(session *gorm.Session) *contentQueryHasManyComments {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyComments) Model(m *Content) *contentQueryHasManyCommentsTx {
|
||||
return &contentQueryHasManyCommentsTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyComments) Unscoped() *contentQueryHasManyComments {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type contentQueryHasManyCommentsTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a contentQueryHasManyCommentsTx) Find() (result []*Comment, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyCommentsTx) Append(values ...*Comment) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyCommentsTx) Replace(values ...*Comment) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyCommentsTx) Delete(values ...*Comment) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyCommentsTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyCommentsTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a contentQueryHasManyCommentsTx) Unscoped() *contentQueryHasManyCommentsTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type contentQueryDo struct{ gen.DO }
|
||||
|
||||
func (c contentQueryDo) Debug() *contentQueryDo {
|
||||
|
||||
65
backend/database/models/notification_templates.gen.go
Normal file
65
backend/database/models/notification_templates.gen.go
Normal file
@@ -0,0 +1,65 @@
|
||||
// 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"
|
||||
"time"
|
||||
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"go.ipao.vip/gen"
|
||||
)
|
||||
|
||||
const TableNameNotificationTemplate = "notification_templates"
|
||||
|
||||
// NotificationTemplate mapped from table <notification_templates>
|
||||
type NotificationTemplate struct {
|
||||
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true;comment:模板主键ID,用于后台检索与引用。" json:"id"` // 模板主键ID,用于后台检索与引用。
|
||||
TenantID int64 `gorm:"column:tenant_id;type:bigint;not null;comment:归属租户ID(0 表示平台级模板);用于限制模板适用范围。" json:"tenant_id"` // 归属租户ID(0 表示平台级模板);用于限制模板适用范围。
|
||||
Name string `gorm:"column:name;type:character varying(128);not null;comment:模板名称,用于后台识别用途(如“提现提醒”“内容审核通过”),不直接下发给用户。" json:"name"` // 模板名称,用于后台识别用途(如“提现提醒”“内容审核通过”),不直接下发给用户。
|
||||
Type consts.NotificationType `gorm:"column:type;type:character varying(32);not null;comment:通知类型(system/order/audit/interaction),需与前端枚举一致,用于分类与筛选。" json:"type"` // 通知类型(system/order/audit/interaction),需与前端枚举一致,用于分类与筛选。
|
||||
Title string `gorm:"column:title;type:character varying(255);not null;comment:通知标题,直接展示给用户的标题文本。" json:"title"` // 通知标题,直接展示给用户的标题文本。
|
||||
Content string `gorm:"column:content;type:text;not null;comment:通知内容,直接展示给用户的正文,可包含简要说明与行动提示。" json:"content"` // 通知内容,直接展示给用户的正文,可包含简要说明与行动提示。
|
||||
IsActive bool `gorm:"column:is_active;type:boolean;not null;default:true;comment:是否启用;禁用模板不可用于发送,便于临时下架或停用。" json:"is_active"` // 是否启用;禁用模板不可用于发送,便于临时下架或停用。
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;not null;default:now();comment:创建时间,按时间排序与审计使用。" json:"created_at"` // 创建时间,按时间排序与审计使用。
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;not null;default:now();comment:更新时间,记录最近一次编辑时间。" json:"updated_at"` // 更新时间,记录最近一次编辑时间。
|
||||
}
|
||||
|
||||
// Quick operations without importing query package
|
||||
// Update applies changed fields to the database using the default DB.
|
||||
func (m *NotificationTemplate) Update(ctx context.Context) (gen.ResultInfo, error) {
|
||||
return Q.NotificationTemplate.WithContext(ctx).Updates(m)
|
||||
}
|
||||
|
||||
// Save upserts the model using the default DB.
|
||||
func (m *NotificationTemplate) Save(ctx context.Context) error {
|
||||
return Q.NotificationTemplate.WithContext(ctx).Save(m)
|
||||
}
|
||||
|
||||
// Create inserts the model using the default DB.
|
||||
func (m *NotificationTemplate) Create(ctx context.Context) error {
|
||||
return Q.NotificationTemplate.WithContext(ctx).Create(m)
|
||||
}
|
||||
|
||||
// Delete removes the row represented by the model using the default DB.
|
||||
func (m *NotificationTemplate) Delete(ctx context.Context) (gen.ResultInfo, error) {
|
||||
return Q.NotificationTemplate.WithContext(ctx).Delete(m)
|
||||
}
|
||||
|
||||
// ForceDelete permanently deletes the row (ignores soft delete) using the default DB.
|
||||
func (m *NotificationTemplate) ForceDelete(ctx context.Context) (gen.ResultInfo, error) {
|
||||
return Q.NotificationTemplate.WithContext(ctx).Unscoped().Delete(m)
|
||||
}
|
||||
|
||||
// Reload reloads the model from database by its primary key and overwrites current fields.
|
||||
func (m *NotificationTemplate) Reload(ctx context.Context) error {
|
||||
fresh, err := Q.NotificationTemplate.WithContext(ctx).GetByID(m.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*m = *fresh
|
||||
return nil
|
||||
}
|
||||
495
backend/database/models/notification_templates.query.gen.go
Normal file
495
backend/database/models/notification_templates.query.gen.go
Normal file
@@ -0,0 +1,495 @@
|
||||
// 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 // 归属租户ID(0 表示平台级模板);用于限制模板适用范围。
|
||||
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
|
||||
}
|
||||
@@ -16,27 +16,28 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
Q = new(Query)
|
||||
CommentQuery *commentQuery
|
||||
ContentQuery *contentQuery
|
||||
ContentAccessQuery *contentAccessQuery
|
||||
ContentAssetQuery *contentAssetQuery
|
||||
ContentPriceQuery *contentPriceQuery
|
||||
CouponQuery *couponQuery
|
||||
MediaAssetQuery *mediaAssetQuery
|
||||
NotificationQuery *notificationQuery
|
||||
OrderQuery *orderQuery
|
||||
OrderItemQuery *orderItemQuery
|
||||
PayoutAccountQuery *payoutAccountQuery
|
||||
TenantQuery *tenantQuery
|
||||
TenantInviteQuery *tenantInviteQuery
|
||||
TenantJoinRequestQuery *tenantJoinRequestQuery
|
||||
TenantLedgerQuery *tenantLedgerQuery
|
||||
TenantUserQuery *tenantUserQuery
|
||||
UserQuery *userQuery
|
||||
UserCommentActionQuery *userCommentActionQuery
|
||||
UserContentActionQuery *userContentActionQuery
|
||||
UserCouponQuery *userCouponQuery
|
||||
Q = new(Query)
|
||||
CommentQuery *commentQuery
|
||||
ContentQuery *contentQuery
|
||||
ContentAccessQuery *contentAccessQuery
|
||||
ContentAssetQuery *contentAssetQuery
|
||||
ContentPriceQuery *contentPriceQuery
|
||||
CouponQuery *couponQuery
|
||||
MediaAssetQuery *mediaAssetQuery
|
||||
NotificationQuery *notificationQuery
|
||||
NotificationTemplateQuery *notificationTemplateQuery
|
||||
OrderQuery *orderQuery
|
||||
OrderItemQuery *orderItemQuery
|
||||
PayoutAccountQuery *payoutAccountQuery
|
||||
TenantQuery *tenantQuery
|
||||
TenantInviteQuery *tenantInviteQuery
|
||||
TenantJoinRequestQuery *tenantJoinRequestQuery
|
||||
TenantLedgerQuery *tenantLedgerQuery
|
||||
TenantUserQuery *tenantUserQuery
|
||||
UserQuery *userQuery
|
||||
UserCommentActionQuery *userCommentActionQuery
|
||||
UserContentActionQuery *userContentActionQuery
|
||||
UserCouponQuery *userCouponQuery
|
||||
)
|
||||
|
||||
func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
|
||||
@@ -49,6 +50,7 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
|
||||
CouponQuery = &Q.Coupon
|
||||
MediaAssetQuery = &Q.MediaAsset
|
||||
NotificationQuery = &Q.Notification
|
||||
NotificationTemplateQuery = &Q.NotificationTemplate
|
||||
OrderQuery = &Q.Order
|
||||
OrderItemQuery = &Q.OrderItem
|
||||
PayoutAccountQuery = &Q.PayoutAccount
|
||||
@@ -65,80 +67,83 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
|
||||
|
||||
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
|
||||
return &Query{
|
||||
db: db,
|
||||
Comment: newComment(db, opts...),
|
||||
Content: newContent(db, opts...),
|
||||
ContentAccess: newContentAccess(db, opts...),
|
||||
ContentAsset: newContentAsset(db, opts...),
|
||||
ContentPrice: newContentPrice(db, opts...),
|
||||
Coupon: newCoupon(db, opts...),
|
||||
MediaAsset: newMediaAsset(db, opts...),
|
||||
Notification: newNotification(db, opts...),
|
||||
Order: newOrder(db, opts...),
|
||||
OrderItem: newOrderItem(db, opts...),
|
||||
PayoutAccount: newPayoutAccount(db, opts...),
|
||||
Tenant: newTenant(db, opts...),
|
||||
TenantInvite: newTenantInvite(db, opts...),
|
||||
TenantJoinRequest: newTenantJoinRequest(db, opts...),
|
||||
TenantLedger: newTenantLedger(db, opts...),
|
||||
TenantUser: newTenantUser(db, opts...),
|
||||
User: newUser(db, opts...),
|
||||
UserCommentAction: newUserCommentAction(db, opts...),
|
||||
UserContentAction: newUserContentAction(db, opts...),
|
||||
UserCoupon: newUserCoupon(db, opts...),
|
||||
db: db,
|
||||
Comment: newComment(db, opts...),
|
||||
Content: newContent(db, opts...),
|
||||
ContentAccess: newContentAccess(db, opts...),
|
||||
ContentAsset: newContentAsset(db, opts...),
|
||||
ContentPrice: newContentPrice(db, opts...),
|
||||
Coupon: newCoupon(db, opts...),
|
||||
MediaAsset: newMediaAsset(db, opts...),
|
||||
Notification: newNotification(db, opts...),
|
||||
NotificationTemplate: newNotificationTemplate(db, opts...),
|
||||
Order: newOrder(db, opts...),
|
||||
OrderItem: newOrderItem(db, opts...),
|
||||
PayoutAccount: newPayoutAccount(db, opts...),
|
||||
Tenant: newTenant(db, opts...),
|
||||
TenantInvite: newTenantInvite(db, opts...),
|
||||
TenantJoinRequest: newTenantJoinRequest(db, opts...),
|
||||
TenantLedger: newTenantLedger(db, opts...),
|
||||
TenantUser: newTenantUser(db, opts...),
|
||||
User: newUser(db, opts...),
|
||||
UserCommentAction: newUserCommentAction(db, opts...),
|
||||
UserContentAction: newUserContentAction(db, opts...),
|
||||
UserCoupon: newUserCoupon(db, opts...),
|
||||
}
|
||||
}
|
||||
|
||||
type Query struct {
|
||||
db *gorm.DB
|
||||
|
||||
Comment commentQuery
|
||||
Content contentQuery
|
||||
ContentAccess contentAccessQuery
|
||||
ContentAsset contentAssetQuery
|
||||
ContentPrice contentPriceQuery
|
||||
Coupon couponQuery
|
||||
MediaAsset mediaAssetQuery
|
||||
Notification notificationQuery
|
||||
Order orderQuery
|
||||
OrderItem orderItemQuery
|
||||
PayoutAccount payoutAccountQuery
|
||||
Tenant tenantQuery
|
||||
TenantInvite tenantInviteQuery
|
||||
TenantJoinRequest tenantJoinRequestQuery
|
||||
TenantLedger tenantLedgerQuery
|
||||
TenantUser tenantUserQuery
|
||||
User userQuery
|
||||
UserCommentAction userCommentActionQuery
|
||||
UserContentAction userContentActionQuery
|
||||
UserCoupon userCouponQuery
|
||||
Comment commentQuery
|
||||
Content contentQuery
|
||||
ContentAccess contentAccessQuery
|
||||
ContentAsset contentAssetQuery
|
||||
ContentPrice contentPriceQuery
|
||||
Coupon couponQuery
|
||||
MediaAsset mediaAssetQuery
|
||||
Notification notificationQuery
|
||||
NotificationTemplate notificationTemplateQuery
|
||||
Order orderQuery
|
||||
OrderItem orderItemQuery
|
||||
PayoutAccount payoutAccountQuery
|
||||
Tenant tenantQuery
|
||||
TenantInvite tenantInviteQuery
|
||||
TenantJoinRequest tenantJoinRequestQuery
|
||||
TenantLedger tenantLedgerQuery
|
||||
TenantUser tenantUserQuery
|
||||
User userQuery
|
||||
UserCommentAction userCommentActionQuery
|
||||
UserContentAction userContentActionQuery
|
||||
UserCoupon userCouponQuery
|
||||
}
|
||||
|
||||
func (q *Query) Available() bool { return q.db != nil }
|
||||
|
||||
func (q *Query) clone(db *gorm.DB) *Query {
|
||||
return &Query{
|
||||
db: db,
|
||||
Comment: q.Comment.clone(db),
|
||||
Content: q.Content.clone(db),
|
||||
ContentAccess: q.ContentAccess.clone(db),
|
||||
ContentAsset: q.ContentAsset.clone(db),
|
||||
ContentPrice: q.ContentPrice.clone(db),
|
||||
Coupon: q.Coupon.clone(db),
|
||||
MediaAsset: q.MediaAsset.clone(db),
|
||||
Notification: q.Notification.clone(db),
|
||||
Order: q.Order.clone(db),
|
||||
OrderItem: q.OrderItem.clone(db),
|
||||
PayoutAccount: q.PayoutAccount.clone(db),
|
||||
Tenant: q.Tenant.clone(db),
|
||||
TenantInvite: q.TenantInvite.clone(db),
|
||||
TenantJoinRequest: q.TenantJoinRequest.clone(db),
|
||||
TenantLedger: q.TenantLedger.clone(db),
|
||||
TenantUser: q.TenantUser.clone(db),
|
||||
User: q.User.clone(db),
|
||||
UserCommentAction: q.UserCommentAction.clone(db),
|
||||
UserContentAction: q.UserContentAction.clone(db),
|
||||
UserCoupon: q.UserCoupon.clone(db),
|
||||
db: db,
|
||||
Comment: q.Comment.clone(db),
|
||||
Content: q.Content.clone(db),
|
||||
ContentAccess: q.ContentAccess.clone(db),
|
||||
ContentAsset: q.ContentAsset.clone(db),
|
||||
ContentPrice: q.ContentPrice.clone(db),
|
||||
Coupon: q.Coupon.clone(db),
|
||||
MediaAsset: q.MediaAsset.clone(db),
|
||||
Notification: q.Notification.clone(db),
|
||||
NotificationTemplate: q.NotificationTemplate.clone(db),
|
||||
Order: q.Order.clone(db),
|
||||
OrderItem: q.OrderItem.clone(db),
|
||||
PayoutAccount: q.PayoutAccount.clone(db),
|
||||
Tenant: q.Tenant.clone(db),
|
||||
TenantInvite: q.TenantInvite.clone(db),
|
||||
TenantJoinRequest: q.TenantJoinRequest.clone(db),
|
||||
TenantLedger: q.TenantLedger.clone(db),
|
||||
TenantUser: q.TenantUser.clone(db),
|
||||
User: q.User.clone(db),
|
||||
UserCommentAction: q.UserCommentAction.clone(db),
|
||||
UserContentAction: q.UserContentAction.clone(db),
|
||||
UserCoupon: q.UserCoupon.clone(db),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,75 +157,78 @@ func (q *Query) WriteDB() *Query {
|
||||
|
||||
func (q *Query) ReplaceDB(db *gorm.DB) *Query {
|
||||
return &Query{
|
||||
db: db,
|
||||
Comment: q.Comment.replaceDB(db),
|
||||
Content: q.Content.replaceDB(db),
|
||||
ContentAccess: q.ContentAccess.replaceDB(db),
|
||||
ContentAsset: q.ContentAsset.replaceDB(db),
|
||||
ContentPrice: q.ContentPrice.replaceDB(db),
|
||||
Coupon: q.Coupon.replaceDB(db),
|
||||
MediaAsset: q.MediaAsset.replaceDB(db),
|
||||
Notification: q.Notification.replaceDB(db),
|
||||
Order: q.Order.replaceDB(db),
|
||||
OrderItem: q.OrderItem.replaceDB(db),
|
||||
PayoutAccount: q.PayoutAccount.replaceDB(db),
|
||||
Tenant: q.Tenant.replaceDB(db),
|
||||
TenantInvite: q.TenantInvite.replaceDB(db),
|
||||
TenantJoinRequest: q.TenantJoinRequest.replaceDB(db),
|
||||
TenantLedger: q.TenantLedger.replaceDB(db),
|
||||
TenantUser: q.TenantUser.replaceDB(db),
|
||||
User: q.User.replaceDB(db),
|
||||
UserCommentAction: q.UserCommentAction.replaceDB(db),
|
||||
UserContentAction: q.UserContentAction.replaceDB(db),
|
||||
UserCoupon: q.UserCoupon.replaceDB(db),
|
||||
db: db,
|
||||
Comment: q.Comment.replaceDB(db),
|
||||
Content: q.Content.replaceDB(db),
|
||||
ContentAccess: q.ContentAccess.replaceDB(db),
|
||||
ContentAsset: q.ContentAsset.replaceDB(db),
|
||||
ContentPrice: q.ContentPrice.replaceDB(db),
|
||||
Coupon: q.Coupon.replaceDB(db),
|
||||
MediaAsset: q.MediaAsset.replaceDB(db),
|
||||
Notification: q.Notification.replaceDB(db),
|
||||
NotificationTemplate: q.NotificationTemplate.replaceDB(db),
|
||||
Order: q.Order.replaceDB(db),
|
||||
OrderItem: q.OrderItem.replaceDB(db),
|
||||
PayoutAccount: q.PayoutAccount.replaceDB(db),
|
||||
Tenant: q.Tenant.replaceDB(db),
|
||||
TenantInvite: q.TenantInvite.replaceDB(db),
|
||||
TenantJoinRequest: q.TenantJoinRequest.replaceDB(db),
|
||||
TenantLedger: q.TenantLedger.replaceDB(db),
|
||||
TenantUser: q.TenantUser.replaceDB(db),
|
||||
User: q.User.replaceDB(db),
|
||||
UserCommentAction: q.UserCommentAction.replaceDB(db),
|
||||
UserContentAction: q.UserContentAction.replaceDB(db),
|
||||
UserCoupon: q.UserCoupon.replaceDB(db),
|
||||
}
|
||||
}
|
||||
|
||||
type queryCtx struct {
|
||||
Comment *commentQueryDo
|
||||
Content *contentQueryDo
|
||||
ContentAccess *contentAccessQueryDo
|
||||
ContentAsset *contentAssetQueryDo
|
||||
ContentPrice *contentPriceQueryDo
|
||||
Coupon *couponQueryDo
|
||||
MediaAsset *mediaAssetQueryDo
|
||||
Notification *notificationQueryDo
|
||||
Order *orderQueryDo
|
||||
OrderItem *orderItemQueryDo
|
||||
PayoutAccount *payoutAccountQueryDo
|
||||
Tenant *tenantQueryDo
|
||||
TenantInvite *tenantInviteQueryDo
|
||||
TenantJoinRequest *tenantJoinRequestQueryDo
|
||||
TenantLedger *tenantLedgerQueryDo
|
||||
TenantUser *tenantUserQueryDo
|
||||
User *userQueryDo
|
||||
UserCommentAction *userCommentActionQueryDo
|
||||
UserContentAction *userContentActionQueryDo
|
||||
UserCoupon *userCouponQueryDo
|
||||
Comment *commentQueryDo
|
||||
Content *contentQueryDo
|
||||
ContentAccess *contentAccessQueryDo
|
||||
ContentAsset *contentAssetQueryDo
|
||||
ContentPrice *contentPriceQueryDo
|
||||
Coupon *couponQueryDo
|
||||
MediaAsset *mediaAssetQueryDo
|
||||
Notification *notificationQueryDo
|
||||
NotificationTemplate *notificationTemplateQueryDo
|
||||
Order *orderQueryDo
|
||||
OrderItem *orderItemQueryDo
|
||||
PayoutAccount *payoutAccountQueryDo
|
||||
Tenant *tenantQueryDo
|
||||
TenantInvite *tenantInviteQueryDo
|
||||
TenantJoinRequest *tenantJoinRequestQueryDo
|
||||
TenantLedger *tenantLedgerQueryDo
|
||||
TenantUser *tenantUserQueryDo
|
||||
User *userQueryDo
|
||||
UserCommentAction *userCommentActionQueryDo
|
||||
UserContentAction *userContentActionQueryDo
|
||||
UserCoupon *userCouponQueryDo
|
||||
}
|
||||
|
||||
func (q *Query) WithContext(ctx context.Context) *queryCtx {
|
||||
return &queryCtx{
|
||||
Comment: q.Comment.WithContext(ctx),
|
||||
Content: q.Content.WithContext(ctx),
|
||||
ContentAccess: q.ContentAccess.WithContext(ctx),
|
||||
ContentAsset: q.ContentAsset.WithContext(ctx),
|
||||
ContentPrice: q.ContentPrice.WithContext(ctx),
|
||||
Coupon: q.Coupon.WithContext(ctx),
|
||||
MediaAsset: q.MediaAsset.WithContext(ctx),
|
||||
Notification: q.Notification.WithContext(ctx),
|
||||
Order: q.Order.WithContext(ctx),
|
||||
OrderItem: q.OrderItem.WithContext(ctx),
|
||||
PayoutAccount: q.PayoutAccount.WithContext(ctx),
|
||||
Tenant: q.Tenant.WithContext(ctx),
|
||||
TenantInvite: q.TenantInvite.WithContext(ctx),
|
||||
TenantJoinRequest: q.TenantJoinRequest.WithContext(ctx),
|
||||
TenantLedger: q.TenantLedger.WithContext(ctx),
|
||||
TenantUser: q.TenantUser.WithContext(ctx),
|
||||
User: q.User.WithContext(ctx),
|
||||
UserCommentAction: q.UserCommentAction.WithContext(ctx),
|
||||
UserContentAction: q.UserContentAction.WithContext(ctx),
|
||||
UserCoupon: q.UserCoupon.WithContext(ctx),
|
||||
Comment: q.Comment.WithContext(ctx),
|
||||
Content: q.Content.WithContext(ctx),
|
||||
ContentAccess: q.ContentAccess.WithContext(ctx),
|
||||
ContentAsset: q.ContentAsset.WithContext(ctx),
|
||||
ContentPrice: q.ContentPrice.WithContext(ctx),
|
||||
Coupon: q.Coupon.WithContext(ctx),
|
||||
MediaAsset: q.MediaAsset.WithContext(ctx),
|
||||
Notification: q.Notification.WithContext(ctx),
|
||||
NotificationTemplate: q.NotificationTemplate.WithContext(ctx),
|
||||
Order: q.Order.WithContext(ctx),
|
||||
OrderItem: q.OrderItem.WithContext(ctx),
|
||||
PayoutAccount: q.PayoutAccount.WithContext(ctx),
|
||||
Tenant: q.Tenant.WithContext(ctx),
|
||||
TenantInvite: q.TenantInvite.WithContext(ctx),
|
||||
TenantJoinRequest: q.TenantJoinRequest.WithContext(ctx),
|
||||
TenantLedger: q.TenantLedger.WithContext(ctx),
|
||||
TenantUser: q.TenantUser.WithContext(ctx),
|
||||
User: q.User.WithContext(ctx),
|
||||
UserCommentAction: q.UserCommentAction.WithContext(ctx),
|
||||
UserContentAction: q.UserContentAction.WithContext(ctx),
|
||||
UserCoupon: q.UserCoupon.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user