Files
quyun-v2/backend/database/models/tenant_invites.gen.go

70 lines
5.6 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"
"time"
"quyun/v2/pkg/consts"
"go.ipao.vip/gen"
)
const TableNameTenantInvite = "tenant_invites"
// TenantInvite mapped from table <tenant_invites>
type TenantInvite 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多租户隔离关键字段所有查询/写入必须限定 tenant_id" json:"tenant_id"` // 租户ID多租户隔离关键字段所有查询/写入必须限定 tenant_id
UserID int64 `gorm:"column:user_id;type:bigint;not null;comment:创建人用户ID生成邀请码的租户管理员审计用" json:"user_id"` // 创建人用户ID生成邀请码的租户管理员审计用
Code string `gorm:"column:code;type:character varying(64);not null;comment:邀请码:用户加入租户时提交;同一租户内唯一" json:"code"` // 邀请码:用户加入租户时提交;同一租户内唯一
Status consts.TenantInviteStatus `gorm:"column:status;type:character varying(32);not null;default:active;comment:邀请状态active/disabled/expiredexpired 也可由 expires_at 推导,业务侧需保持一致" json:"status"` // 邀请状态active/disabled/expiredexpired 也可由 expires_at 推导,业务侧需保持一致
MaxUses int32 `gorm:"column:max_uses;type:integer;not null;comment:最大可使用次数0 表示不限制;>0 时 used_count 达到该值后视为失效" json:"max_uses"` // 最大可使用次数0 表示不限制;>0 时 used_count 达到该值后视为失效
UsedCount int32 `gorm:"column:used_count;type:integer;not null;comment:已使用次数:每次成功加入时 +1需事务保证并发下不超发" json:"used_count"` // 已使用次数:每次成功加入时 +1需事务保证并发下不超发
ExpiresAt time.Time `gorm:"column:expires_at;type:timestamp with time zone;comment:过期时间到期后不可再使用UTC为空表示不过期" json:"expires_at"` // 过期时间到期后不可再使用UTC为空表示不过期
DisabledAt time.Time `gorm:"column:disabled_at;type:timestamp with time zone;comment:禁用时间租户管理员禁用该邀请的时间UTC" json:"disabled_at"` // 禁用时间租户管理员禁用该邀请的时间UTC
DisabledOperatorUserID int64 `gorm:"column:disabled_operator_user_id;type:bigint;comment:禁用操作人用户ID租户管理员审计用" json:"disabled_operator_user_id"` // 禁用操作人用户ID租户管理员审计用
Remark string `gorm:"column:remark;type:character varying(255);not null;comment:备注:生成/禁用原因等(审计用)" json:"remark"` // 备注:生成/禁用原因等(审计用)
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;not null;default:now();comment:创建时间:默认 now()" json:"created_at"` // 创建时间:默认 now()
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;not null;default:now();comment:更新时间:默认 now()" json:"updated_at"` // 更新时间:默认 now()
}
// Quick operations without importing query package
// Update applies changed fields to the database using the default DB.
func (m *TenantInvite) Update(ctx context.Context) (gen.ResultInfo, error) {
return Q.TenantInvite.WithContext(ctx).Updates(m)
}
// Save upserts the model using the default DB.
func (m *TenantInvite) Save(ctx context.Context) error {
return Q.TenantInvite.WithContext(ctx).Save(m)
}
// Create inserts the model using the default DB.
func (m *TenantInvite) Create(ctx context.Context) error {
return Q.TenantInvite.WithContext(ctx).Create(m)
}
// Delete removes the row represented by the model using the default DB.
func (m *TenantInvite) Delete(ctx context.Context) (gen.ResultInfo, error) {
return Q.TenantInvite.WithContext(ctx).Delete(m)
}
// ForceDelete permanently deletes the row (ignores soft delete) using the default DB.
func (m *TenantInvite) ForceDelete(ctx context.Context) (gen.ResultInfo, error) {
return Q.TenantInvite.WithContext(ctx).Unscoped().Delete(m)
}
// Reload reloads the model from database by its primary key and overwrites current fields.
func (m *TenantInvite) Reload(ctx context.Context) error {
fresh, err := Q.TenantInvite.WithContext(ctx).GetByID(m.ID)
if err != nil {
return err
}
*m = *fresh
return nil
}