✨ add casbin ent adapter & code migration
This commit is contained in:
515
app/core/api/repository/casbinx/adapter/adapter.go
Normal file
515
app/core/api/repository/casbinx/adapter/adapter.go
Normal file
@@ -0,0 +1,515 @@
|
||||
package adapter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
entsql "entgo.io/ent/dialect/sql"
|
||||
"github.com/casbin/casbin/v2/model"
|
||||
"github.com/casbin/casbin/v2/persist"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultTableName = "sca_auth_permission_rule"
|
||||
DefaultDatabase = "schisandra_album_cloud"
|
||||
)
|
||||
|
||||
type Adapter struct {
|
||||
client *ent.Client
|
||||
ctx context.Context
|
||||
|
||||
filtered bool
|
||||
}
|
||||
|
||||
type Filter struct {
|
||||
Ptype []string
|
||||
V0 []string
|
||||
V1 []string
|
||||
V2 []string
|
||||
V3 []string
|
||||
V4 []string
|
||||
V5 []string
|
||||
}
|
||||
|
||||
type Option func(a *Adapter) error
|
||||
|
||||
func open(driverName, dataSourceName string) (*ent.Client, error) {
|
||||
db, err := sql.Open(driverName, dataSourceName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var drv dialect.Driver
|
||||
if driverName == "pgx" {
|
||||
drv = entsql.OpenDB(dialect.Postgres, db)
|
||||
} else {
|
||||
drv = entsql.OpenDB(driverName, db)
|
||||
}
|
||||
return ent.NewClient(ent.Driver(drv)), nil
|
||||
}
|
||||
|
||||
// NewAdapter returns an adapter by driver name and data source string.
|
||||
func NewAdapter(driverName, dataSourceName string, options ...Option) (*Adapter, error) {
|
||||
client, err := open(driverName, dataSourceName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
a := &Adapter{
|
||||
client: client,
|
||||
ctx: context.Background(),
|
||||
}
|
||||
for _, option := range options {
|
||||
if err := option(a); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if err := client.Schema.Create(a.ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
// NewAdapterWithClient create an adapter with client passed in.
|
||||
// This method does not ensure the existence of database, user should create database manually.
|
||||
func NewAdapterWithClient(client *ent.Client, options ...Option) (*Adapter, error) {
|
||||
a := &Adapter{
|
||||
client: client,
|
||||
ctx: context.Background(),
|
||||
}
|
||||
for _, option := range options {
|
||||
if err := option(a); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if err := client.Schema.Create(a.ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
// LoadPolicy loads all policy rules from the storage.
|
||||
func (a *Adapter) LoadPolicy(model model.Model) error {
|
||||
policies, err := a.client.ScaAuthPermissionRule.Query().Order(ent.Asc("id")).All(a.ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, policy := range policies {
|
||||
loadPolicyLine(policy, model)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadFilteredPolicy loads only policy rules that match the filter.
|
||||
// Filter parameter here is a Filter structure
|
||||
func (a *Adapter) LoadFilteredPolicy(model model.Model, filter interface{}) error {
|
||||
|
||||
filterValue, ok := filter.(Filter)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid filter type: %v", reflect.TypeOf(filter))
|
||||
}
|
||||
|
||||
session := a.client.ScaAuthPermissionRule.Query()
|
||||
if len(filterValue.Ptype) != 0 {
|
||||
session.Where(scaauthpermissionrule.PtypeIn(filterValue.Ptype...))
|
||||
}
|
||||
if len(filterValue.V0) != 0 {
|
||||
session.Where(scaauthpermissionrule.V0In(filterValue.V0...))
|
||||
}
|
||||
if len(filterValue.V1) != 0 {
|
||||
session.Where(scaauthpermissionrule.V1In(filterValue.V1...))
|
||||
}
|
||||
if len(filterValue.V2) != 0 {
|
||||
session.Where(scaauthpermissionrule.V2In(filterValue.V2...))
|
||||
}
|
||||
if len(filterValue.V3) != 0 {
|
||||
session.Where(scaauthpermissionrule.V3In(filterValue.V3...))
|
||||
}
|
||||
if len(filterValue.V4) != 0 {
|
||||
session.Where(scaauthpermissionrule.V4In(filterValue.V4...))
|
||||
}
|
||||
if len(filterValue.V5) != 0 {
|
||||
session.Where(scaauthpermissionrule.V5In(filterValue.V5...))
|
||||
}
|
||||
|
||||
lines, err := session.All(a.ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, line := range lines {
|
||||
loadPolicyLine(line, model)
|
||||
}
|
||||
a.filtered = true
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsFiltered returns true if the loaded policy has been filtered.
|
||||
func (a *Adapter) IsFiltered() bool {
|
||||
return a.filtered
|
||||
}
|
||||
|
||||
// SavePolicy saves all policy rules to the storage.
|
||||
func (a *Adapter) SavePolicy(model model.Model) error {
|
||||
return a.WithTx(func(tx *ent.Tx) error {
|
||||
if _, err := tx.ScaAuthPermissionRule.Delete().Exec(a.ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
lines := make([]*ent.ScaAuthPermissionRuleCreate, 0)
|
||||
|
||||
for ptype, ast := range model["p"] {
|
||||
for _, policy := range ast.Policy {
|
||||
line := a.savePolicyLine(tx, ptype, policy)
|
||||
lines = append(lines, line)
|
||||
}
|
||||
}
|
||||
|
||||
for ptype, ast := range model["g"] {
|
||||
for _, policy := range ast.Policy {
|
||||
line := a.savePolicyLine(tx, ptype, policy)
|
||||
lines = append(lines, line)
|
||||
}
|
||||
}
|
||||
|
||||
_, err := tx.ScaAuthPermissionRule.CreateBulk(lines...).Save(a.ctx)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
// AddPolicy adds a policy rule to the storage.
|
||||
// This is part of the Auto-Save feature.
|
||||
func (a *Adapter) AddPolicy(sec string, ptype string, rule []string) error {
|
||||
return a.WithTx(func(tx *ent.Tx) error {
|
||||
_, err := a.savePolicyLine(tx, ptype, rule).Save(a.ctx)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
// RemovePolicy removes a policy rule from the storage.
|
||||
// This is part of the Auto-Save feature.
|
||||
func (a *Adapter) RemovePolicy(sec string, ptype string, rule []string) error {
|
||||
return a.WithTx(func(tx *ent.Tx) error {
|
||||
instance := a.toInstance(ptype, rule)
|
||||
_, err := tx.ScaAuthPermissionRule.Delete().Where(
|
||||
scaauthpermissionrule.PtypeEQ(instance.Ptype),
|
||||
scaauthpermissionrule.V0EQ(instance.V0),
|
||||
scaauthpermissionrule.V1EQ(instance.V1),
|
||||
scaauthpermissionrule.V2EQ(instance.V2),
|
||||
scaauthpermissionrule.V3EQ(instance.V3),
|
||||
scaauthpermissionrule.V4EQ(instance.V4),
|
||||
scaauthpermissionrule.V5EQ(instance.V5),
|
||||
).Exec(a.ctx)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
// RemoveFilteredPolicy removes policy rules that match the filter from the storage.
|
||||
// This is part of the Auto-Save feature.
|
||||
func (a *Adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error {
|
||||
return a.WithTx(func(tx *ent.Tx) error {
|
||||
cond := make([]predicate.ScaAuthPermissionRule, 0)
|
||||
cond = append(cond, scaauthpermissionrule.PtypeEQ(ptype))
|
||||
if fieldIndex <= 0 && 0 < fieldIndex+len(fieldValues) && len(fieldValues[0-fieldIndex]) > 0 {
|
||||
cond = append(cond, scaauthpermissionrule.V0EQ(fieldValues[0-fieldIndex]))
|
||||
}
|
||||
if fieldIndex <= 1 && 1 < fieldIndex+len(fieldValues) && len(fieldValues[1-fieldIndex]) > 0 {
|
||||
cond = append(cond, scaauthpermissionrule.V1EQ(fieldValues[1-fieldIndex]))
|
||||
}
|
||||
if fieldIndex <= 2 && 2 < fieldIndex+len(fieldValues) && len(fieldValues[2-fieldIndex]) > 0 {
|
||||
cond = append(cond, scaauthpermissionrule.V2EQ(fieldValues[2-fieldIndex]))
|
||||
}
|
||||
if fieldIndex <= 3 && 3 < fieldIndex+len(fieldValues) && len(fieldValues[3-fieldIndex]) > 0 {
|
||||
cond = append(cond, scaauthpermissionrule.V3EQ(fieldValues[3-fieldIndex]))
|
||||
}
|
||||
if fieldIndex <= 4 && 4 < fieldIndex+len(fieldValues) && len(fieldValues[4-fieldIndex]) > 0 {
|
||||
cond = append(cond, scaauthpermissionrule.V4EQ(fieldValues[4-fieldIndex]))
|
||||
}
|
||||
if fieldIndex <= 5 && 5 < fieldIndex+len(fieldValues) && len(fieldValues[5-fieldIndex]) > 0 {
|
||||
cond = append(cond, scaauthpermissionrule.V5EQ(fieldValues[5-fieldIndex]))
|
||||
}
|
||||
_, err := tx.ScaAuthPermissionRule.Delete().Where(
|
||||
cond...,
|
||||
).Exec(a.ctx)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
// AddPolicies adds policy rules to the storage.
|
||||
// This is part of the Auto-Save feature.
|
||||
func (a *Adapter) AddPolicies(sec string, ptype string, rules [][]string) error {
|
||||
return a.WithTx(func(tx *ent.Tx) error {
|
||||
return a.createPolicies(tx, ptype, rules)
|
||||
})
|
||||
}
|
||||
|
||||
// RemovePolicies removes policy rules from the storage.
|
||||
// This is part of the Auto-Save feature.
|
||||
func (a *Adapter) RemovePolicies(sec string, ptype string, rules [][]string) error {
|
||||
return a.WithTx(func(tx *ent.Tx) error {
|
||||
for _, rule := range rules {
|
||||
instance := a.toInstance(ptype, rule)
|
||||
if _, err := tx.ScaAuthPermissionRule.Delete().Where(
|
||||
scaauthpermissionrule.PtypeEQ(instance.Ptype),
|
||||
scaauthpermissionrule.V0EQ(instance.V0),
|
||||
scaauthpermissionrule.V1EQ(instance.V1),
|
||||
scaauthpermissionrule.V2EQ(instance.V2),
|
||||
scaauthpermissionrule.V3EQ(instance.V3),
|
||||
scaauthpermissionrule.V4EQ(instance.V4),
|
||||
scaauthpermissionrule.V5EQ(instance.V5),
|
||||
).Exec(a.ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (a *Adapter) WithTx(fn func(tx *ent.Tx) error) error {
|
||||
tx, err := a.client.Tx(a.ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if v := recover(); v != nil {
|
||||
_ = tx.Rollback()
|
||||
panic(v)
|
||||
}
|
||||
}()
|
||||
if err := fn(tx); err != nil {
|
||||
if rerr := tx.Rollback(); rerr != nil {
|
||||
err = errors.Wrapf(err, "rolling back transaction: %v", rerr)
|
||||
}
|
||||
return err
|
||||
}
|
||||
if err := tx.Commit(); err != nil {
|
||||
return errors.Wrapf(err, "committing transaction: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func loadPolicyLine(line *ent.ScaAuthPermissionRule, model model.Model) {
|
||||
var p = []string{line.Ptype,
|
||||
line.V0, line.V1, line.V2, line.V3, line.V4, line.V5}
|
||||
|
||||
var lineText string
|
||||
if line.V5 != "" {
|
||||
lineText = strings.Join(p, ", ")
|
||||
} else if line.V4 != "" {
|
||||
lineText = strings.Join(p[:6], ", ")
|
||||
} else if line.V3 != "" {
|
||||
lineText = strings.Join(p[:5], ", ")
|
||||
} else if line.V2 != "" {
|
||||
lineText = strings.Join(p[:4], ", ")
|
||||
} else if line.V1 != "" {
|
||||
lineText = strings.Join(p[:3], ", ")
|
||||
} else if line.V0 != "" {
|
||||
lineText = strings.Join(p[:2], ", ")
|
||||
}
|
||||
|
||||
persist.LoadPolicyLine(lineText, model)
|
||||
}
|
||||
|
||||
func (a *Adapter) toInstance(ptype string, rule []string) *ent.ScaAuthPermissionRule {
|
||||
instance := &ent.ScaAuthPermissionRule{}
|
||||
|
||||
instance.Ptype = ptype
|
||||
|
||||
if len(rule) > 0 {
|
||||
instance.V0 = rule[0]
|
||||
}
|
||||
if len(rule) > 1 {
|
||||
instance.V1 = rule[1]
|
||||
}
|
||||
if len(rule) > 2 {
|
||||
instance.V2 = rule[2]
|
||||
}
|
||||
if len(rule) > 3 {
|
||||
instance.V3 = rule[3]
|
||||
}
|
||||
if len(rule) > 4 {
|
||||
instance.V4 = rule[4]
|
||||
}
|
||||
if len(rule) > 5 {
|
||||
instance.V5 = rule[5]
|
||||
}
|
||||
return instance
|
||||
}
|
||||
|
||||
func (a *Adapter) savePolicyLine(tx *ent.Tx, ptype string, rule []string) *ent.ScaAuthPermissionRuleCreate {
|
||||
line := tx.ScaAuthPermissionRule.Create()
|
||||
|
||||
line.SetPtype(ptype)
|
||||
if len(rule) > 0 {
|
||||
line.SetV0(rule[0])
|
||||
}
|
||||
if len(rule) > 1 {
|
||||
line.SetV1(rule[1])
|
||||
}
|
||||
if len(rule) > 2 {
|
||||
line.SetV2(rule[2])
|
||||
}
|
||||
if len(rule) > 3 {
|
||||
line.SetV3(rule[3])
|
||||
}
|
||||
if len(rule) > 4 {
|
||||
line.SetV4(rule[4])
|
||||
}
|
||||
if len(rule) > 5 {
|
||||
line.SetV5(rule[5])
|
||||
}
|
||||
|
||||
return line
|
||||
}
|
||||
|
||||
// UpdatePolicy updates a policy rule from storage.
|
||||
// This is part of the Auto-Save feature.
|
||||
func (a *Adapter) UpdatePolicy(sec string, ptype string, oldRule, newPolicy []string) error {
|
||||
return a.WithTx(func(tx *ent.Tx) error {
|
||||
rule := a.toInstance(ptype, oldRule)
|
||||
line := tx.ScaAuthPermissionRule.Update().Where(
|
||||
scaauthpermissionrule.PtypeEQ(rule.Ptype),
|
||||
scaauthpermissionrule.V0EQ(rule.V0),
|
||||
scaauthpermissionrule.V1EQ(rule.V1),
|
||||
scaauthpermissionrule.V2EQ(rule.V2),
|
||||
scaauthpermissionrule.V3EQ(rule.V3),
|
||||
scaauthpermissionrule.V4EQ(rule.V4),
|
||||
scaauthpermissionrule.V5EQ(rule.V5),
|
||||
)
|
||||
rule = a.toInstance(ptype, newPolicy)
|
||||
line.SetV0(rule.V0)
|
||||
line.SetV1(rule.V1)
|
||||
line.SetV2(rule.V2)
|
||||
line.SetV3(rule.V3)
|
||||
line.SetV4(rule.V4)
|
||||
line.SetV5(rule.V5)
|
||||
_, err := line.Save(a.ctx)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
// UpdatePolicies updates some policy rules to storage, like db, redis.
|
||||
func (a *Adapter) UpdatePolicies(sec string, ptype string, oldRules, newRules [][]string) error {
|
||||
return a.WithTx(func(tx *ent.Tx) error {
|
||||
for _, policy := range oldRules {
|
||||
rule := a.toInstance(ptype, policy)
|
||||
if _, err := tx.ScaAuthPermissionRule.Delete().Where(
|
||||
scaauthpermissionrule.PtypeEQ(rule.Ptype),
|
||||
scaauthpermissionrule.V0EQ(rule.V0),
|
||||
scaauthpermissionrule.V1EQ(rule.V1),
|
||||
scaauthpermissionrule.V2EQ(rule.V2),
|
||||
scaauthpermissionrule.V3EQ(rule.V3),
|
||||
scaauthpermissionrule.V4EQ(rule.V4),
|
||||
scaauthpermissionrule.V5EQ(rule.V5),
|
||||
).Exec(a.ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
lines := make([]*ent.ScaAuthPermissionRuleCreate, 0)
|
||||
for _, policy := range newRules {
|
||||
lines = append(lines, a.savePolicyLine(tx, ptype, policy))
|
||||
}
|
||||
if _, err := tx.ScaAuthPermissionRule.CreateBulk(lines...).Save(a.ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateFilteredPolicies deletes old rules and adds new rules.
|
||||
func (a *Adapter) UpdateFilteredPolicies(sec string, ptype string, newPolicies [][]string, fieldIndex int, fieldValues ...string) ([][]string, error) {
|
||||
oldPolicies := make([][]string, 0)
|
||||
err := a.WithTx(func(tx *ent.Tx) error {
|
||||
cond := make([]predicate.ScaAuthPermissionRule, 0)
|
||||
cond = append(cond, scaauthpermissionrule.PtypeEQ(ptype))
|
||||
if fieldIndex <= 0 && 0 < fieldIndex+len(fieldValues) && len(fieldValues[0-fieldIndex]) > 0 {
|
||||
cond = append(cond, scaauthpermissionrule.V0EQ(fieldValues[0-fieldIndex]))
|
||||
}
|
||||
if fieldIndex <= 1 && 1 < fieldIndex+len(fieldValues) && len(fieldValues[1-fieldIndex]) > 0 {
|
||||
cond = append(cond, scaauthpermissionrule.V1EQ(fieldValues[1-fieldIndex]))
|
||||
}
|
||||
if fieldIndex <= 2 && 2 < fieldIndex+len(fieldValues) && len(fieldValues[2-fieldIndex]) > 0 {
|
||||
cond = append(cond, scaauthpermissionrule.V2EQ(fieldValues[2-fieldIndex]))
|
||||
}
|
||||
if fieldIndex <= 3 && 3 < fieldIndex+len(fieldValues) && len(fieldValues[3-fieldIndex]) > 0 {
|
||||
cond = append(cond, scaauthpermissionrule.V3EQ(fieldValues[3-fieldIndex]))
|
||||
}
|
||||
if fieldIndex <= 4 && 4 < fieldIndex+len(fieldValues) && len(fieldValues[4-fieldIndex]) > 0 {
|
||||
cond = append(cond, scaauthpermissionrule.V4EQ(fieldValues[4-fieldIndex]))
|
||||
}
|
||||
if fieldIndex <= 5 && 5 < fieldIndex+len(fieldValues) && len(fieldValues[5-fieldIndex]) > 0 {
|
||||
cond = append(cond, scaauthpermissionrule.V5EQ(fieldValues[5-fieldIndex]))
|
||||
}
|
||||
rules, err := tx.ScaAuthPermissionRule.Query().
|
||||
Where(cond...).
|
||||
All(a.ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ruleIDs := make([]int, 0, len(rules))
|
||||
for _, r := range rules {
|
||||
ruleIDs = append(ruleIDs, r.ID)
|
||||
}
|
||||
|
||||
_, err = tx.ScaAuthPermissionRule.Delete().
|
||||
Where(scaauthpermissionrule.IDIn(ruleIDs...)).
|
||||
Exec(a.ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.createPolicies(tx, ptype, newPolicies); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, rule := range rules {
|
||||
oldPolicies = append(oldPolicies, ScaAuthPermissionRuleToStringArray(rule))
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return oldPolicies, nil
|
||||
}
|
||||
|
||||
func (a *Adapter) createPolicies(tx *ent.Tx, ptype string, policies [][]string) error {
|
||||
lines := make([]*ent.ScaAuthPermissionRuleCreate, 0)
|
||||
for _, policy := range policies {
|
||||
lines = append(lines, a.savePolicyLine(tx, ptype, policy))
|
||||
}
|
||||
if _, err := tx.ScaAuthPermissionRule.CreateBulk(lines...).Save(a.ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ScaAuthPermissionRuleToStringArray(rule *ent.ScaAuthPermissionRule) []string {
|
||||
arr := make([]string, 0)
|
||||
if rule.V0 != "" {
|
||||
arr = append(arr, rule.V0)
|
||||
}
|
||||
if rule.V1 != "" {
|
||||
arr = append(arr, rule.V1)
|
||||
}
|
||||
if rule.V2 != "" {
|
||||
arr = append(arr, rule.V2)
|
||||
}
|
||||
if rule.V3 != "" {
|
||||
arr = append(arr, rule.V3)
|
||||
}
|
||||
if rule.V4 != "" {
|
||||
arr = append(arr, rule.V4)
|
||||
}
|
||||
if rule.V5 != "" {
|
||||
arr = append(arr, rule.V5)
|
||||
}
|
||||
return arr
|
||||
}
|
39
app/core/api/repository/casbinx/init.go
Normal file
39
app/core/api/repository/casbinx/init.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package casbinx
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/casbin/casbin/v2"
|
||||
"github.com/casbin/casbin/v2/model"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/casbinx/adapter"
|
||||
)
|
||||
|
||||
// NewCasbin creates a new casbinx enforcer with a mysql adapter and loads the policy from the file system.
|
||||
func NewCasbin(dataSourceName string) *casbin.CachedEnforcer {
|
||||
a, err := adapter.NewAdapter("mysql", dataSourceName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
path := filepath.Join(cwd, "etc", "rbac_model.conf")
|
||||
modelFile, err := model.NewModelFromFile(path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
e, err := casbin.NewCachedEnforcer(modelFile, a)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
e.EnableCache(true)
|
||||
e.SetExpireTime(60 * 60)
|
||||
err = e.LoadPolicy()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return e
|
||||
}
|
10
app/core/api/repository/idgenerator/init.go
Normal file
10
app/core/api/repository/idgenerator/init.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package idgenerator
|
||||
|
||||
import "github.com/yitter/idgenerator-go/idgen"
|
||||
|
||||
func NewIDGenerator() {
|
||||
var options = idgen.NewIdGeneratorOptions(1)
|
||||
options.WorkerIdBitLength = 6 // 默认值6,限定 WorkerId 最大值为2^6-1,即默认最多支持64个节点。
|
||||
options.SeqBitLength = 6 // 默认值6,限制每毫秒生成的ID个数。若生成速度超过5万个/秒,建议加大 SeqBitLength 到 10。
|
||||
idgen.SetIdGenerator(options)
|
||||
}
|
@@ -20,7 +20,6 @@ import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
// Client is the client that holds all ent builders.
|
||||
@@ -299,7 +298,7 @@ func (c *ScaAuthPermissionRuleClient) UpdateOne(sapr *ScaAuthPermissionRule) *Sc
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *ScaAuthPermissionRuleClient) UpdateOneID(id int64) *ScaAuthPermissionRuleUpdateOne {
|
||||
func (c *ScaAuthPermissionRuleClient) UpdateOneID(id int) *ScaAuthPermissionRuleUpdateOne {
|
||||
mutation := newScaAuthPermissionRuleMutation(c.config, OpUpdateOne, withScaAuthPermissionRuleID(id))
|
||||
return &ScaAuthPermissionRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
@@ -316,7 +315,7 @@ func (c *ScaAuthPermissionRuleClient) DeleteOne(sapr *ScaAuthPermissionRule) *Sc
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *ScaAuthPermissionRuleClient) DeleteOneID(id int64) *ScaAuthPermissionRuleDeleteOne {
|
||||
func (c *ScaAuthPermissionRuleClient) DeleteOneID(id int) *ScaAuthPermissionRuleDeleteOne {
|
||||
builder := c.Delete().Where(scaauthpermissionrule.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
@@ -333,12 +332,12 @@ func (c *ScaAuthPermissionRuleClient) Query() *ScaAuthPermissionRuleQuery {
|
||||
}
|
||||
|
||||
// Get returns a ScaAuthPermissionRule entity by its id.
|
||||
func (c *ScaAuthPermissionRuleClient) Get(ctx context.Context, id int64) (*ScaAuthPermissionRule, error) {
|
||||
func (c *ScaAuthPermissionRuleClient) Get(ctx context.Context, id int) (*ScaAuthPermissionRule, error) {
|
||||
return c.Query().Where(scaauthpermissionrule.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *ScaAuthPermissionRuleClient) GetX(ctx context.Context, id int64) *ScaAuthPermissionRule {
|
||||
func (c *ScaAuthPermissionRuleClient) GetX(ctx context.Context, id int) *ScaAuthPermissionRule {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -346,22 +345,6 @@ func (c *ScaAuthPermissionRuleClient) GetX(ctx context.Context, id int64) *ScaAu
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryScaAuthRole queries the sca_auth_role edge of a ScaAuthPermissionRule.
|
||||
func (c *ScaAuthPermissionRuleClient) QueryScaAuthRole(sapr *ScaAuthPermissionRule) *ScaAuthRoleQuery {
|
||||
query := (&ScaAuthRoleClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := sapr.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(scaauthpermissionrule.Table, scaauthpermissionrule.FieldID, id),
|
||||
sqlgraph.To(scaauthrole.Table, scaauthrole.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, scaauthpermissionrule.ScaAuthRoleTable, scaauthpermissionrule.ScaAuthRoleColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(sapr.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *ScaAuthPermissionRuleClient) Hooks() []Hook {
|
||||
return c.hooks.ScaAuthPermissionRule
|
||||
@@ -495,22 +478,6 @@ func (c *ScaAuthRoleClient) GetX(ctx context.Context, id int64) *ScaAuthRole {
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryScaAuthPermissionRule queries the sca_auth_permission_rule edge of a ScaAuthRole.
|
||||
func (c *ScaAuthRoleClient) QueryScaAuthPermissionRule(sar *ScaAuthRole) *ScaAuthPermissionRuleQuery {
|
||||
query := (&ScaAuthPermissionRuleClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := sar.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(scaauthrole.Table, scaauthrole.FieldID, id),
|
||||
sqlgraph.To(scaauthpermissionrule.Table, scaauthpermissionrule.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, scaauthrole.ScaAuthPermissionRuleTable, scaauthrole.ScaAuthPermissionRuleColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(sar.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *ScaAuthRoleClient) Hooks() []Hook {
|
||||
return c.hooks.ScaAuthRole
|
||||
@@ -644,38 +611,6 @@ func (c *ScaAuthUserClient) GetX(ctx context.Context, id int64) *ScaAuthUser {
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryScaAuthUserSocial queries the sca_auth_user_social edge of a ScaAuthUser.
|
||||
func (c *ScaAuthUserClient) QueryScaAuthUserSocial(sau *ScaAuthUser) *ScaAuthUserSocialQuery {
|
||||
query := (&ScaAuthUserSocialClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := sau.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(scaauthuser.Table, scaauthuser.FieldID, id),
|
||||
sqlgraph.To(scaauthusersocial.Table, scaauthusersocial.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, scaauthuser.ScaAuthUserSocialTable, scaauthuser.ScaAuthUserSocialColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(sau.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryScaAuthUserDevice queries the sca_auth_user_device edge of a ScaAuthUser.
|
||||
func (c *ScaAuthUserClient) QueryScaAuthUserDevice(sau *ScaAuthUser) *ScaAuthUserDeviceQuery {
|
||||
query := (&ScaAuthUserDeviceClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := sau.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(scaauthuser.Table, scaauthuser.FieldID, id),
|
||||
sqlgraph.To(scaauthuserdevice.Table, scaauthuserdevice.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, scaauthuser.ScaAuthUserDeviceTable, scaauthuser.ScaAuthUserDeviceColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(sau.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *ScaAuthUserClient) Hooks() []Hook {
|
||||
return c.hooks.ScaAuthUser
|
||||
@@ -809,22 +744,6 @@ func (c *ScaAuthUserDeviceClient) GetX(ctx context.Context, id int64) *ScaAuthUs
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryScaAuthUser queries the sca_auth_user edge of a ScaAuthUserDevice.
|
||||
func (c *ScaAuthUserDeviceClient) QueryScaAuthUser(saud *ScaAuthUserDevice) *ScaAuthUserQuery {
|
||||
query := (&ScaAuthUserClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := saud.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(scaauthuserdevice.Table, scaauthuserdevice.FieldID, id),
|
||||
sqlgraph.To(scaauthuser.Table, scaauthuser.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, scaauthuserdevice.ScaAuthUserTable, scaauthuserdevice.ScaAuthUserColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(saud.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *ScaAuthUserDeviceClient) Hooks() []Hook {
|
||||
return c.hooks.ScaAuthUserDevice
|
||||
@@ -958,22 +877,6 @@ func (c *ScaAuthUserSocialClient) GetX(ctx context.Context, id int64) *ScaAuthUs
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryScaAuthUser queries the sca_auth_user edge of a ScaAuthUserSocial.
|
||||
func (c *ScaAuthUserSocialClient) QueryScaAuthUser(saus *ScaAuthUserSocial) *ScaAuthUserQuery {
|
||||
query := (&ScaAuthUserClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := saus.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(scaauthusersocial.Table, scaauthusersocial.FieldID, id),
|
||||
sqlgraph.To(scaauthuser.Table, scaauthuser.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, scaauthusersocial.ScaAuthUserTable, scaauthusersocial.ScaAuthUserColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(saus.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *ScaAuthUserSocialClient) Hooks() []Hook {
|
||||
return c.hooks.ScaAuthUserSocial
|
||||
|
@@ -3,7 +3,6 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
|
||||
@@ -24,7 +23,7 @@ var schemaGraph = func() *sqlgraph.Schema {
|
||||
Table: scaauthpermissionrule.Table,
|
||||
Columns: scaauthpermissionrule.Columns,
|
||||
ID: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt64,
|
||||
Type: field.TypeInt,
|
||||
Column: scaauthpermissionrule.FieldID,
|
||||
},
|
||||
},
|
||||
@@ -77,7 +76,7 @@ var schemaGraph = func() *sqlgraph.Schema {
|
||||
scaauthuser.FieldEmail: {Type: field.TypeString, Column: scaauthuser.FieldEmail},
|
||||
scaauthuser.FieldPhone: {Type: field.TypeString, Column: scaauthuser.FieldPhone},
|
||||
scaauthuser.FieldPassword: {Type: field.TypeString, Column: scaauthuser.FieldPassword},
|
||||
scaauthuser.FieldGender: {Type: field.TypeString, Column: scaauthuser.FieldGender},
|
||||
scaauthuser.FieldGender: {Type: field.TypeInt8, Column: scaauthuser.FieldGender},
|
||||
scaauthuser.FieldAvatar: {Type: field.TypeString, Column: scaauthuser.FieldAvatar},
|
||||
scaauthuser.FieldStatus: {Type: field.TypeInt8, Column: scaauthuser.FieldStatus},
|
||||
scaauthuser.FieldIntroduce: {Type: field.TypeString, Column: scaauthuser.FieldIntroduce},
|
||||
@@ -135,78 +134,6 @@ var schemaGraph = func() *sqlgraph.Schema {
|
||||
scaauthusersocial.FieldStatus: {Type: field.TypeInt, Column: scaauthusersocial.FieldStatus},
|
||||
},
|
||||
}
|
||||
graph.MustAddE(
|
||||
"sca_auth_role",
|
||||
&sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthpermissionrule.ScaAuthRoleTable,
|
||||
Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn},
|
||||
Bidi: false,
|
||||
},
|
||||
"ScaAuthPermissionRule",
|
||||
"ScaAuthRole",
|
||||
)
|
||||
graph.MustAddE(
|
||||
"sca_auth_permission_rule",
|
||||
&sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthrole.ScaAuthPermissionRuleTable,
|
||||
Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
|
||||
Bidi: false,
|
||||
},
|
||||
"ScaAuthRole",
|
||||
"ScaAuthPermissionRule",
|
||||
)
|
||||
graph.MustAddE(
|
||||
"sca_auth_user_social",
|
||||
&sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthuser.ScaAuthUserSocialTable,
|
||||
Columns: []string{scaauthuser.ScaAuthUserSocialColumn},
|
||||
Bidi: false,
|
||||
},
|
||||
"ScaAuthUser",
|
||||
"ScaAuthUserSocial",
|
||||
)
|
||||
graph.MustAddE(
|
||||
"sca_auth_user_device",
|
||||
&sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthuser.ScaAuthUserDeviceTable,
|
||||
Columns: []string{scaauthuser.ScaAuthUserDeviceColumn},
|
||||
Bidi: false,
|
||||
},
|
||||
"ScaAuthUser",
|
||||
"ScaAuthUserDevice",
|
||||
)
|
||||
graph.MustAddE(
|
||||
"sca_auth_user",
|
||||
&sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthuserdevice.ScaAuthUserTable,
|
||||
Columns: []string{scaauthuserdevice.ScaAuthUserColumn},
|
||||
Bidi: false,
|
||||
},
|
||||
"ScaAuthUserDevice",
|
||||
"ScaAuthUser",
|
||||
)
|
||||
graph.MustAddE(
|
||||
"sca_auth_user",
|
||||
&sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthusersocial.ScaAuthUserTable,
|
||||
Columns: []string{scaauthusersocial.ScaAuthUserColumn},
|
||||
Bidi: false,
|
||||
},
|
||||
"ScaAuthUserSocial",
|
||||
"ScaAuthUser",
|
||||
)
|
||||
return graph
|
||||
}()
|
||||
|
||||
@@ -251,8 +178,8 @@ func (f *ScaAuthPermissionRuleFilter) Where(p entql.P) {
|
||||
})
|
||||
}
|
||||
|
||||
// WhereID applies the entql int64 predicate on the id field.
|
||||
func (f *ScaAuthPermissionRuleFilter) WhereID(p entql.Int64P) {
|
||||
// WhereID applies the entql int predicate on the id field.
|
||||
func (f *ScaAuthPermissionRuleFilter) WhereID(p entql.IntP) {
|
||||
f.Where(p.Field(scaauthpermissionrule.FieldID))
|
||||
}
|
||||
|
||||
@@ -291,20 +218,6 @@ func (f *ScaAuthPermissionRuleFilter) WhereV5(p entql.StringP) {
|
||||
f.Where(p.Field(scaauthpermissionrule.FieldV5))
|
||||
}
|
||||
|
||||
// WhereHasScaAuthRole applies a predicate to check if query has an edge sca_auth_role.
|
||||
func (f *ScaAuthPermissionRuleFilter) WhereHasScaAuthRole() {
|
||||
f.Where(entql.HasEdge("sca_auth_role"))
|
||||
}
|
||||
|
||||
// WhereHasScaAuthRoleWith applies a predicate to check if query has an edge sca_auth_role with a given conditions (other predicates).
|
||||
func (f *ScaAuthPermissionRuleFilter) WhereHasScaAuthRoleWith(preds ...predicate.ScaAuthRole) {
|
||||
f.Where(entql.HasEdgeWith("sca_auth_role", sqlgraph.WrapFunc(func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})))
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
func (sarq *ScaAuthRoleQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
sarq.predicates = append(sarq.predicates, pred)
|
||||
@@ -370,20 +283,6 @@ func (f *ScaAuthRoleFilter) WhereRoleKey(p entql.StringP) {
|
||||
f.Where(p.Field(scaauthrole.FieldRoleKey))
|
||||
}
|
||||
|
||||
// WhereHasScaAuthPermissionRule applies a predicate to check if query has an edge sca_auth_permission_rule.
|
||||
func (f *ScaAuthRoleFilter) WhereHasScaAuthPermissionRule() {
|
||||
f.Where(entql.HasEdge("sca_auth_permission_rule"))
|
||||
}
|
||||
|
||||
// WhereHasScaAuthPermissionRuleWith applies a predicate to check if query has an edge sca_auth_permission_rule with a given conditions (other predicates).
|
||||
func (f *ScaAuthRoleFilter) WhereHasScaAuthPermissionRuleWith(preds ...predicate.ScaAuthPermissionRule) {
|
||||
f.Where(entql.HasEdgeWith("sca_auth_permission_rule", sqlgraph.WrapFunc(func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})))
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
func (sauq *ScaAuthUserQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
sauq.predicates = append(sauq.predicates, pred)
|
||||
@@ -469,8 +368,8 @@ func (f *ScaAuthUserFilter) WherePassword(p entql.StringP) {
|
||||
f.Where(p.Field(scaauthuser.FieldPassword))
|
||||
}
|
||||
|
||||
// WhereGender applies the entql string predicate on the gender field.
|
||||
func (f *ScaAuthUserFilter) WhereGender(p entql.StringP) {
|
||||
// WhereGender applies the entql int8 predicate on the gender field.
|
||||
func (f *ScaAuthUserFilter) WhereGender(p entql.Int8P) {
|
||||
f.Where(p.Field(scaauthuser.FieldGender))
|
||||
}
|
||||
|
||||
@@ -504,34 +403,6 @@ func (f *ScaAuthUserFilter) WhereCompany(p entql.StringP) {
|
||||
f.Where(p.Field(scaauthuser.FieldCompany))
|
||||
}
|
||||
|
||||
// WhereHasScaAuthUserSocial applies a predicate to check if query has an edge sca_auth_user_social.
|
||||
func (f *ScaAuthUserFilter) WhereHasScaAuthUserSocial() {
|
||||
f.Where(entql.HasEdge("sca_auth_user_social"))
|
||||
}
|
||||
|
||||
// WhereHasScaAuthUserSocialWith applies a predicate to check if query has an edge sca_auth_user_social with a given conditions (other predicates).
|
||||
func (f *ScaAuthUserFilter) WhereHasScaAuthUserSocialWith(preds ...predicate.ScaAuthUserSocial) {
|
||||
f.Where(entql.HasEdgeWith("sca_auth_user_social", sqlgraph.WrapFunc(func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})))
|
||||
}
|
||||
|
||||
// WhereHasScaAuthUserDevice applies a predicate to check if query has an edge sca_auth_user_device.
|
||||
func (f *ScaAuthUserFilter) WhereHasScaAuthUserDevice() {
|
||||
f.Where(entql.HasEdge("sca_auth_user_device"))
|
||||
}
|
||||
|
||||
// WhereHasScaAuthUserDeviceWith applies a predicate to check if query has an edge sca_auth_user_device with a given conditions (other predicates).
|
||||
func (f *ScaAuthUserFilter) WhereHasScaAuthUserDeviceWith(preds ...predicate.ScaAuthUserDevice) {
|
||||
f.Where(entql.HasEdgeWith("sca_auth_user_device", sqlgraph.WrapFunc(func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})))
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
func (saudq *ScaAuthUserDeviceQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
saudq.predicates = append(saudq.predicates, pred)
|
||||
@@ -652,20 +523,6 @@ func (f *ScaAuthUserDeviceFilter) WhereEngineVersion(p entql.StringP) {
|
||||
f.Where(p.Field(scaauthuserdevice.FieldEngineVersion))
|
||||
}
|
||||
|
||||
// WhereHasScaAuthUser applies a predicate to check if query has an edge sca_auth_user.
|
||||
func (f *ScaAuthUserDeviceFilter) WhereHasScaAuthUser() {
|
||||
f.Where(entql.HasEdge("sca_auth_user"))
|
||||
}
|
||||
|
||||
// WhereHasScaAuthUserWith applies a predicate to check if query has an edge sca_auth_user with a given conditions (other predicates).
|
||||
func (f *ScaAuthUserDeviceFilter) WhereHasScaAuthUserWith(preds ...predicate.ScaAuthUser) {
|
||||
f.Where(entql.HasEdgeWith("sca_auth_user", sqlgraph.WrapFunc(func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})))
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
func (sausq *ScaAuthUserSocialQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
sausq.predicates = append(sausq.predicates, pred)
|
||||
@@ -740,17 +597,3 @@ func (f *ScaAuthUserSocialFilter) WhereSource(p entql.StringP) {
|
||||
func (f *ScaAuthUserSocialFilter) WhereStatus(p entql.IntP) {
|
||||
f.Where(p.Field(scaauthusersocial.FieldStatus))
|
||||
}
|
||||
|
||||
// WhereHasScaAuthUser applies a predicate to check if query has an edge sca_auth_user.
|
||||
func (f *ScaAuthUserSocialFilter) WhereHasScaAuthUser() {
|
||||
f.Where(entql.HasEdge("sca_auth_user"))
|
||||
}
|
||||
|
||||
// WhereHasScaAuthUserWith applies a predicate to check if query has an edge sca_auth_user with a given conditions (other predicates).
|
||||
func (f *ScaAuthUserSocialFilter) WhereHasScaAuthUserWith(preds ...predicate.ScaAuthUser) {
|
||||
f.Where(entql.HasEdgeWith("sca_auth_user", sqlgraph.WrapFunc(func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})))
|
||||
}
|
||||
|
@@ -11,15 +11,14 @@ import (
|
||||
var (
|
||||
// ScaAuthPermissionRuleColumns holds the columns for the "sca_auth_permission_rule" table.
|
||||
ScaAuthPermissionRuleColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt64, Increment: true, SchemaType: map[string]string{"mysql": "bigint(20) unsigned"}},
|
||||
{Name: "ptype", Type: field.TypeString, Size: 100},
|
||||
{Name: "v0", Type: field.TypeString, Size: 100},
|
||||
{Name: "v1", Type: field.TypeString, Size: 100},
|
||||
{Name: "id", Type: field.TypeInt, Increment: true, SchemaType: map[string]string{"mysql": "int(11)"}},
|
||||
{Name: "ptype", Type: field.TypeString, Nullable: true, Size: 100},
|
||||
{Name: "v0", Type: field.TypeString, Nullable: true, Size: 100},
|
||||
{Name: "v1", Type: field.TypeString, Nullable: true, Size: 100},
|
||||
{Name: "v2", Type: field.TypeString, Nullable: true, Size: 100},
|
||||
{Name: "v3", Type: field.TypeString, Nullable: true, Size: 100},
|
||||
{Name: "v4", Type: field.TypeString, Nullable: true, Size: 100},
|
||||
{Name: "v5", Type: field.TypeString, Nullable: true, Size: 100},
|
||||
{Name: "sca_auth_role_sca_auth_permission_rule", Type: field.TypeInt64, Nullable: true, SchemaType: map[string]string{"mysql": "bigint(20)"}},
|
||||
}
|
||||
// ScaAuthPermissionRuleTable holds the schema information for the "sca_auth_permission_rule" table.
|
||||
ScaAuthPermissionRuleTable = &schema.Table{
|
||||
@@ -27,14 +26,6 @@ var (
|
||||
Comment: "角色权限规则表",
|
||||
Columns: ScaAuthPermissionRuleColumns,
|
||||
PrimaryKey: []*schema.Column{ScaAuthPermissionRuleColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "sca_auth_permission_rule_sca_auth_role_sca_auth_permission_rule",
|
||||
Columns: []*schema.Column{ScaAuthPermissionRuleColumns[8]},
|
||||
RefColumns: []*schema.Column{ScaAuthRoleColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
}
|
||||
// ScaAuthRoleColumns holds the columns for the "sca_auth_role" table.
|
||||
ScaAuthRoleColumns = []*schema.Column{
|
||||
@@ -64,7 +55,7 @@ var (
|
||||
{Name: "email", Type: field.TypeString, Nullable: true, Size: 32, Comment: "邮箱"},
|
||||
{Name: "phone", Type: field.TypeString, Nullable: true, Size: 32, Comment: "电话"},
|
||||
{Name: "password", Type: field.TypeString, Nullable: true, Size: 64, Comment: "密码"},
|
||||
{Name: "gender", Type: field.TypeString, Nullable: true, Size: 32, Comment: "性别"},
|
||||
{Name: "gender", Type: field.TypeInt8, Nullable: true, Comment: "性别"},
|
||||
{Name: "avatar", Type: field.TypeString, Nullable: true, Comment: "头像"},
|
||||
{Name: "status", Type: field.TypeInt8, Nullable: true, Comment: "状态 0 正常 1 封禁", Default: 0},
|
||||
{Name: "introduce", Type: field.TypeString, Nullable: true, Size: 255, Comment: "介绍"},
|
||||
@@ -115,7 +106,6 @@ var (
|
||||
{Name: "platform", Type: field.TypeString, Size: 20, Comment: "平台"},
|
||||
{Name: "engine_name", Type: field.TypeString, Size: 20, Comment: "引擎名称"},
|
||||
{Name: "engine_version", Type: field.TypeString, Size: 20, Comment: "引擎版本"},
|
||||
{Name: "sca_auth_user_sca_auth_user_device", Type: field.TypeInt64, Nullable: true, SchemaType: map[string]string{"mysql": "bigint(20)"}},
|
||||
}
|
||||
// ScaAuthUserDeviceTable holds the schema information for the "sca_auth_user_device" table.
|
||||
ScaAuthUserDeviceTable = &schema.Table{
|
||||
@@ -123,14 +113,6 @@ var (
|
||||
Comment: "用户设备表",
|
||||
Columns: ScaAuthUserDeviceColumns,
|
||||
PrimaryKey: []*schema.Column{ScaAuthUserDeviceColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "sca_auth_user_device_sca_auth_user_sca_auth_user_device",
|
||||
Columns: []*schema.Column{ScaAuthUserDeviceColumns[17]},
|
||||
RefColumns: []*schema.Column{ScaAuthUserColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "scaauthuserdevice_id",
|
||||
@@ -149,7 +131,6 @@ var (
|
||||
{Name: "open_id", Type: field.TypeString, Size: 50, Comment: "第三方用户的 open id"},
|
||||
{Name: "source", Type: field.TypeString, Size: 10, Comment: "第三方用户来源"},
|
||||
{Name: "status", Type: field.TypeInt, Comment: "状态 0正常 1 封禁", Default: 0},
|
||||
{Name: "sca_auth_user_sca_auth_user_social", Type: field.TypeInt64, Nullable: true, SchemaType: map[string]string{"mysql": "bigint(20)"}},
|
||||
}
|
||||
// ScaAuthUserSocialTable holds the schema information for the "sca_auth_user_social" table.
|
||||
ScaAuthUserSocialTable = &schema.Table{
|
||||
@@ -157,14 +138,6 @@ var (
|
||||
Comment: "用户第三方登录信息",
|
||||
Columns: ScaAuthUserSocialColumns,
|
||||
PrimaryKey: []*schema.Column{ScaAuthUserSocialColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "sca_auth_user_social_sca_auth_user_sca_auth_user_social",
|
||||
Columns: []*schema.Column{ScaAuthUserSocialColumns[8]},
|
||||
RefColumns: []*schema.Column{ScaAuthUserColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "scaauthusersocial_id",
|
||||
@@ -194,7 +167,6 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
ScaAuthPermissionRuleTable.ForeignKeys[0].RefTable = ScaAuthRoleTable
|
||||
ScaAuthPermissionRuleTable.Annotation = &entsql.Annotation{
|
||||
Table: "sca_auth_permission_rule",
|
||||
}
|
||||
@@ -204,11 +176,9 @@ func init() {
|
||||
ScaAuthUserTable.Annotation = &entsql.Annotation{
|
||||
Table: "sca_auth_user",
|
||||
}
|
||||
ScaAuthUserDeviceTable.ForeignKeys[0].RefTable = ScaAuthUserTable
|
||||
ScaAuthUserDeviceTable.Annotation = &entsql.Annotation{
|
||||
Table: "sca_auth_user_device",
|
||||
}
|
||||
ScaAuthUserSocialTable.ForeignKeys[0].RefTable = ScaAuthUserTable
|
||||
ScaAuthUserSocialTable.Annotation = &entsql.Annotation{
|
||||
Table: "sca_auth_user_social",
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -120,10 +120,6 @@ func init() {
|
||||
scaauthuserDescPassword := scaauthuserFields[6].Descriptor()
|
||||
// scaauthuser.PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
scaauthuser.PasswordValidator = scaauthuserDescPassword.Validators[0].(func(string) error)
|
||||
// scaauthuserDescGender is the schema descriptor for gender field.
|
||||
scaauthuserDescGender := scaauthuserFields[7].Descriptor()
|
||||
// scaauthuser.GenderValidator is a validator for the "gender" field. It is called by the builders before save.
|
||||
scaauthuser.GenderValidator = scaauthuserDescGender.Validators[0].(func(string) error)
|
||||
// scaauthuserDescStatus is the schema descriptor for status field.
|
||||
scaauthuserDescStatus := scaauthuserFields[9].Descriptor()
|
||||
// scaauthuser.DefaultStatus holds the default value on creation for the status field.
|
||||
|
@@ -5,7 +5,6 @@ package ent
|
||||
import (
|
||||
"fmt"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent"
|
||||
@@ -16,46 +15,22 @@ import (
|
||||
type ScaAuthPermissionRule struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int64 `json:"id,omitempty"`
|
||||
ID int `json:"id,omitempty"`
|
||||
// Ptype holds the value of the "ptype" field.
|
||||
Ptype *string `json:"ptype,omitempty"`
|
||||
Ptype string `json:"ptype,omitempty"`
|
||||
// V0 holds the value of the "v0" field.
|
||||
V0 *string `json:"v0,omitempty"`
|
||||
V0 string `json:"v0,omitempty"`
|
||||
// V1 holds the value of the "v1" field.
|
||||
V1 *string `json:"v1,omitempty"`
|
||||
V1 string `json:"v1,omitempty"`
|
||||
// V2 holds the value of the "v2" field.
|
||||
V2 *string `json:"v2,omitempty"`
|
||||
V2 string `json:"v2,omitempty"`
|
||||
// V3 holds the value of the "v3" field.
|
||||
V3 *string `json:"v3,omitempty"`
|
||||
V3 string `json:"v3,omitempty"`
|
||||
// V4 holds the value of the "v4" field.
|
||||
V4 *string `json:"v4,omitempty"`
|
||||
V4 string `json:"v4,omitempty"`
|
||||
// V5 holds the value of the "v5" field.
|
||||
V5 *string `json:"v5,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the ScaAuthPermissionRuleQuery when eager-loading is set.
|
||||
Edges ScaAuthPermissionRuleEdges `json:"edges"`
|
||||
sca_auth_role_sca_auth_permission_rule *int64
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// ScaAuthPermissionRuleEdges holds the relations/edges for other nodes in the graph.
|
||||
type ScaAuthPermissionRuleEdges struct {
|
||||
// ScaAuthRole holds the value of the sca_auth_role edge.
|
||||
ScaAuthRole *ScaAuthRole `json:"sca_auth_role,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// ScaAuthRoleOrErr returns the ScaAuthRole value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e ScaAuthPermissionRuleEdges) ScaAuthRoleOrErr() (*ScaAuthRole, error) {
|
||||
if e.ScaAuthRole != nil {
|
||||
return e.ScaAuthRole, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: scaauthrole.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "sca_auth_role"}
|
||||
V5 string `json:"v5,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
@@ -67,8 +42,6 @@ func (*ScaAuthPermissionRule) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullInt64)
|
||||
case scaauthpermissionrule.FieldPtype, scaauthpermissionrule.FieldV0, scaauthpermissionrule.FieldV1, scaauthpermissionrule.FieldV2, scaauthpermissionrule.FieldV3, scaauthpermissionrule.FieldV4, scaauthpermissionrule.FieldV5:
|
||||
values[i] = new(sql.NullString)
|
||||
case scaauthpermissionrule.ForeignKeys[0]: // sca_auth_role_sca_auth_permission_rule
|
||||
values[i] = new(sql.NullInt64)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
@@ -89,62 +62,48 @@ func (sapr *ScaAuthPermissionRule) assignValues(columns []string, values []any)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
sapr.ID = int64(value.Int64)
|
||||
sapr.ID = int(value.Int64)
|
||||
case scaauthpermissionrule.FieldPtype:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field ptype", values[i])
|
||||
} else if value.Valid {
|
||||
sapr.Ptype = new(string)
|
||||
*sapr.Ptype = value.String
|
||||
sapr.Ptype = value.String
|
||||
}
|
||||
case scaauthpermissionrule.FieldV0:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field v0", values[i])
|
||||
} else if value.Valid {
|
||||
sapr.V0 = new(string)
|
||||
*sapr.V0 = value.String
|
||||
sapr.V0 = value.String
|
||||
}
|
||||
case scaauthpermissionrule.FieldV1:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field v1", values[i])
|
||||
} else if value.Valid {
|
||||
sapr.V1 = new(string)
|
||||
*sapr.V1 = value.String
|
||||
sapr.V1 = value.String
|
||||
}
|
||||
case scaauthpermissionrule.FieldV2:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field v2", values[i])
|
||||
} else if value.Valid {
|
||||
sapr.V2 = new(string)
|
||||
*sapr.V2 = value.String
|
||||
sapr.V2 = value.String
|
||||
}
|
||||
case scaauthpermissionrule.FieldV3:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field v3", values[i])
|
||||
} else if value.Valid {
|
||||
sapr.V3 = new(string)
|
||||
*sapr.V3 = value.String
|
||||
sapr.V3 = value.String
|
||||
}
|
||||
case scaauthpermissionrule.FieldV4:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field v4", values[i])
|
||||
} else if value.Valid {
|
||||
sapr.V4 = new(string)
|
||||
*sapr.V4 = value.String
|
||||
sapr.V4 = value.String
|
||||
}
|
||||
case scaauthpermissionrule.FieldV5:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field v5", values[i])
|
||||
} else if value.Valid {
|
||||
sapr.V5 = new(string)
|
||||
*sapr.V5 = value.String
|
||||
}
|
||||
case scaauthpermissionrule.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for edge-field sca_auth_role_sca_auth_permission_rule", value)
|
||||
} else if value.Valid {
|
||||
sapr.sca_auth_role_sca_auth_permission_rule = new(int64)
|
||||
*sapr.sca_auth_role_sca_auth_permission_rule = int64(value.Int64)
|
||||
sapr.V5 = value.String
|
||||
}
|
||||
default:
|
||||
sapr.selectValues.Set(columns[i], values[i])
|
||||
@@ -159,11 +118,6 @@ func (sapr *ScaAuthPermissionRule) Value(name string) (ent.Value, error) {
|
||||
return sapr.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryScaAuthRole queries the "sca_auth_role" edge of the ScaAuthPermissionRule entity.
|
||||
func (sapr *ScaAuthPermissionRule) QueryScaAuthRole() *ScaAuthRoleQuery {
|
||||
return NewScaAuthPermissionRuleClient(sapr.config).QueryScaAuthRole(sapr)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this ScaAuthPermissionRule.
|
||||
// Note that you need to call ScaAuthPermissionRule.Unwrap() before calling this method if this ScaAuthPermissionRule
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
@@ -187,40 +141,26 @@ func (sapr *ScaAuthPermissionRule) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("ScaAuthPermissionRule(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", sapr.ID))
|
||||
if v := sapr.Ptype; v != nil {
|
||||
builder.WriteString("ptype=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString("ptype=")
|
||||
builder.WriteString(sapr.Ptype)
|
||||
builder.WriteString(", ")
|
||||
if v := sapr.V0; v != nil {
|
||||
builder.WriteString("v0=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString("v0=")
|
||||
builder.WriteString(sapr.V0)
|
||||
builder.WriteString(", ")
|
||||
if v := sapr.V1; v != nil {
|
||||
builder.WriteString("v1=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString("v1=")
|
||||
builder.WriteString(sapr.V1)
|
||||
builder.WriteString(", ")
|
||||
if v := sapr.V2; v != nil {
|
||||
builder.WriteString("v2=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString("v2=")
|
||||
builder.WriteString(sapr.V2)
|
||||
builder.WriteString(", ")
|
||||
if v := sapr.V3; v != nil {
|
||||
builder.WriteString("v3=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString("v3=")
|
||||
builder.WriteString(sapr.V3)
|
||||
builder.WriteString(", ")
|
||||
if v := sapr.V4; v != nil {
|
||||
builder.WriteString("v4=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString("v4=")
|
||||
builder.WriteString(sapr.V4)
|
||||
builder.WriteString(", ")
|
||||
if v := sapr.V5; v != nil {
|
||||
builder.WriteString("v5=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString("v5=")
|
||||
builder.WriteString(sapr.V5)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ package scaauthpermissionrule
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -26,17 +25,8 @@ const (
|
||||
FieldV4 = "v4"
|
||||
// FieldV5 holds the string denoting the v5 field in the database.
|
||||
FieldV5 = "v5"
|
||||
// EdgeScaAuthRole holds the string denoting the sca_auth_role edge name in mutations.
|
||||
EdgeScaAuthRole = "sca_auth_role"
|
||||
// Table holds the table name of the scaauthpermissionrule in the database.
|
||||
Table = "sca_auth_permission_rule"
|
||||
// ScaAuthRoleTable is the table that holds the sca_auth_role relation/edge.
|
||||
ScaAuthRoleTable = "sca_auth_permission_rule"
|
||||
// ScaAuthRoleInverseTable is the table name for the ScaAuthRole entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "scaauthrole" package.
|
||||
ScaAuthRoleInverseTable = "sca_auth_role"
|
||||
// ScaAuthRoleColumn is the table column denoting the sca_auth_role relation/edge.
|
||||
ScaAuthRoleColumn = "sca_auth_role_sca_auth_permission_rule"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for scaauthpermissionrule fields.
|
||||
@@ -51,12 +41,6 @@ var Columns = []string{
|
||||
FieldV5,
|
||||
}
|
||||
|
||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "sca_auth_permission_rule"
|
||||
// table and are not defined as standalone fields in the schema.
|
||||
var ForeignKeys = []string{
|
||||
"sca_auth_role_sca_auth_permission_rule",
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
@@ -64,11 +48,6 @@ func ValidColumn(column string) bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
for i := range ForeignKeys {
|
||||
if column == ForeignKeys[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -131,17 +110,3 @@ func ByV4(opts ...sql.OrderTermOption) OrderOption {
|
||||
func ByV5(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldV5, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByScaAuthRoleField orders the results by sca_auth_role field.
|
||||
func ByScaAuthRoleField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newScaAuthRoleStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newScaAuthRoleStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(ScaAuthRoleInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthRoleTable, ScaAuthRoleColumn),
|
||||
)
|
||||
}
|
||||
|
@@ -6,51 +6,50 @@ import (
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int64) predicate.ScaAuthPermissionRule {
|
||||
func ID(id int) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int64) predicate.ScaAuthPermissionRule {
|
||||
func IDEQ(id int) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int64) predicate.ScaAuthPermissionRule {
|
||||
func IDNEQ(id int) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int64) predicate.ScaAuthPermissionRule {
|
||||
func IDIn(ids ...int) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int64) predicate.ScaAuthPermissionRule {
|
||||
func IDNotIn(ids ...int) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int64) predicate.ScaAuthPermissionRule {
|
||||
func IDGT(id int) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int64) predicate.ScaAuthPermissionRule {
|
||||
func IDGTE(id int) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int64) predicate.ScaAuthPermissionRule {
|
||||
func IDLT(id int) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int64) predicate.ScaAuthPermissionRule {
|
||||
func IDLTE(id int) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
@@ -144,6 +143,16 @@ func PtypeHasSuffix(v string) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldPtype, v))
|
||||
}
|
||||
|
||||
// PtypeIsNil applies the IsNil predicate on the "ptype" field.
|
||||
func PtypeIsNil() predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldPtype))
|
||||
}
|
||||
|
||||
// PtypeNotNil applies the NotNil predicate on the "ptype" field.
|
||||
func PtypeNotNil() predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldPtype))
|
||||
}
|
||||
|
||||
// PtypeEqualFold applies the EqualFold predicate on the "ptype" field.
|
||||
func PtypeEqualFold(v string) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldPtype, v))
|
||||
@@ -209,6 +218,16 @@ func V0HasSuffix(v string) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV0, v))
|
||||
}
|
||||
|
||||
// V0IsNil applies the IsNil predicate on the "v0" field.
|
||||
func V0IsNil() predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldV0))
|
||||
}
|
||||
|
||||
// V0NotNil applies the NotNil predicate on the "v0" field.
|
||||
func V0NotNil() predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldV0))
|
||||
}
|
||||
|
||||
// V0EqualFold applies the EqualFold predicate on the "v0" field.
|
||||
func V0EqualFold(v string) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV0, v))
|
||||
@@ -274,6 +293,16 @@ func V1HasSuffix(v string) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV1, v))
|
||||
}
|
||||
|
||||
// V1IsNil applies the IsNil predicate on the "v1" field.
|
||||
func V1IsNil() predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldV1))
|
||||
}
|
||||
|
||||
// V1NotNil applies the NotNil predicate on the "v1" field.
|
||||
func V1NotNil() predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldV1))
|
||||
}
|
||||
|
||||
// V1EqualFold applies the EqualFold predicate on the "v1" field.
|
||||
func V1EqualFold(v string) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV1, v))
|
||||
@@ -584,29 +613,6 @@ func V5ContainsFold(v string) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV5, v))
|
||||
}
|
||||
|
||||
// HasScaAuthRole applies the HasEdge predicate on the "sca_auth_role" edge.
|
||||
func HasScaAuthRole() predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthRoleTable, ScaAuthRoleColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasScaAuthRoleWith applies the HasEdge predicate on the "sca_auth_role" edge with a given conditions (other predicates).
|
||||
func HasScaAuthRoleWith(preds ...predicate.ScaAuthRole) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(func(s *sql.Selector) {
|
||||
step := newScaAuthRoleStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.ScaAuthPermissionRule) predicate.ScaAuthPermissionRule {
|
||||
return predicate.ScaAuthPermissionRule(sql.AndPredicates(predicates...))
|
||||
|
@@ -4,10 +4,8 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -26,18 +24,42 @@ func (saprc *ScaAuthPermissionRuleCreate) SetPtype(s string) *ScaAuthPermissionR
|
||||
return saprc
|
||||
}
|
||||
|
||||
// SetNillablePtype sets the "ptype" field if the given value is not nil.
|
||||
func (saprc *ScaAuthPermissionRuleCreate) SetNillablePtype(s *string) *ScaAuthPermissionRuleCreate {
|
||||
if s != nil {
|
||||
saprc.SetPtype(*s)
|
||||
}
|
||||
return saprc
|
||||
}
|
||||
|
||||
// SetV0 sets the "v0" field.
|
||||
func (saprc *ScaAuthPermissionRuleCreate) SetV0(s string) *ScaAuthPermissionRuleCreate {
|
||||
saprc.mutation.SetV0(s)
|
||||
return saprc
|
||||
}
|
||||
|
||||
// SetNillableV0 sets the "v0" field if the given value is not nil.
|
||||
func (saprc *ScaAuthPermissionRuleCreate) SetNillableV0(s *string) *ScaAuthPermissionRuleCreate {
|
||||
if s != nil {
|
||||
saprc.SetV0(*s)
|
||||
}
|
||||
return saprc
|
||||
}
|
||||
|
||||
// SetV1 sets the "v1" field.
|
||||
func (saprc *ScaAuthPermissionRuleCreate) SetV1(s string) *ScaAuthPermissionRuleCreate {
|
||||
saprc.mutation.SetV1(s)
|
||||
return saprc
|
||||
}
|
||||
|
||||
// SetNillableV1 sets the "v1" field if the given value is not nil.
|
||||
func (saprc *ScaAuthPermissionRuleCreate) SetNillableV1(s *string) *ScaAuthPermissionRuleCreate {
|
||||
if s != nil {
|
||||
saprc.SetV1(*s)
|
||||
}
|
||||
return saprc
|
||||
}
|
||||
|
||||
// SetV2 sets the "v2" field.
|
||||
func (saprc *ScaAuthPermissionRuleCreate) SetV2(s string) *ScaAuthPermissionRuleCreate {
|
||||
saprc.mutation.SetV2(s)
|
||||
@@ -95,30 +117,11 @@ func (saprc *ScaAuthPermissionRuleCreate) SetNillableV5(s *string) *ScaAuthPermi
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (saprc *ScaAuthPermissionRuleCreate) SetID(i int64) *ScaAuthPermissionRuleCreate {
|
||||
func (saprc *ScaAuthPermissionRuleCreate) SetID(i int) *ScaAuthPermissionRuleCreate {
|
||||
saprc.mutation.SetID(i)
|
||||
return saprc
|
||||
}
|
||||
|
||||
// SetScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID.
|
||||
func (saprc *ScaAuthPermissionRuleCreate) SetScaAuthRoleID(id int64) *ScaAuthPermissionRuleCreate {
|
||||
saprc.mutation.SetScaAuthRoleID(id)
|
||||
return saprc
|
||||
}
|
||||
|
||||
// SetNillableScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID if the given value is not nil.
|
||||
func (saprc *ScaAuthPermissionRuleCreate) SetNillableScaAuthRoleID(id *int64) *ScaAuthPermissionRuleCreate {
|
||||
if id != nil {
|
||||
saprc = saprc.SetScaAuthRoleID(*id)
|
||||
}
|
||||
return saprc
|
||||
}
|
||||
|
||||
// SetScaAuthRole sets the "sca_auth_role" edge to the ScaAuthRole entity.
|
||||
func (saprc *ScaAuthPermissionRuleCreate) SetScaAuthRole(s *ScaAuthRole) *ScaAuthPermissionRuleCreate {
|
||||
return saprc.SetScaAuthRoleID(s.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthPermissionRuleMutation object of the builder.
|
||||
func (saprc *ScaAuthPermissionRuleCreate) Mutation() *ScaAuthPermissionRuleMutation {
|
||||
return saprc.mutation
|
||||
@@ -153,25 +156,16 @@ func (saprc *ScaAuthPermissionRuleCreate) ExecX(ctx context.Context) {
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (saprc *ScaAuthPermissionRuleCreate) check() error {
|
||||
if _, ok := saprc.mutation.Ptype(); !ok {
|
||||
return &ValidationError{Name: "ptype", err: errors.New(`ent: missing required field "ScaAuthPermissionRule.ptype"`)}
|
||||
}
|
||||
if v, ok := saprc.mutation.Ptype(); ok {
|
||||
if err := scaauthpermissionrule.PtypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "ptype", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.ptype": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := saprc.mutation.V0(); !ok {
|
||||
return &ValidationError{Name: "v0", err: errors.New(`ent: missing required field "ScaAuthPermissionRule.v0"`)}
|
||||
}
|
||||
if v, ok := saprc.mutation.V0(); ok {
|
||||
if err := scaauthpermissionrule.V0Validator(v); err != nil {
|
||||
return &ValidationError{Name: "v0", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v0": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := saprc.mutation.V1(); !ok {
|
||||
return &ValidationError{Name: "v1", err: errors.New(`ent: missing required field "ScaAuthPermissionRule.v1"`)}
|
||||
}
|
||||
if v, ok := saprc.mutation.V1(); ok {
|
||||
if err := scaauthpermissionrule.V1Validator(v); err != nil {
|
||||
return &ValidationError{Name: "v1", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v1": %w`, err)}
|
||||
@@ -213,7 +207,7 @@ func (saprc *ScaAuthPermissionRuleCreate) sqlSave(ctx context.Context) (*ScaAuth
|
||||
}
|
||||
if _spec.ID.Value != _node.ID {
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int64(id)
|
||||
_node.ID = int(id)
|
||||
}
|
||||
saprc.mutation.id = &_node.ID
|
||||
saprc.mutation.done = true
|
||||
@@ -223,7 +217,7 @@ func (saprc *ScaAuthPermissionRuleCreate) sqlSave(ctx context.Context) (*ScaAuth
|
||||
func (saprc *ScaAuthPermissionRuleCreate) createSpec() (*ScaAuthPermissionRule, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &ScaAuthPermissionRule{config: saprc.config}
|
||||
_spec = sqlgraph.NewCreateSpec(scaauthpermissionrule.Table, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64))
|
||||
_spec = sqlgraph.NewCreateSpec(scaauthpermissionrule.Table, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt))
|
||||
)
|
||||
if id, ok := saprc.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
@@ -231,48 +225,31 @@ func (saprc *ScaAuthPermissionRuleCreate) createSpec() (*ScaAuthPermissionRule,
|
||||
}
|
||||
if value, ok := saprc.mutation.Ptype(); ok {
|
||||
_spec.SetField(scaauthpermissionrule.FieldPtype, field.TypeString, value)
|
||||
_node.Ptype = &value
|
||||
_node.Ptype = value
|
||||
}
|
||||
if value, ok := saprc.mutation.V0(); ok {
|
||||
_spec.SetField(scaauthpermissionrule.FieldV0, field.TypeString, value)
|
||||
_node.V0 = &value
|
||||
_node.V0 = value
|
||||
}
|
||||
if value, ok := saprc.mutation.V1(); ok {
|
||||
_spec.SetField(scaauthpermissionrule.FieldV1, field.TypeString, value)
|
||||
_node.V1 = &value
|
||||
_node.V1 = value
|
||||
}
|
||||
if value, ok := saprc.mutation.V2(); ok {
|
||||
_spec.SetField(scaauthpermissionrule.FieldV2, field.TypeString, value)
|
||||
_node.V2 = &value
|
||||
_node.V2 = value
|
||||
}
|
||||
if value, ok := saprc.mutation.V3(); ok {
|
||||
_spec.SetField(scaauthpermissionrule.FieldV3, field.TypeString, value)
|
||||
_node.V3 = &value
|
||||
_node.V3 = value
|
||||
}
|
||||
if value, ok := saprc.mutation.V4(); ok {
|
||||
_spec.SetField(scaauthpermissionrule.FieldV4, field.TypeString, value)
|
||||
_node.V4 = &value
|
||||
_node.V4 = value
|
||||
}
|
||||
if value, ok := saprc.mutation.V5(); ok {
|
||||
_spec.SetField(scaauthpermissionrule.FieldV5, field.TypeString, value)
|
||||
_node.V5 = &value
|
||||
}
|
||||
if nodes := saprc.mutation.ScaAuthRoleIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthpermissionrule.ScaAuthRoleTable,
|
||||
Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.sca_auth_role_sca_auth_permission_rule = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
_node.V5 = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
@@ -323,7 +300,7 @@ func (saprcb *ScaAuthPermissionRuleCreateBulk) Save(ctx context.Context) ([]*Sca
|
||||
mutation.id = &nodes[i].ID
|
||||
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int64(id)
|
||||
nodes[i].ID = int(id)
|
||||
}
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
|
@@ -40,7 +40,7 @@ func (saprd *ScaAuthPermissionRuleDelete) ExecX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
func (saprd *ScaAuthPermissionRuleDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(scaauthpermissionrule.Table, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64))
|
||||
_spec := sqlgraph.NewDeleteSpec(scaauthpermissionrule.Table, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt))
|
||||
if ps := saprd.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
|
@@ -8,7 +8,6 @@ import (
|
||||
"math"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
@@ -19,12 +18,10 @@ import (
|
||||
// ScaAuthPermissionRuleQuery is the builder for querying ScaAuthPermissionRule entities.
|
||||
type ScaAuthPermissionRuleQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []scaauthpermissionrule.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.ScaAuthPermissionRule
|
||||
withScaAuthRole *ScaAuthRoleQuery
|
||||
withFKs bool
|
||||
ctx *QueryContext
|
||||
order []scaauthpermissionrule.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.ScaAuthPermissionRule
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
@@ -61,28 +58,6 @@ func (saprq *ScaAuthPermissionRuleQuery) Order(o ...scaauthpermissionrule.OrderO
|
||||
return saprq
|
||||
}
|
||||
|
||||
// QueryScaAuthRole chains the current query on the "sca_auth_role" edge.
|
||||
func (saprq *ScaAuthPermissionRuleQuery) QueryScaAuthRole() *ScaAuthRoleQuery {
|
||||
query := (&ScaAuthRoleClient{config: saprq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := saprq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := saprq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(scaauthpermissionrule.Table, scaauthpermissionrule.FieldID, selector),
|
||||
sqlgraph.To(scaauthrole.Table, scaauthrole.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, scaauthpermissionrule.ScaAuthRoleTable, scaauthpermissionrule.ScaAuthRoleColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(saprq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first ScaAuthPermissionRule entity from the query.
|
||||
// Returns a *NotFoundError when no ScaAuthPermissionRule was found.
|
||||
func (saprq *ScaAuthPermissionRuleQuery) First(ctx context.Context) (*ScaAuthPermissionRule, error) {
|
||||
@@ -107,8 +82,8 @@ func (saprq *ScaAuthPermissionRuleQuery) FirstX(ctx context.Context) *ScaAuthPer
|
||||
|
||||
// FirstID returns the first ScaAuthPermissionRule ID from the query.
|
||||
// Returns a *NotFoundError when no ScaAuthPermissionRule ID was found.
|
||||
func (saprq *ScaAuthPermissionRuleQuery) FirstID(ctx context.Context) (id int64, err error) {
|
||||
var ids []int64
|
||||
func (saprq *ScaAuthPermissionRuleQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = saprq.Limit(1).IDs(setContextOp(ctx, saprq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -120,7 +95,7 @@ func (saprq *ScaAuthPermissionRuleQuery) FirstID(ctx context.Context) (id int64,
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (saprq *ScaAuthPermissionRuleQuery) FirstIDX(ctx context.Context) int64 {
|
||||
func (saprq *ScaAuthPermissionRuleQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := saprq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
@@ -158,8 +133,8 @@ func (saprq *ScaAuthPermissionRuleQuery) OnlyX(ctx context.Context) *ScaAuthPerm
|
||||
// OnlyID is like Only, but returns the only ScaAuthPermissionRule ID in the query.
|
||||
// Returns a *NotSingularError when more than one ScaAuthPermissionRule ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (saprq *ScaAuthPermissionRuleQuery) OnlyID(ctx context.Context) (id int64, err error) {
|
||||
var ids []int64
|
||||
func (saprq *ScaAuthPermissionRuleQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = saprq.Limit(2).IDs(setContextOp(ctx, saprq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -175,7 +150,7 @@ func (saprq *ScaAuthPermissionRuleQuery) OnlyID(ctx context.Context) (id int64,
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (saprq *ScaAuthPermissionRuleQuery) OnlyIDX(ctx context.Context) int64 {
|
||||
func (saprq *ScaAuthPermissionRuleQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := saprq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -203,7 +178,7 @@ func (saprq *ScaAuthPermissionRuleQuery) AllX(ctx context.Context) []*ScaAuthPer
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of ScaAuthPermissionRule IDs.
|
||||
func (saprq *ScaAuthPermissionRuleQuery) IDs(ctx context.Context) (ids []int64, err error) {
|
||||
func (saprq *ScaAuthPermissionRuleQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if saprq.ctx.Unique == nil && saprq.path != nil {
|
||||
saprq.Unique(true)
|
||||
}
|
||||
@@ -215,7 +190,7 @@ func (saprq *ScaAuthPermissionRuleQuery) IDs(ctx context.Context) (ids []int64,
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (saprq *ScaAuthPermissionRuleQuery) IDsX(ctx context.Context) []int64 {
|
||||
func (saprq *ScaAuthPermissionRuleQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := saprq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -270,29 +245,17 @@ func (saprq *ScaAuthPermissionRuleQuery) Clone() *ScaAuthPermissionRuleQuery {
|
||||
return nil
|
||||
}
|
||||
return &ScaAuthPermissionRuleQuery{
|
||||
config: saprq.config,
|
||||
ctx: saprq.ctx.Clone(),
|
||||
order: append([]scaauthpermissionrule.OrderOption{}, saprq.order...),
|
||||
inters: append([]Interceptor{}, saprq.inters...),
|
||||
predicates: append([]predicate.ScaAuthPermissionRule{}, saprq.predicates...),
|
||||
withScaAuthRole: saprq.withScaAuthRole.Clone(),
|
||||
config: saprq.config,
|
||||
ctx: saprq.ctx.Clone(),
|
||||
order: append([]scaauthpermissionrule.OrderOption{}, saprq.order...),
|
||||
inters: append([]Interceptor{}, saprq.inters...),
|
||||
predicates: append([]predicate.ScaAuthPermissionRule{}, saprq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: saprq.sql.Clone(),
|
||||
path: saprq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithScaAuthRole tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "sca_auth_role" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (saprq *ScaAuthPermissionRuleQuery) WithScaAuthRole(opts ...func(*ScaAuthRoleQuery)) *ScaAuthPermissionRuleQuery {
|
||||
query := (&ScaAuthRoleClient{config: saprq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
saprq.withScaAuthRole = query
|
||||
return saprq
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
@@ -369,26 +332,15 @@ func (saprq *ScaAuthPermissionRuleQuery) prepareQuery(ctx context.Context) error
|
||||
|
||||
func (saprq *ScaAuthPermissionRuleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthPermissionRule, error) {
|
||||
var (
|
||||
nodes = []*ScaAuthPermissionRule{}
|
||||
withFKs = saprq.withFKs
|
||||
_spec = saprq.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
saprq.withScaAuthRole != nil,
|
||||
}
|
||||
nodes = []*ScaAuthPermissionRule{}
|
||||
_spec = saprq.querySpec()
|
||||
)
|
||||
if saprq.withScaAuthRole != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, scaauthpermissionrule.ForeignKeys...)
|
||||
}
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*ScaAuthPermissionRule).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &ScaAuthPermissionRule{config: saprq.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
@@ -400,48 +352,9 @@ func (saprq *ScaAuthPermissionRuleQuery) sqlAll(ctx context.Context, hooks ...qu
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := saprq.withScaAuthRole; query != nil {
|
||||
if err := saprq.loadScaAuthRole(ctx, query, nodes, nil,
|
||||
func(n *ScaAuthPermissionRule, e *ScaAuthRole) { n.Edges.ScaAuthRole = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (saprq *ScaAuthPermissionRuleQuery) loadScaAuthRole(ctx context.Context, query *ScaAuthRoleQuery, nodes []*ScaAuthPermissionRule, init func(*ScaAuthPermissionRule), assign func(*ScaAuthPermissionRule, *ScaAuthRole)) error {
|
||||
ids := make([]int64, 0, len(nodes))
|
||||
nodeids := make(map[int64][]*ScaAuthPermissionRule)
|
||||
for i := range nodes {
|
||||
if nodes[i].sca_auth_role_sca_auth_permission_rule == nil {
|
||||
continue
|
||||
}
|
||||
fk := *nodes[i].sca_auth_role_sca_auth_permission_rule
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(scaauthrole.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "sca_auth_role_sca_auth_permission_rule" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (saprq *ScaAuthPermissionRuleQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := saprq.querySpec()
|
||||
_spec.Node.Columns = saprq.ctx.Fields
|
||||
@@ -452,7 +365,7 @@ func (saprq *ScaAuthPermissionRuleQuery) sqlCount(ctx context.Context) (int, err
|
||||
}
|
||||
|
||||
func (saprq *ScaAuthPermissionRuleQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64))
|
||||
_spec := sqlgraph.NewQuerySpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt))
|
||||
_spec.From = saprq.sql
|
||||
if unique := saprq.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
|
@@ -8,7 +8,6 @@ import (
|
||||
"fmt"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -42,6 +41,12 @@ func (sapru *ScaAuthPermissionRuleUpdate) SetNillablePtype(s *string) *ScaAuthPe
|
||||
return sapru
|
||||
}
|
||||
|
||||
// ClearPtype clears the value of the "ptype" field.
|
||||
func (sapru *ScaAuthPermissionRuleUpdate) ClearPtype() *ScaAuthPermissionRuleUpdate {
|
||||
sapru.mutation.ClearPtype()
|
||||
return sapru
|
||||
}
|
||||
|
||||
// SetV0 sets the "v0" field.
|
||||
func (sapru *ScaAuthPermissionRuleUpdate) SetV0(s string) *ScaAuthPermissionRuleUpdate {
|
||||
sapru.mutation.SetV0(s)
|
||||
@@ -56,6 +61,12 @@ func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV0(s *string) *ScaAuthPermi
|
||||
return sapru
|
||||
}
|
||||
|
||||
// ClearV0 clears the value of the "v0" field.
|
||||
func (sapru *ScaAuthPermissionRuleUpdate) ClearV0() *ScaAuthPermissionRuleUpdate {
|
||||
sapru.mutation.ClearV0()
|
||||
return sapru
|
||||
}
|
||||
|
||||
// SetV1 sets the "v1" field.
|
||||
func (sapru *ScaAuthPermissionRuleUpdate) SetV1(s string) *ScaAuthPermissionRuleUpdate {
|
||||
sapru.mutation.SetV1(s)
|
||||
@@ -70,6 +81,12 @@ func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV1(s *string) *ScaAuthPermi
|
||||
return sapru
|
||||
}
|
||||
|
||||
// ClearV1 clears the value of the "v1" field.
|
||||
func (sapru *ScaAuthPermissionRuleUpdate) ClearV1() *ScaAuthPermissionRuleUpdate {
|
||||
sapru.mutation.ClearV1()
|
||||
return sapru
|
||||
}
|
||||
|
||||
// SetV2 sets the "v2" field.
|
||||
func (sapru *ScaAuthPermissionRuleUpdate) SetV2(s string) *ScaAuthPermissionRuleUpdate {
|
||||
sapru.mutation.SetV2(s)
|
||||
@@ -150,36 +167,11 @@ func (sapru *ScaAuthPermissionRuleUpdate) ClearV5() *ScaAuthPermissionRuleUpdate
|
||||
return sapru
|
||||
}
|
||||
|
||||
// SetScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID.
|
||||
func (sapru *ScaAuthPermissionRuleUpdate) SetScaAuthRoleID(id int64) *ScaAuthPermissionRuleUpdate {
|
||||
sapru.mutation.SetScaAuthRoleID(id)
|
||||
return sapru
|
||||
}
|
||||
|
||||
// SetNillableScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID if the given value is not nil.
|
||||
func (sapru *ScaAuthPermissionRuleUpdate) SetNillableScaAuthRoleID(id *int64) *ScaAuthPermissionRuleUpdate {
|
||||
if id != nil {
|
||||
sapru = sapru.SetScaAuthRoleID(*id)
|
||||
}
|
||||
return sapru
|
||||
}
|
||||
|
||||
// SetScaAuthRole sets the "sca_auth_role" edge to the ScaAuthRole entity.
|
||||
func (sapru *ScaAuthPermissionRuleUpdate) SetScaAuthRole(s *ScaAuthRole) *ScaAuthPermissionRuleUpdate {
|
||||
return sapru.SetScaAuthRoleID(s.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthPermissionRuleMutation object of the builder.
|
||||
func (sapru *ScaAuthPermissionRuleUpdate) Mutation() *ScaAuthPermissionRuleMutation {
|
||||
return sapru.mutation
|
||||
}
|
||||
|
||||
// ClearScaAuthRole clears the "sca_auth_role" edge to the ScaAuthRole entity.
|
||||
func (sapru *ScaAuthPermissionRuleUpdate) ClearScaAuthRole() *ScaAuthPermissionRuleUpdate {
|
||||
sapru.mutation.ClearScaAuthRole()
|
||||
return sapru
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (sapru *ScaAuthPermissionRuleUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, sapru.sqlSave, sapru.mutation, sapru.hooks)
|
||||
@@ -251,7 +243,7 @@ func (sapru *ScaAuthPermissionRuleUpdate) sqlSave(ctx context.Context) (n int, e
|
||||
if err := sapru.check(); err != nil {
|
||||
return n, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64))
|
||||
_spec := sqlgraph.NewUpdateSpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt))
|
||||
if ps := sapru.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
@@ -262,12 +254,21 @@ func (sapru *ScaAuthPermissionRuleUpdate) sqlSave(ctx context.Context) (n int, e
|
||||
if value, ok := sapru.mutation.Ptype(); ok {
|
||||
_spec.SetField(scaauthpermissionrule.FieldPtype, field.TypeString, value)
|
||||
}
|
||||
if sapru.mutation.PtypeCleared() {
|
||||
_spec.ClearField(scaauthpermissionrule.FieldPtype, field.TypeString)
|
||||
}
|
||||
if value, ok := sapru.mutation.V0(); ok {
|
||||
_spec.SetField(scaauthpermissionrule.FieldV0, field.TypeString, value)
|
||||
}
|
||||
if sapru.mutation.V0Cleared() {
|
||||
_spec.ClearField(scaauthpermissionrule.FieldV0, field.TypeString)
|
||||
}
|
||||
if value, ok := sapru.mutation.V1(); ok {
|
||||
_spec.SetField(scaauthpermissionrule.FieldV1, field.TypeString, value)
|
||||
}
|
||||
if sapru.mutation.V1Cleared() {
|
||||
_spec.ClearField(scaauthpermissionrule.FieldV1, field.TypeString)
|
||||
}
|
||||
if value, ok := sapru.mutation.V2(); ok {
|
||||
_spec.SetField(scaauthpermissionrule.FieldV2, field.TypeString, value)
|
||||
}
|
||||
@@ -292,35 +293,6 @@ func (sapru *ScaAuthPermissionRuleUpdate) sqlSave(ctx context.Context) (n int, e
|
||||
if sapru.mutation.V5Cleared() {
|
||||
_spec.ClearField(scaauthpermissionrule.FieldV5, field.TypeString)
|
||||
}
|
||||
if sapru.mutation.ScaAuthRoleCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthpermissionrule.ScaAuthRoleTable,
|
||||
Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := sapru.mutation.ScaAuthRoleIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthpermissionrule.ScaAuthRoleTable,
|
||||
Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, sapru.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{scaauthpermissionrule.Label}
|
||||
@@ -355,6 +327,12 @@ func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillablePtype(s *string) *ScaAu
|
||||
return sapruo
|
||||
}
|
||||
|
||||
// ClearPtype clears the value of the "ptype" field.
|
||||
func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearPtype() *ScaAuthPermissionRuleUpdateOne {
|
||||
sapruo.mutation.ClearPtype()
|
||||
return sapruo
|
||||
}
|
||||
|
||||
// SetV0 sets the "v0" field.
|
||||
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV0(s string) *ScaAuthPermissionRuleUpdateOne {
|
||||
sapruo.mutation.SetV0(s)
|
||||
@@ -369,6 +347,12 @@ func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV0(s *string) *ScaAuthP
|
||||
return sapruo
|
||||
}
|
||||
|
||||
// ClearV0 clears the value of the "v0" field.
|
||||
func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV0() *ScaAuthPermissionRuleUpdateOne {
|
||||
sapruo.mutation.ClearV0()
|
||||
return sapruo
|
||||
}
|
||||
|
||||
// SetV1 sets the "v1" field.
|
||||
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV1(s string) *ScaAuthPermissionRuleUpdateOne {
|
||||
sapruo.mutation.SetV1(s)
|
||||
@@ -383,6 +367,12 @@ func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV1(s *string) *ScaAuthP
|
||||
return sapruo
|
||||
}
|
||||
|
||||
// ClearV1 clears the value of the "v1" field.
|
||||
func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV1() *ScaAuthPermissionRuleUpdateOne {
|
||||
sapruo.mutation.ClearV1()
|
||||
return sapruo
|
||||
}
|
||||
|
||||
// SetV2 sets the "v2" field.
|
||||
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV2(s string) *ScaAuthPermissionRuleUpdateOne {
|
||||
sapruo.mutation.SetV2(s)
|
||||
@@ -463,36 +453,11 @@ func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV5() *ScaAuthPermissionRuleUp
|
||||
return sapruo
|
||||
}
|
||||
|
||||
// SetScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID.
|
||||
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetScaAuthRoleID(id int64) *ScaAuthPermissionRuleUpdateOne {
|
||||
sapruo.mutation.SetScaAuthRoleID(id)
|
||||
return sapruo
|
||||
}
|
||||
|
||||
// SetNillableScaAuthRoleID sets the "sca_auth_role" edge to the ScaAuthRole entity by ID if the given value is not nil.
|
||||
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableScaAuthRoleID(id *int64) *ScaAuthPermissionRuleUpdateOne {
|
||||
if id != nil {
|
||||
sapruo = sapruo.SetScaAuthRoleID(*id)
|
||||
}
|
||||
return sapruo
|
||||
}
|
||||
|
||||
// SetScaAuthRole sets the "sca_auth_role" edge to the ScaAuthRole entity.
|
||||
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetScaAuthRole(s *ScaAuthRole) *ScaAuthPermissionRuleUpdateOne {
|
||||
return sapruo.SetScaAuthRoleID(s.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthPermissionRuleMutation object of the builder.
|
||||
func (sapruo *ScaAuthPermissionRuleUpdateOne) Mutation() *ScaAuthPermissionRuleMutation {
|
||||
return sapruo.mutation
|
||||
}
|
||||
|
||||
// ClearScaAuthRole clears the "sca_auth_role" edge to the ScaAuthRole entity.
|
||||
func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearScaAuthRole() *ScaAuthPermissionRuleUpdateOne {
|
||||
sapruo.mutation.ClearScaAuthRole()
|
||||
return sapruo
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ScaAuthPermissionRuleUpdate builder.
|
||||
func (sapruo *ScaAuthPermissionRuleUpdateOne) Where(ps ...predicate.ScaAuthPermissionRule) *ScaAuthPermissionRuleUpdateOne {
|
||||
sapruo.mutation.Where(ps...)
|
||||
@@ -577,7 +542,7 @@ func (sapruo *ScaAuthPermissionRuleUpdateOne) sqlSave(ctx context.Context) (_nod
|
||||
if err := sapruo.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64))
|
||||
_spec := sqlgraph.NewUpdateSpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt))
|
||||
id, ok := sapruo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaAuthPermissionRule.id" for update`)}
|
||||
@@ -605,12 +570,21 @@ func (sapruo *ScaAuthPermissionRuleUpdateOne) sqlSave(ctx context.Context) (_nod
|
||||
if value, ok := sapruo.mutation.Ptype(); ok {
|
||||
_spec.SetField(scaauthpermissionrule.FieldPtype, field.TypeString, value)
|
||||
}
|
||||
if sapruo.mutation.PtypeCleared() {
|
||||
_spec.ClearField(scaauthpermissionrule.FieldPtype, field.TypeString)
|
||||
}
|
||||
if value, ok := sapruo.mutation.V0(); ok {
|
||||
_spec.SetField(scaauthpermissionrule.FieldV0, field.TypeString, value)
|
||||
}
|
||||
if sapruo.mutation.V0Cleared() {
|
||||
_spec.ClearField(scaauthpermissionrule.FieldV0, field.TypeString)
|
||||
}
|
||||
if value, ok := sapruo.mutation.V1(); ok {
|
||||
_spec.SetField(scaauthpermissionrule.FieldV1, field.TypeString, value)
|
||||
}
|
||||
if sapruo.mutation.V1Cleared() {
|
||||
_spec.ClearField(scaauthpermissionrule.FieldV1, field.TypeString)
|
||||
}
|
||||
if value, ok := sapruo.mutation.V2(); ok {
|
||||
_spec.SetField(scaauthpermissionrule.FieldV2, field.TypeString, value)
|
||||
}
|
||||
@@ -635,35 +609,6 @@ func (sapruo *ScaAuthPermissionRuleUpdateOne) sqlSave(ctx context.Context) (_nod
|
||||
if sapruo.mutation.V5Cleared() {
|
||||
_spec.ClearField(scaauthpermissionrule.FieldV5, field.TypeString)
|
||||
}
|
||||
if sapruo.mutation.ScaAuthRoleCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthpermissionrule.ScaAuthRoleTable,
|
||||
Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := sapruo.mutation.ScaAuthRoleIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthpermissionrule.ScaAuthRoleTable,
|
||||
Columns: []string{scaauthpermissionrule.ScaAuthRoleColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &ScaAuthPermissionRule{config: sapruo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
|
@@ -27,31 +27,10 @@ type ScaAuthRole struct {
|
||||
// 角色名称
|
||||
RoleName string `json:"role_name,omitempty"`
|
||||
// 角色关键字
|
||||
RoleKey string `json:"role_key,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the ScaAuthRoleQuery when eager-loading is set.
|
||||
Edges ScaAuthRoleEdges `json:"edges"`
|
||||
RoleKey string `json:"role_key,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// ScaAuthRoleEdges holds the relations/edges for other nodes in the graph.
|
||||
type ScaAuthRoleEdges struct {
|
||||
// ScaAuthPermissionRule holds the value of the sca_auth_permission_rule edge.
|
||||
ScaAuthPermissionRule []*ScaAuthPermissionRule `json:"sca_auth_permission_rule,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// ScaAuthPermissionRuleOrErr returns the ScaAuthPermissionRule value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e ScaAuthRoleEdges) ScaAuthPermissionRuleOrErr() ([]*ScaAuthPermissionRule, error) {
|
||||
if e.loadedTypes[0] {
|
||||
return e.ScaAuthPermissionRule, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "sca_auth_permission_rule"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*ScaAuthRole) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
@@ -127,11 +106,6 @@ func (sar *ScaAuthRole) Value(name string) (ent.Value, error) {
|
||||
return sar.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryScaAuthPermissionRule queries the "sca_auth_permission_rule" edge of the ScaAuthRole entity.
|
||||
func (sar *ScaAuthRole) QueryScaAuthPermissionRule() *ScaAuthPermissionRuleQuery {
|
||||
return NewScaAuthRoleClient(sar.config).QueryScaAuthPermissionRule(sar)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this ScaAuthRole.
|
||||
// Note that you need to call ScaAuthRole.Unwrap() before calling this method if this ScaAuthRole
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
|
@@ -6,7 +6,6 @@ import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -24,17 +23,8 @@ const (
|
||||
FieldRoleName = "role_name"
|
||||
// FieldRoleKey holds the string denoting the role_key field in the database.
|
||||
FieldRoleKey = "role_key"
|
||||
// EdgeScaAuthPermissionRule holds the string denoting the sca_auth_permission_rule edge name in mutations.
|
||||
EdgeScaAuthPermissionRule = "sca_auth_permission_rule"
|
||||
// Table holds the table name of the scaauthrole in the database.
|
||||
Table = "sca_auth_role"
|
||||
// ScaAuthPermissionRuleTable is the table that holds the sca_auth_permission_rule relation/edge.
|
||||
ScaAuthPermissionRuleTable = "sca_auth_permission_rule"
|
||||
// ScaAuthPermissionRuleInverseTable is the table name for the ScaAuthPermissionRule entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "scaauthpermissionrule" package.
|
||||
ScaAuthPermissionRuleInverseTable = "sca_auth_permission_rule"
|
||||
// ScaAuthPermissionRuleColumn is the table column denoting the sca_auth_permission_rule relation/edge.
|
||||
ScaAuthPermissionRuleColumn = "sca_auth_role_sca_auth_permission_rule"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for scaauthrole fields.
|
||||
@@ -106,24 +96,3 @@ func ByRoleName(opts ...sql.OrderTermOption) OrderOption {
|
||||
func ByRoleKey(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldRoleKey, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByScaAuthPermissionRuleCount orders the results by sca_auth_permission_rule count.
|
||||
func ByScaAuthPermissionRuleCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newScaAuthPermissionRuleStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByScaAuthPermissionRule orders the results by sca_auth_permission_rule terms.
|
||||
func ByScaAuthPermissionRule(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newScaAuthPermissionRuleStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
func newScaAuthPermissionRuleStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(ScaAuthPermissionRuleInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthPermissionRuleTable, ScaAuthPermissionRuleColumn),
|
||||
)
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@ import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
@@ -340,29 +339,6 @@ func RoleKeyContainsFold(v string) predicate.ScaAuthRole {
|
||||
return predicate.ScaAuthRole(sql.FieldContainsFold(FieldRoleKey, v))
|
||||
}
|
||||
|
||||
// HasScaAuthPermissionRule applies the HasEdge predicate on the "sca_auth_permission_rule" edge.
|
||||
func HasScaAuthPermissionRule() predicate.ScaAuthRole {
|
||||
return predicate.ScaAuthRole(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthPermissionRuleTable, ScaAuthPermissionRuleColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasScaAuthPermissionRuleWith applies the HasEdge predicate on the "sca_auth_permission_rule" edge with a given conditions (other predicates).
|
||||
func HasScaAuthPermissionRuleWith(preds ...predicate.ScaAuthPermissionRule) predicate.ScaAuthRole {
|
||||
return predicate.ScaAuthRole(func(s *sql.Selector) {
|
||||
step := newScaAuthPermissionRuleStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.ScaAuthRole) predicate.ScaAuthRole {
|
||||
return predicate.ScaAuthRole(sql.AndPredicates(predicates...))
|
||||
|
@@ -6,7 +6,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
|
||||
"time"
|
||||
|
||||
@@ -81,21 +80,6 @@ func (sarc *ScaAuthRoleCreate) SetID(i int64) *ScaAuthRoleCreate {
|
||||
return sarc
|
||||
}
|
||||
|
||||
// AddScaAuthPermissionRuleIDs adds the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity by IDs.
|
||||
func (sarc *ScaAuthRoleCreate) AddScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleCreate {
|
||||
sarc.mutation.AddScaAuthPermissionRuleIDs(ids...)
|
||||
return sarc
|
||||
}
|
||||
|
||||
// AddScaAuthPermissionRule adds the "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity.
|
||||
func (sarc *ScaAuthRoleCreate) AddScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleCreate {
|
||||
ids := make([]int64, len(s))
|
||||
for i := range s {
|
||||
ids[i] = s[i].ID
|
||||
}
|
||||
return sarc.AddScaAuthPermissionRuleIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthRoleMutation object of the builder.
|
||||
func (sarc *ScaAuthRoleCreate) Mutation() *ScaAuthRoleMutation {
|
||||
return sarc.mutation
|
||||
@@ -226,22 +210,6 @@ func (sarc *ScaAuthRoleCreate) createSpec() (*ScaAuthRole, *sqlgraph.CreateSpec)
|
||||
_spec.SetField(scaauthrole.FieldRoleKey, field.TypeString, value)
|
||||
_node.RoleKey = value
|
||||
}
|
||||
if nodes := sarc.mutation.ScaAuthPermissionRuleIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthrole.ScaAuthPermissionRuleTable,
|
||||
Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
|
@@ -4,11 +4,9 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"math"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
|
||||
|
||||
"entgo.io/ent"
|
||||
@@ -20,11 +18,10 @@ import (
|
||||
// ScaAuthRoleQuery is the builder for querying ScaAuthRole entities.
|
||||
type ScaAuthRoleQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []scaauthrole.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.ScaAuthRole
|
||||
withScaAuthPermissionRule *ScaAuthPermissionRuleQuery
|
||||
ctx *QueryContext
|
||||
order []scaauthrole.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.ScaAuthRole
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
@@ -61,28 +58,6 @@ func (sarq *ScaAuthRoleQuery) Order(o ...scaauthrole.OrderOption) *ScaAuthRoleQu
|
||||
return sarq
|
||||
}
|
||||
|
||||
// QueryScaAuthPermissionRule chains the current query on the "sca_auth_permission_rule" edge.
|
||||
func (sarq *ScaAuthRoleQuery) QueryScaAuthPermissionRule() *ScaAuthPermissionRuleQuery {
|
||||
query := (&ScaAuthPermissionRuleClient{config: sarq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := sarq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := sarq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(scaauthrole.Table, scaauthrole.FieldID, selector),
|
||||
sqlgraph.To(scaauthpermissionrule.Table, scaauthpermissionrule.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, scaauthrole.ScaAuthPermissionRuleTable, scaauthrole.ScaAuthPermissionRuleColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(sarq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first ScaAuthRole entity from the query.
|
||||
// Returns a *NotFoundError when no ScaAuthRole was found.
|
||||
func (sarq *ScaAuthRoleQuery) First(ctx context.Context) (*ScaAuthRole, error) {
|
||||
@@ -270,29 +245,17 @@ func (sarq *ScaAuthRoleQuery) Clone() *ScaAuthRoleQuery {
|
||||
return nil
|
||||
}
|
||||
return &ScaAuthRoleQuery{
|
||||
config: sarq.config,
|
||||
ctx: sarq.ctx.Clone(),
|
||||
order: append([]scaauthrole.OrderOption{}, sarq.order...),
|
||||
inters: append([]Interceptor{}, sarq.inters...),
|
||||
predicates: append([]predicate.ScaAuthRole{}, sarq.predicates...),
|
||||
withScaAuthPermissionRule: sarq.withScaAuthPermissionRule.Clone(),
|
||||
config: sarq.config,
|
||||
ctx: sarq.ctx.Clone(),
|
||||
order: append([]scaauthrole.OrderOption{}, sarq.order...),
|
||||
inters: append([]Interceptor{}, sarq.inters...),
|
||||
predicates: append([]predicate.ScaAuthRole{}, sarq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: sarq.sql.Clone(),
|
||||
path: sarq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithScaAuthPermissionRule tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "sca_auth_permission_rule" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (sarq *ScaAuthRoleQuery) WithScaAuthPermissionRule(opts ...func(*ScaAuthPermissionRuleQuery)) *ScaAuthRoleQuery {
|
||||
query := (&ScaAuthPermissionRuleClient{config: sarq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
sarq.withScaAuthPermissionRule = query
|
||||
return sarq
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
@@ -369,11 +332,8 @@ func (sarq *ScaAuthRoleQuery) prepareQuery(ctx context.Context) error {
|
||||
|
||||
func (sarq *ScaAuthRoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthRole, error) {
|
||||
var (
|
||||
nodes = []*ScaAuthRole{}
|
||||
_spec = sarq.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
sarq.withScaAuthPermissionRule != nil,
|
||||
}
|
||||
nodes = []*ScaAuthRole{}
|
||||
_spec = sarq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*ScaAuthRole).scanValues(nil, columns)
|
||||
@@ -381,7 +341,6 @@ func (sarq *ScaAuthRoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &ScaAuthRole{config: sarq.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
@@ -393,50 +352,9 @@ func (sarq *ScaAuthRoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := sarq.withScaAuthPermissionRule; query != nil {
|
||||
if err := sarq.loadScaAuthPermissionRule(ctx, query, nodes,
|
||||
func(n *ScaAuthRole) { n.Edges.ScaAuthPermissionRule = []*ScaAuthPermissionRule{} },
|
||||
func(n *ScaAuthRole, e *ScaAuthPermissionRule) {
|
||||
n.Edges.ScaAuthPermissionRule = append(n.Edges.ScaAuthPermissionRule, e)
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (sarq *ScaAuthRoleQuery) loadScaAuthPermissionRule(ctx context.Context, query *ScaAuthPermissionRuleQuery, nodes []*ScaAuthRole, init func(*ScaAuthRole), assign func(*ScaAuthRole, *ScaAuthPermissionRule)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[int64]*ScaAuthRole)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
if init != nil {
|
||||
init(nodes[i])
|
||||
}
|
||||
}
|
||||
query.withFKs = true
|
||||
query.Where(predicate.ScaAuthPermissionRule(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(scaauthrole.ScaAuthPermissionRuleColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.sca_auth_role_sca_auth_permission_rule
|
||||
if fk == nil {
|
||||
return fmt.Errorf(`foreign-key "sca_auth_role_sca_auth_permission_rule" is nil for node %v`, n.ID)
|
||||
}
|
||||
node, ok := nodeids[*fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "sca_auth_role_sca_auth_permission_rule" returned %v for node %v`, *fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sarq *ScaAuthRoleQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := sarq.querySpec()
|
||||
_spec.Node.Columns = sarq.ctx.Fields
|
||||
|
@@ -7,7 +7,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthpermissionrule"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthrole"
|
||||
"time"
|
||||
|
||||
@@ -90,47 +89,11 @@ func (saru *ScaAuthRoleUpdate) SetNillableRoleKey(s *string) *ScaAuthRoleUpdate
|
||||
return saru
|
||||
}
|
||||
|
||||
// AddScaAuthPermissionRuleIDs adds the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity by IDs.
|
||||
func (saru *ScaAuthRoleUpdate) AddScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleUpdate {
|
||||
saru.mutation.AddScaAuthPermissionRuleIDs(ids...)
|
||||
return saru
|
||||
}
|
||||
|
||||
// AddScaAuthPermissionRule adds the "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity.
|
||||
func (saru *ScaAuthRoleUpdate) AddScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleUpdate {
|
||||
ids := make([]int64, len(s))
|
||||
for i := range s {
|
||||
ids[i] = s[i].ID
|
||||
}
|
||||
return saru.AddScaAuthPermissionRuleIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthRoleMutation object of the builder.
|
||||
func (saru *ScaAuthRoleUpdate) Mutation() *ScaAuthRoleMutation {
|
||||
return saru.mutation
|
||||
}
|
||||
|
||||
// ClearScaAuthPermissionRule clears all "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity.
|
||||
func (saru *ScaAuthRoleUpdate) ClearScaAuthPermissionRule() *ScaAuthRoleUpdate {
|
||||
saru.mutation.ClearScaAuthPermissionRule()
|
||||
return saru
|
||||
}
|
||||
|
||||
// RemoveScaAuthPermissionRuleIDs removes the "sca_auth_permission_rule" edge to ScaAuthPermissionRule entities by IDs.
|
||||
func (saru *ScaAuthRoleUpdate) RemoveScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleUpdate {
|
||||
saru.mutation.RemoveScaAuthPermissionRuleIDs(ids...)
|
||||
return saru
|
||||
}
|
||||
|
||||
// RemoveScaAuthPermissionRule removes "sca_auth_permission_rule" edges to ScaAuthPermissionRule entities.
|
||||
func (saru *ScaAuthRoleUpdate) RemoveScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleUpdate {
|
||||
ids := make([]int64, len(s))
|
||||
for i := range s {
|
||||
ids[i] = s[i].ID
|
||||
}
|
||||
return saru.RemoveScaAuthPermissionRuleIDs(ids...)
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (saru *ScaAuthRoleUpdate) Save(ctx context.Context) (int, error) {
|
||||
saru.defaults()
|
||||
@@ -217,51 +180,6 @@ func (saru *ScaAuthRoleUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if value, ok := saru.mutation.RoleKey(); ok {
|
||||
_spec.SetField(scaauthrole.FieldRoleKey, field.TypeString, value)
|
||||
}
|
||||
if saru.mutation.ScaAuthPermissionRuleCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthrole.ScaAuthPermissionRuleTable,
|
||||
Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := saru.mutation.RemovedScaAuthPermissionRuleIDs(); len(nodes) > 0 && !saru.mutation.ScaAuthPermissionRuleCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthrole.ScaAuthPermissionRuleTable,
|
||||
Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := saru.mutation.ScaAuthPermissionRuleIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthrole.ScaAuthPermissionRuleTable,
|
||||
Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, saru.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{scaauthrole.Label}
|
||||
@@ -343,47 +261,11 @@ func (saruo *ScaAuthRoleUpdateOne) SetNillableRoleKey(s *string) *ScaAuthRoleUpd
|
||||
return saruo
|
||||
}
|
||||
|
||||
// AddScaAuthPermissionRuleIDs adds the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity by IDs.
|
||||
func (saruo *ScaAuthRoleUpdateOne) AddScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleUpdateOne {
|
||||
saruo.mutation.AddScaAuthPermissionRuleIDs(ids...)
|
||||
return saruo
|
||||
}
|
||||
|
||||
// AddScaAuthPermissionRule adds the "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity.
|
||||
func (saruo *ScaAuthRoleUpdateOne) AddScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleUpdateOne {
|
||||
ids := make([]int64, len(s))
|
||||
for i := range s {
|
||||
ids[i] = s[i].ID
|
||||
}
|
||||
return saruo.AddScaAuthPermissionRuleIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthRoleMutation object of the builder.
|
||||
func (saruo *ScaAuthRoleUpdateOne) Mutation() *ScaAuthRoleMutation {
|
||||
return saruo.mutation
|
||||
}
|
||||
|
||||
// ClearScaAuthPermissionRule clears all "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity.
|
||||
func (saruo *ScaAuthRoleUpdateOne) ClearScaAuthPermissionRule() *ScaAuthRoleUpdateOne {
|
||||
saruo.mutation.ClearScaAuthPermissionRule()
|
||||
return saruo
|
||||
}
|
||||
|
||||
// RemoveScaAuthPermissionRuleIDs removes the "sca_auth_permission_rule" edge to ScaAuthPermissionRule entities by IDs.
|
||||
func (saruo *ScaAuthRoleUpdateOne) RemoveScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleUpdateOne {
|
||||
saruo.mutation.RemoveScaAuthPermissionRuleIDs(ids...)
|
||||
return saruo
|
||||
}
|
||||
|
||||
// RemoveScaAuthPermissionRule removes "sca_auth_permission_rule" edges to ScaAuthPermissionRule entities.
|
||||
func (saruo *ScaAuthRoleUpdateOne) RemoveScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleUpdateOne {
|
||||
ids := make([]int64, len(s))
|
||||
for i := range s {
|
||||
ids[i] = s[i].ID
|
||||
}
|
||||
return saruo.RemoveScaAuthPermissionRuleIDs(ids...)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ScaAuthRoleUpdate builder.
|
||||
func (saruo *ScaAuthRoleUpdateOne) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleUpdateOne {
|
||||
saruo.mutation.Where(ps...)
|
||||
@@ -500,51 +382,6 @@ func (saruo *ScaAuthRoleUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthR
|
||||
if value, ok := saruo.mutation.RoleKey(); ok {
|
||||
_spec.SetField(scaauthrole.FieldRoleKey, field.TypeString, value)
|
||||
}
|
||||
if saruo.mutation.ScaAuthPermissionRuleCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthrole.ScaAuthPermissionRuleTable,
|
||||
Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := saruo.mutation.RemovedScaAuthPermissionRuleIDs(); len(nodes) > 0 && !saruo.mutation.ScaAuthPermissionRuleCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthrole.ScaAuthPermissionRuleTable,
|
||||
Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := saruo.mutation.ScaAuthPermissionRuleIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthrole.ScaAuthPermissionRuleTable,
|
||||
Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &ScaAuthRole{config: saruo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
|
@@ -37,7 +37,7 @@ type ScaAuthUser struct {
|
||||
// 密码
|
||||
Password string `json:"-"`
|
||||
// 性别
|
||||
Gender string `json:"gender,omitempty"`
|
||||
Gender int8 `json:"gender,omitempty"`
|
||||
// 头像
|
||||
Avatar string `json:"avatar,omitempty"`
|
||||
// 状态 0 正常 1 封禁
|
||||
@@ -49,50 +49,18 @@ type ScaAuthUser struct {
|
||||
// 地址
|
||||
Location *string `json:"location,omitempty"`
|
||||
// 公司
|
||||
Company *string `json:"company,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the ScaAuthUserQuery when eager-loading is set.
|
||||
Edges ScaAuthUserEdges `json:"edges"`
|
||||
Company *string `json:"company,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// ScaAuthUserEdges holds the relations/edges for other nodes in the graph.
|
||||
type ScaAuthUserEdges struct {
|
||||
// ScaAuthUserSocial holds the value of the sca_auth_user_social edge.
|
||||
ScaAuthUserSocial []*ScaAuthUserSocial `json:"sca_auth_user_social,omitempty"`
|
||||
// ScaAuthUserDevice holds the value of the sca_auth_user_device edge.
|
||||
ScaAuthUserDevice []*ScaAuthUserDevice `json:"sca_auth_user_device,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [2]bool
|
||||
}
|
||||
|
||||
// ScaAuthUserSocialOrErr returns the ScaAuthUserSocial value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e ScaAuthUserEdges) ScaAuthUserSocialOrErr() ([]*ScaAuthUserSocial, error) {
|
||||
if e.loadedTypes[0] {
|
||||
return e.ScaAuthUserSocial, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "sca_auth_user_social"}
|
||||
}
|
||||
|
||||
// ScaAuthUserDeviceOrErr returns the ScaAuthUserDevice value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e ScaAuthUserEdges) ScaAuthUserDeviceOrErr() ([]*ScaAuthUserDevice, error) {
|
||||
if e.loadedTypes[1] {
|
||||
return e.ScaAuthUserDevice, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "sca_auth_user_device"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*ScaAuthUser) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case scaauthuser.FieldID, scaauthuser.FieldDeleted, scaauthuser.FieldStatus:
|
||||
case scaauthuser.FieldID, scaauthuser.FieldDeleted, scaauthuser.FieldGender, scaauthuser.FieldStatus:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case scaauthuser.FieldUID, scaauthuser.FieldUsername, scaauthuser.FieldNickname, scaauthuser.FieldEmail, scaauthuser.FieldPhone, scaauthuser.FieldPassword, scaauthuser.FieldGender, scaauthuser.FieldAvatar, scaauthuser.FieldIntroduce, scaauthuser.FieldBlog, scaauthuser.FieldLocation, scaauthuser.FieldCompany:
|
||||
case scaauthuser.FieldUID, scaauthuser.FieldUsername, scaauthuser.FieldNickname, scaauthuser.FieldEmail, scaauthuser.FieldPhone, scaauthuser.FieldPassword, scaauthuser.FieldAvatar, scaauthuser.FieldIntroduce, scaauthuser.FieldBlog, scaauthuser.FieldLocation, scaauthuser.FieldCompany:
|
||||
values[i] = new(sql.NullString)
|
||||
case scaauthuser.FieldCreatedAt, scaauthuser.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
@@ -172,10 +140,10 @@ func (sau *ScaAuthUser) assignValues(columns []string, values []any) error {
|
||||
sau.Password = value.String
|
||||
}
|
||||
case scaauthuser.FieldGender:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field gender", values[i])
|
||||
} else if value.Valid {
|
||||
sau.Gender = value.String
|
||||
sau.Gender = int8(value.Int64)
|
||||
}
|
||||
case scaauthuser.FieldAvatar:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
@@ -229,16 +197,6 @@ func (sau *ScaAuthUser) Value(name string) (ent.Value, error) {
|
||||
return sau.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryScaAuthUserSocial queries the "sca_auth_user_social" edge of the ScaAuthUser entity.
|
||||
func (sau *ScaAuthUser) QueryScaAuthUserSocial() *ScaAuthUserSocialQuery {
|
||||
return NewScaAuthUserClient(sau.config).QueryScaAuthUserSocial(sau)
|
||||
}
|
||||
|
||||
// QueryScaAuthUserDevice queries the "sca_auth_user_device" edge of the ScaAuthUser entity.
|
||||
func (sau *ScaAuthUser) QueryScaAuthUserDevice() *ScaAuthUserDeviceQuery {
|
||||
return NewScaAuthUserClient(sau.config).QueryScaAuthUserDevice(sau)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this ScaAuthUser.
|
||||
// Note that you need to call ScaAuthUser.Unwrap() before calling this method if this ScaAuthUser
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
@@ -289,7 +247,7 @@ func (sau *ScaAuthUser) String() string {
|
||||
builder.WriteString("password=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("gender=")
|
||||
builder.WriteString(sau.Gender)
|
||||
builder.WriteString(fmt.Sprintf("%v", sau.Gender))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("avatar=")
|
||||
builder.WriteString(sau.Avatar)
|
||||
|
@@ -6,7 +6,6 @@ import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -46,26 +45,8 @@ const (
|
||||
FieldLocation = "location"
|
||||
// FieldCompany holds the string denoting the company field in the database.
|
||||
FieldCompany = "company"
|
||||
// EdgeScaAuthUserSocial holds the string denoting the sca_auth_user_social edge name in mutations.
|
||||
EdgeScaAuthUserSocial = "sca_auth_user_social"
|
||||
// EdgeScaAuthUserDevice holds the string denoting the sca_auth_user_device edge name in mutations.
|
||||
EdgeScaAuthUserDevice = "sca_auth_user_device"
|
||||
// Table holds the table name of the scaauthuser in the database.
|
||||
Table = "sca_auth_user"
|
||||
// ScaAuthUserSocialTable is the table that holds the sca_auth_user_social relation/edge.
|
||||
ScaAuthUserSocialTable = "sca_auth_user_social"
|
||||
// ScaAuthUserSocialInverseTable is the table name for the ScaAuthUserSocial entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "scaauthusersocial" package.
|
||||
ScaAuthUserSocialInverseTable = "sca_auth_user_social"
|
||||
// ScaAuthUserSocialColumn is the table column denoting the sca_auth_user_social relation/edge.
|
||||
ScaAuthUserSocialColumn = "sca_auth_user_sca_auth_user_social"
|
||||
// ScaAuthUserDeviceTable is the table that holds the sca_auth_user_device relation/edge.
|
||||
ScaAuthUserDeviceTable = "sca_auth_user_device"
|
||||
// ScaAuthUserDeviceInverseTable is the table name for the ScaAuthUserDevice entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "scaauthuserdevice" package.
|
||||
ScaAuthUserDeviceInverseTable = "sca_auth_user_device"
|
||||
// ScaAuthUserDeviceColumn is the table column denoting the sca_auth_user_device relation/edge.
|
||||
ScaAuthUserDeviceColumn = "sca_auth_user_sca_auth_user_device"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for scaauthuser fields.
|
||||
@@ -122,8 +103,6 @@ var (
|
||||
PhoneValidator func(string) error
|
||||
// PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
PasswordValidator func(string) error
|
||||
// GenderValidator is a validator for the "gender" field. It is called by the builders before save.
|
||||
GenderValidator func(string) error
|
||||
// DefaultStatus holds the default value on creation for the "status" field.
|
||||
DefaultStatus int8
|
||||
// IntroduceValidator is a validator for the "introduce" field. It is called by the builders before save.
|
||||
@@ -223,45 +202,3 @@ func ByLocation(opts ...sql.OrderTermOption) OrderOption {
|
||||
func ByCompany(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCompany, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByScaAuthUserSocialCount orders the results by sca_auth_user_social count.
|
||||
func ByScaAuthUserSocialCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newScaAuthUserSocialStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByScaAuthUserSocial orders the results by sca_auth_user_social terms.
|
||||
func ByScaAuthUserSocial(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newScaAuthUserSocialStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByScaAuthUserDeviceCount orders the results by sca_auth_user_device count.
|
||||
func ByScaAuthUserDeviceCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newScaAuthUserDeviceStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByScaAuthUserDevice orders the results by sca_auth_user_device terms.
|
||||
func ByScaAuthUserDevice(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newScaAuthUserDeviceStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
func newScaAuthUserSocialStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(ScaAuthUserSocialInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthUserSocialTable, ScaAuthUserSocialColumn),
|
||||
)
|
||||
}
|
||||
func newScaAuthUserDeviceStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(ScaAuthUserDeviceInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthUserDeviceTable, ScaAuthUserDeviceColumn),
|
||||
)
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@ import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
@@ -101,7 +100,7 @@ func Password(v string) predicate.ScaAuthUser {
|
||||
}
|
||||
|
||||
// Gender applies equality check predicate on the "gender" field. It's identical to GenderEQ.
|
||||
func Gender(v string) predicate.ScaAuthUser {
|
||||
func Gender(v int8) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldEQ(FieldGender, v))
|
||||
}
|
||||
|
||||
@@ -706,60 +705,45 @@ func PasswordContainsFold(v string) predicate.ScaAuthUser {
|
||||
}
|
||||
|
||||
// GenderEQ applies the EQ predicate on the "gender" field.
|
||||
func GenderEQ(v string) predicate.ScaAuthUser {
|
||||
func GenderEQ(v int8) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldEQ(FieldGender, v))
|
||||
}
|
||||
|
||||
// GenderNEQ applies the NEQ predicate on the "gender" field.
|
||||
func GenderNEQ(v string) predicate.ScaAuthUser {
|
||||
func GenderNEQ(v int8) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldNEQ(FieldGender, v))
|
||||
}
|
||||
|
||||
// GenderIn applies the In predicate on the "gender" field.
|
||||
func GenderIn(vs ...string) predicate.ScaAuthUser {
|
||||
func GenderIn(vs ...int8) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldIn(FieldGender, vs...))
|
||||
}
|
||||
|
||||
// GenderNotIn applies the NotIn predicate on the "gender" field.
|
||||
func GenderNotIn(vs ...string) predicate.ScaAuthUser {
|
||||
func GenderNotIn(vs ...int8) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldNotIn(FieldGender, vs...))
|
||||
}
|
||||
|
||||
// GenderGT applies the GT predicate on the "gender" field.
|
||||
func GenderGT(v string) predicate.ScaAuthUser {
|
||||
func GenderGT(v int8) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldGT(FieldGender, v))
|
||||
}
|
||||
|
||||
// GenderGTE applies the GTE predicate on the "gender" field.
|
||||
func GenderGTE(v string) predicate.ScaAuthUser {
|
||||
func GenderGTE(v int8) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldGTE(FieldGender, v))
|
||||
}
|
||||
|
||||
// GenderLT applies the LT predicate on the "gender" field.
|
||||
func GenderLT(v string) predicate.ScaAuthUser {
|
||||
func GenderLT(v int8) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldLT(FieldGender, v))
|
||||
}
|
||||
|
||||
// GenderLTE applies the LTE predicate on the "gender" field.
|
||||
func GenderLTE(v string) predicate.ScaAuthUser {
|
||||
func GenderLTE(v int8) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldLTE(FieldGender, v))
|
||||
}
|
||||
|
||||
// GenderContains applies the Contains predicate on the "gender" field.
|
||||
func GenderContains(v string) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldContains(FieldGender, v))
|
||||
}
|
||||
|
||||
// GenderHasPrefix applies the HasPrefix predicate on the "gender" field.
|
||||
func GenderHasPrefix(v string) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldHasPrefix(FieldGender, v))
|
||||
}
|
||||
|
||||
// GenderHasSuffix applies the HasSuffix predicate on the "gender" field.
|
||||
func GenderHasSuffix(v string) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldHasSuffix(FieldGender, v))
|
||||
}
|
||||
|
||||
// GenderIsNil applies the IsNil predicate on the "gender" field.
|
||||
func GenderIsNil() predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldIsNull(FieldGender))
|
||||
@@ -770,16 +754,6 @@ func GenderNotNil() predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldNotNull(FieldGender))
|
||||
}
|
||||
|
||||
// GenderEqualFold applies the EqualFold predicate on the "gender" field.
|
||||
func GenderEqualFold(v string) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldEqualFold(FieldGender, v))
|
||||
}
|
||||
|
||||
// GenderContainsFold applies the ContainsFold predicate on the "gender" field.
|
||||
func GenderContainsFold(v string) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldContainsFold(FieldGender, v))
|
||||
}
|
||||
|
||||
// AvatarEQ applies the EQ predicate on the "avatar" field.
|
||||
func AvatarEQ(v string) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldEQ(FieldAvatar, v))
|
||||
@@ -1205,52 +1179,6 @@ func CompanyContainsFold(v string) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.FieldContainsFold(FieldCompany, v))
|
||||
}
|
||||
|
||||
// HasScaAuthUserSocial applies the HasEdge predicate on the "sca_auth_user_social" edge.
|
||||
func HasScaAuthUserSocial() predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthUserSocialTable, ScaAuthUserSocialColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasScaAuthUserSocialWith applies the HasEdge predicate on the "sca_auth_user_social" edge with a given conditions (other predicates).
|
||||
func HasScaAuthUserSocialWith(preds ...predicate.ScaAuthUserSocial) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(func(s *sql.Selector) {
|
||||
step := newScaAuthUserSocialStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// HasScaAuthUserDevice applies the HasEdge predicate on the "sca_auth_user_device" edge.
|
||||
func HasScaAuthUserDevice() predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, ScaAuthUserDeviceTable, ScaAuthUserDeviceColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasScaAuthUserDeviceWith applies the HasEdge predicate on the "sca_auth_user_device" edge with a given conditions (other predicates).
|
||||
func HasScaAuthUserDeviceWith(preds ...predicate.ScaAuthUserDevice) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(func(s *sql.Selector) {
|
||||
step := newScaAuthUserDeviceStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.ScaAuthUser) predicate.ScaAuthUser {
|
||||
return predicate.ScaAuthUser(sql.AndPredicates(predicates...))
|
||||
|
@@ -7,8 +7,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -141,15 +139,15 @@ func (sauc *ScaAuthUserCreate) SetNillablePassword(s *string) *ScaAuthUserCreate
|
||||
}
|
||||
|
||||
// SetGender sets the "gender" field.
|
||||
func (sauc *ScaAuthUserCreate) SetGender(s string) *ScaAuthUserCreate {
|
||||
sauc.mutation.SetGender(s)
|
||||
func (sauc *ScaAuthUserCreate) SetGender(i int8) *ScaAuthUserCreate {
|
||||
sauc.mutation.SetGender(i)
|
||||
return sauc
|
||||
}
|
||||
|
||||
// SetNillableGender sets the "gender" field if the given value is not nil.
|
||||
func (sauc *ScaAuthUserCreate) SetNillableGender(s *string) *ScaAuthUserCreate {
|
||||
if s != nil {
|
||||
sauc.SetGender(*s)
|
||||
func (sauc *ScaAuthUserCreate) SetNillableGender(i *int8) *ScaAuthUserCreate {
|
||||
if i != nil {
|
||||
sauc.SetGender(*i)
|
||||
}
|
||||
return sauc
|
||||
}
|
||||
@@ -244,36 +242,6 @@ func (sauc *ScaAuthUserCreate) SetID(i int64) *ScaAuthUserCreate {
|
||||
return sauc
|
||||
}
|
||||
|
||||
// AddScaAuthUserSocialIDs adds the "sca_auth_user_social" edge to the ScaAuthUserSocial entity by IDs.
|
||||
func (sauc *ScaAuthUserCreate) AddScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserCreate {
|
||||
sauc.mutation.AddScaAuthUserSocialIDs(ids...)
|
||||
return sauc
|
||||
}
|
||||
|
||||
// AddScaAuthUserSocial adds the "sca_auth_user_social" edges to the ScaAuthUserSocial entity.
|
||||
func (sauc *ScaAuthUserCreate) AddScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserCreate {
|
||||
ids := make([]int64, len(s))
|
||||
for i := range s {
|
||||
ids[i] = s[i].ID
|
||||
}
|
||||
return sauc.AddScaAuthUserSocialIDs(ids...)
|
||||
}
|
||||
|
||||
// AddScaAuthUserDeviceIDs adds the "sca_auth_user_device" edge to the ScaAuthUserDevice entity by IDs.
|
||||
func (sauc *ScaAuthUserCreate) AddScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserCreate {
|
||||
sauc.mutation.AddScaAuthUserDeviceIDs(ids...)
|
||||
return sauc
|
||||
}
|
||||
|
||||
// AddScaAuthUserDevice adds the "sca_auth_user_device" edges to the ScaAuthUserDevice entity.
|
||||
func (sauc *ScaAuthUserCreate) AddScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserCreate {
|
||||
ids := make([]int64, len(s))
|
||||
for i := range s {
|
||||
ids[i] = s[i].ID
|
||||
}
|
||||
return sauc.AddScaAuthUserDeviceIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthUserMutation object of the builder.
|
||||
func (sauc *ScaAuthUserCreate) Mutation() *ScaAuthUserMutation {
|
||||
return sauc.mutation
|
||||
@@ -373,11 +341,6 @@ func (sauc *ScaAuthUserCreate) check() error {
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.password": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := sauc.mutation.Gender(); ok {
|
||||
if err := scaauthuser.GenderValidator(v); err != nil {
|
||||
return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.gender": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := sauc.mutation.Introduce(); ok {
|
||||
if err := scaauthuser.IntroduceValidator(v); err != nil {
|
||||
return &ValidationError{Name: "introduce", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.introduce": %w`, err)}
|
||||
@@ -467,7 +430,7 @@ func (sauc *ScaAuthUserCreate) createSpec() (*ScaAuthUser, *sqlgraph.CreateSpec)
|
||||
_node.Password = value
|
||||
}
|
||||
if value, ok := sauc.mutation.Gender(); ok {
|
||||
_spec.SetField(scaauthuser.FieldGender, field.TypeString, value)
|
||||
_spec.SetField(scaauthuser.FieldGender, field.TypeInt8, value)
|
||||
_node.Gender = value
|
||||
}
|
||||
if value, ok := sauc.mutation.Avatar(); ok {
|
||||
@@ -494,38 +457,6 @@ func (sauc *ScaAuthUserCreate) createSpec() (*ScaAuthUser, *sqlgraph.CreateSpec)
|
||||
_spec.SetField(scaauthuser.FieldCompany, field.TypeString, value)
|
||||
_node.Company = &value
|
||||
}
|
||||
if nodes := sauc.mutation.ScaAuthUserSocialIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthuser.ScaAuthUserSocialTable,
|
||||
Columns: []string{scaauthuser.ScaAuthUserSocialColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := sauc.mutation.ScaAuthUserDeviceIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthuser.ScaAuthUserDeviceTable,
|
||||
Columns: []string{scaauthuser.ScaAuthUserDeviceColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
|
@@ -4,13 +4,10 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"math"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
@@ -21,12 +18,10 @@ import (
|
||||
// ScaAuthUserQuery is the builder for querying ScaAuthUser entities.
|
||||
type ScaAuthUserQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []scaauthuser.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.ScaAuthUser
|
||||
withScaAuthUserSocial *ScaAuthUserSocialQuery
|
||||
withScaAuthUserDevice *ScaAuthUserDeviceQuery
|
||||
ctx *QueryContext
|
||||
order []scaauthuser.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.ScaAuthUser
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
@@ -63,50 +58,6 @@ func (sauq *ScaAuthUserQuery) Order(o ...scaauthuser.OrderOption) *ScaAuthUserQu
|
||||
return sauq
|
||||
}
|
||||
|
||||
// QueryScaAuthUserSocial chains the current query on the "sca_auth_user_social" edge.
|
||||
func (sauq *ScaAuthUserQuery) QueryScaAuthUserSocial() *ScaAuthUserSocialQuery {
|
||||
query := (&ScaAuthUserSocialClient{config: sauq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := sauq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := sauq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(scaauthuser.Table, scaauthuser.FieldID, selector),
|
||||
sqlgraph.To(scaauthusersocial.Table, scaauthusersocial.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, scaauthuser.ScaAuthUserSocialTable, scaauthuser.ScaAuthUserSocialColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(sauq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryScaAuthUserDevice chains the current query on the "sca_auth_user_device" edge.
|
||||
func (sauq *ScaAuthUserQuery) QueryScaAuthUserDevice() *ScaAuthUserDeviceQuery {
|
||||
query := (&ScaAuthUserDeviceClient{config: sauq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := sauq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := sauq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(scaauthuser.Table, scaauthuser.FieldID, selector),
|
||||
sqlgraph.To(scaauthuserdevice.Table, scaauthuserdevice.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, scaauthuser.ScaAuthUserDeviceTable, scaauthuser.ScaAuthUserDeviceColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(sauq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first ScaAuthUser entity from the query.
|
||||
// Returns a *NotFoundError when no ScaAuthUser was found.
|
||||
func (sauq *ScaAuthUserQuery) First(ctx context.Context) (*ScaAuthUser, error) {
|
||||
@@ -294,41 +245,17 @@ func (sauq *ScaAuthUserQuery) Clone() *ScaAuthUserQuery {
|
||||
return nil
|
||||
}
|
||||
return &ScaAuthUserQuery{
|
||||
config: sauq.config,
|
||||
ctx: sauq.ctx.Clone(),
|
||||
order: append([]scaauthuser.OrderOption{}, sauq.order...),
|
||||
inters: append([]Interceptor{}, sauq.inters...),
|
||||
predicates: append([]predicate.ScaAuthUser{}, sauq.predicates...),
|
||||
withScaAuthUserSocial: sauq.withScaAuthUserSocial.Clone(),
|
||||
withScaAuthUserDevice: sauq.withScaAuthUserDevice.Clone(),
|
||||
config: sauq.config,
|
||||
ctx: sauq.ctx.Clone(),
|
||||
order: append([]scaauthuser.OrderOption{}, sauq.order...),
|
||||
inters: append([]Interceptor{}, sauq.inters...),
|
||||
predicates: append([]predicate.ScaAuthUser{}, sauq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: sauq.sql.Clone(),
|
||||
path: sauq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithScaAuthUserSocial tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "sca_auth_user_social" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (sauq *ScaAuthUserQuery) WithScaAuthUserSocial(opts ...func(*ScaAuthUserSocialQuery)) *ScaAuthUserQuery {
|
||||
query := (&ScaAuthUserSocialClient{config: sauq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
sauq.withScaAuthUserSocial = query
|
||||
return sauq
|
||||
}
|
||||
|
||||
// WithScaAuthUserDevice tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "sca_auth_user_device" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (sauq *ScaAuthUserQuery) WithScaAuthUserDevice(opts ...func(*ScaAuthUserDeviceQuery)) *ScaAuthUserQuery {
|
||||
query := (&ScaAuthUserDeviceClient{config: sauq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
sauq.withScaAuthUserDevice = query
|
||||
return sauq
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
@@ -405,12 +332,8 @@ func (sauq *ScaAuthUserQuery) prepareQuery(ctx context.Context) error {
|
||||
|
||||
func (sauq *ScaAuthUserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthUser, error) {
|
||||
var (
|
||||
nodes = []*ScaAuthUser{}
|
||||
_spec = sauq.querySpec()
|
||||
loadedTypes = [2]bool{
|
||||
sauq.withScaAuthUserSocial != nil,
|
||||
sauq.withScaAuthUserDevice != nil,
|
||||
}
|
||||
nodes = []*ScaAuthUser{}
|
||||
_spec = sauq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*ScaAuthUser).scanValues(nil, columns)
|
||||
@@ -418,7 +341,6 @@ func (sauq *ScaAuthUserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &ScaAuthUser{config: sauq.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
@@ -430,90 +352,9 @@ func (sauq *ScaAuthUserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := sauq.withScaAuthUserSocial; query != nil {
|
||||
if err := sauq.loadScaAuthUserSocial(ctx, query, nodes,
|
||||
func(n *ScaAuthUser) { n.Edges.ScaAuthUserSocial = []*ScaAuthUserSocial{} },
|
||||
func(n *ScaAuthUser, e *ScaAuthUserSocial) {
|
||||
n.Edges.ScaAuthUserSocial = append(n.Edges.ScaAuthUserSocial, e)
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := sauq.withScaAuthUserDevice; query != nil {
|
||||
if err := sauq.loadScaAuthUserDevice(ctx, query, nodes,
|
||||
func(n *ScaAuthUser) { n.Edges.ScaAuthUserDevice = []*ScaAuthUserDevice{} },
|
||||
func(n *ScaAuthUser, e *ScaAuthUserDevice) {
|
||||
n.Edges.ScaAuthUserDevice = append(n.Edges.ScaAuthUserDevice, e)
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (sauq *ScaAuthUserQuery) loadScaAuthUserSocial(ctx context.Context, query *ScaAuthUserSocialQuery, nodes []*ScaAuthUser, init func(*ScaAuthUser), assign func(*ScaAuthUser, *ScaAuthUserSocial)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[int64]*ScaAuthUser)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
if init != nil {
|
||||
init(nodes[i])
|
||||
}
|
||||
}
|
||||
query.withFKs = true
|
||||
query.Where(predicate.ScaAuthUserSocial(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(scaauthuser.ScaAuthUserSocialColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.sca_auth_user_sca_auth_user_social
|
||||
if fk == nil {
|
||||
return fmt.Errorf(`foreign-key "sca_auth_user_sca_auth_user_social" is nil for node %v`, n.ID)
|
||||
}
|
||||
node, ok := nodeids[*fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "sca_auth_user_sca_auth_user_social" returned %v for node %v`, *fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (sauq *ScaAuthUserQuery) loadScaAuthUserDevice(ctx context.Context, query *ScaAuthUserDeviceQuery, nodes []*ScaAuthUser, init func(*ScaAuthUser), assign func(*ScaAuthUser, *ScaAuthUserDevice)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[int64]*ScaAuthUser)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
if init != nil {
|
||||
init(nodes[i])
|
||||
}
|
||||
}
|
||||
query.withFKs = true
|
||||
query.Where(predicate.ScaAuthUserDevice(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(scaauthuser.ScaAuthUserDeviceColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.sca_auth_user_sca_auth_user_device
|
||||
if fk == nil {
|
||||
return fmt.Errorf(`foreign-key "sca_auth_user_sca_auth_user_device" is nil for node %v`, n.ID)
|
||||
}
|
||||
node, ok := nodeids[*fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "sca_auth_user_sca_auth_user_device" returned %v for node %v`, *fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sauq *ScaAuthUserQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := sauq.querySpec()
|
||||
_spec.Node.Columns = sauq.ctx.Fields
|
||||
|
@@ -8,8 +8,6 @@ import (
|
||||
"fmt"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
@@ -178,19 +176,26 @@ func (sauu *ScaAuthUserUpdate) ClearPassword() *ScaAuthUserUpdate {
|
||||
}
|
||||
|
||||
// SetGender sets the "gender" field.
|
||||
func (sauu *ScaAuthUserUpdate) SetGender(s string) *ScaAuthUserUpdate {
|
||||
sauu.mutation.SetGender(s)
|
||||
func (sauu *ScaAuthUserUpdate) SetGender(i int8) *ScaAuthUserUpdate {
|
||||
sauu.mutation.ResetGender()
|
||||
sauu.mutation.SetGender(i)
|
||||
return sauu
|
||||
}
|
||||
|
||||
// SetNillableGender sets the "gender" field if the given value is not nil.
|
||||
func (sauu *ScaAuthUserUpdate) SetNillableGender(s *string) *ScaAuthUserUpdate {
|
||||
if s != nil {
|
||||
sauu.SetGender(*s)
|
||||
func (sauu *ScaAuthUserUpdate) SetNillableGender(i *int8) *ScaAuthUserUpdate {
|
||||
if i != nil {
|
||||
sauu.SetGender(*i)
|
||||
}
|
||||
return sauu
|
||||
}
|
||||
|
||||
// AddGender adds i to the "gender" field.
|
||||
func (sauu *ScaAuthUserUpdate) AddGender(i int8) *ScaAuthUserUpdate {
|
||||
sauu.mutation.AddGender(i)
|
||||
return sauu
|
||||
}
|
||||
|
||||
// ClearGender clears the value of the "gender" field.
|
||||
func (sauu *ScaAuthUserUpdate) ClearGender() *ScaAuthUserUpdate {
|
||||
sauu.mutation.ClearGender()
|
||||
@@ -324,83 +329,11 @@ func (sauu *ScaAuthUserUpdate) ClearCompany() *ScaAuthUserUpdate {
|
||||
return sauu
|
||||
}
|
||||
|
||||
// AddScaAuthUserSocialIDs adds the "sca_auth_user_social" edge to the ScaAuthUserSocial entity by IDs.
|
||||
func (sauu *ScaAuthUserUpdate) AddScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserUpdate {
|
||||
sauu.mutation.AddScaAuthUserSocialIDs(ids...)
|
||||
return sauu
|
||||
}
|
||||
|
||||
// AddScaAuthUserSocial adds the "sca_auth_user_social" edges to the ScaAuthUserSocial entity.
|
||||
func (sauu *ScaAuthUserUpdate) AddScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserUpdate {
|
||||
ids := make([]int64, len(s))
|
||||
for i := range s {
|
||||
ids[i] = s[i].ID
|
||||
}
|
||||
return sauu.AddScaAuthUserSocialIDs(ids...)
|
||||
}
|
||||
|
||||
// AddScaAuthUserDeviceIDs adds the "sca_auth_user_device" edge to the ScaAuthUserDevice entity by IDs.
|
||||
func (sauu *ScaAuthUserUpdate) AddScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserUpdate {
|
||||
sauu.mutation.AddScaAuthUserDeviceIDs(ids...)
|
||||
return sauu
|
||||
}
|
||||
|
||||
// AddScaAuthUserDevice adds the "sca_auth_user_device" edges to the ScaAuthUserDevice entity.
|
||||
func (sauu *ScaAuthUserUpdate) AddScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserUpdate {
|
||||
ids := make([]int64, len(s))
|
||||
for i := range s {
|
||||
ids[i] = s[i].ID
|
||||
}
|
||||
return sauu.AddScaAuthUserDeviceIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthUserMutation object of the builder.
|
||||
func (sauu *ScaAuthUserUpdate) Mutation() *ScaAuthUserMutation {
|
||||
return sauu.mutation
|
||||
}
|
||||
|
||||
// ClearScaAuthUserSocial clears all "sca_auth_user_social" edges to the ScaAuthUserSocial entity.
|
||||
func (sauu *ScaAuthUserUpdate) ClearScaAuthUserSocial() *ScaAuthUserUpdate {
|
||||
sauu.mutation.ClearScaAuthUserSocial()
|
||||
return sauu
|
||||
}
|
||||
|
||||
// RemoveScaAuthUserSocialIDs removes the "sca_auth_user_social" edge to ScaAuthUserSocial entities by IDs.
|
||||
func (sauu *ScaAuthUserUpdate) RemoveScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserUpdate {
|
||||
sauu.mutation.RemoveScaAuthUserSocialIDs(ids...)
|
||||
return sauu
|
||||
}
|
||||
|
||||
// RemoveScaAuthUserSocial removes "sca_auth_user_social" edges to ScaAuthUserSocial entities.
|
||||
func (sauu *ScaAuthUserUpdate) RemoveScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserUpdate {
|
||||
ids := make([]int64, len(s))
|
||||
for i := range s {
|
||||
ids[i] = s[i].ID
|
||||
}
|
||||
return sauu.RemoveScaAuthUserSocialIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearScaAuthUserDevice clears all "sca_auth_user_device" edges to the ScaAuthUserDevice entity.
|
||||
func (sauu *ScaAuthUserUpdate) ClearScaAuthUserDevice() *ScaAuthUserUpdate {
|
||||
sauu.mutation.ClearScaAuthUserDevice()
|
||||
return sauu
|
||||
}
|
||||
|
||||
// RemoveScaAuthUserDeviceIDs removes the "sca_auth_user_device" edge to ScaAuthUserDevice entities by IDs.
|
||||
func (sauu *ScaAuthUserUpdate) RemoveScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserUpdate {
|
||||
sauu.mutation.RemoveScaAuthUserDeviceIDs(ids...)
|
||||
return sauu
|
||||
}
|
||||
|
||||
// RemoveScaAuthUserDevice removes "sca_auth_user_device" edges to ScaAuthUserDevice entities.
|
||||
func (sauu *ScaAuthUserUpdate) RemoveScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserUpdate {
|
||||
ids := make([]int64, len(s))
|
||||
for i := range s {
|
||||
ids[i] = s[i].ID
|
||||
}
|
||||
return sauu.RemoveScaAuthUserDeviceIDs(ids...)
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (sauu *ScaAuthUserUpdate) Save(ctx context.Context) (int, error) {
|
||||
sauu.defaults()
|
||||
@@ -474,11 +407,6 @@ func (sauu *ScaAuthUserUpdate) check() error {
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.password": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := sauu.mutation.Gender(); ok {
|
||||
if err := scaauthuser.GenderValidator(v); err != nil {
|
||||
return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.gender": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := sauu.mutation.Introduce(); ok {
|
||||
if err := scaauthuser.IntroduceValidator(v); err != nil {
|
||||
return &ValidationError{Name: "introduce", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.introduce": %w`, err)}
|
||||
@@ -560,10 +488,13 @@ func (sauu *ScaAuthUserUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
_spec.ClearField(scaauthuser.FieldPassword, field.TypeString)
|
||||
}
|
||||
if value, ok := sauu.mutation.Gender(); ok {
|
||||
_spec.SetField(scaauthuser.FieldGender, field.TypeString, value)
|
||||
_spec.SetField(scaauthuser.FieldGender, field.TypeInt8, value)
|
||||
}
|
||||
if value, ok := sauu.mutation.AddedGender(); ok {
|
||||
_spec.AddField(scaauthuser.FieldGender, field.TypeInt8, value)
|
||||
}
|
||||
if sauu.mutation.GenderCleared() {
|
||||
_spec.ClearField(scaauthuser.FieldGender, field.TypeString)
|
||||
_spec.ClearField(scaauthuser.FieldGender, field.TypeInt8)
|
||||
}
|
||||
if value, ok := sauu.mutation.Avatar(); ok {
|
||||
_spec.SetField(scaauthuser.FieldAvatar, field.TypeString, value)
|
||||
@@ -604,96 +535,6 @@ func (sauu *ScaAuthUserUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if sauu.mutation.CompanyCleared() {
|
||||
_spec.ClearField(scaauthuser.FieldCompany, field.TypeString)
|
||||
}
|
||||
if sauu.mutation.ScaAuthUserSocialCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthuser.ScaAuthUserSocialTable,
|
||||
Columns: []string{scaauthuser.ScaAuthUserSocialColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := sauu.mutation.RemovedScaAuthUserSocialIDs(); len(nodes) > 0 && !sauu.mutation.ScaAuthUserSocialCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthuser.ScaAuthUserSocialTable,
|
||||
Columns: []string{scaauthuser.ScaAuthUserSocialColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := sauu.mutation.ScaAuthUserSocialIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthuser.ScaAuthUserSocialTable,
|
||||
Columns: []string{scaauthuser.ScaAuthUserSocialColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if sauu.mutation.ScaAuthUserDeviceCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthuser.ScaAuthUserDeviceTable,
|
||||
Columns: []string{scaauthuser.ScaAuthUserDeviceColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := sauu.mutation.RemovedScaAuthUserDeviceIDs(); len(nodes) > 0 && !sauu.mutation.ScaAuthUserDeviceCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthuser.ScaAuthUserDeviceTable,
|
||||
Columns: []string{scaauthuser.ScaAuthUserDeviceColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := sauu.mutation.ScaAuthUserDeviceIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthuser.ScaAuthUserDeviceTable,
|
||||
Columns: []string{scaauthuser.ScaAuthUserDeviceColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, sauu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{scaauthuser.Label}
|
||||
@@ -862,19 +703,26 @@ func (sauuo *ScaAuthUserUpdateOne) ClearPassword() *ScaAuthUserUpdateOne {
|
||||
}
|
||||
|
||||
// SetGender sets the "gender" field.
|
||||
func (sauuo *ScaAuthUserUpdateOne) SetGender(s string) *ScaAuthUserUpdateOne {
|
||||
sauuo.mutation.SetGender(s)
|
||||
func (sauuo *ScaAuthUserUpdateOne) SetGender(i int8) *ScaAuthUserUpdateOne {
|
||||
sauuo.mutation.ResetGender()
|
||||
sauuo.mutation.SetGender(i)
|
||||
return sauuo
|
||||
}
|
||||
|
||||
// SetNillableGender sets the "gender" field if the given value is not nil.
|
||||
func (sauuo *ScaAuthUserUpdateOne) SetNillableGender(s *string) *ScaAuthUserUpdateOne {
|
||||
if s != nil {
|
||||
sauuo.SetGender(*s)
|
||||
func (sauuo *ScaAuthUserUpdateOne) SetNillableGender(i *int8) *ScaAuthUserUpdateOne {
|
||||
if i != nil {
|
||||
sauuo.SetGender(*i)
|
||||
}
|
||||
return sauuo
|
||||
}
|
||||
|
||||
// AddGender adds i to the "gender" field.
|
||||
func (sauuo *ScaAuthUserUpdateOne) AddGender(i int8) *ScaAuthUserUpdateOne {
|
||||
sauuo.mutation.AddGender(i)
|
||||
return sauuo
|
||||
}
|
||||
|
||||
// ClearGender clears the value of the "gender" field.
|
||||
func (sauuo *ScaAuthUserUpdateOne) ClearGender() *ScaAuthUserUpdateOne {
|
||||
sauuo.mutation.ClearGender()
|
||||
@@ -1008,83 +856,11 @@ func (sauuo *ScaAuthUserUpdateOne) ClearCompany() *ScaAuthUserUpdateOne {
|
||||
return sauuo
|
||||
}
|
||||
|
||||
// AddScaAuthUserSocialIDs adds the "sca_auth_user_social" edge to the ScaAuthUserSocial entity by IDs.
|
||||
func (sauuo *ScaAuthUserUpdateOne) AddScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserUpdateOne {
|
||||
sauuo.mutation.AddScaAuthUserSocialIDs(ids...)
|
||||
return sauuo
|
||||
}
|
||||
|
||||
// AddScaAuthUserSocial adds the "sca_auth_user_social" edges to the ScaAuthUserSocial entity.
|
||||
func (sauuo *ScaAuthUserUpdateOne) AddScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserUpdateOne {
|
||||
ids := make([]int64, len(s))
|
||||
for i := range s {
|
||||
ids[i] = s[i].ID
|
||||
}
|
||||
return sauuo.AddScaAuthUserSocialIDs(ids...)
|
||||
}
|
||||
|
||||
// AddScaAuthUserDeviceIDs adds the "sca_auth_user_device" edge to the ScaAuthUserDevice entity by IDs.
|
||||
func (sauuo *ScaAuthUserUpdateOne) AddScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserUpdateOne {
|
||||
sauuo.mutation.AddScaAuthUserDeviceIDs(ids...)
|
||||
return sauuo
|
||||
}
|
||||
|
||||
// AddScaAuthUserDevice adds the "sca_auth_user_device" edges to the ScaAuthUserDevice entity.
|
||||
func (sauuo *ScaAuthUserUpdateOne) AddScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserUpdateOne {
|
||||
ids := make([]int64, len(s))
|
||||
for i := range s {
|
||||
ids[i] = s[i].ID
|
||||
}
|
||||
return sauuo.AddScaAuthUserDeviceIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthUserMutation object of the builder.
|
||||
func (sauuo *ScaAuthUserUpdateOne) Mutation() *ScaAuthUserMutation {
|
||||
return sauuo.mutation
|
||||
}
|
||||
|
||||
// ClearScaAuthUserSocial clears all "sca_auth_user_social" edges to the ScaAuthUserSocial entity.
|
||||
func (sauuo *ScaAuthUserUpdateOne) ClearScaAuthUserSocial() *ScaAuthUserUpdateOne {
|
||||
sauuo.mutation.ClearScaAuthUserSocial()
|
||||
return sauuo
|
||||
}
|
||||
|
||||
// RemoveScaAuthUserSocialIDs removes the "sca_auth_user_social" edge to ScaAuthUserSocial entities by IDs.
|
||||
func (sauuo *ScaAuthUserUpdateOne) RemoveScaAuthUserSocialIDs(ids ...int64) *ScaAuthUserUpdateOne {
|
||||
sauuo.mutation.RemoveScaAuthUserSocialIDs(ids...)
|
||||
return sauuo
|
||||
}
|
||||
|
||||
// RemoveScaAuthUserSocial removes "sca_auth_user_social" edges to ScaAuthUserSocial entities.
|
||||
func (sauuo *ScaAuthUserUpdateOne) RemoveScaAuthUserSocial(s ...*ScaAuthUserSocial) *ScaAuthUserUpdateOne {
|
||||
ids := make([]int64, len(s))
|
||||
for i := range s {
|
||||
ids[i] = s[i].ID
|
||||
}
|
||||
return sauuo.RemoveScaAuthUserSocialIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearScaAuthUserDevice clears all "sca_auth_user_device" edges to the ScaAuthUserDevice entity.
|
||||
func (sauuo *ScaAuthUserUpdateOne) ClearScaAuthUserDevice() *ScaAuthUserUpdateOne {
|
||||
sauuo.mutation.ClearScaAuthUserDevice()
|
||||
return sauuo
|
||||
}
|
||||
|
||||
// RemoveScaAuthUserDeviceIDs removes the "sca_auth_user_device" edge to ScaAuthUserDevice entities by IDs.
|
||||
func (sauuo *ScaAuthUserUpdateOne) RemoveScaAuthUserDeviceIDs(ids ...int64) *ScaAuthUserUpdateOne {
|
||||
sauuo.mutation.RemoveScaAuthUserDeviceIDs(ids...)
|
||||
return sauuo
|
||||
}
|
||||
|
||||
// RemoveScaAuthUserDevice removes "sca_auth_user_device" edges to ScaAuthUserDevice entities.
|
||||
func (sauuo *ScaAuthUserUpdateOne) RemoveScaAuthUserDevice(s ...*ScaAuthUserDevice) *ScaAuthUserUpdateOne {
|
||||
ids := make([]int64, len(s))
|
||||
for i := range s {
|
||||
ids[i] = s[i].ID
|
||||
}
|
||||
return sauuo.RemoveScaAuthUserDeviceIDs(ids...)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ScaAuthUserUpdate builder.
|
||||
func (sauuo *ScaAuthUserUpdateOne) Where(ps ...predicate.ScaAuthUser) *ScaAuthUserUpdateOne {
|
||||
sauuo.mutation.Where(ps...)
|
||||
@@ -1171,11 +947,6 @@ func (sauuo *ScaAuthUserUpdateOne) check() error {
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.password": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := sauuo.mutation.Gender(); ok {
|
||||
if err := scaauthuser.GenderValidator(v); err != nil {
|
||||
return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.gender": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := sauuo.mutation.Introduce(); ok {
|
||||
if err := scaauthuser.IntroduceValidator(v); err != nil {
|
||||
return &ValidationError{Name: "introduce", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.introduce": %w`, err)}
|
||||
@@ -1274,10 +1045,13 @@ func (sauuo *ScaAuthUserUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthU
|
||||
_spec.ClearField(scaauthuser.FieldPassword, field.TypeString)
|
||||
}
|
||||
if value, ok := sauuo.mutation.Gender(); ok {
|
||||
_spec.SetField(scaauthuser.FieldGender, field.TypeString, value)
|
||||
_spec.SetField(scaauthuser.FieldGender, field.TypeInt8, value)
|
||||
}
|
||||
if value, ok := sauuo.mutation.AddedGender(); ok {
|
||||
_spec.AddField(scaauthuser.FieldGender, field.TypeInt8, value)
|
||||
}
|
||||
if sauuo.mutation.GenderCleared() {
|
||||
_spec.ClearField(scaauthuser.FieldGender, field.TypeString)
|
||||
_spec.ClearField(scaauthuser.FieldGender, field.TypeInt8)
|
||||
}
|
||||
if value, ok := sauuo.mutation.Avatar(); ok {
|
||||
_spec.SetField(scaauthuser.FieldAvatar, field.TypeString, value)
|
||||
@@ -1318,96 +1092,6 @@ func (sauuo *ScaAuthUserUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthU
|
||||
if sauuo.mutation.CompanyCleared() {
|
||||
_spec.ClearField(scaauthuser.FieldCompany, field.TypeString)
|
||||
}
|
||||
if sauuo.mutation.ScaAuthUserSocialCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthuser.ScaAuthUserSocialTable,
|
||||
Columns: []string{scaauthuser.ScaAuthUserSocialColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := sauuo.mutation.RemovedScaAuthUserSocialIDs(); len(nodes) > 0 && !sauuo.mutation.ScaAuthUserSocialCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthuser.ScaAuthUserSocialTable,
|
||||
Columns: []string{scaauthuser.ScaAuthUserSocialColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := sauuo.mutation.ScaAuthUserSocialIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthuser.ScaAuthUserSocialTable,
|
||||
Columns: []string{scaauthuser.ScaAuthUserSocialColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if sauuo.mutation.ScaAuthUserDeviceCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthuser.ScaAuthUserDeviceTable,
|
||||
Columns: []string{scaauthuser.ScaAuthUserDeviceColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := sauuo.mutation.RemovedScaAuthUserDeviceIDs(); len(nodes) > 0 && !sauuo.mutation.ScaAuthUserDeviceCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthuser.ScaAuthUserDeviceTable,
|
||||
Columns: []string{scaauthuser.ScaAuthUserDeviceColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := sauuo.mutation.ScaAuthUserDeviceIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: scaauthuser.ScaAuthUserDeviceTable,
|
||||
Columns: []string{scaauthuser.ScaAuthUserDeviceColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &ScaAuthUser{config: sauuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
|
@@ -4,7 +4,6 @@ package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -51,31 +50,7 @@ type ScaAuthUserDevice struct {
|
||||
EngineName string `json:"engine_name,omitempty"`
|
||||
// 引擎版本
|
||||
EngineVersion string `json:"engine_version,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the ScaAuthUserDeviceQuery when eager-loading is set.
|
||||
Edges ScaAuthUserDeviceEdges `json:"edges"`
|
||||
sca_auth_user_sca_auth_user_device *int64
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// ScaAuthUserDeviceEdges holds the relations/edges for other nodes in the graph.
|
||||
type ScaAuthUserDeviceEdges struct {
|
||||
// ScaAuthUser holds the value of the sca_auth_user edge.
|
||||
ScaAuthUser *ScaAuthUser `json:"sca_auth_user,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// ScaAuthUserOrErr returns the ScaAuthUser value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e ScaAuthUserDeviceEdges) ScaAuthUserOrErr() (*ScaAuthUser, error) {
|
||||
if e.ScaAuthUser != nil {
|
||||
return e.ScaAuthUser, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: scaauthuser.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "sca_auth_user"}
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
@@ -91,8 +66,6 @@ func (*ScaAuthUserDevice) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullString)
|
||||
case scaauthuserdevice.FieldCreatedAt, scaauthuserdevice.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case scaauthuserdevice.ForeignKeys[0]: // sca_auth_user_sca_auth_user_device
|
||||
values[i] = new(sql.NullInt64)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
@@ -210,13 +183,6 @@ func (saud *ScaAuthUserDevice) assignValues(columns []string, values []any) erro
|
||||
} else if value.Valid {
|
||||
saud.EngineVersion = value.String
|
||||
}
|
||||
case scaauthuserdevice.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for edge-field sca_auth_user_sca_auth_user_device", value)
|
||||
} else if value.Valid {
|
||||
saud.sca_auth_user_sca_auth_user_device = new(int64)
|
||||
*saud.sca_auth_user_sca_auth_user_device = int64(value.Int64)
|
||||
}
|
||||
default:
|
||||
saud.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
@@ -230,11 +196,6 @@ func (saud *ScaAuthUserDevice) Value(name string) (ent.Value, error) {
|
||||
return saud.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryScaAuthUser queries the "sca_auth_user" edge of the ScaAuthUserDevice entity.
|
||||
func (saud *ScaAuthUserDevice) QueryScaAuthUser() *ScaAuthUserQuery {
|
||||
return NewScaAuthUserDeviceClient(saud.config).QueryScaAuthUser(saud)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this ScaAuthUserDevice.
|
||||
// Note that you need to call ScaAuthUserDevice.Unwrap() before calling this method if this ScaAuthUserDevice
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
|
@@ -6,7 +6,6 @@ import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -46,17 +45,8 @@ const (
|
||||
FieldEngineName = "engine_name"
|
||||
// FieldEngineVersion holds the string denoting the engine_version field in the database.
|
||||
FieldEngineVersion = "engine_version"
|
||||
// EdgeScaAuthUser holds the string denoting the sca_auth_user edge name in mutations.
|
||||
EdgeScaAuthUser = "sca_auth_user"
|
||||
// Table holds the table name of the scaauthuserdevice in the database.
|
||||
Table = "sca_auth_user_device"
|
||||
// ScaAuthUserTable is the table that holds the sca_auth_user relation/edge.
|
||||
ScaAuthUserTable = "sca_auth_user_device"
|
||||
// ScaAuthUserInverseTable is the table name for the ScaAuthUser entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "scaauthuser" package.
|
||||
ScaAuthUserInverseTable = "sca_auth_user"
|
||||
// ScaAuthUserColumn is the table column denoting the sca_auth_user relation/edge.
|
||||
ScaAuthUserColumn = "sca_auth_user_sca_auth_user_device"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for scaauthuserdevice fields.
|
||||
@@ -80,12 +70,6 @@ var Columns = []string{
|
||||
FieldEngineVersion,
|
||||
}
|
||||
|
||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "sca_auth_user_device"
|
||||
// table and are not defined as standalone fields in the schema.
|
||||
var ForeignKeys = []string{
|
||||
"sca_auth_user_sca_auth_user_device",
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
@@ -93,11 +77,6 @@ func ValidColumn(column string) bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
for i := range ForeignKeys {
|
||||
if column == ForeignKeys[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -223,17 +202,3 @@ func ByEngineName(opts ...sql.OrderTermOption) OrderOption {
|
||||
func ByEngineVersion(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldEngineVersion, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByScaAuthUserField orders the results by sca_auth_user field.
|
||||
func ByScaAuthUserField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newScaAuthUserStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newScaAuthUserStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(ScaAuthUserInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthUserTable, ScaAuthUserColumn),
|
||||
)
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@ import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
@@ -1000,29 +999,6 @@ func EngineVersionContainsFold(v string) predicate.ScaAuthUserDevice {
|
||||
return predicate.ScaAuthUserDevice(sql.FieldContainsFold(FieldEngineVersion, v))
|
||||
}
|
||||
|
||||
// HasScaAuthUser applies the HasEdge predicate on the "sca_auth_user" edge.
|
||||
func HasScaAuthUser() predicate.ScaAuthUserDevice {
|
||||
return predicate.ScaAuthUserDevice(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthUserTable, ScaAuthUserColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasScaAuthUserWith applies the HasEdge predicate on the "sca_auth_user" edge with a given conditions (other predicates).
|
||||
func HasScaAuthUserWith(preds ...predicate.ScaAuthUser) predicate.ScaAuthUserDevice {
|
||||
return predicate.ScaAuthUserDevice(func(s *sql.Selector) {
|
||||
step := newScaAuthUserStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.ScaAuthUserDevice) predicate.ScaAuthUserDevice {
|
||||
return predicate.ScaAuthUserDevice(sql.AndPredicates(predicates...))
|
||||
|
@@ -6,7 +6,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
|
||||
"time"
|
||||
|
||||
@@ -147,25 +146,6 @@ func (saudc *ScaAuthUserDeviceCreate) SetID(i int64) *ScaAuthUserDeviceCreate {
|
||||
return saudc
|
||||
}
|
||||
|
||||
// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID.
|
||||
func (saudc *ScaAuthUserDeviceCreate) SetScaAuthUserID(id int64) *ScaAuthUserDeviceCreate {
|
||||
saudc.mutation.SetScaAuthUserID(id)
|
||||
return saudc
|
||||
}
|
||||
|
||||
// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil.
|
||||
func (saudc *ScaAuthUserDeviceCreate) SetNillableScaAuthUserID(id *int64) *ScaAuthUserDeviceCreate {
|
||||
if id != nil {
|
||||
saudc = saudc.SetScaAuthUserID(*id)
|
||||
}
|
||||
return saudc
|
||||
}
|
||||
|
||||
// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity.
|
||||
func (saudc *ScaAuthUserDeviceCreate) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserDeviceCreate {
|
||||
return saudc.SetScaAuthUserID(s.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthUserDeviceMutation object of the builder.
|
||||
func (saudc *ScaAuthUserDeviceCreate) Mutation() *ScaAuthUserDeviceMutation {
|
||||
return saudc.mutation
|
||||
@@ -418,23 +398,6 @@ func (saudc *ScaAuthUserDeviceCreate) createSpec() (*ScaAuthUserDevice, *sqlgrap
|
||||
_spec.SetField(scaauthuserdevice.FieldEngineVersion, field.TypeString, value)
|
||||
_node.EngineVersion = value
|
||||
}
|
||||
if nodes := saudc.mutation.ScaAuthUserIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthuserdevice.ScaAuthUserTable,
|
||||
Columns: []string{scaauthuserdevice.ScaAuthUserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.sca_auth_user_sca_auth_user_device = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,6 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
|
||||
|
||||
"entgo.io/ent"
|
||||
@@ -19,12 +18,10 @@ import (
|
||||
// ScaAuthUserDeviceQuery is the builder for querying ScaAuthUserDevice entities.
|
||||
type ScaAuthUserDeviceQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []scaauthuserdevice.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.ScaAuthUserDevice
|
||||
withScaAuthUser *ScaAuthUserQuery
|
||||
withFKs bool
|
||||
ctx *QueryContext
|
||||
order []scaauthuserdevice.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.ScaAuthUserDevice
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
@@ -61,28 +58,6 @@ func (saudq *ScaAuthUserDeviceQuery) Order(o ...scaauthuserdevice.OrderOption) *
|
||||
return saudq
|
||||
}
|
||||
|
||||
// QueryScaAuthUser chains the current query on the "sca_auth_user" edge.
|
||||
func (saudq *ScaAuthUserDeviceQuery) QueryScaAuthUser() *ScaAuthUserQuery {
|
||||
query := (&ScaAuthUserClient{config: saudq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := saudq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := saudq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(scaauthuserdevice.Table, scaauthuserdevice.FieldID, selector),
|
||||
sqlgraph.To(scaauthuser.Table, scaauthuser.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, scaauthuserdevice.ScaAuthUserTable, scaauthuserdevice.ScaAuthUserColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(saudq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first ScaAuthUserDevice entity from the query.
|
||||
// Returns a *NotFoundError when no ScaAuthUserDevice was found.
|
||||
func (saudq *ScaAuthUserDeviceQuery) First(ctx context.Context) (*ScaAuthUserDevice, error) {
|
||||
@@ -270,29 +245,17 @@ func (saudq *ScaAuthUserDeviceQuery) Clone() *ScaAuthUserDeviceQuery {
|
||||
return nil
|
||||
}
|
||||
return &ScaAuthUserDeviceQuery{
|
||||
config: saudq.config,
|
||||
ctx: saudq.ctx.Clone(),
|
||||
order: append([]scaauthuserdevice.OrderOption{}, saudq.order...),
|
||||
inters: append([]Interceptor{}, saudq.inters...),
|
||||
predicates: append([]predicate.ScaAuthUserDevice{}, saudq.predicates...),
|
||||
withScaAuthUser: saudq.withScaAuthUser.Clone(),
|
||||
config: saudq.config,
|
||||
ctx: saudq.ctx.Clone(),
|
||||
order: append([]scaauthuserdevice.OrderOption{}, saudq.order...),
|
||||
inters: append([]Interceptor{}, saudq.inters...),
|
||||
predicates: append([]predicate.ScaAuthUserDevice{}, saudq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: saudq.sql.Clone(),
|
||||
path: saudq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithScaAuthUser tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "sca_auth_user" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (saudq *ScaAuthUserDeviceQuery) WithScaAuthUser(opts ...func(*ScaAuthUserQuery)) *ScaAuthUserDeviceQuery {
|
||||
query := (&ScaAuthUserClient{config: saudq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
saudq.withScaAuthUser = query
|
||||
return saudq
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
@@ -369,26 +332,15 @@ func (saudq *ScaAuthUserDeviceQuery) prepareQuery(ctx context.Context) error {
|
||||
|
||||
func (saudq *ScaAuthUserDeviceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthUserDevice, error) {
|
||||
var (
|
||||
nodes = []*ScaAuthUserDevice{}
|
||||
withFKs = saudq.withFKs
|
||||
_spec = saudq.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
saudq.withScaAuthUser != nil,
|
||||
}
|
||||
nodes = []*ScaAuthUserDevice{}
|
||||
_spec = saudq.querySpec()
|
||||
)
|
||||
if saudq.withScaAuthUser != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, scaauthuserdevice.ForeignKeys...)
|
||||
}
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*ScaAuthUserDevice).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &ScaAuthUserDevice{config: saudq.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
@@ -400,48 +352,9 @@ func (saudq *ScaAuthUserDeviceQuery) sqlAll(ctx context.Context, hooks ...queryH
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := saudq.withScaAuthUser; query != nil {
|
||||
if err := saudq.loadScaAuthUser(ctx, query, nodes, nil,
|
||||
func(n *ScaAuthUserDevice, e *ScaAuthUser) { n.Edges.ScaAuthUser = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (saudq *ScaAuthUserDeviceQuery) loadScaAuthUser(ctx context.Context, query *ScaAuthUserQuery, nodes []*ScaAuthUserDevice, init func(*ScaAuthUserDevice), assign func(*ScaAuthUserDevice, *ScaAuthUser)) error {
|
||||
ids := make([]int64, 0, len(nodes))
|
||||
nodeids := make(map[int64][]*ScaAuthUserDevice)
|
||||
for i := range nodes {
|
||||
if nodes[i].sca_auth_user_sca_auth_user_device == nil {
|
||||
continue
|
||||
}
|
||||
fk := *nodes[i].sca_auth_user_sca_auth_user_device
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(scaauthuser.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "sca_auth_user_sca_auth_user_device" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (saudq *ScaAuthUserDeviceQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := saudq.querySpec()
|
||||
_spec.Node.Columns = saudq.ctx.Fields
|
||||
|
@@ -7,7 +7,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuserdevice"
|
||||
"time"
|
||||
|
||||
@@ -244,36 +243,11 @@ func (saudu *ScaAuthUserDeviceUpdate) SetNillableEngineVersion(s *string) *ScaAu
|
||||
return saudu
|
||||
}
|
||||
|
||||
// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID.
|
||||
func (saudu *ScaAuthUserDeviceUpdate) SetScaAuthUserID(id int64) *ScaAuthUserDeviceUpdate {
|
||||
saudu.mutation.SetScaAuthUserID(id)
|
||||
return saudu
|
||||
}
|
||||
|
||||
// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil.
|
||||
func (saudu *ScaAuthUserDeviceUpdate) SetNillableScaAuthUserID(id *int64) *ScaAuthUserDeviceUpdate {
|
||||
if id != nil {
|
||||
saudu = saudu.SetScaAuthUserID(*id)
|
||||
}
|
||||
return saudu
|
||||
}
|
||||
|
||||
// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity.
|
||||
func (saudu *ScaAuthUserDeviceUpdate) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserDeviceUpdate {
|
||||
return saudu.SetScaAuthUserID(s.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthUserDeviceMutation object of the builder.
|
||||
func (saudu *ScaAuthUserDeviceUpdate) Mutation() *ScaAuthUserDeviceMutation {
|
||||
return saudu.mutation
|
||||
}
|
||||
|
||||
// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity.
|
||||
func (saudu *ScaAuthUserDeviceUpdate) ClearScaAuthUser() *ScaAuthUserDeviceUpdate {
|
||||
saudu.mutation.ClearScaAuthUser()
|
||||
return saudu
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (saudu *ScaAuthUserDeviceUpdate) Save(ctx context.Context) (int, error) {
|
||||
saudu.defaults()
|
||||
@@ -438,35 +412,6 @@ func (saudu *ScaAuthUserDeviceUpdate) sqlSave(ctx context.Context) (n int, err e
|
||||
if value, ok := saudu.mutation.EngineVersion(); ok {
|
||||
_spec.SetField(scaauthuserdevice.FieldEngineVersion, field.TypeString, value)
|
||||
}
|
||||
if saudu.mutation.ScaAuthUserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthuserdevice.ScaAuthUserTable,
|
||||
Columns: []string{scaauthuserdevice.ScaAuthUserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := saudu.mutation.ScaAuthUserIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthuserdevice.ScaAuthUserTable,
|
||||
Columns: []string{scaauthuserdevice.ScaAuthUserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, saudu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{scaauthuserdevice.Label}
|
||||
@@ -702,36 +647,11 @@ func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableEngineVersion(s *string) *S
|
||||
return sauduo
|
||||
}
|
||||
|
||||
// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID.
|
||||
func (sauduo *ScaAuthUserDeviceUpdateOne) SetScaAuthUserID(id int64) *ScaAuthUserDeviceUpdateOne {
|
||||
sauduo.mutation.SetScaAuthUserID(id)
|
||||
return sauduo
|
||||
}
|
||||
|
||||
// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil.
|
||||
func (sauduo *ScaAuthUserDeviceUpdateOne) SetNillableScaAuthUserID(id *int64) *ScaAuthUserDeviceUpdateOne {
|
||||
if id != nil {
|
||||
sauduo = sauduo.SetScaAuthUserID(*id)
|
||||
}
|
||||
return sauduo
|
||||
}
|
||||
|
||||
// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity.
|
||||
func (sauduo *ScaAuthUserDeviceUpdateOne) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserDeviceUpdateOne {
|
||||
return sauduo.SetScaAuthUserID(s.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthUserDeviceMutation object of the builder.
|
||||
func (sauduo *ScaAuthUserDeviceUpdateOne) Mutation() *ScaAuthUserDeviceMutation {
|
||||
return sauduo.mutation
|
||||
}
|
||||
|
||||
// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity.
|
||||
func (sauduo *ScaAuthUserDeviceUpdateOne) ClearScaAuthUser() *ScaAuthUserDeviceUpdateOne {
|
||||
sauduo.mutation.ClearScaAuthUser()
|
||||
return sauduo
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ScaAuthUserDeviceUpdate builder.
|
||||
func (sauduo *ScaAuthUserDeviceUpdateOne) Where(ps ...predicate.ScaAuthUserDevice) *ScaAuthUserDeviceUpdateOne {
|
||||
sauduo.mutation.Where(ps...)
|
||||
@@ -926,35 +846,6 @@ func (sauduo *ScaAuthUserDeviceUpdateOne) sqlSave(ctx context.Context) (_node *S
|
||||
if value, ok := sauduo.mutation.EngineVersion(); ok {
|
||||
_spec.SetField(scaauthuserdevice.FieldEngineVersion, field.TypeString, value)
|
||||
}
|
||||
if sauduo.mutation.ScaAuthUserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthuserdevice.ScaAuthUserTable,
|
||||
Columns: []string{scaauthuserdevice.ScaAuthUserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := sauduo.mutation.ScaAuthUserIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthuserdevice.ScaAuthUserTable,
|
||||
Columns: []string{scaauthuserdevice.ScaAuthUserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &ScaAuthUserDevice{config: sauduo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
|
@@ -4,7 +4,6 @@ package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -32,32 +31,8 @@ type ScaAuthUserSocial struct {
|
||||
// 第三方用户来源
|
||||
Source string `json:"source,omitempty"`
|
||||
// 状态 0正常 1 封禁
|
||||
Status int `json:"status,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the ScaAuthUserSocialQuery when eager-loading is set.
|
||||
Edges ScaAuthUserSocialEdges `json:"edges"`
|
||||
sca_auth_user_sca_auth_user_social *int64
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// ScaAuthUserSocialEdges holds the relations/edges for other nodes in the graph.
|
||||
type ScaAuthUserSocialEdges struct {
|
||||
// ScaAuthUser holds the value of the sca_auth_user edge.
|
||||
ScaAuthUser *ScaAuthUser `json:"sca_auth_user,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// ScaAuthUserOrErr returns the ScaAuthUser value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e ScaAuthUserSocialEdges) ScaAuthUserOrErr() (*ScaAuthUser, error) {
|
||||
if e.ScaAuthUser != nil {
|
||||
return e.ScaAuthUser, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: scaauthuser.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "sca_auth_user"}
|
||||
Status int `json:"status,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
@@ -71,8 +46,6 @@ func (*ScaAuthUserSocial) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullString)
|
||||
case scaauthusersocial.FieldCreatedAt, scaauthusersocial.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case scaauthusersocial.ForeignKeys[0]: // sca_auth_user_sca_auth_user_social
|
||||
values[i] = new(sql.NullInt64)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
@@ -136,13 +109,6 @@ func (saus *ScaAuthUserSocial) assignValues(columns []string, values []any) erro
|
||||
} else if value.Valid {
|
||||
saus.Status = int(value.Int64)
|
||||
}
|
||||
case scaauthusersocial.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for edge-field sca_auth_user_sca_auth_user_social", value)
|
||||
} else if value.Valid {
|
||||
saus.sca_auth_user_sca_auth_user_social = new(int64)
|
||||
*saus.sca_auth_user_sca_auth_user_social = int64(value.Int64)
|
||||
}
|
||||
default:
|
||||
saus.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
@@ -156,11 +122,6 @@ func (saus *ScaAuthUserSocial) Value(name string) (ent.Value, error) {
|
||||
return saus.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryScaAuthUser queries the "sca_auth_user" edge of the ScaAuthUserSocial entity.
|
||||
func (saus *ScaAuthUserSocial) QueryScaAuthUser() *ScaAuthUserQuery {
|
||||
return NewScaAuthUserSocialClient(saus.config).QueryScaAuthUser(saus)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this ScaAuthUserSocial.
|
||||
// Note that you need to call ScaAuthUserSocial.Unwrap() before calling this method if this ScaAuthUserSocial
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
|
@@ -6,7 +6,6 @@ import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -28,17 +27,8 @@ const (
|
||||
FieldSource = "source"
|
||||
// FieldStatus holds the string denoting the status field in the database.
|
||||
FieldStatus = "status"
|
||||
// EdgeScaAuthUser holds the string denoting the sca_auth_user edge name in mutations.
|
||||
EdgeScaAuthUser = "sca_auth_user"
|
||||
// Table holds the table name of the scaauthusersocial in the database.
|
||||
Table = "sca_auth_user_social"
|
||||
// ScaAuthUserTable is the table that holds the sca_auth_user relation/edge.
|
||||
ScaAuthUserTable = "sca_auth_user_social"
|
||||
// ScaAuthUserInverseTable is the table name for the ScaAuthUser entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "scaauthuser" package.
|
||||
ScaAuthUserInverseTable = "sca_auth_user"
|
||||
// ScaAuthUserColumn is the table column denoting the sca_auth_user relation/edge.
|
||||
ScaAuthUserColumn = "sca_auth_user_sca_auth_user_social"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for scaauthusersocial fields.
|
||||
@@ -53,12 +43,6 @@ var Columns = []string{
|
||||
FieldStatus,
|
||||
}
|
||||
|
||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "sca_auth_user_social"
|
||||
// table and are not defined as standalone fields in the schema.
|
||||
var ForeignKeys = []string{
|
||||
"sca_auth_user_sca_auth_user_social",
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
@@ -66,11 +50,6 @@ func ValidColumn(column string) bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
for i := range ForeignKeys {
|
||||
if column == ForeignKeys[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -137,17 +116,3 @@ func BySource(opts ...sql.OrderTermOption) OrderOption {
|
||||
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldStatus, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByScaAuthUserField orders the results by sca_auth_user field.
|
||||
func ByScaAuthUserField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newScaAuthUserStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newScaAuthUserStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(ScaAuthUserInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthUserTable, ScaAuthUserColumn),
|
||||
)
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@ import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
@@ -455,29 +454,6 @@ func StatusLTE(v int) predicate.ScaAuthUserSocial {
|
||||
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldStatus, v))
|
||||
}
|
||||
|
||||
// HasScaAuthUser applies the HasEdge predicate on the "sca_auth_user" edge.
|
||||
func HasScaAuthUser() predicate.ScaAuthUserSocial {
|
||||
return predicate.ScaAuthUserSocial(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, ScaAuthUserTable, ScaAuthUserColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasScaAuthUserWith applies the HasEdge predicate on the "sca_auth_user" edge with a given conditions (other predicates).
|
||||
func HasScaAuthUserWith(preds ...predicate.ScaAuthUser) predicate.ScaAuthUserSocial {
|
||||
return predicate.ScaAuthUserSocial(func(s *sql.Selector) {
|
||||
step := newScaAuthUserStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.ScaAuthUserSocial) predicate.ScaAuthUserSocial {
|
||||
return predicate.ScaAuthUserSocial(sql.AndPredicates(predicates...))
|
||||
|
@@ -6,7 +6,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
|
||||
"time"
|
||||
|
||||
@@ -101,25 +100,6 @@ func (sausc *ScaAuthUserSocialCreate) SetID(i int64) *ScaAuthUserSocialCreate {
|
||||
return sausc
|
||||
}
|
||||
|
||||
// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID.
|
||||
func (sausc *ScaAuthUserSocialCreate) SetScaAuthUserID(id int64) *ScaAuthUserSocialCreate {
|
||||
sausc.mutation.SetScaAuthUserID(id)
|
||||
return sausc
|
||||
}
|
||||
|
||||
// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil.
|
||||
func (sausc *ScaAuthUserSocialCreate) SetNillableScaAuthUserID(id *int64) *ScaAuthUserSocialCreate {
|
||||
if id != nil {
|
||||
sausc = sausc.SetScaAuthUserID(*id)
|
||||
}
|
||||
return sausc
|
||||
}
|
||||
|
||||
// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity.
|
||||
func (sausc *ScaAuthUserSocialCreate) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserSocialCreate {
|
||||
return sausc.SetScaAuthUserID(s.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthUserSocialMutation object of the builder.
|
||||
func (sausc *ScaAuthUserSocialCreate) Mutation() *ScaAuthUserSocialMutation {
|
||||
return sausc.mutation
|
||||
@@ -273,23 +253,6 @@ func (sausc *ScaAuthUserSocialCreate) createSpec() (*ScaAuthUserSocial, *sqlgrap
|
||||
_spec.SetField(scaauthusersocial.FieldStatus, field.TypeInt, value)
|
||||
_node.Status = value
|
||||
}
|
||||
if nodes := sausc.mutation.ScaAuthUserIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthusersocial.ScaAuthUserTable,
|
||||
Columns: []string{scaauthusersocial.ScaAuthUserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.sca_auth_user_sca_auth_user_social = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,6 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
|
||||
|
||||
"entgo.io/ent"
|
||||
@@ -19,12 +18,10 @@ import (
|
||||
// ScaAuthUserSocialQuery is the builder for querying ScaAuthUserSocial entities.
|
||||
type ScaAuthUserSocialQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []scaauthusersocial.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.ScaAuthUserSocial
|
||||
withScaAuthUser *ScaAuthUserQuery
|
||||
withFKs bool
|
||||
ctx *QueryContext
|
||||
order []scaauthusersocial.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.ScaAuthUserSocial
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
@@ -61,28 +58,6 @@ func (sausq *ScaAuthUserSocialQuery) Order(o ...scaauthusersocial.OrderOption) *
|
||||
return sausq
|
||||
}
|
||||
|
||||
// QueryScaAuthUser chains the current query on the "sca_auth_user" edge.
|
||||
func (sausq *ScaAuthUserSocialQuery) QueryScaAuthUser() *ScaAuthUserQuery {
|
||||
query := (&ScaAuthUserClient{config: sausq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := sausq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := sausq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(scaauthusersocial.Table, scaauthusersocial.FieldID, selector),
|
||||
sqlgraph.To(scaauthuser.Table, scaauthuser.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, scaauthusersocial.ScaAuthUserTable, scaauthusersocial.ScaAuthUserColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(sausq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first ScaAuthUserSocial entity from the query.
|
||||
// Returns a *NotFoundError when no ScaAuthUserSocial was found.
|
||||
func (sausq *ScaAuthUserSocialQuery) First(ctx context.Context) (*ScaAuthUserSocial, error) {
|
||||
@@ -270,29 +245,17 @@ func (sausq *ScaAuthUserSocialQuery) Clone() *ScaAuthUserSocialQuery {
|
||||
return nil
|
||||
}
|
||||
return &ScaAuthUserSocialQuery{
|
||||
config: sausq.config,
|
||||
ctx: sausq.ctx.Clone(),
|
||||
order: append([]scaauthusersocial.OrderOption{}, sausq.order...),
|
||||
inters: append([]Interceptor{}, sausq.inters...),
|
||||
predicates: append([]predicate.ScaAuthUserSocial{}, sausq.predicates...),
|
||||
withScaAuthUser: sausq.withScaAuthUser.Clone(),
|
||||
config: sausq.config,
|
||||
ctx: sausq.ctx.Clone(),
|
||||
order: append([]scaauthusersocial.OrderOption{}, sausq.order...),
|
||||
inters: append([]Interceptor{}, sausq.inters...),
|
||||
predicates: append([]predicate.ScaAuthUserSocial{}, sausq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: sausq.sql.Clone(),
|
||||
path: sausq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithScaAuthUser tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "sca_auth_user" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (sausq *ScaAuthUserSocialQuery) WithScaAuthUser(opts ...func(*ScaAuthUserQuery)) *ScaAuthUserSocialQuery {
|
||||
query := (&ScaAuthUserClient{config: sausq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
sausq.withScaAuthUser = query
|
||||
return sausq
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
@@ -369,26 +332,15 @@ func (sausq *ScaAuthUserSocialQuery) prepareQuery(ctx context.Context) error {
|
||||
|
||||
func (sausq *ScaAuthUserSocialQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthUserSocial, error) {
|
||||
var (
|
||||
nodes = []*ScaAuthUserSocial{}
|
||||
withFKs = sausq.withFKs
|
||||
_spec = sausq.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
sausq.withScaAuthUser != nil,
|
||||
}
|
||||
nodes = []*ScaAuthUserSocial{}
|
||||
_spec = sausq.querySpec()
|
||||
)
|
||||
if sausq.withScaAuthUser != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, scaauthusersocial.ForeignKeys...)
|
||||
}
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*ScaAuthUserSocial).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &ScaAuthUserSocial{config: sausq.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
@@ -400,48 +352,9 @@ func (sausq *ScaAuthUserSocialQuery) sqlAll(ctx context.Context, hooks ...queryH
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := sausq.withScaAuthUser; query != nil {
|
||||
if err := sausq.loadScaAuthUser(ctx, query, nodes, nil,
|
||||
func(n *ScaAuthUserSocial, e *ScaAuthUser) { n.Edges.ScaAuthUser = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (sausq *ScaAuthUserSocialQuery) loadScaAuthUser(ctx context.Context, query *ScaAuthUserQuery, nodes []*ScaAuthUserSocial, init func(*ScaAuthUserSocial), assign func(*ScaAuthUserSocial, *ScaAuthUser)) error {
|
||||
ids := make([]int64, 0, len(nodes))
|
||||
nodeids := make(map[int64][]*ScaAuthUserSocial)
|
||||
for i := range nodes {
|
||||
if nodes[i].sca_auth_user_sca_auth_user_social == nil {
|
||||
continue
|
||||
}
|
||||
fk := *nodes[i].sca_auth_user_sca_auth_user_social
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(scaauthuser.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "sca_auth_user_sca_auth_user_social" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sausq *ScaAuthUserSocialQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := sausq.querySpec()
|
||||
_spec.Node.Columns = sausq.ctx.Fields
|
||||
|
@@ -7,7 +7,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/predicate"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthuser"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent/scaauthusersocial"
|
||||
"time"
|
||||
|
||||
@@ -125,36 +124,11 @@ func (sausu *ScaAuthUserSocialUpdate) AddStatus(i int) *ScaAuthUserSocialUpdate
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetScaAuthUserID(id int64) *ScaAuthUserSocialUpdate {
|
||||
sausu.mutation.SetScaAuthUserID(id)
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetNillableScaAuthUserID(id *int64) *ScaAuthUserSocialUpdate {
|
||||
if id != nil {
|
||||
sausu = sausu.SetScaAuthUserID(*id)
|
||||
}
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserSocialUpdate {
|
||||
return sausu.SetScaAuthUserID(s.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthUserSocialMutation object of the builder.
|
||||
func (sausu *ScaAuthUserSocialUpdate) Mutation() *ScaAuthUserSocialMutation {
|
||||
return sausu.mutation
|
||||
}
|
||||
|
||||
// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity.
|
||||
func (sausu *ScaAuthUserSocialUpdate) ClearScaAuthUser() *ScaAuthUserSocialUpdate {
|
||||
sausu.mutation.ClearScaAuthUser()
|
||||
return sausu
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (sausu *ScaAuthUserSocialUpdate) Save(ctx context.Context) (int, error) {
|
||||
sausu.defaults()
|
||||
@@ -255,35 +229,6 @@ func (sausu *ScaAuthUserSocialUpdate) sqlSave(ctx context.Context) (n int, err e
|
||||
if value, ok := sausu.mutation.AddedStatus(); ok {
|
||||
_spec.AddField(scaauthusersocial.FieldStatus, field.TypeInt, value)
|
||||
}
|
||||
if sausu.mutation.ScaAuthUserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthusersocial.ScaAuthUserTable,
|
||||
Columns: []string{scaauthusersocial.ScaAuthUserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := sausu.mutation.ScaAuthUserIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthusersocial.ScaAuthUserTable,
|
||||
Columns: []string{scaauthusersocial.ScaAuthUserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, sausu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{scaauthusersocial.Label}
|
||||
@@ -400,36 +345,11 @@ func (sausuo *ScaAuthUserSocialUpdateOne) AddStatus(i int) *ScaAuthUserSocialUpd
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetScaAuthUserID(id int64) *ScaAuthUserSocialUpdateOne {
|
||||
sausuo.mutation.SetScaAuthUserID(id)
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableScaAuthUserID(id *int64) *ScaAuthUserSocialUpdateOne {
|
||||
if id != nil {
|
||||
sausuo = sausuo.SetScaAuthUserID(*id)
|
||||
}
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserSocialUpdateOne {
|
||||
return sausuo.SetScaAuthUserID(s.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthUserSocialMutation object of the builder.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) Mutation() *ScaAuthUserSocialMutation {
|
||||
return sausuo.mutation
|
||||
}
|
||||
|
||||
// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) ClearScaAuthUser() *ScaAuthUserSocialUpdateOne {
|
||||
sausuo.mutation.ClearScaAuthUser()
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ScaAuthUserSocialUpdate builder.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialUpdateOne {
|
||||
sausuo.mutation.Where(ps...)
|
||||
@@ -560,35 +480,6 @@ func (sausuo *ScaAuthUserSocialUpdateOne) sqlSave(ctx context.Context) (_node *S
|
||||
if value, ok := sausuo.mutation.AddedStatus(); ok {
|
||||
_spec.AddField(scaauthusersocial.FieldStatus, field.TypeInt, value)
|
||||
}
|
||||
if sausuo.mutation.ScaAuthUserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthusersocial.ScaAuthUserTable,
|
||||
Columns: []string{scaauthusersocial.ScaAuthUserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := sausuo.mutation.ScaAuthUserIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthusersocial.ScaAuthUserTable,
|
||||
Columns: []string{scaauthusersocial.ScaAuthUserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &ScaAuthUserSocial{config: sausuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
|
@@ -5,7 +5,6 @@ import (
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
@@ -17,48 +16,42 @@ type ScaAuthPermissionRule struct {
|
||||
// Fields of the ScaAuthPermissionRule.
|
||||
func (ScaAuthPermissionRule) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int64("id").
|
||||
field.Int("id").
|
||||
SchemaType(map[string]string{
|
||||
dialect.MySQL: "bigint(20) unsigned",
|
||||
dialect.MySQL: "int(11)",
|
||||
}).
|
||||
Unique(),
|
||||
field.String("ptype").
|
||||
MaxLen(100).
|
||||
Nillable(),
|
||||
Optional(),
|
||||
field.String("v0").
|
||||
MaxLen(100).
|
||||
Nillable(),
|
||||
Optional(),
|
||||
field.String("v1").
|
||||
MaxLen(100).
|
||||
Nillable(),
|
||||
Optional(),
|
||||
field.String("v2").
|
||||
MaxLen(100).
|
||||
Optional().
|
||||
Nillable(),
|
||||
Optional(),
|
||||
field.String("v3").
|
||||
MaxLen(100).
|
||||
Optional().
|
||||
Nillable(),
|
||||
Optional(),
|
||||
field.String("v4").
|
||||
MaxLen(100).
|
||||
Optional().
|
||||
Nillable(),
|
||||
Optional(),
|
||||
field.String("v5").
|
||||
MaxLen(100).
|
||||
Optional().
|
||||
Nillable().Annotations(
|
||||
entsql.WithComments(true),
|
||||
),
|
||||
Annotations(
|
||||
entsql.WithComments(true),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the ScaAuthPermissionRule.
|
||||
func (ScaAuthPermissionRule) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("sca_auth_role", ScaAuthRole.Type).
|
||||
Ref("sca_auth_permission_rule").
|
||||
Unique(),
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Annotations of the ScaAuthPermissionRule.
|
||||
|
@@ -5,7 +5,6 @@ import (
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/model/mixin"
|
||||
@@ -45,9 +44,7 @@ func (ScaAuthRole) Fields() []ent.Field {
|
||||
|
||||
// Edges of the ScaAuthRole.
|
||||
func (ScaAuthRole) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.To("sca_auth_permission_rule", ScaAuthPermissionRule.Type),
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Indexes of the ScaAuthRole.
|
||||
|
@@ -5,7 +5,6 @@ import (
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
|
||||
@@ -57,8 +56,7 @@ func (ScaAuthUser) Fields() []ent.Field {
|
||||
Optional().
|
||||
Sensitive().
|
||||
Comment("密码"),
|
||||
field.String("gender").
|
||||
MaxLen(32).
|
||||
field.Int8("gender").
|
||||
Optional().
|
||||
Comment("性别"),
|
||||
field.String("avatar").
|
||||
@@ -95,10 +93,7 @@ func (ScaAuthUser) Fields() []ent.Field {
|
||||
|
||||
// Edges of the ScaAuthUser.
|
||||
func (ScaAuthUser) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.To("sca_auth_user_social", ScaAuthUserSocial.Type),
|
||||
edge.To("sca_auth_user_device", ScaAuthUserDevice.Type),
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Indexes of the ScaAuthUser.
|
||||
|
@@ -5,7 +5,6 @@ import (
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
|
||||
@@ -76,11 +75,7 @@ func (ScaAuthUserDevice) Fields() []ent.Field {
|
||||
|
||||
// Edges of the ScaAuthUserDevice.
|
||||
func (ScaAuthUserDevice) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("sca_auth_user", ScaAuthUser.Type).
|
||||
Ref("sca_auth_user_device").
|
||||
Unique(),
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Indexes of the ScaAuthUserDevice.
|
||||
|
@@ -5,7 +5,6 @@ import (
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
|
||||
@@ -51,11 +50,7 @@ func (ScaAuthUserSocial) Fields() []ent.Field {
|
||||
|
||||
// Edges of the ScaAuthUserSocial.
|
||||
func (ScaAuthUserSocial) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("sca_auth_user", ScaAuthUser.Type).
|
||||
Ref("sca_auth_user_social").
|
||||
Unique(),
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Indexes of the ScaAuthUserSocial.
|
||||
|
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/zeromicro/go-zero/core/logc"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/core/api/common/constant"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/redis_session/types"
|
||||
"schisandra-album-cloud-microservices/app/core/api/internal/types"
|
||||
)
|
||||
|
||||
func NewRedisSession(addr string, password string) *redisstore.RedisStore {
|
||||
|
@@ -1,7 +0,0 @@
|
||||
package types
|
||||
|
||||
// SessionData 返回数据
|
||||
type SessionData struct {
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
UID string `json:"uid"`
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
package types
|
||||
|
||||
type RedisToken struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
UID string `json:"uid"`
|
||||
}
|
Reference in New Issue
Block a user