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

63 lines
2.5 KiB
Go

// 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"
"go.ipao.vip/gen/types"
)
const TableNameTenantUser = "tenant_users"
// TenantUser mapped from table <tenant_users>
type TenantUser struct {
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
TenantID int64 `gorm:"column:tenant_id;type:bigint;not null" json:"tenant_id"`
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
Role types.Array[consts.TenantUserRole] `gorm:"column:role;type:text[];not null;default:ARRAY['member" json:"role"`
Status consts.UserStatus `gorm:"column:status;type:character varying(50);not null;default:verified" json:"status"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;not null;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;not null;default:now()" json:"updated_at"`
}
// Quick operations without importing query package
// Update applies changed fields to the database using the default DB.
func (m *TenantUser) Update(ctx context.Context) (gen.ResultInfo, error) {
return Q.TenantUser.WithContext(ctx).Updates(m)
}
// Save upserts the model using the default DB.
func (m *TenantUser) Save(ctx context.Context) error { return Q.TenantUser.WithContext(ctx).Save(m) }
// Create inserts the model using the default DB.
func (m *TenantUser) Create(ctx context.Context) error {
return Q.TenantUser.WithContext(ctx).Create(m)
}
// Delete removes the row represented by the model using the default DB.
func (m *TenantUser) Delete(ctx context.Context) (gen.ResultInfo, error) {
return Q.TenantUser.WithContext(ctx).Delete(m)
}
// ForceDelete permanently deletes the row (ignores soft delete) using the default DB.
func (m *TenantUser) ForceDelete(ctx context.Context) (gen.ResultInfo, error) {
return Q.TenantUser.WithContext(ctx).Unscoped().Delete(m)
}
// Reload reloads the model from database by its primary key and overwrites current fields.
func (m *TenantUser) Reload(ctx context.Context) error {
fresh, err := Q.TenantUser.WithContext(ctx).GetByID(m.ID)
if err != nil {
return err
}
*m = *fresh
return nil
}