// 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 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 }