// 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 TableNameTenantJoinRequest = "tenant_join_requests" // TenantJoinRequest mapped from table type TenantJoinRequest 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:发起加入申请的用户 Status consts.TenantJoinRequestStatus `gorm:"column:status;type:character varying(32);not null;default:pending;comment:申请状态:pending/approved/rejected;状态变更需记录 decided_at 与 decided_operator_user_id" json:"status"` // 申请状态:pending/approved/rejected;状态变更需记录 decided_at 与 decided_operator_user_id Reason string `gorm:"column:reason;type:character varying(255);not null;comment:申请原因:用户填写的加入说明(可选)" json:"reason"` // 申请原因:用户填写的加入说明(可选) DecidedAt time.Time `gorm:"column:decided_at;type:timestamp with time zone;comment:处理时间:审核通过/拒绝时记录(UTC)" json:"decided_at"` // 处理时间:审核通过/拒绝时记录(UTC) DecidedOperatorUserID int64 `gorm:"column:decided_operator_user_id;type:bigint;comment:处理人用户ID:租户管理员(审计用)" json:"decided_operator_user_id"` // 处理人用户ID:租户管理员(审计用) DecidedReason string `gorm:"column:decided_reason;type:character varying(255);not null;comment:处理说明:管理员通过/拒绝的原因(可选,审计用)" json:"decided_reason"` // 处理说明:管理员通过/拒绝的原因(可选,审计用) 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 *TenantJoinRequest) Update(ctx context.Context) (gen.ResultInfo, error) { return Q.TenantJoinRequest.WithContext(ctx).Updates(m) } // Save upserts the model using the default DB. func (m *TenantJoinRequest) Save(ctx context.Context) error { return Q.TenantJoinRequest.WithContext(ctx).Save(m) } // Create inserts the model using the default DB. func (m *TenantJoinRequest) Create(ctx context.Context) error { return Q.TenantJoinRequest.WithContext(ctx).Create(m) } // Delete removes the row represented by the model using the default DB. func (m *TenantJoinRequest) Delete(ctx context.Context) (gen.ResultInfo, error) { return Q.TenantJoinRequest.WithContext(ctx).Delete(m) } // ForceDelete permanently deletes the row (ignores soft delete) using the default DB. func (m *TenantJoinRequest) ForceDelete(ctx context.Context) (gen.ResultInfo, error) { return Q.TenantJoinRequest.WithContext(ctx).Unscoped().Delete(m) } // Reload reloads the model from database by its primary key and overwrites current fields. func (m *TenantJoinRequest) Reload(ctx context.Context) error { fresh, err := Q.TenantJoinRequest.WithContext(ctx).GetByID(m.ID) if err != nil { return err } *m = *fresh return nil }