add mongodb/jwt

This commit is contained in:
landaiqing
2024-11-13 13:37:47 +08:00
parent ae743ba8a6
commit c95d5fc041
85 changed files with 3370 additions and 239 deletions

View File

@@ -1,35 +0,0 @@
package core
import (
"context"
"database/sql"
"log"
"time"
entsql "entgo.io/ent/dialect/sql"
_ "github.com/go-sql-driver/mysql"
"schisandra-album-cloud-microservices/common/ent"
)
func InitMySQL(url string) *ent.Client {
var db *sql.DB
db, err := sql.Open("mysql", url)
if err != nil {
log.Panicf("failed to connect to database: %v", err)
return nil
}
db.SetMaxOpenConns(100)
db.SetMaxIdleConns(10)
db.SetConnMaxLifetime(time.Hour)
drv := entsql.OpenDB("mysql", db)
client := ent.NewClient(ent.Driver(drv), ent.Debug())
defer client.Close()
if err = client.Schema.Create(context.Background()); err != nil {
log.Panicf("failed creating schema resources: %v", err)
}
return client
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,616 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"reflect"
"schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule"
"schisandra-album-cloud-microservices/common/ent/scaauthrole"
"schisandra-album-cloud-microservices/common/ent/scaauthuser"
"schisandra-album-cloud-microservices/common/ent/scaauthuserdevice"
"schisandra-album-cloud-microservices/common/ent/scaauthusersocial"
"sync"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
// ent aliases to avoid import conflicts in user's code.
type (
Op = ent.Op
Hook = ent.Hook
Value = ent.Value
Query = ent.Query
QueryContext = ent.QueryContext
Querier = ent.Querier
QuerierFunc = ent.QuerierFunc
Interceptor = ent.Interceptor
InterceptFunc = ent.InterceptFunc
Traverser = ent.Traverser
TraverseFunc = ent.TraverseFunc
Policy = ent.Policy
Mutator = ent.Mutator
Mutation = ent.Mutation
MutateFunc = ent.MutateFunc
)
type clientCtxKey struct{}
// FromContext returns a Client stored inside a context, or nil if there isn't one.
func FromContext(ctx context.Context) *Client {
c, _ := ctx.Value(clientCtxKey{}).(*Client)
return c
}
// NewContext returns a new context with the given Client attached.
func NewContext(parent context.Context, c *Client) context.Context {
return context.WithValue(parent, clientCtxKey{}, c)
}
type txCtxKey struct{}
// TxFromContext returns a Tx stored inside a context, or nil if there isn't one.
func TxFromContext(ctx context.Context) *Tx {
tx, _ := ctx.Value(txCtxKey{}).(*Tx)
return tx
}
// NewTxContext returns a new context with the given Tx attached.
func NewTxContext(parent context.Context, tx *Tx) context.Context {
return context.WithValue(parent, txCtxKey{}, tx)
}
// OrderFunc applies an ordering on the sql selector.
// Deprecated: Use Asc/Desc functions or the package builders instead.
type OrderFunc func(*sql.Selector)
var (
initCheck sync.Once
columnCheck sql.ColumnCheck
)
// checkColumn checks if the column exists in the given table.
func checkColumn(table, column string) error {
initCheck.Do(func() {
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
scaauthpermissionrule.Table: scaauthpermissionrule.ValidColumn,
scaauthrole.Table: scaauthrole.ValidColumn,
scaauthuser.Table: scaauthuser.ValidColumn,
scaauthuserdevice.Table: scaauthuserdevice.ValidColumn,
scaauthusersocial.Table: scaauthusersocial.ValidColumn,
})
})
return columnCheck(table, column)
}
// Asc applies the given fields in ASC order.
func Asc(fields ...string) func(*sql.Selector) {
return func(s *sql.Selector) {
for _, f := range fields {
if err := checkColumn(s.TableName(), f); err != nil {
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
}
s.OrderBy(sql.Asc(s.C(f)))
}
}
}
// Desc applies the given fields in DESC order.
func Desc(fields ...string) func(*sql.Selector) {
return func(s *sql.Selector) {
for _, f := range fields {
if err := checkColumn(s.TableName(), f); err != nil {
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
}
s.OrderBy(sql.Desc(s.C(f)))
}
}
}
// AggregateFunc applies an aggregation step on the group-by traversal/selector.
type AggregateFunc func(*sql.Selector) string
// As is a pseudo aggregation function for renaming another other functions with custom names. For example:
//
// GroupBy(field1, field2).
// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
// Scan(ctx, &v)
func As(fn AggregateFunc, end string) AggregateFunc {
return func(s *sql.Selector) string {
return sql.As(fn(s), end)
}
}
// Count applies the "count" aggregation function on each group.
func Count() AggregateFunc {
return func(s *sql.Selector) string {
return sql.Count("*")
}
}
// Max applies the "max" aggregation function on the given field of each group.
func Max(field string) AggregateFunc {
return func(s *sql.Selector) string {
if err := checkColumn(s.TableName(), field); err != nil {
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
return ""
}
return sql.Max(s.C(field))
}
}
// Mean applies the "mean" aggregation function on the given field of each group.
func Mean(field string) AggregateFunc {
return func(s *sql.Selector) string {
if err := checkColumn(s.TableName(), field); err != nil {
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
return ""
}
return sql.Avg(s.C(field))
}
}
// Min applies the "min" aggregation function on the given field of each group.
func Min(field string) AggregateFunc {
return func(s *sql.Selector) string {
if err := checkColumn(s.TableName(), field); err != nil {
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
return ""
}
return sql.Min(s.C(field))
}
}
// Sum applies the "sum" aggregation function on the given field of each group.
func Sum(field string) AggregateFunc {
return func(s *sql.Selector) string {
if err := checkColumn(s.TableName(), field); err != nil {
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
return ""
}
return sql.Sum(s.C(field))
}
}
// ValidationError returns when validating a field or edge fails.
type ValidationError struct {
Name string // Field or edge name.
err error
}
// Error implements the error interface.
func (e *ValidationError) Error() string {
return e.err.Error()
}
// Unwrap implements the errors.Wrapper interface.
func (e *ValidationError) Unwrap() error {
return e.err
}
// IsValidationError returns a boolean indicating whether the error is a validation error.
func IsValidationError(err error) bool {
if err == nil {
return false
}
var e *ValidationError
return errors.As(err, &e)
}
// NotFoundError returns when trying to fetch a specific entity and it was not found in the database.
type NotFoundError struct {
label string
}
// Error implements the error interface.
func (e *NotFoundError) Error() string {
return "ent: " + e.label + " not found"
}
// IsNotFound returns a boolean indicating whether the error is a not found error.
func IsNotFound(err error) bool {
if err == nil {
return false
}
var e *NotFoundError
return errors.As(err, &e)
}
// MaskNotFound masks not found error.
func MaskNotFound(err error) error {
if IsNotFound(err) {
return nil
}
return err
}
// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database.
type NotSingularError struct {
label string
}
// Error implements the error interface.
func (e *NotSingularError) Error() string {
return "ent: " + e.label + " not singular"
}
// IsNotSingular returns a boolean indicating whether the error is a not singular error.
func IsNotSingular(err error) bool {
if err == nil {
return false
}
var e *NotSingularError
return errors.As(err, &e)
}
// NotLoadedError returns when trying to get a node that was not loaded by the query.
type NotLoadedError struct {
edge string
}
// Error implements the error interface.
func (e *NotLoadedError) Error() string {
return "ent: " + e.edge + " edge was not loaded"
}
// IsNotLoaded returns a boolean indicating whether the error is a not loaded error.
func IsNotLoaded(err error) bool {
if err == nil {
return false
}
var e *NotLoadedError
return errors.As(err, &e)
}
// ConstraintError returns when trying to create/update one or more entities and
// one or more of their constraints failed. For example, violation of edge or
// field uniqueness.
type ConstraintError struct {
msg string
wrap error
}
// Error implements the error interface.
func (e ConstraintError) Error() string {
return "ent: constraint failed: " + e.msg
}
// Unwrap implements the errors.Wrapper interface.
func (e *ConstraintError) Unwrap() error {
return e.wrap
}
// IsConstraintError returns a boolean indicating whether the error is a constraint failure.
func IsConstraintError(err error) bool {
if err == nil {
return false
}
var e *ConstraintError
return errors.As(err, &e)
}
// selector embedded by the different Select/GroupBy builders.
type selector struct {
label string
flds *[]string
fns []AggregateFunc
scan func(context.Context, any) error
}
// ScanX is like Scan, but panics if an error occurs.
func (s *selector) ScanX(ctx context.Context, v any) {
if err := s.scan(ctx, v); err != nil {
panic(err)
}
}
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (s *selector) Strings(ctx context.Context) ([]string, error) {
if len(*s.flds) > 1 {
return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field")
}
var v []string
if err := s.scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (s *selector) StringsX(ctx context.Context) []string {
v, err := s.Strings(ctx)
if err != nil {
panic(err)
}
return v
}
// String returns a single string from a selector. It is only allowed when selecting one field.
func (s *selector) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = s.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{s.label}
default:
err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (s *selector) StringX(ctx context.Context) string {
v, err := s.String(ctx)
if err != nil {
panic(err)
}
return v
}
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (s *selector) Ints(ctx context.Context) ([]int, error) {
if len(*s.flds) > 1 {
return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field")
}
var v []int
if err := s.scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (s *selector) IntsX(ctx context.Context) []int {
v, err := s.Ints(ctx)
if err != nil {
panic(err)
}
return v
}
// Int returns a single int from a selector. It is only allowed when selecting one field.
func (s *selector) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = s.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{s.label}
default:
err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (s *selector) IntX(ctx context.Context) int {
v, err := s.Int(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (s *selector) Float64s(ctx context.Context) ([]float64, error) {
if len(*s.flds) > 1 {
return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field")
}
var v []float64
if err := s.scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (s *selector) Float64sX(ctx context.Context) []float64 {
v, err := s.Float64s(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (s *selector) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = s.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{s.label}
default:
err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (s *selector) Float64X(ctx context.Context) float64 {
v, err := s.Float64(ctx)
if err != nil {
panic(err)
}
return v
}
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (s *selector) Bools(ctx context.Context) ([]bool, error) {
if len(*s.flds) > 1 {
return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field")
}
var v []bool
if err := s.scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (s *selector) BoolsX(ctx context.Context) []bool {
v, err := s.Bools(ctx)
if err != nil {
panic(err)
}
return v
}
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (s *selector) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = s.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{s.label}
default:
err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (s *selector) BoolX(ctx context.Context) bool {
v, err := s.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
// withHooks invokes the builder operation with the given hooks, if any.
func withHooks[V Value, M any, PM interface {
*M
Mutation
}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) {
if len(hooks) == 0 {
return exec(ctx)
}
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutationT, ok := any(m).(PM)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
// Set the mutation to the builder.
*mutation = *mutationT
return exec(ctx)
})
for i := len(hooks) - 1; i >= 0; i-- {
if hooks[i] == nil {
return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
}
mut = hooks[i](mut)
}
v, err := mut.Mutate(ctx, mutation)
if err != nil {
return value, err
}
nv, ok := v.(V)
if !ok {
return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation)
}
return nv, nil
}
// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist.
func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context {
if ent.QueryFromContext(ctx) == nil {
qc.Op = op
ctx = ent.NewQueryContext(ctx, qc)
}
return ctx
}
func querierAll[V Value, Q interface {
sqlAll(context.Context, ...queryHook) (V, error)
}]() Querier {
return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
query, ok := q.(Q)
if !ok {
return nil, fmt.Errorf("unexpected query type %T", q)
}
return query.sqlAll(ctx)
})
}
func querierCount[Q interface {
sqlCount(context.Context) (int, error)
}]() Querier {
return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
query, ok := q.(Q)
if !ok {
return nil, fmt.Errorf("unexpected query type %T", q)
}
return query.sqlCount(ctx)
})
}
func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) {
for i := len(inters) - 1; i >= 0; i-- {
qr = inters[i].Intercept(qr)
}
rv, err := qr.Query(ctx, q)
if err != nil {
return v, err
}
vt, ok := rv.(V)
if !ok {
return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v)
}
return vt, nil
}
func scanWithInterceptors[Q1 ent.Query, Q2 interface {
sqlScan(context.Context, Q1, any) error
}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error {
rv := reflect.ValueOf(v)
var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
query, ok := q.(Q1)
if !ok {
return nil, fmt.Errorf("unexpected query type %T", q)
}
if err := selectOrGroup.sqlScan(ctx, query, v); err != nil {
return nil, err
}
if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() {
return rv.Elem().Interface(), nil
}
return v, nil
})
for i := len(inters) - 1; i >= 0; i-- {
qr = inters[i].Intercept(qr)
}
vv, err := qr.Query(ctx, rootQuery)
if err != nil {
return err
}
switch rv2 := reflect.ValueOf(vv); {
case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer:
case rv.Type() == rv2.Type():
rv.Elem().Set(rv2.Elem())
case rv.Elem().Type() == rv2.Type():
rv.Elem().Set(rv2)
}
return nil
}
// queryHook describes an internal hook for the different sqlAll methods.
type queryHook func(context.Context, *sqlgraph.QuerySpec)

View File

@@ -1,756 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"schisandra-album-cloud-microservices/common/ent/predicate"
"schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule"
"schisandra-album-cloud-microservices/common/ent/scaauthrole"
"schisandra-album-cloud-microservices/common/ent/scaauthuser"
"schisandra-album-cloud-microservices/common/ent/scaauthuserdevice"
"schisandra-album-cloud-microservices/common/ent/scaauthusersocial"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/entql"
"entgo.io/ent/schema/field"
)
// schemaGraph holds a representation of ent/schema at runtime.
var schemaGraph = func() *sqlgraph.Schema {
graph := &sqlgraph.Schema{Nodes: make([]*sqlgraph.Node, 5)}
graph.Nodes[0] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: scaauthpermissionrule.Table,
Columns: scaauthpermissionrule.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt64,
Column: scaauthpermissionrule.FieldID,
},
},
Type: "ScaAuthPermissionRule",
Fields: map[string]*sqlgraph.FieldSpec{
scaauthpermissionrule.FieldPtype: {Type: field.TypeString, Column: scaauthpermissionrule.FieldPtype},
scaauthpermissionrule.FieldV0: {Type: field.TypeString, Column: scaauthpermissionrule.FieldV0},
scaauthpermissionrule.FieldV1: {Type: field.TypeString, Column: scaauthpermissionrule.FieldV1},
scaauthpermissionrule.FieldV2: {Type: field.TypeString, Column: scaauthpermissionrule.FieldV2},
scaauthpermissionrule.FieldV3: {Type: field.TypeString, Column: scaauthpermissionrule.FieldV3},
scaauthpermissionrule.FieldV4: {Type: field.TypeString, Column: scaauthpermissionrule.FieldV4},
scaauthpermissionrule.FieldV5: {Type: field.TypeString, Column: scaauthpermissionrule.FieldV5},
},
}
graph.Nodes[1] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: scaauthrole.Table,
Columns: scaauthrole.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt64,
Column: scaauthrole.FieldID,
},
},
Type: "ScaAuthRole",
Fields: map[string]*sqlgraph.FieldSpec{
scaauthrole.FieldCreatedAt: {Type: field.TypeTime, Column: scaauthrole.FieldCreatedAt},
scaauthrole.FieldUpdatedAt: {Type: field.TypeTime, Column: scaauthrole.FieldUpdatedAt},
scaauthrole.FieldDeleted: {Type: field.TypeInt8, Column: scaauthrole.FieldDeleted},
scaauthrole.FieldRoleName: {Type: field.TypeString, Column: scaauthrole.FieldRoleName},
scaauthrole.FieldRoleKey: {Type: field.TypeString, Column: scaauthrole.FieldRoleKey},
},
}
graph.Nodes[2] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: scaauthuser.Table,
Columns: scaauthuser.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt64,
Column: scaauthuser.FieldID,
},
},
Type: "ScaAuthUser",
Fields: map[string]*sqlgraph.FieldSpec{
scaauthuser.FieldCreatedAt: {Type: field.TypeTime, Column: scaauthuser.FieldCreatedAt},
scaauthuser.FieldUpdatedAt: {Type: field.TypeTime, Column: scaauthuser.FieldUpdatedAt},
scaauthuser.FieldDeleted: {Type: field.TypeInt8, Column: scaauthuser.FieldDeleted},
scaauthuser.FieldUID: {Type: field.TypeString, Column: scaauthuser.FieldUID},
scaauthuser.FieldUsername: {Type: field.TypeString, Column: scaauthuser.FieldUsername},
scaauthuser.FieldNickname: {Type: field.TypeString, Column: scaauthuser.FieldNickname},
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.FieldAvatar: {Type: field.TypeString, Column: scaauthuser.FieldAvatar},
scaauthuser.FieldStatus: {Type: field.TypeInt8, Column: scaauthuser.FieldStatus},
scaauthuser.FieldIntroduce: {Type: field.TypeString, Column: scaauthuser.FieldIntroduce},
scaauthuser.FieldBlog: {Type: field.TypeString, Column: scaauthuser.FieldBlog},
scaauthuser.FieldLocation: {Type: field.TypeString, Column: scaauthuser.FieldLocation},
scaauthuser.FieldCompany: {Type: field.TypeString, Column: scaauthuser.FieldCompany},
},
}
graph.Nodes[3] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: scaauthuserdevice.Table,
Columns: scaauthuserdevice.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt64,
Column: scaauthuserdevice.FieldID,
},
},
Type: "ScaAuthUserDevice",
Fields: map[string]*sqlgraph.FieldSpec{
scaauthuserdevice.FieldCreatedAt: {Type: field.TypeTime, Column: scaauthuserdevice.FieldCreatedAt},
scaauthuserdevice.FieldUpdatedAt: {Type: field.TypeTime, Column: scaauthuserdevice.FieldUpdatedAt},
scaauthuserdevice.FieldDeleted: {Type: field.TypeInt8, Column: scaauthuserdevice.FieldDeleted},
scaauthuserdevice.FieldUserID: {Type: field.TypeString, Column: scaauthuserdevice.FieldUserID},
scaauthuserdevice.FieldIP: {Type: field.TypeString, Column: scaauthuserdevice.FieldIP},
scaauthuserdevice.FieldLocation: {Type: field.TypeString, Column: scaauthuserdevice.FieldLocation},
scaauthuserdevice.FieldAgent: {Type: field.TypeString, Column: scaauthuserdevice.FieldAgent},
scaauthuserdevice.FieldBrowser: {Type: field.TypeString, Column: scaauthuserdevice.FieldBrowser},
scaauthuserdevice.FieldOperatingSystem: {Type: field.TypeString, Column: scaauthuserdevice.FieldOperatingSystem},
scaauthuserdevice.FieldBrowserVersion: {Type: field.TypeString, Column: scaauthuserdevice.FieldBrowserVersion},
scaauthuserdevice.FieldMobile: {Type: field.TypeInt, Column: scaauthuserdevice.FieldMobile},
scaauthuserdevice.FieldBot: {Type: field.TypeInt, Column: scaauthuserdevice.FieldBot},
scaauthuserdevice.FieldMozilla: {Type: field.TypeString, Column: scaauthuserdevice.FieldMozilla},
scaauthuserdevice.FieldPlatform: {Type: field.TypeString, Column: scaauthuserdevice.FieldPlatform},
scaauthuserdevice.FieldEngineName: {Type: field.TypeString, Column: scaauthuserdevice.FieldEngineName},
scaauthuserdevice.FieldEngineVersion: {Type: field.TypeString, Column: scaauthuserdevice.FieldEngineVersion},
},
}
graph.Nodes[4] = &sqlgraph.Node{
NodeSpec: sqlgraph.NodeSpec{
Table: scaauthusersocial.Table,
Columns: scaauthusersocial.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt64,
Column: scaauthusersocial.FieldID,
},
},
Type: "ScaAuthUserSocial",
Fields: map[string]*sqlgraph.FieldSpec{
scaauthusersocial.FieldCreatedAt: {Type: field.TypeTime, Column: scaauthusersocial.FieldCreatedAt},
scaauthusersocial.FieldUpdatedAt: {Type: field.TypeTime, Column: scaauthusersocial.FieldUpdatedAt},
scaauthusersocial.FieldDeleted: {Type: field.TypeInt8, Column: scaauthusersocial.FieldDeleted},
scaauthusersocial.FieldUserID: {Type: field.TypeString, Column: scaauthusersocial.FieldUserID},
scaauthusersocial.FieldOpenID: {Type: field.TypeString, Column: scaauthusersocial.FieldOpenID},
scaauthusersocial.FieldSource: {Type: field.TypeString, Column: scaauthusersocial.FieldSource},
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
}()
// predicateAdder wraps the addPredicate method.
// All update, update-one and query builders implement this interface.
type predicateAdder interface {
addPredicate(func(s *sql.Selector))
}
// addPredicate implements the predicateAdder interface.
func (saprq *ScaAuthPermissionRuleQuery) addPredicate(pred func(s *sql.Selector)) {
saprq.predicates = append(saprq.predicates, pred)
}
// Filter returns a Filter implementation to apply filters on the ScaAuthPermissionRuleQuery builder.
func (saprq *ScaAuthPermissionRuleQuery) Filter() *ScaAuthPermissionRuleFilter {
return &ScaAuthPermissionRuleFilter{config: saprq.config, predicateAdder: saprq}
}
// addPredicate implements the predicateAdder interface.
func (m *ScaAuthPermissionRuleMutation) addPredicate(pred func(s *sql.Selector)) {
m.predicates = append(m.predicates, pred)
}
// Filter returns an entql.Where implementation to apply filters on the ScaAuthPermissionRuleMutation builder.
func (m *ScaAuthPermissionRuleMutation) Filter() *ScaAuthPermissionRuleFilter {
return &ScaAuthPermissionRuleFilter{config: m.config, predicateAdder: m}
}
// ScaAuthPermissionRuleFilter provides a generic filtering capability at runtime for ScaAuthPermissionRuleQuery.
type ScaAuthPermissionRuleFilter struct {
predicateAdder
config
}
// Where applies the entql predicate on the query filter.
func (f *ScaAuthPermissionRuleFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[0].Type, p, s); err != nil {
s.AddError(err)
}
})
}
// WhereID applies the entql int64 predicate on the id field.
func (f *ScaAuthPermissionRuleFilter) WhereID(p entql.Int64P) {
f.Where(p.Field(scaauthpermissionrule.FieldID))
}
// WherePtype applies the entql string predicate on the ptype field.
func (f *ScaAuthPermissionRuleFilter) WherePtype(p entql.StringP) {
f.Where(p.Field(scaauthpermissionrule.FieldPtype))
}
// WhereV0 applies the entql string predicate on the v0 field.
func (f *ScaAuthPermissionRuleFilter) WhereV0(p entql.StringP) {
f.Where(p.Field(scaauthpermissionrule.FieldV0))
}
// WhereV1 applies the entql string predicate on the v1 field.
func (f *ScaAuthPermissionRuleFilter) WhereV1(p entql.StringP) {
f.Where(p.Field(scaauthpermissionrule.FieldV1))
}
// WhereV2 applies the entql string predicate on the v2 field.
func (f *ScaAuthPermissionRuleFilter) WhereV2(p entql.StringP) {
f.Where(p.Field(scaauthpermissionrule.FieldV2))
}
// WhereV3 applies the entql string predicate on the v3 field.
func (f *ScaAuthPermissionRuleFilter) WhereV3(p entql.StringP) {
f.Where(p.Field(scaauthpermissionrule.FieldV3))
}
// WhereV4 applies the entql string predicate on the v4 field.
func (f *ScaAuthPermissionRuleFilter) WhereV4(p entql.StringP) {
f.Where(p.Field(scaauthpermissionrule.FieldV4))
}
// WhereV5 applies the entql string predicate on the v5 field.
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)
}
// Filter returns a Filter implementation to apply filters on the ScaAuthRoleQuery builder.
func (sarq *ScaAuthRoleQuery) Filter() *ScaAuthRoleFilter {
return &ScaAuthRoleFilter{config: sarq.config, predicateAdder: sarq}
}
// addPredicate implements the predicateAdder interface.
func (m *ScaAuthRoleMutation) addPredicate(pred func(s *sql.Selector)) {
m.predicates = append(m.predicates, pred)
}
// Filter returns an entql.Where implementation to apply filters on the ScaAuthRoleMutation builder.
func (m *ScaAuthRoleMutation) Filter() *ScaAuthRoleFilter {
return &ScaAuthRoleFilter{config: m.config, predicateAdder: m}
}
// ScaAuthRoleFilter provides a generic filtering capability at runtime for ScaAuthRoleQuery.
type ScaAuthRoleFilter struct {
predicateAdder
config
}
// Where applies the entql predicate on the query filter.
func (f *ScaAuthRoleFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[1].Type, p, s); err != nil {
s.AddError(err)
}
})
}
// WhereID applies the entql int64 predicate on the id field.
func (f *ScaAuthRoleFilter) WhereID(p entql.Int64P) {
f.Where(p.Field(scaauthrole.FieldID))
}
// WhereCreatedAt applies the entql time.Time predicate on the created_at field.
func (f *ScaAuthRoleFilter) WhereCreatedAt(p entql.TimeP) {
f.Where(p.Field(scaauthrole.FieldCreatedAt))
}
// WhereUpdatedAt applies the entql time.Time predicate on the updated_at field.
func (f *ScaAuthRoleFilter) WhereUpdatedAt(p entql.TimeP) {
f.Where(p.Field(scaauthrole.FieldUpdatedAt))
}
// WhereDeleted applies the entql int8 predicate on the deleted field.
func (f *ScaAuthRoleFilter) WhereDeleted(p entql.Int8P) {
f.Where(p.Field(scaauthrole.FieldDeleted))
}
// WhereRoleName applies the entql string predicate on the role_name field.
func (f *ScaAuthRoleFilter) WhereRoleName(p entql.StringP) {
f.Where(p.Field(scaauthrole.FieldRoleName))
}
// WhereRoleKey applies the entql string predicate on the role_key field.
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)
}
// Filter returns a Filter implementation to apply filters on the ScaAuthUserQuery builder.
func (sauq *ScaAuthUserQuery) Filter() *ScaAuthUserFilter {
return &ScaAuthUserFilter{config: sauq.config, predicateAdder: sauq}
}
// addPredicate implements the predicateAdder interface.
func (m *ScaAuthUserMutation) addPredicate(pred func(s *sql.Selector)) {
m.predicates = append(m.predicates, pred)
}
// Filter returns an entql.Where implementation to apply filters on the ScaAuthUserMutation builder.
func (m *ScaAuthUserMutation) Filter() *ScaAuthUserFilter {
return &ScaAuthUserFilter{config: m.config, predicateAdder: m}
}
// ScaAuthUserFilter provides a generic filtering capability at runtime for ScaAuthUserQuery.
type ScaAuthUserFilter struct {
predicateAdder
config
}
// Where applies the entql predicate on the query filter.
func (f *ScaAuthUserFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[2].Type, p, s); err != nil {
s.AddError(err)
}
})
}
// WhereID applies the entql int64 predicate on the id field.
func (f *ScaAuthUserFilter) WhereID(p entql.Int64P) {
f.Where(p.Field(scaauthuser.FieldID))
}
// WhereCreatedAt applies the entql time.Time predicate on the created_at field.
func (f *ScaAuthUserFilter) WhereCreatedAt(p entql.TimeP) {
f.Where(p.Field(scaauthuser.FieldCreatedAt))
}
// WhereUpdatedAt applies the entql time.Time predicate on the updated_at field.
func (f *ScaAuthUserFilter) WhereUpdatedAt(p entql.TimeP) {
f.Where(p.Field(scaauthuser.FieldUpdatedAt))
}
// WhereDeleted applies the entql int8 predicate on the deleted field.
func (f *ScaAuthUserFilter) WhereDeleted(p entql.Int8P) {
f.Where(p.Field(scaauthuser.FieldDeleted))
}
// WhereUID applies the entql string predicate on the uid field.
func (f *ScaAuthUserFilter) WhereUID(p entql.StringP) {
f.Where(p.Field(scaauthuser.FieldUID))
}
// WhereUsername applies the entql string predicate on the username field.
func (f *ScaAuthUserFilter) WhereUsername(p entql.StringP) {
f.Where(p.Field(scaauthuser.FieldUsername))
}
// WhereNickname applies the entql string predicate on the nickname field.
func (f *ScaAuthUserFilter) WhereNickname(p entql.StringP) {
f.Where(p.Field(scaauthuser.FieldNickname))
}
// WhereEmail applies the entql string predicate on the email field.
func (f *ScaAuthUserFilter) WhereEmail(p entql.StringP) {
f.Where(p.Field(scaauthuser.FieldEmail))
}
// WherePhone applies the entql string predicate on the phone field.
func (f *ScaAuthUserFilter) WherePhone(p entql.StringP) {
f.Where(p.Field(scaauthuser.FieldPhone))
}
// WherePassword applies the entql string predicate on the password field.
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) {
f.Where(p.Field(scaauthuser.FieldGender))
}
// WhereAvatar applies the entql string predicate on the avatar field.
func (f *ScaAuthUserFilter) WhereAvatar(p entql.StringP) {
f.Where(p.Field(scaauthuser.FieldAvatar))
}
// WhereStatus applies the entql int8 predicate on the status field.
func (f *ScaAuthUserFilter) WhereStatus(p entql.Int8P) {
f.Where(p.Field(scaauthuser.FieldStatus))
}
// WhereIntroduce applies the entql string predicate on the introduce field.
func (f *ScaAuthUserFilter) WhereIntroduce(p entql.StringP) {
f.Where(p.Field(scaauthuser.FieldIntroduce))
}
// WhereBlog applies the entql string predicate on the blog field.
func (f *ScaAuthUserFilter) WhereBlog(p entql.StringP) {
f.Where(p.Field(scaauthuser.FieldBlog))
}
// WhereLocation applies the entql string predicate on the location field.
func (f *ScaAuthUserFilter) WhereLocation(p entql.StringP) {
f.Where(p.Field(scaauthuser.FieldLocation))
}
// WhereCompany applies the entql string predicate on the company field.
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)
}
// Filter returns a Filter implementation to apply filters on the ScaAuthUserDeviceQuery builder.
func (saudq *ScaAuthUserDeviceQuery) Filter() *ScaAuthUserDeviceFilter {
return &ScaAuthUserDeviceFilter{config: saudq.config, predicateAdder: saudq}
}
// addPredicate implements the predicateAdder interface.
func (m *ScaAuthUserDeviceMutation) addPredicate(pred func(s *sql.Selector)) {
m.predicates = append(m.predicates, pred)
}
// Filter returns an entql.Where implementation to apply filters on the ScaAuthUserDeviceMutation builder.
func (m *ScaAuthUserDeviceMutation) Filter() *ScaAuthUserDeviceFilter {
return &ScaAuthUserDeviceFilter{config: m.config, predicateAdder: m}
}
// ScaAuthUserDeviceFilter provides a generic filtering capability at runtime for ScaAuthUserDeviceQuery.
type ScaAuthUserDeviceFilter struct {
predicateAdder
config
}
// Where applies the entql predicate on the query filter.
func (f *ScaAuthUserDeviceFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[3].Type, p, s); err != nil {
s.AddError(err)
}
})
}
// WhereID applies the entql int64 predicate on the id field.
func (f *ScaAuthUserDeviceFilter) WhereID(p entql.Int64P) {
f.Where(p.Field(scaauthuserdevice.FieldID))
}
// WhereCreatedAt applies the entql time.Time predicate on the created_at field.
func (f *ScaAuthUserDeviceFilter) WhereCreatedAt(p entql.TimeP) {
f.Where(p.Field(scaauthuserdevice.FieldCreatedAt))
}
// WhereUpdatedAt applies the entql time.Time predicate on the updated_at field.
func (f *ScaAuthUserDeviceFilter) WhereUpdatedAt(p entql.TimeP) {
f.Where(p.Field(scaauthuserdevice.FieldUpdatedAt))
}
// WhereDeleted applies the entql int8 predicate on the deleted field.
func (f *ScaAuthUserDeviceFilter) WhereDeleted(p entql.Int8P) {
f.Where(p.Field(scaauthuserdevice.FieldDeleted))
}
// WhereUserID applies the entql string predicate on the user_id field.
func (f *ScaAuthUserDeviceFilter) WhereUserID(p entql.StringP) {
f.Where(p.Field(scaauthuserdevice.FieldUserID))
}
// WhereIP applies the entql string predicate on the ip field.
func (f *ScaAuthUserDeviceFilter) WhereIP(p entql.StringP) {
f.Where(p.Field(scaauthuserdevice.FieldIP))
}
// WhereLocation applies the entql string predicate on the location field.
func (f *ScaAuthUserDeviceFilter) WhereLocation(p entql.StringP) {
f.Where(p.Field(scaauthuserdevice.FieldLocation))
}
// WhereAgent applies the entql string predicate on the agent field.
func (f *ScaAuthUserDeviceFilter) WhereAgent(p entql.StringP) {
f.Where(p.Field(scaauthuserdevice.FieldAgent))
}
// WhereBrowser applies the entql string predicate on the browser field.
func (f *ScaAuthUserDeviceFilter) WhereBrowser(p entql.StringP) {
f.Where(p.Field(scaauthuserdevice.FieldBrowser))
}
// WhereOperatingSystem applies the entql string predicate on the operating_system field.
func (f *ScaAuthUserDeviceFilter) WhereOperatingSystem(p entql.StringP) {
f.Where(p.Field(scaauthuserdevice.FieldOperatingSystem))
}
// WhereBrowserVersion applies the entql string predicate on the browser_version field.
func (f *ScaAuthUserDeviceFilter) WhereBrowserVersion(p entql.StringP) {
f.Where(p.Field(scaauthuserdevice.FieldBrowserVersion))
}
// WhereMobile applies the entql int predicate on the mobile field.
func (f *ScaAuthUserDeviceFilter) WhereMobile(p entql.IntP) {
f.Where(p.Field(scaauthuserdevice.FieldMobile))
}
// WhereBot applies the entql int predicate on the bot field.
func (f *ScaAuthUserDeviceFilter) WhereBot(p entql.IntP) {
f.Where(p.Field(scaauthuserdevice.FieldBot))
}
// WhereMozilla applies the entql string predicate on the mozilla field.
func (f *ScaAuthUserDeviceFilter) WhereMozilla(p entql.StringP) {
f.Where(p.Field(scaauthuserdevice.FieldMozilla))
}
// WherePlatform applies the entql string predicate on the platform field.
func (f *ScaAuthUserDeviceFilter) WherePlatform(p entql.StringP) {
f.Where(p.Field(scaauthuserdevice.FieldPlatform))
}
// WhereEngineName applies the entql string predicate on the engine_name field.
func (f *ScaAuthUserDeviceFilter) WhereEngineName(p entql.StringP) {
f.Where(p.Field(scaauthuserdevice.FieldEngineName))
}
// WhereEngineVersion applies the entql string predicate on the engine_version field.
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)
}
// Filter returns a Filter implementation to apply filters on the ScaAuthUserSocialQuery builder.
func (sausq *ScaAuthUserSocialQuery) Filter() *ScaAuthUserSocialFilter {
return &ScaAuthUserSocialFilter{config: sausq.config, predicateAdder: sausq}
}
// addPredicate implements the predicateAdder interface.
func (m *ScaAuthUserSocialMutation) addPredicate(pred func(s *sql.Selector)) {
m.predicates = append(m.predicates, pred)
}
// Filter returns an entql.Where implementation to apply filters on the ScaAuthUserSocialMutation builder.
func (m *ScaAuthUserSocialMutation) Filter() *ScaAuthUserSocialFilter {
return &ScaAuthUserSocialFilter{config: m.config, predicateAdder: m}
}
// ScaAuthUserSocialFilter provides a generic filtering capability at runtime for ScaAuthUserSocialQuery.
type ScaAuthUserSocialFilter struct {
predicateAdder
config
}
// Where applies the entql predicate on the query filter.
func (f *ScaAuthUserSocialFilter) Where(p entql.P) {
f.addPredicate(func(s *sql.Selector) {
if err := schemaGraph.EvalP(schemaGraph.Nodes[4].Type, p, s); err != nil {
s.AddError(err)
}
})
}
// WhereID applies the entql int64 predicate on the id field.
func (f *ScaAuthUserSocialFilter) WhereID(p entql.Int64P) {
f.Where(p.Field(scaauthusersocial.FieldID))
}
// WhereCreatedAt applies the entql time.Time predicate on the created_at field.
func (f *ScaAuthUserSocialFilter) WhereCreatedAt(p entql.TimeP) {
f.Where(p.Field(scaauthusersocial.FieldCreatedAt))
}
// WhereUpdatedAt applies the entql time.Time predicate on the updated_at field.
func (f *ScaAuthUserSocialFilter) WhereUpdatedAt(p entql.TimeP) {
f.Where(p.Field(scaauthusersocial.FieldUpdatedAt))
}
// WhereDeleted applies the entql int8 predicate on the deleted field.
func (f *ScaAuthUserSocialFilter) WhereDeleted(p entql.Int8P) {
f.Where(p.Field(scaauthusersocial.FieldDeleted))
}
// WhereUserID applies the entql string predicate on the user_id field.
func (f *ScaAuthUserSocialFilter) WhereUserID(p entql.StringP) {
f.Where(p.Field(scaauthusersocial.FieldUserID))
}
// WhereOpenID applies the entql string predicate on the open_id field.
func (f *ScaAuthUserSocialFilter) WhereOpenID(p entql.StringP) {
f.Where(p.Field(scaauthusersocial.FieldOpenID))
}
// WhereSource applies the entql string predicate on the source field.
func (f *ScaAuthUserSocialFilter) WhereSource(p entql.StringP) {
f.Where(p.Field(scaauthusersocial.FieldSource))
}
// WhereStatus applies the entql int predicate on the status field.
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)
}
})))
}

View File

@@ -1,85 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package enttest
import (
"context"
"schisandra-album-cloud-microservices/common/ent"
// required by schema hooks.
_ "schisandra-album-cloud-microservices/common/ent/runtime"
"schisandra-album-cloud-microservices/common/ent/migrate"
"entgo.io/ent/dialect/sql/schema"
)
type (
// TestingT is the interface that is shared between
// testing.T and testing.B and used by enttest.
TestingT interface {
FailNow()
Error(...any)
}
// Option configures client creation.
Option func(*options)
options struct {
opts []ent.Option
migrateOpts []schema.MigrateOption
}
)
// WithOptions forwards options to client creation.
func WithOptions(opts ...ent.Option) Option {
return func(o *options) {
o.opts = append(o.opts, opts...)
}
}
// WithMigrateOptions forwards options to auto migration.
func WithMigrateOptions(opts ...schema.MigrateOption) Option {
return func(o *options) {
o.migrateOpts = append(o.migrateOpts, opts...)
}
}
func newOptions(opts []Option) *options {
o := &options{}
for _, opt := range opts {
opt(o)
}
return o
}
// Open calls ent.Open and auto-run migration.
func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client {
o := newOptions(opts)
c, err := ent.Open(driverName, dataSourceName, o.opts...)
if err != nil {
t.Error(err)
t.FailNow()
}
migrateSchema(t, c, o)
return c
}
// NewClient calls ent.NewClient and auto-run migration.
func NewClient(t TestingT, opts ...Option) *ent.Client {
o := newOptions(opts)
c := ent.NewClient(o.opts...)
migrateSchema(t, c, o)
return c
}
func migrateSchema(t TestingT, c *ent.Client, o *options) {
tables, err := schema.CopyTables(migrate.Tables)
if err != nil {
t.Error(err)
t.FailNow()
}
if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil {
t.Error(err)
t.FailNow()
}
}

View File

@@ -1,3 +0,0 @@
package ent
//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate --feature privacy,entql ./schema

View File

@@ -1,246 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package hook
import (
"context"
"fmt"
"schisandra-album-cloud-microservices/common/ent"
)
// The ScaAuthPermissionRuleFunc type is an adapter to allow the use of ordinary
// function as ScaAuthPermissionRule mutator.
type ScaAuthPermissionRuleFunc func(context.Context, *ent.ScaAuthPermissionRuleMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ScaAuthPermissionRuleFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ScaAuthPermissionRuleMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaAuthPermissionRuleMutation", m)
}
// The ScaAuthRoleFunc type is an adapter to allow the use of ordinary
// function as ScaAuthRole mutator.
type ScaAuthRoleFunc func(context.Context, *ent.ScaAuthRoleMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ScaAuthRoleFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ScaAuthRoleMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaAuthRoleMutation", m)
}
// The ScaAuthUserFunc type is an adapter to allow the use of ordinary
// function as ScaAuthUser mutator.
type ScaAuthUserFunc func(context.Context, *ent.ScaAuthUserMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ScaAuthUserFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ScaAuthUserMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaAuthUserMutation", m)
}
// The ScaAuthUserDeviceFunc type is an adapter to allow the use of ordinary
// function as ScaAuthUserDevice mutator.
type ScaAuthUserDeviceFunc func(context.Context, *ent.ScaAuthUserDeviceMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ScaAuthUserDeviceFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ScaAuthUserDeviceMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaAuthUserDeviceMutation", m)
}
// The ScaAuthUserSocialFunc type is an adapter to allow the use of ordinary
// function as ScaAuthUserSocial mutator.
type ScaAuthUserSocialFunc func(context.Context, *ent.ScaAuthUserSocialMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ScaAuthUserSocialFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ScaAuthUserSocialMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ScaAuthUserSocialMutation", m)
}
// Condition is a hook condition function.
type Condition func(context.Context, ent.Mutation) bool
// And groups conditions with the AND operator.
func And(first, second Condition, rest ...Condition) Condition {
return func(ctx context.Context, m ent.Mutation) bool {
if !first(ctx, m) || !second(ctx, m) {
return false
}
for _, cond := range rest {
if !cond(ctx, m) {
return false
}
}
return true
}
}
// Or groups conditions with the OR operator.
func Or(first, second Condition, rest ...Condition) Condition {
return func(ctx context.Context, m ent.Mutation) bool {
if first(ctx, m) || second(ctx, m) {
return true
}
for _, cond := range rest {
if cond(ctx, m) {
return true
}
}
return false
}
}
// Not negates a given condition.
func Not(cond Condition) Condition {
return func(ctx context.Context, m ent.Mutation) bool {
return !cond(ctx, m)
}
}
// HasOp is a condition testing mutation operation.
func HasOp(op ent.Op) Condition {
return func(_ context.Context, m ent.Mutation) bool {
return m.Op().Is(op)
}
}
// HasAddedFields is a condition validating `.AddedField` on fields.
func HasAddedFields(field string, fields ...string) Condition {
return func(_ context.Context, m ent.Mutation) bool {
if _, exists := m.AddedField(field); !exists {
return false
}
for _, field := range fields {
if _, exists := m.AddedField(field); !exists {
return false
}
}
return true
}
}
// HasClearedFields is a condition validating `.FieldCleared` on fields.
func HasClearedFields(field string, fields ...string) Condition {
return func(_ context.Context, m ent.Mutation) bool {
if exists := m.FieldCleared(field); !exists {
return false
}
for _, field := range fields {
if exists := m.FieldCleared(field); !exists {
return false
}
}
return true
}
}
// HasFields is a condition validating `.Field` on fields.
func HasFields(field string, fields ...string) Condition {
return func(_ context.Context, m ent.Mutation) bool {
if _, exists := m.Field(field); !exists {
return false
}
for _, field := range fields {
if _, exists := m.Field(field); !exists {
return false
}
}
return true
}
}
// If executes the given hook under condition.
//
// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))
func If(hk ent.Hook, cond Condition) ent.Hook {
return func(next ent.Mutator) ent.Mutator {
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if cond(ctx, m) {
return hk(next).Mutate(ctx, m)
}
return next.Mutate(ctx, m)
})
}
}
// On executes the given hook only for the given operation.
//
// hook.On(Log, ent.Delete|ent.Create)
func On(hk ent.Hook, op ent.Op) ent.Hook {
return If(hk, HasOp(op))
}
// Unless skips the given hook only for the given operation.
//
// hook.Unless(Log, ent.Update|ent.UpdateOne)
func Unless(hk ent.Hook, op ent.Op) ent.Hook {
return If(hk, Not(HasOp(op)))
}
// FixedError is a hook returning a fixed error.
func FixedError(err error) ent.Hook {
return func(ent.Mutator) ent.Mutator {
return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) {
return nil, err
})
}
}
// Reject returns a hook that rejects all operations that match op.
//
// func (T) Hooks() []ent.Hook {
// return []ent.Hook{
// Reject(ent.Delete|ent.Update),
// }
// }
func Reject(op ent.Op) ent.Hook {
hk := FixedError(fmt.Errorf("%s operation is not allowed", op))
return On(hk, op)
}
// Chain acts as a list of hooks and is effectively immutable.
// Once created, it will always hold the same set of hooks in the same order.
type Chain struct {
hooks []ent.Hook
}
// NewChain creates a new chain of hooks.
func NewChain(hooks ...ent.Hook) Chain {
return Chain{append([]ent.Hook(nil), hooks...)}
}
// Hook chains the list of hooks and returns the final hook.
func (c Chain) Hook() ent.Hook {
return func(mutator ent.Mutator) ent.Mutator {
for i := len(c.hooks) - 1; i >= 0; i-- {
mutator = c.hooks[i](mutator)
}
return mutator
}
}
// Append extends a chain, adding the specified hook
// as the last ones in the mutation flow.
func (c Chain) Append(hooks ...ent.Hook) Chain {
newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks))
newHooks = append(newHooks, c.hooks...)
newHooks = append(newHooks, hooks...)
return Chain{newHooks}
}
// Extend extends a chain, adding the specified chain
// as the last ones in the mutation flow.
func (c Chain) Extend(chain Chain) Chain {
return c.Append(chain.hooks...)
}

View File

@@ -1,64 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package migrate
import (
"context"
"fmt"
"io"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql/schema"
)
var (
// WithGlobalUniqueID sets the universal ids options to the migration.
// If this option is enabled, ent migration will allocate a 1<<32 range
// for the ids of each entity (table).
// Note that this option cannot be applied on tables that already exist.
WithGlobalUniqueID = schema.WithGlobalUniqueID
// WithDropColumn sets the drop column option to the migration.
// If this option is enabled, ent migration will drop old columns
// that were used for both fields and edges. This defaults to false.
WithDropColumn = schema.WithDropColumn
// WithDropIndex sets the drop index option to the migration.
// If this option is enabled, ent migration will drop old indexes
// that were defined in the schema. This defaults to false.
// Note that unique constraints are defined using `UNIQUE INDEX`,
// and therefore, it's recommended to enable this option to get more
// flexibility in the schema changes.
WithDropIndex = schema.WithDropIndex
// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
WithForeignKeys = schema.WithForeignKeys
)
// Schema is the API for creating, migrating and dropping a schema.
type Schema struct {
drv dialect.Driver
}
// NewSchema creates a new schema client.
func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
// Create creates all schema resources.
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
return Create(ctx, s, Tables, opts...)
}
// Create creates all table resources using the given schema driver.
func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error {
migrate, err := schema.NewMigrate(s.drv, opts...)
if err != nil {
return fmt.Errorf("ent/migrate: %w", err)
}
return migrate.Create(ctx, tables...)
}
// WriteTo writes the schema changes to w instead of running them against the database.
//
// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
// log.Fatal(err)
// }
func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error {
return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...)
}

View File

@@ -1,215 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package migrate
import (
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/dialect/sql/schema"
"entgo.io/ent/schema/field"
)
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: "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{
Name: "sca_auth_permission_rule",
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{
{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "主键ID", SchemaType: map[string]string{"mysql": "bigint(20)"}},
{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
{Name: "deleted", Type: field.TypeInt8, Nullable: true, Comment: "是否删除 0 未删除 1 已删除", Default: 0},
{Name: "role_name", Type: field.TypeString, Size: 32, Comment: "角色名称"},
{Name: "role_key", Type: field.TypeString, Size: 64, Comment: "角色关键字"},
}
// ScaAuthRoleTable holds the schema information for the "sca_auth_role" table.
ScaAuthRoleTable = &schema.Table{
Name: "sca_auth_role",
Comment: "角色表",
Columns: ScaAuthRoleColumns,
PrimaryKey: []*schema.Column{ScaAuthRoleColumns[0]},
}
// ScaAuthUserColumns holds the columns for the "sca_auth_user" table.
ScaAuthUserColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "自增ID", SchemaType: map[string]string{"mysql": "bigint(20)"}},
{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
{Name: "deleted", Type: field.TypeInt8, Nullable: true, Comment: "是否删除 0 未删除 1 已删除", Default: 0},
{Name: "uid", Type: field.TypeString, Unique: true, Size: 20, Comment: "唯一ID"},
{Name: "username", Type: field.TypeString, Nullable: true, Size: 32, Comment: "用户名"},
{Name: "nickname", Type: field.TypeString, Nullable: true, Size: 32, Comment: "昵称"},
{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: "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: "介绍"},
{Name: "blog", Type: field.TypeString, Nullable: true, Size: 30, Comment: "博客"},
{Name: "location", Type: field.TypeString, Nullable: true, Size: 50, Comment: "地址"},
{Name: "company", Type: field.TypeString, Nullable: true, Size: 50, Comment: "公司"},
}
// ScaAuthUserTable holds the schema information for the "sca_auth_user" table.
ScaAuthUserTable = &schema.Table{
Name: "sca_auth_user",
Comment: "用户表",
Columns: ScaAuthUserColumns,
PrimaryKey: []*schema.Column{ScaAuthUserColumns[0]},
Indexes: []*schema.Index{
{
Name: "scaauthuser_id",
Unique: true,
Columns: []*schema.Column{ScaAuthUserColumns[0]},
},
{
Name: "scaauthuser_uid",
Unique: true,
Columns: []*schema.Column{ScaAuthUserColumns[4]},
},
{
Name: "scaauthuser_phone",
Unique: true,
Columns: []*schema.Column{ScaAuthUserColumns[8]},
},
},
}
// ScaAuthUserDeviceColumns holds the columns for the "sca_auth_user_device" table.
ScaAuthUserDeviceColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "主键ID", SchemaType: map[string]string{"mysql": "bigint(20)"}},
{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
{Name: "deleted", Type: field.TypeInt8, Nullable: true, Comment: "是否删除 0 未删除 1 已删除", Default: 0},
{Name: "user_id", Type: field.TypeString, Size: 20, Comment: "用户ID"},
{Name: "ip", Type: field.TypeString, Size: 20, Comment: "登录IP"},
{Name: "location", Type: field.TypeString, Size: 20, Comment: "地址"},
{Name: "agent", Type: field.TypeString, Size: 255, Comment: "设备信息"},
{Name: "browser", Type: field.TypeString, Size: 20, Comment: "浏览器"},
{Name: "operating_system", Type: field.TypeString, Size: 20, Comment: "操作系统"},
{Name: "browser_version", Type: field.TypeString, Size: 20, Comment: "浏览器版本"},
{Name: "mobile", Type: field.TypeInt, Comment: "是否为手机 0否1是"},
{Name: "bot", Type: field.TypeInt, Comment: "是否为bot 0否1是"},
{Name: "mozilla", Type: field.TypeString, Size: 10, Comment: "火狐版本"},
{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{
Name: "sca_auth_user_device",
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",
Unique: true,
Columns: []*schema.Column{ScaAuthUserDeviceColumns[0]},
},
},
}
// ScaAuthUserSocialColumns holds the columns for the "sca_auth_user_social" table.
ScaAuthUserSocialColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true, Comment: "主键ID", SchemaType: map[string]string{"mysql": "bigint(20)"}},
{Name: "created_at", Type: field.TypeTime, Comment: "创建时间"},
{Name: "updated_at", Type: field.TypeTime, Comment: "更新时间"},
{Name: "deleted", Type: field.TypeInt8, Nullable: true, Comment: "是否删除 0 未删除 1 已删除", Default: 0},
{Name: "user_id", Type: field.TypeString, Size: 20, Comment: "用户ID"},
{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{
Name: "sca_auth_user_social",
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",
Unique: true,
Columns: []*schema.Column{ScaAuthUserSocialColumns[0]},
},
{
Name: "scaauthusersocial_user_id",
Unique: true,
Columns: []*schema.Column{ScaAuthUserSocialColumns[4]},
},
{
Name: "scaauthusersocial_open_id",
Unique: true,
Columns: []*schema.Column{ScaAuthUserSocialColumns[5]},
},
},
}
// Tables holds all the tables in the schema.
Tables = []*schema.Table{
ScaAuthPermissionRuleTable,
ScaAuthRoleTable,
ScaAuthUserTable,
ScaAuthUserDeviceTable,
ScaAuthUserSocialTable,
}
)
func init() {
ScaAuthPermissionRuleTable.ForeignKeys[0].RefTable = ScaAuthRoleTable
ScaAuthPermissionRuleTable.Annotation = &entsql.Annotation{
Table: "sca_auth_permission_rule",
}
ScaAuthRoleTable.Annotation = &entsql.Annotation{
Table: "sca_auth_role",
}
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

View File

@@ -1,22 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package predicate
import (
"entgo.io/ent/dialect/sql"
)
// ScaAuthPermissionRule is the predicate function for scaauthpermissionrule builders.
type ScaAuthPermissionRule func(*sql.Selector)
// ScaAuthRole is the predicate function for scaauthrole builders.
type ScaAuthRole func(*sql.Selector)
// ScaAuthUser is the predicate function for scaauthuser builders.
type ScaAuthUser func(*sql.Selector)
// ScaAuthUserDevice is the predicate function for scaauthuserdevice builders.
type ScaAuthUserDevice func(*sql.Selector)
// ScaAuthUserSocial is the predicate function for scaauthusersocial builders.
type ScaAuthUserSocial func(*sql.Selector)

View File

@@ -1,299 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package privacy
import (
"context"
"schisandra-album-cloud-microservices/common/ent"
"entgo.io/ent/entql"
"entgo.io/ent/privacy"
)
var (
// Allow may be returned by rules to indicate that the policy
// evaluation should terminate with allow decision.
Allow = privacy.Allow
// Deny may be returned by rules to indicate that the policy
// evaluation should terminate with deny decision.
Deny = privacy.Deny
// Skip may be returned by rules to indicate that the policy
// evaluation should continue to the next rule.
Skip = privacy.Skip
)
// Allowf returns a formatted wrapped Allow decision.
func Allowf(format string, a ...any) error {
return privacy.Allowf(format, a...)
}
// Denyf returns a formatted wrapped Deny decision.
func Denyf(format string, a ...any) error {
return privacy.Denyf(format, a...)
}
// Skipf returns a formatted wrapped Skip decision.
func Skipf(format string, a ...any) error {
return privacy.Skipf(format, a...)
}
// DecisionContext creates a new context from the given parent context with
// a policy decision attach to it.
func DecisionContext(parent context.Context, decision error) context.Context {
return privacy.DecisionContext(parent, decision)
}
// DecisionFromContext retrieves the policy decision from the context.
func DecisionFromContext(ctx context.Context) (error, bool) {
return privacy.DecisionFromContext(ctx)
}
type (
// Policy groups query and mutation policies.
Policy = privacy.Policy
// QueryRule defines the interface deciding whether a
// query is allowed and optionally modify it.
QueryRule = privacy.QueryRule
// QueryPolicy combines multiple query rules into a single policy.
QueryPolicy = privacy.QueryPolicy
// MutationRule defines the interface which decides whether a
// mutation is allowed and optionally modifies it.
MutationRule = privacy.MutationRule
// MutationPolicy combines multiple mutation rules into a single policy.
MutationPolicy = privacy.MutationPolicy
// MutationRuleFunc type is an adapter which allows the use of
// ordinary functions as mutation rules.
MutationRuleFunc = privacy.MutationRuleFunc
// QueryMutationRule is an interface which groups query and mutation rules.
QueryMutationRule = privacy.QueryMutationRule
)
// QueryRuleFunc type is an adapter to allow the use of
// ordinary functions as query rules.
type QueryRuleFunc func(context.Context, ent.Query) error
// Eval returns f(ctx, q).
func (f QueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
return f(ctx, q)
}
// AlwaysAllowRule returns a rule that returns an allow decision.
func AlwaysAllowRule() QueryMutationRule {
return privacy.AlwaysAllowRule()
}
// AlwaysDenyRule returns a rule that returns a deny decision.
func AlwaysDenyRule() QueryMutationRule {
return privacy.AlwaysDenyRule()
}
// ContextQueryMutationRule creates a query/mutation rule from a context eval func.
func ContextQueryMutationRule(eval func(context.Context) error) QueryMutationRule {
return privacy.ContextQueryMutationRule(eval)
}
// OnMutationOperation evaluates the given rule only on a given mutation operation.
func OnMutationOperation(rule MutationRule, op ent.Op) MutationRule {
return privacy.OnMutationOperation(rule, op)
}
// DenyMutationOperationRule returns a rule denying specified mutation operation.
func DenyMutationOperationRule(op ent.Op) MutationRule {
rule := MutationRuleFunc(func(_ context.Context, m ent.Mutation) error {
return Denyf("ent/privacy: operation %s is not allowed", m.Op())
})
return OnMutationOperation(rule, op)
}
// The ScaAuthPermissionRuleQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type ScaAuthPermissionRuleQueryRuleFunc func(context.Context, *ent.ScaAuthPermissionRuleQuery) error
// EvalQuery return f(ctx, q).
func (f ScaAuthPermissionRuleQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.ScaAuthPermissionRuleQuery); ok {
return f(ctx, q)
}
return Denyf("ent/privacy: unexpected query type %T, expect *ent.ScaAuthPermissionRuleQuery", q)
}
// The ScaAuthPermissionRuleMutationRuleFunc type is an adapter to allow the use of ordinary
// functions as a mutation rule.
type ScaAuthPermissionRuleMutationRuleFunc func(context.Context, *ent.ScaAuthPermissionRuleMutation) error
// EvalMutation calls f(ctx, m).
func (f ScaAuthPermissionRuleMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
if m, ok := m.(*ent.ScaAuthPermissionRuleMutation); ok {
return f(ctx, m)
}
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ScaAuthPermissionRuleMutation", m)
}
// The ScaAuthRoleQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type ScaAuthRoleQueryRuleFunc func(context.Context, *ent.ScaAuthRoleQuery) error
// EvalQuery return f(ctx, q).
func (f ScaAuthRoleQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.ScaAuthRoleQuery); ok {
return f(ctx, q)
}
return Denyf("ent/privacy: unexpected query type %T, expect *ent.ScaAuthRoleQuery", q)
}
// The ScaAuthRoleMutationRuleFunc type is an adapter to allow the use of ordinary
// functions as a mutation rule.
type ScaAuthRoleMutationRuleFunc func(context.Context, *ent.ScaAuthRoleMutation) error
// EvalMutation calls f(ctx, m).
func (f ScaAuthRoleMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
if m, ok := m.(*ent.ScaAuthRoleMutation); ok {
return f(ctx, m)
}
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ScaAuthRoleMutation", m)
}
// The ScaAuthUserQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type ScaAuthUserQueryRuleFunc func(context.Context, *ent.ScaAuthUserQuery) error
// EvalQuery return f(ctx, q).
func (f ScaAuthUserQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.ScaAuthUserQuery); ok {
return f(ctx, q)
}
return Denyf("ent/privacy: unexpected query type %T, expect *ent.ScaAuthUserQuery", q)
}
// The ScaAuthUserMutationRuleFunc type is an adapter to allow the use of ordinary
// functions as a mutation rule.
type ScaAuthUserMutationRuleFunc func(context.Context, *ent.ScaAuthUserMutation) error
// EvalMutation calls f(ctx, m).
func (f ScaAuthUserMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
if m, ok := m.(*ent.ScaAuthUserMutation); ok {
return f(ctx, m)
}
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ScaAuthUserMutation", m)
}
// The ScaAuthUserDeviceQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type ScaAuthUserDeviceQueryRuleFunc func(context.Context, *ent.ScaAuthUserDeviceQuery) error
// EvalQuery return f(ctx, q).
func (f ScaAuthUserDeviceQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.ScaAuthUserDeviceQuery); ok {
return f(ctx, q)
}
return Denyf("ent/privacy: unexpected query type %T, expect *ent.ScaAuthUserDeviceQuery", q)
}
// The ScaAuthUserDeviceMutationRuleFunc type is an adapter to allow the use of ordinary
// functions as a mutation rule.
type ScaAuthUserDeviceMutationRuleFunc func(context.Context, *ent.ScaAuthUserDeviceMutation) error
// EvalMutation calls f(ctx, m).
func (f ScaAuthUserDeviceMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
if m, ok := m.(*ent.ScaAuthUserDeviceMutation); ok {
return f(ctx, m)
}
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ScaAuthUserDeviceMutation", m)
}
// The ScaAuthUserSocialQueryRuleFunc type is an adapter to allow the use of ordinary
// functions as a query rule.
type ScaAuthUserSocialQueryRuleFunc func(context.Context, *ent.ScaAuthUserSocialQuery) error
// EvalQuery return f(ctx, q).
func (f ScaAuthUserSocialQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.ScaAuthUserSocialQuery); ok {
return f(ctx, q)
}
return Denyf("ent/privacy: unexpected query type %T, expect *ent.ScaAuthUserSocialQuery", q)
}
// The ScaAuthUserSocialMutationRuleFunc type is an adapter to allow the use of ordinary
// functions as a mutation rule.
type ScaAuthUserSocialMutationRuleFunc func(context.Context, *ent.ScaAuthUserSocialMutation) error
// EvalMutation calls f(ctx, m).
func (f ScaAuthUserSocialMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
if m, ok := m.(*ent.ScaAuthUserSocialMutation); ok {
return f(ctx, m)
}
return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ScaAuthUserSocialMutation", m)
}
type (
// Filter is the interface that wraps the Where function
// for filtering nodes in queries and mutations.
Filter interface {
// Where applies a filter on the executed query/mutation.
Where(entql.P)
}
// The FilterFunc type is an adapter that allows the use of ordinary
// functions as filters for query and mutation types.
FilterFunc func(context.Context, Filter) error
)
// EvalQuery calls f(ctx, q) if the query implements the Filter interface, otherwise it is denied.
func (f FilterFunc) EvalQuery(ctx context.Context, q ent.Query) error {
fr, err := queryFilter(q)
if err != nil {
return err
}
return f(ctx, fr)
}
// EvalMutation calls f(ctx, q) if the mutation implements the Filter interface, otherwise it is denied.
func (f FilterFunc) EvalMutation(ctx context.Context, m ent.Mutation) error {
fr, err := mutationFilter(m)
if err != nil {
return err
}
return f(ctx, fr)
}
var _ QueryMutationRule = FilterFunc(nil)
func queryFilter(q ent.Query) (Filter, error) {
switch q := q.(type) {
case *ent.ScaAuthPermissionRuleQuery:
return q.Filter(), nil
case *ent.ScaAuthRoleQuery:
return q.Filter(), nil
case *ent.ScaAuthUserQuery:
return q.Filter(), nil
case *ent.ScaAuthUserDeviceQuery:
return q.Filter(), nil
case *ent.ScaAuthUserSocialQuery:
return q.Filter(), nil
default:
return nil, Denyf("ent/privacy: unexpected query type %T for query filter", q)
}
}
func mutationFilter(m ent.Mutation) (Filter, error) {
switch m := m.(type) {
case *ent.ScaAuthPermissionRuleMutation:
return m.Filter(), nil
case *ent.ScaAuthRoleMutation:
return m.Filter(), nil
case *ent.ScaAuthUserMutation:
return m.Filter(), nil
case *ent.ScaAuthUserDeviceMutation:
return m.Filter(), nil
case *ent.ScaAuthUserSocialMutation:
return m.Filter(), nil
default:
return nil, Denyf("ent/privacy: unexpected mutation type %T for mutation filter", m)
}
}

View File

@@ -1,249 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule"
"schisandra-album-cloud-microservices/common/ent/scaauthrole"
"schisandra-album-cloud-microservices/common/ent/scaauthuser"
"schisandra-album-cloud-microservices/common/ent/scaauthuserdevice"
"schisandra-album-cloud-microservices/common/ent/scaauthusersocial"
"schisandra-album-cloud-microservices/common/ent/schema"
"time"
)
// The init function reads all schema descriptors with runtime code
// (default values, validators, hooks and policies) and stitches it
// to their package variables.
func init() {
scaauthpermissionruleFields := schema.ScaAuthPermissionRule{}.Fields()
_ = scaauthpermissionruleFields
// scaauthpermissionruleDescPtype is the schema descriptor for ptype field.
scaauthpermissionruleDescPtype := scaauthpermissionruleFields[1].Descriptor()
// scaauthpermissionrule.PtypeValidator is a validator for the "ptype" field. It is called by the builders before save.
scaauthpermissionrule.PtypeValidator = scaauthpermissionruleDescPtype.Validators[0].(func(string) error)
// scaauthpermissionruleDescV0 is the schema descriptor for v0 field.
scaauthpermissionruleDescV0 := scaauthpermissionruleFields[2].Descriptor()
// scaauthpermissionrule.V0Validator is a validator for the "v0" field. It is called by the builders before save.
scaauthpermissionrule.V0Validator = scaauthpermissionruleDescV0.Validators[0].(func(string) error)
// scaauthpermissionruleDescV1 is the schema descriptor for v1 field.
scaauthpermissionruleDescV1 := scaauthpermissionruleFields[3].Descriptor()
// scaauthpermissionrule.V1Validator is a validator for the "v1" field. It is called by the builders before save.
scaauthpermissionrule.V1Validator = scaauthpermissionruleDescV1.Validators[0].(func(string) error)
// scaauthpermissionruleDescV2 is the schema descriptor for v2 field.
scaauthpermissionruleDescV2 := scaauthpermissionruleFields[4].Descriptor()
// scaauthpermissionrule.V2Validator is a validator for the "v2" field. It is called by the builders before save.
scaauthpermissionrule.V2Validator = scaauthpermissionruleDescV2.Validators[0].(func(string) error)
// scaauthpermissionruleDescV3 is the schema descriptor for v3 field.
scaauthpermissionruleDescV3 := scaauthpermissionruleFields[5].Descriptor()
// scaauthpermissionrule.V3Validator is a validator for the "v3" field. It is called by the builders before save.
scaauthpermissionrule.V3Validator = scaauthpermissionruleDescV3.Validators[0].(func(string) error)
// scaauthpermissionruleDescV4 is the schema descriptor for v4 field.
scaauthpermissionruleDescV4 := scaauthpermissionruleFields[6].Descriptor()
// scaauthpermissionrule.V4Validator is a validator for the "v4" field. It is called by the builders before save.
scaauthpermissionrule.V4Validator = scaauthpermissionruleDescV4.Validators[0].(func(string) error)
// scaauthpermissionruleDescV5 is the schema descriptor for v5 field.
scaauthpermissionruleDescV5 := scaauthpermissionruleFields[7].Descriptor()
// scaauthpermissionrule.V5Validator is a validator for the "v5" field. It is called by the builders before save.
scaauthpermissionrule.V5Validator = scaauthpermissionruleDescV5.Validators[0].(func(string) error)
scaauthroleMixin := schema.ScaAuthRole{}.Mixin()
scaauthroleMixinFields0 := scaauthroleMixin[0].Fields()
_ = scaauthroleMixinFields0
scaauthroleFields := schema.ScaAuthRole{}.Fields()
_ = scaauthroleFields
// scaauthroleDescCreatedAt is the schema descriptor for created_at field.
scaauthroleDescCreatedAt := scaauthroleMixinFields0[0].Descriptor()
// scaauthrole.DefaultCreatedAt holds the default value on creation for the created_at field.
scaauthrole.DefaultCreatedAt = scaauthroleDescCreatedAt.Default.(func() time.Time)
// scaauthroleDescUpdatedAt is the schema descriptor for updated_at field.
scaauthroleDescUpdatedAt := scaauthroleMixinFields0[1].Descriptor()
// scaauthrole.DefaultUpdatedAt holds the default value on creation for the updated_at field.
scaauthrole.DefaultUpdatedAt = scaauthroleDescUpdatedAt.Default.(func() time.Time)
// scaauthrole.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
scaauthrole.UpdateDefaultUpdatedAt = scaauthroleDescUpdatedAt.UpdateDefault.(func() time.Time)
// scaauthroleDescDeleted is the schema descriptor for deleted field.
scaauthroleDescDeleted := scaauthroleMixinFields0[2].Descriptor()
// scaauthrole.DefaultDeleted holds the default value on creation for the deleted field.
scaauthrole.DefaultDeleted = scaauthroleDescDeleted.Default.(int8)
// scaauthrole.DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
scaauthrole.DeletedValidator = scaauthroleDescDeleted.Validators[0].(func(int8) error)
// scaauthroleDescRoleName is the schema descriptor for role_name field.
scaauthroleDescRoleName := scaauthroleFields[1].Descriptor()
// scaauthrole.RoleNameValidator is a validator for the "role_name" field. It is called by the builders before save.
scaauthrole.RoleNameValidator = scaauthroleDescRoleName.Validators[0].(func(string) error)
// scaauthroleDescRoleKey is the schema descriptor for role_key field.
scaauthroleDescRoleKey := scaauthroleFields[2].Descriptor()
// scaauthrole.RoleKeyValidator is a validator for the "role_key" field. It is called by the builders before save.
scaauthrole.RoleKeyValidator = scaauthroleDescRoleKey.Validators[0].(func(string) error)
scaauthuserMixin := schema.ScaAuthUser{}.Mixin()
scaauthuserMixinFields0 := scaauthuserMixin[0].Fields()
_ = scaauthuserMixinFields0
scaauthuserFields := schema.ScaAuthUser{}.Fields()
_ = scaauthuserFields
// scaauthuserDescCreatedAt is the schema descriptor for created_at field.
scaauthuserDescCreatedAt := scaauthuserMixinFields0[0].Descriptor()
// scaauthuser.DefaultCreatedAt holds the default value on creation for the created_at field.
scaauthuser.DefaultCreatedAt = scaauthuserDescCreatedAt.Default.(func() time.Time)
// scaauthuserDescUpdatedAt is the schema descriptor for updated_at field.
scaauthuserDescUpdatedAt := scaauthuserMixinFields0[1].Descriptor()
// scaauthuser.DefaultUpdatedAt holds the default value on creation for the updated_at field.
scaauthuser.DefaultUpdatedAt = scaauthuserDescUpdatedAt.Default.(func() time.Time)
// scaauthuser.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
scaauthuser.UpdateDefaultUpdatedAt = scaauthuserDescUpdatedAt.UpdateDefault.(func() time.Time)
// scaauthuserDescDeleted is the schema descriptor for deleted field.
scaauthuserDescDeleted := scaauthuserMixinFields0[2].Descriptor()
// scaauthuser.DefaultDeleted holds the default value on creation for the deleted field.
scaauthuser.DefaultDeleted = scaauthuserDescDeleted.Default.(int8)
// scaauthuser.DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
scaauthuser.DeletedValidator = scaauthuserDescDeleted.Validators[0].(func(int8) error)
// scaauthuserDescUID is the schema descriptor for uid field.
scaauthuserDescUID := scaauthuserFields[1].Descriptor()
// scaauthuser.UIDValidator is a validator for the "uid" field. It is called by the builders before save.
scaauthuser.UIDValidator = scaauthuserDescUID.Validators[0].(func(string) error)
// scaauthuserDescUsername is the schema descriptor for username field.
scaauthuserDescUsername := scaauthuserFields[2].Descriptor()
// scaauthuser.UsernameValidator is a validator for the "username" field. It is called by the builders before save.
scaauthuser.UsernameValidator = scaauthuserDescUsername.Validators[0].(func(string) error)
// scaauthuserDescNickname is the schema descriptor for nickname field.
scaauthuserDescNickname := scaauthuserFields[3].Descriptor()
// scaauthuser.NicknameValidator is a validator for the "nickname" field. It is called by the builders before save.
scaauthuser.NicknameValidator = scaauthuserDescNickname.Validators[0].(func(string) error)
// scaauthuserDescEmail is the schema descriptor for email field.
scaauthuserDescEmail := scaauthuserFields[4].Descriptor()
// scaauthuser.EmailValidator is a validator for the "email" field. It is called by the builders before save.
scaauthuser.EmailValidator = scaauthuserDescEmail.Validators[0].(func(string) error)
// scaauthuserDescPhone is the schema descriptor for phone field.
scaauthuserDescPhone := scaauthuserFields[5].Descriptor()
// scaauthuser.PhoneValidator is a validator for the "phone" field. It is called by the builders before save.
scaauthuser.PhoneValidator = scaauthuserDescPhone.Validators[0].(func(string) error)
// scaauthuserDescPassword is the schema descriptor for password field.
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.
scaauthuser.DefaultStatus = scaauthuserDescStatus.Default.(int8)
// scaauthuserDescIntroduce is the schema descriptor for introduce field.
scaauthuserDescIntroduce := scaauthuserFields[10].Descriptor()
// scaauthuser.IntroduceValidator is a validator for the "introduce" field. It is called by the builders before save.
scaauthuser.IntroduceValidator = scaauthuserDescIntroduce.Validators[0].(func(string) error)
// scaauthuserDescBlog is the schema descriptor for blog field.
scaauthuserDescBlog := scaauthuserFields[11].Descriptor()
// scaauthuser.BlogValidator is a validator for the "blog" field. It is called by the builders before save.
scaauthuser.BlogValidator = scaauthuserDescBlog.Validators[0].(func(string) error)
// scaauthuserDescLocation is the schema descriptor for location field.
scaauthuserDescLocation := scaauthuserFields[12].Descriptor()
// scaauthuser.LocationValidator is a validator for the "location" field. It is called by the builders before save.
scaauthuser.LocationValidator = scaauthuserDescLocation.Validators[0].(func(string) error)
// scaauthuserDescCompany is the schema descriptor for company field.
scaauthuserDescCompany := scaauthuserFields[13].Descriptor()
// scaauthuser.CompanyValidator is a validator for the "company" field. It is called by the builders before save.
scaauthuser.CompanyValidator = scaauthuserDescCompany.Validators[0].(func(string) error)
scaauthuserdeviceMixin := schema.ScaAuthUserDevice{}.Mixin()
scaauthuserdeviceMixinFields0 := scaauthuserdeviceMixin[0].Fields()
_ = scaauthuserdeviceMixinFields0
scaauthuserdeviceFields := schema.ScaAuthUserDevice{}.Fields()
_ = scaauthuserdeviceFields
// scaauthuserdeviceDescCreatedAt is the schema descriptor for created_at field.
scaauthuserdeviceDescCreatedAt := scaauthuserdeviceMixinFields0[0].Descriptor()
// scaauthuserdevice.DefaultCreatedAt holds the default value on creation for the created_at field.
scaauthuserdevice.DefaultCreatedAt = scaauthuserdeviceDescCreatedAt.Default.(func() time.Time)
// scaauthuserdeviceDescUpdatedAt is the schema descriptor for updated_at field.
scaauthuserdeviceDescUpdatedAt := scaauthuserdeviceMixinFields0[1].Descriptor()
// scaauthuserdevice.DefaultUpdatedAt holds the default value on creation for the updated_at field.
scaauthuserdevice.DefaultUpdatedAt = scaauthuserdeviceDescUpdatedAt.Default.(func() time.Time)
// scaauthuserdevice.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
scaauthuserdevice.UpdateDefaultUpdatedAt = scaauthuserdeviceDescUpdatedAt.UpdateDefault.(func() time.Time)
// scaauthuserdeviceDescDeleted is the schema descriptor for deleted field.
scaauthuserdeviceDescDeleted := scaauthuserdeviceMixinFields0[2].Descriptor()
// scaauthuserdevice.DefaultDeleted holds the default value on creation for the deleted field.
scaauthuserdevice.DefaultDeleted = scaauthuserdeviceDescDeleted.Default.(int8)
// scaauthuserdevice.DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
scaauthuserdevice.DeletedValidator = scaauthuserdeviceDescDeleted.Validators[0].(func(int8) error)
// scaauthuserdeviceDescUserID is the schema descriptor for user_id field.
scaauthuserdeviceDescUserID := scaauthuserdeviceFields[1].Descriptor()
// scaauthuserdevice.UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
scaauthuserdevice.UserIDValidator = scaauthuserdeviceDescUserID.Validators[0].(func(string) error)
// scaauthuserdeviceDescIP is the schema descriptor for ip field.
scaauthuserdeviceDescIP := scaauthuserdeviceFields[2].Descriptor()
// scaauthuserdevice.IPValidator is a validator for the "ip" field. It is called by the builders before save.
scaauthuserdevice.IPValidator = scaauthuserdeviceDescIP.Validators[0].(func(string) error)
// scaauthuserdeviceDescLocation is the schema descriptor for location field.
scaauthuserdeviceDescLocation := scaauthuserdeviceFields[3].Descriptor()
// scaauthuserdevice.LocationValidator is a validator for the "location" field. It is called by the builders before save.
scaauthuserdevice.LocationValidator = scaauthuserdeviceDescLocation.Validators[0].(func(string) error)
// scaauthuserdeviceDescAgent is the schema descriptor for agent field.
scaauthuserdeviceDescAgent := scaauthuserdeviceFields[4].Descriptor()
// scaauthuserdevice.AgentValidator is a validator for the "agent" field. It is called by the builders before save.
scaauthuserdevice.AgentValidator = scaauthuserdeviceDescAgent.Validators[0].(func(string) error)
// scaauthuserdeviceDescBrowser is the schema descriptor for browser field.
scaauthuserdeviceDescBrowser := scaauthuserdeviceFields[5].Descriptor()
// scaauthuserdevice.BrowserValidator is a validator for the "browser" field. It is called by the builders before save.
scaauthuserdevice.BrowserValidator = scaauthuserdeviceDescBrowser.Validators[0].(func(string) error)
// scaauthuserdeviceDescOperatingSystem is the schema descriptor for operating_system field.
scaauthuserdeviceDescOperatingSystem := scaauthuserdeviceFields[6].Descriptor()
// scaauthuserdevice.OperatingSystemValidator is a validator for the "operating_system" field. It is called by the builders before save.
scaauthuserdevice.OperatingSystemValidator = scaauthuserdeviceDescOperatingSystem.Validators[0].(func(string) error)
// scaauthuserdeviceDescBrowserVersion is the schema descriptor for browser_version field.
scaauthuserdeviceDescBrowserVersion := scaauthuserdeviceFields[7].Descriptor()
// scaauthuserdevice.BrowserVersionValidator is a validator for the "browser_version" field. It is called by the builders before save.
scaauthuserdevice.BrowserVersionValidator = scaauthuserdeviceDescBrowserVersion.Validators[0].(func(string) error)
// scaauthuserdeviceDescMozilla is the schema descriptor for mozilla field.
scaauthuserdeviceDescMozilla := scaauthuserdeviceFields[10].Descriptor()
// scaauthuserdevice.MozillaValidator is a validator for the "mozilla" field. It is called by the builders before save.
scaauthuserdevice.MozillaValidator = scaauthuserdeviceDescMozilla.Validators[0].(func(string) error)
// scaauthuserdeviceDescPlatform is the schema descriptor for platform field.
scaauthuserdeviceDescPlatform := scaauthuserdeviceFields[11].Descriptor()
// scaauthuserdevice.PlatformValidator is a validator for the "platform" field. It is called by the builders before save.
scaauthuserdevice.PlatformValidator = scaauthuserdeviceDescPlatform.Validators[0].(func(string) error)
// scaauthuserdeviceDescEngineName is the schema descriptor for engine_name field.
scaauthuserdeviceDescEngineName := scaauthuserdeviceFields[12].Descriptor()
// scaauthuserdevice.EngineNameValidator is a validator for the "engine_name" field. It is called by the builders before save.
scaauthuserdevice.EngineNameValidator = scaauthuserdeviceDescEngineName.Validators[0].(func(string) error)
// scaauthuserdeviceDescEngineVersion is the schema descriptor for engine_version field.
scaauthuserdeviceDescEngineVersion := scaauthuserdeviceFields[13].Descriptor()
// scaauthuserdevice.EngineVersionValidator is a validator for the "engine_version" field. It is called by the builders before save.
scaauthuserdevice.EngineVersionValidator = scaauthuserdeviceDescEngineVersion.Validators[0].(func(string) error)
scaauthusersocialMixin := schema.ScaAuthUserSocial{}.Mixin()
scaauthusersocialMixinFields0 := scaauthusersocialMixin[0].Fields()
_ = scaauthusersocialMixinFields0
scaauthusersocialFields := schema.ScaAuthUserSocial{}.Fields()
_ = scaauthusersocialFields
// scaauthusersocialDescCreatedAt is the schema descriptor for created_at field.
scaauthusersocialDescCreatedAt := scaauthusersocialMixinFields0[0].Descriptor()
// scaauthusersocial.DefaultCreatedAt holds the default value on creation for the created_at field.
scaauthusersocial.DefaultCreatedAt = scaauthusersocialDescCreatedAt.Default.(func() time.Time)
// scaauthusersocialDescUpdatedAt is the schema descriptor for updated_at field.
scaauthusersocialDescUpdatedAt := scaauthusersocialMixinFields0[1].Descriptor()
// scaauthusersocial.DefaultUpdatedAt holds the default value on creation for the updated_at field.
scaauthusersocial.DefaultUpdatedAt = scaauthusersocialDescUpdatedAt.Default.(func() time.Time)
// scaauthusersocial.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
scaauthusersocial.UpdateDefaultUpdatedAt = scaauthusersocialDescUpdatedAt.UpdateDefault.(func() time.Time)
// scaauthusersocialDescDeleted is the schema descriptor for deleted field.
scaauthusersocialDescDeleted := scaauthusersocialMixinFields0[2].Descriptor()
// scaauthusersocial.DefaultDeleted holds the default value on creation for the deleted field.
scaauthusersocial.DefaultDeleted = scaauthusersocialDescDeleted.Default.(int8)
// scaauthusersocial.DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
scaauthusersocial.DeletedValidator = scaauthusersocialDescDeleted.Validators[0].(func(int8) error)
// scaauthusersocialDescUserID is the schema descriptor for user_id field.
scaauthusersocialDescUserID := scaauthusersocialFields[1].Descriptor()
// scaauthusersocial.UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
scaauthusersocial.UserIDValidator = scaauthusersocialDescUserID.Validators[0].(func(string) error)
// scaauthusersocialDescOpenID is the schema descriptor for open_id field.
scaauthusersocialDescOpenID := scaauthusersocialFields[2].Descriptor()
// scaauthusersocial.OpenIDValidator is a validator for the "open_id" field. It is called by the builders before save.
scaauthusersocial.OpenIDValidator = scaauthusersocialDescOpenID.Validators[0].(func(string) error)
// scaauthusersocialDescSource is the schema descriptor for source field.
scaauthusersocialDescSource := scaauthusersocialFields[3].Descriptor()
// scaauthusersocial.SourceValidator is a validator for the "source" field. It is called by the builders before save.
scaauthusersocial.SourceValidator = scaauthusersocialDescSource.Validators[0].(func(string) error)
// scaauthusersocialDescStatus is the schema descriptor for status field.
scaauthusersocialDescStatus := scaauthusersocialFields[4].Descriptor()
// scaauthusersocial.DefaultStatus holds the default value on creation for the status field.
scaauthusersocial.DefaultStatus = scaauthusersocialDescStatus.Default.(int)
}

View File

@@ -1,10 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package runtime
// The schema-stitching logic is generated in schisandra-album-cloud-microservices/common/ent/runtime.go
const (
Version = "v0.14.1" // Version of ent codegen.
Sum = "h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=" // Sum of ent codegen.
)

View File

@@ -1,229 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule"
"schisandra-album-cloud-microservices/common/ent/scaauthrole"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// 角色权限规则表
type ScaAuthPermissionRule struct {
config `json:"-"`
// ID of the ent.
ID int64 `json:"id,omitempty"`
// Ptype holds the value of the "ptype" field.
Ptype *string `json:"ptype,omitempty"`
// V0 holds the value of the "v0" field.
V0 *string `json:"v0,omitempty"`
// V1 holds the value of the "v1" field.
V1 *string `json:"v1,omitempty"`
// V2 holds the value of the "v2" field.
V2 *string `json:"v2,omitempty"`
// V3 holds the value of the "v3" field.
V3 *string `json:"v3,omitempty"`
// V4 holds the value of the "v4" field.
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"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ScaAuthPermissionRule) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case scaauthpermissionrule.FieldID:
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)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ScaAuthPermissionRule fields.
func (sapr *ScaAuthPermissionRule) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case scaauthpermissionrule.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
sapr.ID = int64(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
}
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
}
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
}
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
}
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
}
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
}
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)
}
default:
sapr.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ScaAuthPermissionRule.
// This includes values selected through modifiers, order, etc.
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.
func (sapr *ScaAuthPermissionRule) Update() *ScaAuthPermissionRuleUpdateOne {
return NewScaAuthPermissionRuleClient(sapr.config).UpdateOne(sapr)
}
// Unwrap unwraps the ScaAuthPermissionRule entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (sapr *ScaAuthPermissionRule) Unwrap() *ScaAuthPermissionRule {
_tx, ok := sapr.config.driver.(*txDriver)
if !ok {
panic("ent: ScaAuthPermissionRule is not a transactional entity")
}
sapr.config.driver = _tx.drv
return sapr
}
// String implements the fmt.Stringer.
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(", ")
if v := sapr.V0; v != nil {
builder.WriteString("v0=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := sapr.V1; v != nil {
builder.WriteString("v1=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := sapr.V2; v != nil {
builder.WriteString("v2=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := sapr.V3; v != nil {
builder.WriteString("v3=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := sapr.V4; v != nil {
builder.WriteString("v4=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := sapr.V5; v != nil {
builder.WriteString("v5=")
builder.WriteString(*v)
}
builder.WriteByte(')')
return builder.String()
}
// ScaAuthPermissionRules is a parsable slice of ScaAuthPermissionRule.
type ScaAuthPermissionRules []*ScaAuthPermissionRule

View File

@@ -1,147 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scaauthpermissionrule
import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the scaauthpermissionrule type in the database.
Label = "sca_auth_permission_rule"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldPtype holds the string denoting the ptype field in the database.
FieldPtype = "ptype"
// FieldV0 holds the string denoting the v0 field in the database.
FieldV0 = "v0"
// FieldV1 holds the string denoting the v1 field in the database.
FieldV1 = "v1"
// FieldV2 holds the string denoting the v2 field in the database.
FieldV2 = "v2"
// FieldV3 holds the string denoting the v3 field in the database.
FieldV3 = "v3"
// FieldV4 holds the string denoting the v4 field in the database.
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.
var Columns = []string{
FieldID,
FieldPtype,
FieldV0,
FieldV1,
FieldV2,
FieldV3,
FieldV4,
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 {
if column == Columns[i] {
return true
}
}
for i := range ForeignKeys {
if column == ForeignKeys[i] {
return true
}
}
return false
}
var (
// PtypeValidator is a validator for the "ptype" field. It is called by the builders before save.
PtypeValidator func(string) error
// V0Validator is a validator for the "v0" field. It is called by the builders before save.
V0Validator func(string) error
// V1Validator is a validator for the "v1" field. It is called by the builders before save.
V1Validator func(string) error
// V2Validator is a validator for the "v2" field. It is called by the builders before save.
V2Validator func(string) error
// V3Validator is a validator for the "v3" field. It is called by the builders before save.
V3Validator func(string) error
// V4Validator is a validator for the "v4" field. It is called by the builders before save.
V4Validator func(string) error
// V5Validator is a validator for the "v5" field. It is called by the builders before save.
V5Validator func(string) error
)
// OrderOption defines the ordering options for the ScaAuthPermissionRule queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByPtype orders the results by the ptype field.
func ByPtype(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPtype, opts...).ToFunc()
}
// ByV0 orders the results by the v0 field.
func ByV0(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldV0, opts...).ToFunc()
}
// ByV1 orders the results by the v1 field.
func ByV1(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldV1, opts...).ToFunc()
}
// ByV2 orders the results by the v2 field.
func ByV2(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldV2, opts...).ToFunc()
}
// ByV3 orders the results by the v3 field.
func ByV3(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldV3, opts...).ToFunc()
}
// ByV4 orders the results by the v4 field.
func ByV4(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldV4, opts...).ToFunc()
}
// ByV5 orders the results by the v5 field.
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),
)
}

View File

@@ -1,623 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scaauthpermissionrule
import (
"schisandra-album-cloud-microservices/common/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 {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldID, id))
}
// Ptype applies equality check predicate on the "ptype" field. It's identical to PtypeEQ.
func Ptype(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldPtype, v))
}
// V0 applies equality check predicate on the "v0" field. It's identical to V0EQ.
func V0(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV0, v))
}
// V1 applies equality check predicate on the "v1" field. It's identical to V1EQ.
func V1(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV1, v))
}
// V2 applies equality check predicate on the "v2" field. It's identical to V2EQ.
func V2(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV2, v))
}
// V3 applies equality check predicate on the "v3" field. It's identical to V3EQ.
func V3(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV3, v))
}
// V4 applies equality check predicate on the "v4" field. It's identical to V4EQ.
func V4(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV4, v))
}
// V5 applies equality check predicate on the "v5" field. It's identical to V5EQ.
func V5(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV5, v))
}
// PtypeEQ applies the EQ predicate on the "ptype" field.
func PtypeEQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldPtype, v))
}
// PtypeNEQ applies the NEQ predicate on the "ptype" field.
func PtypeNEQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldPtype, v))
}
// PtypeIn applies the In predicate on the "ptype" field.
func PtypeIn(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldPtype, vs...))
}
// PtypeNotIn applies the NotIn predicate on the "ptype" field.
func PtypeNotIn(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldPtype, vs...))
}
// PtypeGT applies the GT predicate on the "ptype" field.
func PtypeGT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldPtype, v))
}
// PtypeGTE applies the GTE predicate on the "ptype" field.
func PtypeGTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldPtype, v))
}
// PtypeLT applies the LT predicate on the "ptype" field.
func PtypeLT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldPtype, v))
}
// PtypeLTE applies the LTE predicate on the "ptype" field.
func PtypeLTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldPtype, v))
}
// PtypeContains applies the Contains predicate on the "ptype" field.
func PtypeContains(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldPtype, v))
}
// PtypeHasPrefix applies the HasPrefix predicate on the "ptype" field.
func PtypeHasPrefix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldPtype, v))
}
// PtypeHasSuffix applies the HasSuffix predicate on the "ptype" field.
func PtypeHasSuffix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldPtype, v))
}
// PtypeEqualFold applies the EqualFold predicate on the "ptype" field.
func PtypeEqualFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldPtype, v))
}
// PtypeContainsFold applies the ContainsFold predicate on the "ptype" field.
func PtypeContainsFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldPtype, v))
}
// V0EQ applies the EQ predicate on the "v0" field.
func V0EQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV0, v))
}
// V0NEQ applies the NEQ predicate on the "v0" field.
func V0NEQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV0, v))
}
// V0In applies the In predicate on the "v0" field.
func V0In(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV0, vs...))
}
// V0NotIn applies the NotIn predicate on the "v0" field.
func V0NotIn(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV0, vs...))
}
// V0GT applies the GT predicate on the "v0" field.
func V0GT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV0, v))
}
// V0GTE applies the GTE predicate on the "v0" field.
func V0GTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV0, v))
}
// V0LT applies the LT predicate on the "v0" field.
func V0LT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV0, v))
}
// V0LTE applies the LTE predicate on the "v0" field.
func V0LTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV0, v))
}
// V0Contains applies the Contains predicate on the "v0" field.
func V0Contains(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV0, v))
}
// V0HasPrefix applies the HasPrefix predicate on the "v0" field.
func V0HasPrefix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV0, v))
}
// V0HasSuffix applies the HasSuffix predicate on the "v0" field.
func V0HasSuffix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV0, v))
}
// V0EqualFold applies the EqualFold predicate on the "v0" field.
func V0EqualFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV0, v))
}
// V0ContainsFold applies the ContainsFold predicate on the "v0" field.
func V0ContainsFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV0, v))
}
// V1EQ applies the EQ predicate on the "v1" field.
func V1EQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV1, v))
}
// V1NEQ applies the NEQ predicate on the "v1" field.
func V1NEQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV1, v))
}
// V1In applies the In predicate on the "v1" field.
func V1In(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV1, vs...))
}
// V1NotIn applies the NotIn predicate on the "v1" field.
func V1NotIn(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV1, vs...))
}
// V1GT applies the GT predicate on the "v1" field.
func V1GT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV1, v))
}
// V1GTE applies the GTE predicate on the "v1" field.
func V1GTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV1, v))
}
// V1LT applies the LT predicate on the "v1" field.
func V1LT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV1, v))
}
// V1LTE applies the LTE predicate on the "v1" field.
func V1LTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV1, v))
}
// V1Contains applies the Contains predicate on the "v1" field.
func V1Contains(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV1, v))
}
// V1HasPrefix applies the HasPrefix predicate on the "v1" field.
func V1HasPrefix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV1, v))
}
// V1HasSuffix applies the HasSuffix predicate on the "v1" field.
func V1HasSuffix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV1, v))
}
// V1EqualFold applies the EqualFold predicate on the "v1" field.
func V1EqualFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV1, v))
}
// V1ContainsFold applies the ContainsFold predicate on the "v1" field.
func V1ContainsFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV1, v))
}
// V2EQ applies the EQ predicate on the "v2" field.
func V2EQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV2, v))
}
// V2NEQ applies the NEQ predicate on the "v2" field.
func V2NEQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV2, v))
}
// V2In applies the In predicate on the "v2" field.
func V2In(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV2, vs...))
}
// V2NotIn applies the NotIn predicate on the "v2" field.
func V2NotIn(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV2, vs...))
}
// V2GT applies the GT predicate on the "v2" field.
func V2GT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV2, v))
}
// V2GTE applies the GTE predicate on the "v2" field.
func V2GTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV2, v))
}
// V2LT applies the LT predicate on the "v2" field.
func V2LT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV2, v))
}
// V2LTE applies the LTE predicate on the "v2" field.
func V2LTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV2, v))
}
// V2Contains applies the Contains predicate on the "v2" field.
func V2Contains(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV2, v))
}
// V2HasPrefix applies the HasPrefix predicate on the "v2" field.
func V2HasPrefix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV2, v))
}
// V2HasSuffix applies the HasSuffix predicate on the "v2" field.
func V2HasSuffix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV2, v))
}
// V2IsNil applies the IsNil predicate on the "v2" field.
func V2IsNil() predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldV2))
}
// V2NotNil applies the NotNil predicate on the "v2" field.
func V2NotNil() predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldV2))
}
// V2EqualFold applies the EqualFold predicate on the "v2" field.
func V2EqualFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV2, v))
}
// V2ContainsFold applies the ContainsFold predicate on the "v2" field.
func V2ContainsFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV2, v))
}
// V3EQ applies the EQ predicate on the "v3" field.
func V3EQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV3, v))
}
// V3NEQ applies the NEQ predicate on the "v3" field.
func V3NEQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV3, v))
}
// V3In applies the In predicate on the "v3" field.
func V3In(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV3, vs...))
}
// V3NotIn applies the NotIn predicate on the "v3" field.
func V3NotIn(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV3, vs...))
}
// V3GT applies the GT predicate on the "v3" field.
func V3GT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV3, v))
}
// V3GTE applies the GTE predicate on the "v3" field.
func V3GTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV3, v))
}
// V3LT applies the LT predicate on the "v3" field.
func V3LT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV3, v))
}
// V3LTE applies the LTE predicate on the "v3" field.
func V3LTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV3, v))
}
// V3Contains applies the Contains predicate on the "v3" field.
func V3Contains(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV3, v))
}
// V3HasPrefix applies the HasPrefix predicate on the "v3" field.
func V3HasPrefix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV3, v))
}
// V3HasSuffix applies the HasSuffix predicate on the "v3" field.
func V3HasSuffix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV3, v))
}
// V3IsNil applies the IsNil predicate on the "v3" field.
func V3IsNil() predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldV3))
}
// V3NotNil applies the NotNil predicate on the "v3" field.
func V3NotNil() predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldV3))
}
// V3EqualFold applies the EqualFold predicate on the "v3" field.
func V3EqualFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV3, v))
}
// V3ContainsFold applies the ContainsFold predicate on the "v3" field.
func V3ContainsFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV3, v))
}
// V4EQ applies the EQ predicate on the "v4" field.
func V4EQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV4, v))
}
// V4NEQ applies the NEQ predicate on the "v4" field.
func V4NEQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV4, v))
}
// V4In applies the In predicate on the "v4" field.
func V4In(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV4, vs...))
}
// V4NotIn applies the NotIn predicate on the "v4" field.
func V4NotIn(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV4, vs...))
}
// V4GT applies the GT predicate on the "v4" field.
func V4GT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV4, v))
}
// V4GTE applies the GTE predicate on the "v4" field.
func V4GTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV4, v))
}
// V4LT applies the LT predicate on the "v4" field.
func V4LT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV4, v))
}
// V4LTE applies the LTE predicate on the "v4" field.
func V4LTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV4, v))
}
// V4Contains applies the Contains predicate on the "v4" field.
func V4Contains(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV4, v))
}
// V4HasPrefix applies the HasPrefix predicate on the "v4" field.
func V4HasPrefix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV4, v))
}
// V4HasSuffix applies the HasSuffix predicate on the "v4" field.
func V4HasSuffix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV4, v))
}
// V4IsNil applies the IsNil predicate on the "v4" field.
func V4IsNil() predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldV4))
}
// V4NotNil applies the NotNil predicate on the "v4" field.
func V4NotNil() predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldV4))
}
// V4EqualFold applies the EqualFold predicate on the "v4" field.
func V4EqualFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV4, v))
}
// V4ContainsFold applies the ContainsFold predicate on the "v4" field.
func V4ContainsFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContainsFold(FieldV4, v))
}
// V5EQ applies the EQ predicate on the "v5" field.
func V5EQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEQ(FieldV5, v))
}
// V5NEQ applies the NEQ predicate on the "v5" field.
func V5NEQ(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNEQ(FieldV5, v))
}
// V5In applies the In predicate on the "v5" field.
func V5In(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIn(FieldV5, vs...))
}
// V5NotIn applies the NotIn predicate on the "v5" field.
func V5NotIn(vs ...string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotIn(FieldV5, vs...))
}
// V5GT applies the GT predicate on the "v5" field.
func V5GT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGT(FieldV5, v))
}
// V5GTE applies the GTE predicate on the "v5" field.
func V5GTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldGTE(FieldV5, v))
}
// V5LT applies the LT predicate on the "v5" field.
func V5LT(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLT(FieldV5, v))
}
// V5LTE applies the LTE predicate on the "v5" field.
func V5LTE(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldLTE(FieldV5, v))
}
// V5Contains applies the Contains predicate on the "v5" field.
func V5Contains(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldContains(FieldV5, v))
}
// V5HasPrefix applies the HasPrefix predicate on the "v5" field.
func V5HasPrefix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasPrefix(FieldV5, v))
}
// V5HasSuffix applies the HasSuffix predicate on the "v5" field.
func V5HasSuffix(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldHasSuffix(FieldV5, v))
}
// V5IsNil applies the IsNil predicate on the "v5" field.
func V5IsNil() predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldIsNull(FieldV5))
}
// V5NotNil applies the NotNil predicate on the "v5" field.
func V5NotNil() predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldNotNull(FieldV5))
}
// V5EqualFold applies the EqualFold predicate on the "v5" field.
func V5EqualFold(v string) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.FieldEqualFold(FieldV5, v))
}
// V5ContainsFold applies the ContainsFold predicate on the "v5" field.
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...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.ScaAuthPermissionRule) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.ScaAuthPermissionRule) predicate.ScaAuthPermissionRule {
return predicate.ScaAuthPermissionRule(sql.NotPredicates(p))
}

View File

@@ -1,365 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule"
"schisandra-album-cloud-microservices/common/ent/scaauthrole"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthPermissionRuleCreate is the builder for creating a ScaAuthPermissionRule entity.
type ScaAuthPermissionRuleCreate struct {
config
mutation *ScaAuthPermissionRuleMutation
hooks []Hook
}
// SetPtype sets the "ptype" field.
func (saprc *ScaAuthPermissionRuleCreate) SetPtype(s string) *ScaAuthPermissionRuleCreate {
saprc.mutation.SetPtype(s)
return saprc
}
// SetV0 sets the "v0" field.
func (saprc *ScaAuthPermissionRuleCreate) SetV0(s string) *ScaAuthPermissionRuleCreate {
saprc.mutation.SetV0(s)
return saprc
}
// SetV1 sets the "v1" field.
func (saprc *ScaAuthPermissionRuleCreate) SetV1(s string) *ScaAuthPermissionRuleCreate {
saprc.mutation.SetV1(s)
return saprc
}
// SetV2 sets the "v2" field.
func (saprc *ScaAuthPermissionRuleCreate) SetV2(s string) *ScaAuthPermissionRuleCreate {
saprc.mutation.SetV2(s)
return saprc
}
// SetNillableV2 sets the "v2" field if the given value is not nil.
func (saprc *ScaAuthPermissionRuleCreate) SetNillableV2(s *string) *ScaAuthPermissionRuleCreate {
if s != nil {
saprc.SetV2(*s)
}
return saprc
}
// SetV3 sets the "v3" field.
func (saprc *ScaAuthPermissionRuleCreate) SetV3(s string) *ScaAuthPermissionRuleCreate {
saprc.mutation.SetV3(s)
return saprc
}
// SetNillableV3 sets the "v3" field if the given value is not nil.
func (saprc *ScaAuthPermissionRuleCreate) SetNillableV3(s *string) *ScaAuthPermissionRuleCreate {
if s != nil {
saprc.SetV3(*s)
}
return saprc
}
// SetV4 sets the "v4" field.
func (saprc *ScaAuthPermissionRuleCreate) SetV4(s string) *ScaAuthPermissionRuleCreate {
saprc.mutation.SetV4(s)
return saprc
}
// SetNillableV4 sets the "v4" field if the given value is not nil.
func (saprc *ScaAuthPermissionRuleCreate) SetNillableV4(s *string) *ScaAuthPermissionRuleCreate {
if s != nil {
saprc.SetV4(*s)
}
return saprc
}
// SetV5 sets the "v5" field.
func (saprc *ScaAuthPermissionRuleCreate) SetV5(s string) *ScaAuthPermissionRuleCreate {
saprc.mutation.SetV5(s)
return saprc
}
// SetNillableV5 sets the "v5" field if the given value is not nil.
func (saprc *ScaAuthPermissionRuleCreate) SetNillableV5(s *string) *ScaAuthPermissionRuleCreate {
if s != nil {
saprc.SetV5(*s)
}
return saprc
}
// SetID sets the "id" field.
func (saprc *ScaAuthPermissionRuleCreate) SetID(i int64) *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
}
// Save creates the ScaAuthPermissionRule in the database.
func (saprc *ScaAuthPermissionRuleCreate) Save(ctx context.Context) (*ScaAuthPermissionRule, error) {
return withHooks(ctx, saprc.sqlSave, saprc.mutation, saprc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (saprc *ScaAuthPermissionRuleCreate) SaveX(ctx context.Context) *ScaAuthPermissionRule {
v, err := saprc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (saprc *ScaAuthPermissionRuleCreate) Exec(ctx context.Context) error {
_, err := saprc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (saprc *ScaAuthPermissionRuleCreate) ExecX(ctx context.Context) {
if err := saprc.Exec(ctx); err != nil {
panic(err)
}
}
// 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)}
}
}
if v, ok := saprc.mutation.V2(); ok {
if err := scaauthpermissionrule.V2Validator(v); err != nil {
return &ValidationError{Name: "v2", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v2": %w`, err)}
}
}
if v, ok := saprc.mutation.V3(); ok {
if err := scaauthpermissionrule.V3Validator(v); err != nil {
return &ValidationError{Name: "v3", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v3": %w`, err)}
}
}
if v, ok := saprc.mutation.V4(); ok {
if err := scaauthpermissionrule.V4Validator(v); err != nil {
return &ValidationError{Name: "v4", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v4": %w`, err)}
}
}
if v, ok := saprc.mutation.V5(); ok {
if err := scaauthpermissionrule.V5Validator(v); err != nil {
return &ValidationError{Name: "v5", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v5": %w`, err)}
}
}
return nil
}
func (saprc *ScaAuthPermissionRuleCreate) sqlSave(ctx context.Context) (*ScaAuthPermissionRule, error) {
if err := saprc.check(); err != nil {
return nil, err
}
_node, _spec := saprc.createSpec()
if err := sqlgraph.CreateNode(ctx, saprc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
}
saprc.mutation.id = &_node.ID
saprc.mutation.done = true
return _node, nil
}
func (saprc *ScaAuthPermissionRuleCreate) createSpec() (*ScaAuthPermissionRule, *sqlgraph.CreateSpec) {
var (
_node = &ScaAuthPermissionRule{config: saprc.config}
_spec = sqlgraph.NewCreateSpec(scaauthpermissionrule.Table, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64))
)
if id, ok := saprc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := saprc.mutation.Ptype(); ok {
_spec.SetField(scaauthpermissionrule.FieldPtype, field.TypeString, value)
_node.Ptype = &value
}
if value, ok := saprc.mutation.V0(); ok {
_spec.SetField(scaauthpermissionrule.FieldV0, field.TypeString, value)
_node.V0 = &value
}
if value, ok := saprc.mutation.V1(); ok {
_spec.SetField(scaauthpermissionrule.FieldV1, field.TypeString, value)
_node.V1 = &value
}
if value, ok := saprc.mutation.V2(); ok {
_spec.SetField(scaauthpermissionrule.FieldV2, field.TypeString, value)
_node.V2 = &value
}
if value, ok := saprc.mutation.V3(); ok {
_spec.SetField(scaauthpermissionrule.FieldV3, field.TypeString, value)
_node.V3 = &value
}
if value, ok := saprc.mutation.V4(); ok {
_spec.SetField(scaauthpermissionrule.FieldV4, field.TypeString, 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)
}
return _node, _spec
}
// ScaAuthPermissionRuleCreateBulk is the builder for creating many ScaAuthPermissionRule entities in bulk.
type ScaAuthPermissionRuleCreateBulk struct {
config
err error
builders []*ScaAuthPermissionRuleCreate
}
// Save creates the ScaAuthPermissionRule entities in the database.
func (saprcb *ScaAuthPermissionRuleCreateBulk) Save(ctx context.Context) ([]*ScaAuthPermissionRule, error) {
if saprcb.err != nil {
return nil, saprcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(saprcb.builders))
nodes := make([]*ScaAuthPermissionRule, len(saprcb.builders))
mutators := make([]Mutator, len(saprcb.builders))
for i := range saprcb.builders {
func(i int, root context.Context) {
builder := saprcb.builders[i]
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ScaAuthPermissionRuleMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, saprcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, saprcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, saprcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (saprcb *ScaAuthPermissionRuleCreateBulk) SaveX(ctx context.Context) []*ScaAuthPermissionRule {
v, err := saprcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (saprcb *ScaAuthPermissionRuleCreateBulk) Exec(ctx context.Context) error {
_, err := saprcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (saprcb *ScaAuthPermissionRuleCreateBulk) ExecX(ctx context.Context) {
if err := saprcb.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,88 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"schisandra-album-cloud-microservices/common/ent/predicate"
"schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthPermissionRuleDelete is the builder for deleting a ScaAuthPermissionRule entity.
type ScaAuthPermissionRuleDelete struct {
config
hooks []Hook
mutation *ScaAuthPermissionRuleMutation
}
// Where appends a list predicates to the ScaAuthPermissionRuleDelete builder.
func (saprd *ScaAuthPermissionRuleDelete) Where(ps ...predicate.ScaAuthPermissionRule) *ScaAuthPermissionRuleDelete {
saprd.mutation.Where(ps...)
return saprd
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (saprd *ScaAuthPermissionRuleDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, saprd.sqlExec, saprd.mutation, saprd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (saprd *ScaAuthPermissionRuleDelete) ExecX(ctx context.Context) int {
n, err := saprd.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (saprd *ScaAuthPermissionRuleDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(scaauthpermissionrule.Table, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64))
if ps := saprd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, saprd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
saprd.mutation.done = true
return affected, err
}
// ScaAuthPermissionRuleDeleteOne is the builder for deleting a single ScaAuthPermissionRule entity.
type ScaAuthPermissionRuleDeleteOne struct {
saprd *ScaAuthPermissionRuleDelete
}
// Where appends a list predicates to the ScaAuthPermissionRuleDelete builder.
func (saprdo *ScaAuthPermissionRuleDeleteOne) Where(ps ...predicate.ScaAuthPermissionRule) *ScaAuthPermissionRuleDeleteOne {
saprdo.saprd.mutation.Where(ps...)
return saprdo
}
// Exec executes the deletion query.
func (saprdo *ScaAuthPermissionRuleDeleteOne) Exec(ctx context.Context) error {
n, err := saprdo.saprd.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{scaauthpermissionrule.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (saprdo *ScaAuthPermissionRuleDeleteOne) ExecX(ctx context.Context) {
if err := saprdo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,614 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"schisandra-album-cloud-microservices/common/ent/predicate"
"schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule"
"schisandra-album-cloud-microservices/common/ent/scaauthrole"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// 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
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the ScaAuthPermissionRuleQuery builder.
func (saprq *ScaAuthPermissionRuleQuery) Where(ps ...predicate.ScaAuthPermissionRule) *ScaAuthPermissionRuleQuery {
saprq.predicates = append(saprq.predicates, ps...)
return saprq
}
// Limit the number of records to be returned by this query.
func (saprq *ScaAuthPermissionRuleQuery) Limit(limit int) *ScaAuthPermissionRuleQuery {
saprq.ctx.Limit = &limit
return saprq
}
// Offset to start from.
func (saprq *ScaAuthPermissionRuleQuery) Offset(offset int) *ScaAuthPermissionRuleQuery {
saprq.ctx.Offset = &offset
return saprq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (saprq *ScaAuthPermissionRuleQuery) Unique(unique bool) *ScaAuthPermissionRuleQuery {
saprq.ctx.Unique = &unique
return saprq
}
// Order specifies how the records should be ordered.
func (saprq *ScaAuthPermissionRuleQuery) Order(o ...scaauthpermissionrule.OrderOption) *ScaAuthPermissionRuleQuery {
saprq.order = append(saprq.order, o...)
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) {
nodes, err := saprq.Limit(1).All(setContextOp(ctx, saprq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{scaauthpermissionrule.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (saprq *ScaAuthPermissionRuleQuery) FirstX(ctx context.Context) *ScaAuthPermissionRule {
node, err := saprq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// 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
if ids, err = saprq.Limit(1).IDs(setContextOp(ctx, saprq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{scaauthpermissionrule.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (saprq *ScaAuthPermissionRuleQuery) FirstIDX(ctx context.Context) int64 {
id, err := saprq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single ScaAuthPermissionRule entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ScaAuthPermissionRule entity is found.
// Returns a *NotFoundError when no ScaAuthPermissionRule entities are found.
func (saprq *ScaAuthPermissionRuleQuery) Only(ctx context.Context) (*ScaAuthPermissionRule, error) {
nodes, err := saprq.Limit(2).All(setContextOp(ctx, saprq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{scaauthpermissionrule.Label}
default:
return nil, &NotSingularError{scaauthpermissionrule.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (saprq *ScaAuthPermissionRuleQuery) OnlyX(ctx context.Context) *ScaAuthPermissionRule {
node, err := saprq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// 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
if ids, err = saprq.Limit(2).IDs(setContextOp(ctx, saprq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{scaauthpermissionrule.Label}
default:
err = &NotSingularError{scaauthpermissionrule.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (saprq *ScaAuthPermissionRuleQuery) OnlyIDX(ctx context.Context) int64 {
id, err := saprq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of ScaAuthPermissionRules.
func (saprq *ScaAuthPermissionRuleQuery) All(ctx context.Context) ([]*ScaAuthPermissionRule, error) {
ctx = setContextOp(ctx, saprq.ctx, ent.OpQueryAll)
if err := saprq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ScaAuthPermissionRule, *ScaAuthPermissionRuleQuery]()
return withInterceptors[[]*ScaAuthPermissionRule](ctx, saprq, qr, saprq.inters)
}
// AllX is like All, but panics if an error occurs.
func (saprq *ScaAuthPermissionRuleQuery) AllX(ctx context.Context) []*ScaAuthPermissionRule {
nodes, err := saprq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of ScaAuthPermissionRule IDs.
func (saprq *ScaAuthPermissionRuleQuery) IDs(ctx context.Context) (ids []int64, err error) {
if saprq.ctx.Unique == nil && saprq.path != nil {
saprq.Unique(true)
}
ctx = setContextOp(ctx, saprq.ctx, ent.OpQueryIDs)
if err = saprq.Select(scaauthpermissionrule.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (saprq *ScaAuthPermissionRuleQuery) IDsX(ctx context.Context) []int64 {
ids, err := saprq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (saprq *ScaAuthPermissionRuleQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, saprq.ctx, ent.OpQueryCount)
if err := saprq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, saprq, querierCount[*ScaAuthPermissionRuleQuery](), saprq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (saprq *ScaAuthPermissionRuleQuery) CountX(ctx context.Context) int {
count, err := saprq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (saprq *ScaAuthPermissionRuleQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, saprq.ctx, ent.OpQueryExist)
switch _, err := saprq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (saprq *ScaAuthPermissionRuleQuery) ExistX(ctx context.Context) bool {
exist, err := saprq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the ScaAuthPermissionRuleQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (saprq *ScaAuthPermissionRuleQuery) Clone() *ScaAuthPermissionRuleQuery {
if saprq == nil {
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(),
// 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.
//
// Example:
//
// var v []struct {
// Ptype string `json:"ptype,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ScaAuthPermissionRule.Query().
// GroupBy(scaauthpermissionrule.FieldPtype).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (saprq *ScaAuthPermissionRuleQuery) GroupBy(field string, fields ...string) *ScaAuthPermissionRuleGroupBy {
saprq.ctx.Fields = append([]string{field}, fields...)
grbuild := &ScaAuthPermissionRuleGroupBy{build: saprq}
grbuild.flds = &saprq.ctx.Fields
grbuild.label = scaauthpermissionrule.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// Ptype string `json:"ptype,omitempty"`
// }
//
// client.ScaAuthPermissionRule.Query().
// Select(scaauthpermissionrule.FieldPtype).
// Scan(ctx, &v)
func (saprq *ScaAuthPermissionRuleQuery) Select(fields ...string) *ScaAuthPermissionRuleSelect {
saprq.ctx.Fields = append(saprq.ctx.Fields, fields...)
sbuild := &ScaAuthPermissionRuleSelect{ScaAuthPermissionRuleQuery: saprq}
sbuild.label = scaauthpermissionrule.Label
sbuild.flds, sbuild.scan = &saprq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ScaAuthPermissionRuleSelect configured with the given aggregations.
func (saprq *ScaAuthPermissionRuleQuery) Aggregate(fns ...AggregateFunc) *ScaAuthPermissionRuleSelect {
return saprq.Select().Aggregate(fns...)
}
func (saprq *ScaAuthPermissionRuleQuery) prepareQuery(ctx context.Context) error {
for _, inter := range saprq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, saprq); err != nil {
return err
}
}
}
for _, f := range saprq.ctx.Fields {
if !scaauthpermissionrule.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if saprq.path != nil {
prev, err := saprq.path(ctx)
if err != nil {
return err
}
saprq.sql = prev
}
return nil
}
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,
}
)
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 {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, saprq.driver, _spec); err != nil {
return nil, err
}
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
if len(saprq.ctx.Fields) > 0 {
_spec.Unique = saprq.ctx.Unique != nil && *saprq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, saprq.driver, _spec)
}
func (saprq *ScaAuthPermissionRuleQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64))
_spec.From = saprq.sql
if unique := saprq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if saprq.path != nil {
_spec.Unique = true
}
if fields := saprq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthpermissionrule.FieldID)
for i := range fields {
if fields[i] != scaauthpermissionrule.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := saprq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := saprq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := saprq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := saprq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (saprq *ScaAuthPermissionRuleQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(saprq.driver.Dialect())
t1 := builder.Table(scaauthpermissionrule.Table)
columns := saprq.ctx.Fields
if len(columns) == 0 {
columns = scaauthpermissionrule.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if saprq.sql != nil {
selector = saprq.sql
selector.Select(selector.Columns(columns...)...)
}
if saprq.ctx.Unique != nil && *saprq.ctx.Unique {
selector.Distinct()
}
for _, p := range saprq.predicates {
p(selector)
}
for _, p := range saprq.order {
p(selector)
}
if offset := saprq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := saprq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ScaAuthPermissionRuleGroupBy is the group-by builder for ScaAuthPermissionRule entities.
type ScaAuthPermissionRuleGroupBy struct {
selector
build *ScaAuthPermissionRuleQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (saprgb *ScaAuthPermissionRuleGroupBy) Aggregate(fns ...AggregateFunc) *ScaAuthPermissionRuleGroupBy {
saprgb.fns = append(saprgb.fns, fns...)
return saprgb
}
// Scan applies the selector query and scans the result into the given value.
func (saprgb *ScaAuthPermissionRuleGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, saprgb.build.ctx, ent.OpQueryGroupBy)
if err := saprgb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthPermissionRuleQuery, *ScaAuthPermissionRuleGroupBy](ctx, saprgb.build, saprgb, saprgb.build.inters, v)
}
func (saprgb *ScaAuthPermissionRuleGroupBy) sqlScan(ctx context.Context, root *ScaAuthPermissionRuleQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(saprgb.fns))
for _, fn := range saprgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*saprgb.flds)+len(saprgb.fns))
for _, f := range *saprgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*saprgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := saprgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// ScaAuthPermissionRuleSelect is the builder for selecting fields of ScaAuthPermissionRule entities.
type ScaAuthPermissionRuleSelect struct {
*ScaAuthPermissionRuleQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (saprs *ScaAuthPermissionRuleSelect) Aggregate(fns ...AggregateFunc) *ScaAuthPermissionRuleSelect {
saprs.fns = append(saprs.fns, fns...)
return saprs
}
// Scan applies the selector query and scans the result into the given value.
func (saprs *ScaAuthPermissionRuleSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, saprs.ctx, ent.OpQuerySelect)
if err := saprs.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthPermissionRuleQuery, *ScaAuthPermissionRuleSelect](ctx, saprs.ScaAuthPermissionRuleQuery, saprs, saprs.inters, v)
}
func (saprs *ScaAuthPermissionRuleSelect) sqlScan(ctx context.Context, root *ScaAuthPermissionRuleQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(saprs.fns))
for _, fn := range saprs.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*saprs.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := saprs.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

View File

@@ -1,680 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/common/ent/predicate"
"schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule"
"schisandra-album-cloud-microservices/common/ent/scaauthrole"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthPermissionRuleUpdate is the builder for updating ScaAuthPermissionRule entities.
type ScaAuthPermissionRuleUpdate struct {
config
hooks []Hook
mutation *ScaAuthPermissionRuleMutation
}
// Where appends a list predicates to the ScaAuthPermissionRuleUpdate builder.
func (sapru *ScaAuthPermissionRuleUpdate) Where(ps ...predicate.ScaAuthPermissionRule) *ScaAuthPermissionRuleUpdate {
sapru.mutation.Where(ps...)
return sapru
}
// SetPtype sets the "ptype" field.
func (sapru *ScaAuthPermissionRuleUpdate) SetPtype(s string) *ScaAuthPermissionRuleUpdate {
sapru.mutation.SetPtype(s)
return sapru
}
// SetNillablePtype sets the "ptype" field if the given value is not nil.
func (sapru *ScaAuthPermissionRuleUpdate) SetNillablePtype(s *string) *ScaAuthPermissionRuleUpdate {
if s != nil {
sapru.SetPtype(*s)
}
return sapru
}
// SetV0 sets the "v0" field.
func (sapru *ScaAuthPermissionRuleUpdate) SetV0(s string) *ScaAuthPermissionRuleUpdate {
sapru.mutation.SetV0(s)
return sapru
}
// SetNillableV0 sets the "v0" field if the given value is not nil.
func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV0(s *string) *ScaAuthPermissionRuleUpdate {
if s != nil {
sapru.SetV0(*s)
}
return sapru
}
// SetV1 sets the "v1" field.
func (sapru *ScaAuthPermissionRuleUpdate) SetV1(s string) *ScaAuthPermissionRuleUpdate {
sapru.mutation.SetV1(s)
return sapru
}
// SetNillableV1 sets the "v1" field if the given value is not nil.
func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV1(s *string) *ScaAuthPermissionRuleUpdate {
if s != nil {
sapru.SetV1(*s)
}
return sapru
}
// SetV2 sets the "v2" field.
func (sapru *ScaAuthPermissionRuleUpdate) SetV2(s string) *ScaAuthPermissionRuleUpdate {
sapru.mutation.SetV2(s)
return sapru
}
// SetNillableV2 sets the "v2" field if the given value is not nil.
func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV2(s *string) *ScaAuthPermissionRuleUpdate {
if s != nil {
sapru.SetV2(*s)
}
return sapru
}
// ClearV2 clears the value of the "v2" field.
func (sapru *ScaAuthPermissionRuleUpdate) ClearV2() *ScaAuthPermissionRuleUpdate {
sapru.mutation.ClearV2()
return sapru
}
// SetV3 sets the "v3" field.
func (sapru *ScaAuthPermissionRuleUpdate) SetV3(s string) *ScaAuthPermissionRuleUpdate {
sapru.mutation.SetV3(s)
return sapru
}
// SetNillableV3 sets the "v3" field if the given value is not nil.
func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV3(s *string) *ScaAuthPermissionRuleUpdate {
if s != nil {
sapru.SetV3(*s)
}
return sapru
}
// ClearV3 clears the value of the "v3" field.
func (sapru *ScaAuthPermissionRuleUpdate) ClearV3() *ScaAuthPermissionRuleUpdate {
sapru.mutation.ClearV3()
return sapru
}
// SetV4 sets the "v4" field.
func (sapru *ScaAuthPermissionRuleUpdate) SetV4(s string) *ScaAuthPermissionRuleUpdate {
sapru.mutation.SetV4(s)
return sapru
}
// SetNillableV4 sets the "v4" field if the given value is not nil.
func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV4(s *string) *ScaAuthPermissionRuleUpdate {
if s != nil {
sapru.SetV4(*s)
}
return sapru
}
// ClearV4 clears the value of the "v4" field.
func (sapru *ScaAuthPermissionRuleUpdate) ClearV4() *ScaAuthPermissionRuleUpdate {
sapru.mutation.ClearV4()
return sapru
}
// SetV5 sets the "v5" field.
func (sapru *ScaAuthPermissionRuleUpdate) SetV5(s string) *ScaAuthPermissionRuleUpdate {
sapru.mutation.SetV5(s)
return sapru
}
// SetNillableV5 sets the "v5" field if the given value is not nil.
func (sapru *ScaAuthPermissionRuleUpdate) SetNillableV5(s *string) *ScaAuthPermissionRuleUpdate {
if s != nil {
sapru.SetV5(*s)
}
return sapru
}
// ClearV5 clears the value of the "v5" field.
func (sapru *ScaAuthPermissionRuleUpdate) ClearV5() *ScaAuthPermissionRuleUpdate {
sapru.mutation.ClearV5()
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)
}
// SaveX is like Save, but panics if an error occurs.
func (sapru *ScaAuthPermissionRuleUpdate) SaveX(ctx context.Context) int {
affected, err := sapru.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (sapru *ScaAuthPermissionRuleUpdate) Exec(ctx context.Context) error {
_, err := sapru.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sapru *ScaAuthPermissionRuleUpdate) ExecX(ctx context.Context) {
if err := sapru.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (sapru *ScaAuthPermissionRuleUpdate) check() error {
if v, ok := sapru.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 v, ok := sapru.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 v, ok := sapru.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)}
}
}
if v, ok := sapru.mutation.V2(); ok {
if err := scaauthpermissionrule.V2Validator(v); err != nil {
return &ValidationError{Name: "v2", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v2": %w`, err)}
}
}
if v, ok := sapru.mutation.V3(); ok {
if err := scaauthpermissionrule.V3Validator(v); err != nil {
return &ValidationError{Name: "v3", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v3": %w`, err)}
}
}
if v, ok := sapru.mutation.V4(); ok {
if err := scaauthpermissionrule.V4Validator(v); err != nil {
return &ValidationError{Name: "v4", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v4": %w`, err)}
}
}
if v, ok := sapru.mutation.V5(); ok {
if err := scaauthpermissionrule.V5Validator(v); err != nil {
return &ValidationError{Name: "v5", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v5": %w`, err)}
}
}
return nil
}
func (sapru *ScaAuthPermissionRuleUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := sapru.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64))
if ps := sapru.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := sapru.mutation.Ptype(); ok {
_spec.SetField(scaauthpermissionrule.FieldPtype, field.TypeString, value)
}
if value, ok := sapru.mutation.V0(); ok {
_spec.SetField(scaauthpermissionrule.FieldV0, field.TypeString, value)
}
if value, ok := sapru.mutation.V1(); ok {
_spec.SetField(scaauthpermissionrule.FieldV1, field.TypeString, value)
}
if value, ok := sapru.mutation.V2(); ok {
_spec.SetField(scaauthpermissionrule.FieldV2, field.TypeString, value)
}
if sapru.mutation.V2Cleared() {
_spec.ClearField(scaauthpermissionrule.FieldV2, field.TypeString)
}
if value, ok := sapru.mutation.V3(); ok {
_spec.SetField(scaauthpermissionrule.FieldV3, field.TypeString, value)
}
if sapru.mutation.V3Cleared() {
_spec.ClearField(scaauthpermissionrule.FieldV3, field.TypeString)
}
if value, ok := sapru.mutation.V4(); ok {
_spec.SetField(scaauthpermissionrule.FieldV4, field.TypeString, value)
}
if sapru.mutation.V4Cleared() {
_spec.ClearField(scaauthpermissionrule.FieldV4, field.TypeString)
}
if value, ok := sapru.mutation.V5(); ok {
_spec.SetField(scaauthpermissionrule.FieldV5, field.TypeString, value)
}
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}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
sapru.mutation.done = true
return n, nil
}
// ScaAuthPermissionRuleUpdateOne is the builder for updating a single ScaAuthPermissionRule entity.
type ScaAuthPermissionRuleUpdateOne struct {
config
fields []string
hooks []Hook
mutation *ScaAuthPermissionRuleMutation
}
// SetPtype sets the "ptype" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetPtype(s string) *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.SetPtype(s)
return sapruo
}
// SetNillablePtype sets the "ptype" field if the given value is not nil.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillablePtype(s *string) *ScaAuthPermissionRuleUpdateOne {
if s != nil {
sapruo.SetPtype(*s)
}
return sapruo
}
// SetV0 sets the "v0" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV0(s string) *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.SetV0(s)
return sapruo
}
// SetNillableV0 sets the "v0" field if the given value is not nil.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV0(s *string) *ScaAuthPermissionRuleUpdateOne {
if s != nil {
sapruo.SetV0(*s)
}
return sapruo
}
// SetV1 sets the "v1" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV1(s string) *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.SetV1(s)
return sapruo
}
// SetNillableV1 sets the "v1" field if the given value is not nil.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV1(s *string) *ScaAuthPermissionRuleUpdateOne {
if s != nil {
sapruo.SetV1(*s)
}
return sapruo
}
// SetV2 sets the "v2" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV2(s string) *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.SetV2(s)
return sapruo
}
// SetNillableV2 sets the "v2" field if the given value is not nil.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV2(s *string) *ScaAuthPermissionRuleUpdateOne {
if s != nil {
sapruo.SetV2(*s)
}
return sapruo
}
// ClearV2 clears the value of the "v2" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV2() *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.ClearV2()
return sapruo
}
// SetV3 sets the "v3" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV3(s string) *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.SetV3(s)
return sapruo
}
// SetNillableV3 sets the "v3" field if the given value is not nil.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV3(s *string) *ScaAuthPermissionRuleUpdateOne {
if s != nil {
sapruo.SetV3(*s)
}
return sapruo
}
// ClearV3 clears the value of the "v3" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV3() *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.ClearV3()
return sapruo
}
// SetV4 sets the "v4" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV4(s string) *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.SetV4(s)
return sapruo
}
// SetNillableV4 sets the "v4" field if the given value is not nil.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV4(s *string) *ScaAuthPermissionRuleUpdateOne {
if s != nil {
sapruo.SetV4(*s)
}
return sapruo
}
// ClearV4 clears the value of the "v4" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV4() *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.ClearV4()
return sapruo
}
// SetV5 sets the "v5" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetV5(s string) *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.SetV5(s)
return sapruo
}
// SetNillableV5 sets the "v5" field if the given value is not nil.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SetNillableV5(s *string) *ScaAuthPermissionRuleUpdateOne {
if s != nil {
sapruo.SetV5(*s)
}
return sapruo
}
// ClearV5 clears the value of the "v5" field.
func (sapruo *ScaAuthPermissionRuleUpdateOne) ClearV5() *ScaAuthPermissionRuleUpdateOne {
sapruo.mutation.ClearV5()
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...)
return sapruo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (sapruo *ScaAuthPermissionRuleUpdateOne) Select(field string, fields ...string) *ScaAuthPermissionRuleUpdateOne {
sapruo.fields = append([]string{field}, fields...)
return sapruo
}
// Save executes the query and returns the updated ScaAuthPermissionRule entity.
func (sapruo *ScaAuthPermissionRuleUpdateOne) Save(ctx context.Context) (*ScaAuthPermissionRule, error) {
return withHooks(ctx, sapruo.sqlSave, sapruo.mutation, sapruo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (sapruo *ScaAuthPermissionRuleUpdateOne) SaveX(ctx context.Context) *ScaAuthPermissionRule {
node, err := sapruo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (sapruo *ScaAuthPermissionRuleUpdateOne) Exec(ctx context.Context) error {
_, err := sapruo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sapruo *ScaAuthPermissionRuleUpdateOne) ExecX(ctx context.Context) {
if err := sapruo.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (sapruo *ScaAuthPermissionRuleUpdateOne) check() error {
if v, ok := sapruo.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 v, ok := sapruo.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 v, ok := sapruo.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)}
}
}
if v, ok := sapruo.mutation.V2(); ok {
if err := scaauthpermissionrule.V2Validator(v); err != nil {
return &ValidationError{Name: "v2", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v2": %w`, err)}
}
}
if v, ok := sapruo.mutation.V3(); ok {
if err := scaauthpermissionrule.V3Validator(v); err != nil {
return &ValidationError{Name: "v3", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v3": %w`, err)}
}
}
if v, ok := sapruo.mutation.V4(); ok {
if err := scaauthpermissionrule.V4Validator(v); err != nil {
return &ValidationError{Name: "v4", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v4": %w`, err)}
}
}
if v, ok := sapruo.mutation.V5(); ok {
if err := scaauthpermissionrule.V5Validator(v); err != nil {
return &ValidationError{Name: "v5", err: fmt.Errorf(`ent: validator failed for field "ScaAuthPermissionRule.v5": %w`, err)}
}
}
return nil
}
func (sapruo *ScaAuthPermissionRuleUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthPermissionRule, err error) {
if err := sapruo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(scaauthpermissionrule.Table, scaauthpermissionrule.Columns, sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64))
id, ok := sapruo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaAuthPermissionRule.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := sapruo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthpermissionrule.FieldID)
for _, f := range fields {
if !scaauthpermissionrule.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != scaauthpermissionrule.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := sapruo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := sapruo.mutation.Ptype(); ok {
_spec.SetField(scaauthpermissionrule.FieldPtype, field.TypeString, value)
}
if value, ok := sapruo.mutation.V0(); ok {
_spec.SetField(scaauthpermissionrule.FieldV0, field.TypeString, value)
}
if value, ok := sapruo.mutation.V1(); ok {
_spec.SetField(scaauthpermissionrule.FieldV1, field.TypeString, value)
}
if value, ok := sapruo.mutation.V2(); ok {
_spec.SetField(scaauthpermissionrule.FieldV2, field.TypeString, value)
}
if sapruo.mutation.V2Cleared() {
_spec.ClearField(scaauthpermissionrule.FieldV2, field.TypeString)
}
if value, ok := sapruo.mutation.V3(); ok {
_spec.SetField(scaauthpermissionrule.FieldV3, field.TypeString, value)
}
if sapruo.mutation.V3Cleared() {
_spec.ClearField(scaauthpermissionrule.FieldV3, field.TypeString)
}
if value, ok := sapruo.mutation.V4(); ok {
_spec.SetField(scaauthpermissionrule.FieldV4, field.TypeString, value)
}
if sapruo.mutation.V4Cleared() {
_spec.ClearField(scaauthpermissionrule.FieldV4, field.TypeString)
}
if value, ok := sapruo.mutation.V5(); ok {
_spec.SetField(scaauthpermissionrule.FieldV5, field.TypeString, value)
}
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
if err = sqlgraph.UpdateNode(ctx, sapruo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scaauthpermissionrule.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
sapruo.mutation.done = true
return _node, nil
}

View File

@@ -1,177 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"schisandra-album-cloud-microservices/common/ent/scaauthrole"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// 角色表
type ScaAuthRole struct {
config `json:"-"`
// ID of the ent.
// 主键ID
ID int64 `json:"id,omitempty"`
// 创建时间
CreatedAt time.Time `json:"created_at,omitempty"`
// 更新时间
UpdatedAt time.Time `json:"updated_at,omitempty"`
// 是否删除 0 未删除 1 已删除
Deleted int8 `json:"deleted,omitempty"`
// 角色名称
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"`
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))
for i := range columns {
switch columns[i] {
case scaauthrole.FieldID, scaauthrole.FieldDeleted:
values[i] = new(sql.NullInt64)
case scaauthrole.FieldRoleName, scaauthrole.FieldRoleKey:
values[i] = new(sql.NullString)
case scaauthrole.FieldCreatedAt, scaauthrole.FieldUpdatedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ScaAuthRole fields.
func (sar *ScaAuthRole) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case scaauthrole.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
sar.ID = int64(value.Int64)
case scaauthrole.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
sar.CreatedAt = value.Time
}
case scaauthrole.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
sar.UpdatedAt = value.Time
}
case scaauthrole.FieldDeleted:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field deleted", values[i])
} else if value.Valid {
sar.Deleted = int8(value.Int64)
}
case scaauthrole.FieldRoleName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field role_name", values[i])
} else if value.Valid {
sar.RoleName = value.String
}
case scaauthrole.FieldRoleKey:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field role_key", values[i])
} else if value.Valid {
sar.RoleKey = value.String
}
default:
sar.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ScaAuthRole.
// This includes values selected through modifiers, order, etc.
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.
func (sar *ScaAuthRole) Update() *ScaAuthRoleUpdateOne {
return NewScaAuthRoleClient(sar.config).UpdateOne(sar)
}
// Unwrap unwraps the ScaAuthRole entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (sar *ScaAuthRole) Unwrap() *ScaAuthRole {
_tx, ok := sar.config.driver.(*txDriver)
if !ok {
panic("ent: ScaAuthRole is not a transactional entity")
}
sar.config.driver = _tx.drv
return sar
}
// String implements the fmt.Stringer.
func (sar *ScaAuthRole) String() string {
var builder strings.Builder
builder.WriteString("ScaAuthRole(")
builder.WriteString(fmt.Sprintf("id=%v, ", sar.ID))
builder.WriteString("created_at=")
builder.WriteString(sar.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(sar.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("deleted=")
builder.WriteString(fmt.Sprintf("%v", sar.Deleted))
builder.WriteString(", ")
builder.WriteString("role_name=")
builder.WriteString(sar.RoleName)
builder.WriteString(", ")
builder.WriteString("role_key=")
builder.WriteString(sar.RoleKey)
builder.WriteByte(')')
return builder.String()
}
// ScaAuthRoles is a parsable slice of ScaAuthRole.
type ScaAuthRoles []*ScaAuthRole

View File

@@ -1,129 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scaauthrole
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the scaauthrole type in the database.
Label = "sca_auth_role"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldDeleted holds the string denoting the deleted field in the database.
FieldDeleted = "deleted"
// FieldRoleName holds the string denoting the role_name field in the database.
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.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldDeleted,
FieldRoleName,
FieldRoleKey,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
DefaultUpdatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
// DefaultDeleted holds the default value on creation for the "deleted" field.
DefaultDeleted int8
// DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
DeletedValidator func(int8) error
// RoleNameValidator is a validator for the "role_name" field. It is called by the builders before save.
RoleNameValidator func(string) error
// RoleKeyValidator is a validator for the "role_key" field. It is called by the builders before save.
RoleKeyValidator func(string) error
)
// OrderOption defines the ordering options for the ScaAuthRole queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByDeleted orders the results by the deleted field.
func ByDeleted(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeleted, opts...).ToFunc()
}
// ByRoleName orders the results by the role_name field.
func ByRoleName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRoleName, opts...).ToFunc()
}
// ByRoleKey orders the results by the role_key field.
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),
)
}

View File

@@ -1,379 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scaauthrole
import (
"schisandra-album-cloud-microservices/common/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLTE(FieldID, id))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldCreatedAt, v))
}
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldUpdatedAt, v))
}
// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ.
func Deleted(v int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldDeleted, v))
}
// RoleName applies equality check predicate on the "role_name" field. It's identical to RoleNameEQ.
func RoleName(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldRoleName, v))
}
// RoleKey applies equality check predicate on the "role_key" field. It's identical to RoleKeyEQ.
func RoleKey(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldRoleKey, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLTE(FieldCreatedAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLTE(FieldUpdatedAt, v))
}
// DeletedEQ applies the EQ predicate on the "deleted" field.
func DeletedEQ(v int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldDeleted, v))
}
// DeletedNEQ applies the NEQ predicate on the "deleted" field.
func DeletedNEQ(v int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNEQ(FieldDeleted, v))
}
// DeletedIn applies the In predicate on the "deleted" field.
func DeletedIn(vs ...int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldIn(FieldDeleted, vs...))
}
// DeletedNotIn applies the NotIn predicate on the "deleted" field.
func DeletedNotIn(vs ...int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNotIn(FieldDeleted, vs...))
}
// DeletedGT applies the GT predicate on the "deleted" field.
func DeletedGT(v int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGT(FieldDeleted, v))
}
// DeletedGTE applies the GTE predicate on the "deleted" field.
func DeletedGTE(v int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGTE(FieldDeleted, v))
}
// DeletedLT applies the LT predicate on the "deleted" field.
func DeletedLT(v int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLT(FieldDeleted, v))
}
// DeletedLTE applies the LTE predicate on the "deleted" field.
func DeletedLTE(v int8) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLTE(FieldDeleted, v))
}
// DeletedIsNil applies the IsNil predicate on the "deleted" field.
func DeletedIsNil() predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldIsNull(FieldDeleted))
}
// DeletedNotNil applies the NotNil predicate on the "deleted" field.
func DeletedNotNil() predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNotNull(FieldDeleted))
}
// RoleNameEQ applies the EQ predicate on the "role_name" field.
func RoleNameEQ(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldRoleName, v))
}
// RoleNameNEQ applies the NEQ predicate on the "role_name" field.
func RoleNameNEQ(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNEQ(FieldRoleName, v))
}
// RoleNameIn applies the In predicate on the "role_name" field.
func RoleNameIn(vs ...string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldIn(FieldRoleName, vs...))
}
// RoleNameNotIn applies the NotIn predicate on the "role_name" field.
func RoleNameNotIn(vs ...string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNotIn(FieldRoleName, vs...))
}
// RoleNameGT applies the GT predicate on the "role_name" field.
func RoleNameGT(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGT(FieldRoleName, v))
}
// RoleNameGTE applies the GTE predicate on the "role_name" field.
func RoleNameGTE(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGTE(FieldRoleName, v))
}
// RoleNameLT applies the LT predicate on the "role_name" field.
func RoleNameLT(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLT(FieldRoleName, v))
}
// RoleNameLTE applies the LTE predicate on the "role_name" field.
func RoleNameLTE(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLTE(FieldRoleName, v))
}
// RoleNameContains applies the Contains predicate on the "role_name" field.
func RoleNameContains(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldContains(FieldRoleName, v))
}
// RoleNameHasPrefix applies the HasPrefix predicate on the "role_name" field.
func RoleNameHasPrefix(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldHasPrefix(FieldRoleName, v))
}
// RoleNameHasSuffix applies the HasSuffix predicate on the "role_name" field.
func RoleNameHasSuffix(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldHasSuffix(FieldRoleName, v))
}
// RoleNameEqualFold applies the EqualFold predicate on the "role_name" field.
func RoleNameEqualFold(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEqualFold(FieldRoleName, v))
}
// RoleNameContainsFold applies the ContainsFold predicate on the "role_name" field.
func RoleNameContainsFold(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldContainsFold(FieldRoleName, v))
}
// RoleKeyEQ applies the EQ predicate on the "role_key" field.
func RoleKeyEQ(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEQ(FieldRoleKey, v))
}
// RoleKeyNEQ applies the NEQ predicate on the "role_key" field.
func RoleKeyNEQ(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNEQ(FieldRoleKey, v))
}
// RoleKeyIn applies the In predicate on the "role_key" field.
func RoleKeyIn(vs ...string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldIn(FieldRoleKey, vs...))
}
// RoleKeyNotIn applies the NotIn predicate on the "role_key" field.
func RoleKeyNotIn(vs ...string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldNotIn(FieldRoleKey, vs...))
}
// RoleKeyGT applies the GT predicate on the "role_key" field.
func RoleKeyGT(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGT(FieldRoleKey, v))
}
// RoleKeyGTE applies the GTE predicate on the "role_key" field.
func RoleKeyGTE(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldGTE(FieldRoleKey, v))
}
// RoleKeyLT applies the LT predicate on the "role_key" field.
func RoleKeyLT(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLT(FieldRoleKey, v))
}
// RoleKeyLTE applies the LTE predicate on the "role_key" field.
func RoleKeyLTE(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldLTE(FieldRoleKey, v))
}
// RoleKeyContains applies the Contains predicate on the "role_key" field.
func RoleKeyContains(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldContains(FieldRoleKey, v))
}
// RoleKeyHasPrefix applies the HasPrefix predicate on the "role_key" field.
func RoleKeyHasPrefix(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldHasPrefix(FieldRoleKey, v))
}
// RoleKeyHasSuffix applies the HasSuffix predicate on the "role_key" field.
func RoleKeyHasSuffix(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldHasSuffix(FieldRoleKey, v))
}
// RoleKeyEqualFold applies the EqualFold predicate on the "role_key" field.
func RoleKeyEqualFold(v string) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.FieldEqualFold(FieldRoleKey, v))
}
// RoleKeyContainsFold applies the ContainsFold predicate on the "role_key" field.
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...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.ScaAuthRole) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.ScaAuthRole) predicate.ScaAuthRole {
return predicate.ScaAuthRole(sql.NotPredicates(p))
}

View File

@@ -1,334 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule"
"schisandra-album-cloud-microservices/common/ent/scaauthrole"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthRoleCreate is the builder for creating a ScaAuthRole entity.
type ScaAuthRoleCreate struct {
config
mutation *ScaAuthRoleMutation
hooks []Hook
}
// SetCreatedAt sets the "created_at" field.
func (sarc *ScaAuthRoleCreate) SetCreatedAt(t time.Time) *ScaAuthRoleCreate {
sarc.mutation.SetCreatedAt(t)
return sarc
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (sarc *ScaAuthRoleCreate) SetNillableCreatedAt(t *time.Time) *ScaAuthRoleCreate {
if t != nil {
sarc.SetCreatedAt(*t)
}
return sarc
}
// SetUpdatedAt sets the "updated_at" field.
func (sarc *ScaAuthRoleCreate) SetUpdatedAt(t time.Time) *ScaAuthRoleCreate {
sarc.mutation.SetUpdatedAt(t)
return sarc
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (sarc *ScaAuthRoleCreate) SetNillableUpdatedAt(t *time.Time) *ScaAuthRoleCreate {
if t != nil {
sarc.SetUpdatedAt(*t)
}
return sarc
}
// SetDeleted sets the "deleted" field.
func (sarc *ScaAuthRoleCreate) SetDeleted(i int8) *ScaAuthRoleCreate {
sarc.mutation.SetDeleted(i)
return sarc
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (sarc *ScaAuthRoleCreate) SetNillableDeleted(i *int8) *ScaAuthRoleCreate {
if i != nil {
sarc.SetDeleted(*i)
}
return sarc
}
// SetRoleName sets the "role_name" field.
func (sarc *ScaAuthRoleCreate) SetRoleName(s string) *ScaAuthRoleCreate {
sarc.mutation.SetRoleName(s)
return sarc
}
// SetRoleKey sets the "role_key" field.
func (sarc *ScaAuthRoleCreate) SetRoleKey(s string) *ScaAuthRoleCreate {
sarc.mutation.SetRoleKey(s)
return sarc
}
// SetID sets the "id" field.
func (sarc *ScaAuthRoleCreate) SetID(i int64) *ScaAuthRoleCreate {
sarc.mutation.SetID(i)
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
}
// Save creates the ScaAuthRole in the database.
func (sarc *ScaAuthRoleCreate) Save(ctx context.Context) (*ScaAuthRole, error) {
sarc.defaults()
return withHooks(ctx, sarc.sqlSave, sarc.mutation, sarc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (sarc *ScaAuthRoleCreate) SaveX(ctx context.Context) *ScaAuthRole {
v, err := sarc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sarc *ScaAuthRoleCreate) Exec(ctx context.Context) error {
_, err := sarc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sarc *ScaAuthRoleCreate) ExecX(ctx context.Context) {
if err := sarc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (sarc *ScaAuthRoleCreate) defaults() {
if _, ok := sarc.mutation.CreatedAt(); !ok {
v := scaauthrole.DefaultCreatedAt()
sarc.mutation.SetCreatedAt(v)
}
if _, ok := sarc.mutation.UpdatedAt(); !ok {
v := scaauthrole.DefaultUpdatedAt()
sarc.mutation.SetUpdatedAt(v)
}
if _, ok := sarc.mutation.Deleted(); !ok {
v := scaauthrole.DefaultDeleted
sarc.mutation.SetDeleted(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (sarc *ScaAuthRoleCreate) check() error {
if _, ok := sarc.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ScaAuthRole.created_at"`)}
}
if _, ok := sarc.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ScaAuthRole.updated_at"`)}
}
if v, ok := sarc.mutation.Deleted(); ok {
if err := scaauthrole.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.deleted": %w`, err)}
}
}
if _, ok := sarc.mutation.RoleName(); !ok {
return &ValidationError{Name: "role_name", err: errors.New(`ent: missing required field "ScaAuthRole.role_name"`)}
}
if v, ok := sarc.mutation.RoleName(); ok {
if err := scaauthrole.RoleNameValidator(v); err != nil {
return &ValidationError{Name: "role_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_name": %w`, err)}
}
}
if _, ok := sarc.mutation.RoleKey(); !ok {
return &ValidationError{Name: "role_key", err: errors.New(`ent: missing required field "ScaAuthRole.role_key"`)}
}
if v, ok := sarc.mutation.RoleKey(); ok {
if err := scaauthrole.RoleKeyValidator(v); err != nil {
return &ValidationError{Name: "role_key", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_key": %w`, err)}
}
}
return nil
}
func (sarc *ScaAuthRoleCreate) sqlSave(ctx context.Context) (*ScaAuthRole, error) {
if err := sarc.check(); err != nil {
return nil, err
}
_node, _spec := sarc.createSpec()
if err := sqlgraph.CreateNode(ctx, sarc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
}
sarc.mutation.id = &_node.ID
sarc.mutation.done = true
return _node, nil
}
func (sarc *ScaAuthRoleCreate) createSpec() (*ScaAuthRole, *sqlgraph.CreateSpec) {
var (
_node = &ScaAuthRole{config: sarc.config}
_spec = sqlgraph.NewCreateSpec(scaauthrole.Table, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64))
)
if id, ok := sarc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := sarc.mutation.CreatedAt(); ok {
_spec.SetField(scaauthrole.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := sarc.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthrole.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := sarc.mutation.Deleted(); ok {
_spec.SetField(scaauthrole.FieldDeleted, field.TypeInt8, value)
_node.Deleted = value
}
if value, ok := sarc.mutation.RoleName(); ok {
_spec.SetField(scaauthrole.FieldRoleName, field.TypeString, value)
_node.RoleName = value
}
if value, ok := sarc.mutation.RoleKey(); ok {
_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
}
// ScaAuthRoleCreateBulk is the builder for creating many ScaAuthRole entities in bulk.
type ScaAuthRoleCreateBulk struct {
config
err error
builders []*ScaAuthRoleCreate
}
// Save creates the ScaAuthRole entities in the database.
func (sarcb *ScaAuthRoleCreateBulk) Save(ctx context.Context) ([]*ScaAuthRole, error) {
if sarcb.err != nil {
return nil, sarcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(sarcb.builders))
nodes := make([]*ScaAuthRole, len(sarcb.builders))
mutators := make([]Mutator, len(sarcb.builders))
for i := range sarcb.builders {
func(i int, root context.Context) {
builder := sarcb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ScaAuthRoleMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, sarcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, sarcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, sarcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (sarcb *ScaAuthRoleCreateBulk) SaveX(ctx context.Context) []*ScaAuthRole {
v, err := sarcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sarcb *ScaAuthRoleCreateBulk) Exec(ctx context.Context) error {
_, err := sarcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sarcb *ScaAuthRoleCreateBulk) ExecX(ctx context.Context) {
if err := sarcb.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,88 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"schisandra-album-cloud-microservices/common/ent/predicate"
"schisandra-album-cloud-microservices/common/ent/scaauthrole"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthRoleDelete is the builder for deleting a ScaAuthRole entity.
type ScaAuthRoleDelete struct {
config
hooks []Hook
mutation *ScaAuthRoleMutation
}
// Where appends a list predicates to the ScaAuthRoleDelete builder.
func (sard *ScaAuthRoleDelete) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleDelete {
sard.mutation.Where(ps...)
return sard
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (sard *ScaAuthRoleDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, sard.sqlExec, sard.mutation, sard.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (sard *ScaAuthRoleDelete) ExecX(ctx context.Context) int {
n, err := sard.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (sard *ScaAuthRoleDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(scaauthrole.Table, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64))
if ps := sard.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, sard.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
sard.mutation.done = true
return affected, err
}
// ScaAuthRoleDeleteOne is the builder for deleting a single ScaAuthRole entity.
type ScaAuthRoleDeleteOne struct {
sard *ScaAuthRoleDelete
}
// Where appends a list predicates to the ScaAuthRoleDelete builder.
func (sardo *ScaAuthRoleDeleteOne) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleDeleteOne {
sardo.sard.mutation.Where(ps...)
return sardo
}
// Exec executes the deletion query.
func (sardo *ScaAuthRoleDeleteOne) Exec(ctx context.Context) error {
n, err := sardo.sard.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{scaauthrole.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (sardo *ScaAuthRoleDeleteOne) ExecX(ctx context.Context) {
if err := sardo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,609 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"database/sql/driver"
"fmt"
"math"
"schisandra-album-cloud-microservices/common/ent/predicate"
"schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule"
"schisandra-album-cloud-microservices/common/ent/scaauthrole"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthRoleQuery is the builder for querying ScaAuthRole entities.
type ScaAuthRoleQuery struct {
config
ctx *QueryContext
order []scaauthrole.OrderOption
inters []Interceptor
predicates []predicate.ScaAuthRole
withScaAuthPermissionRule *ScaAuthPermissionRuleQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the ScaAuthRoleQuery builder.
func (sarq *ScaAuthRoleQuery) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleQuery {
sarq.predicates = append(sarq.predicates, ps...)
return sarq
}
// Limit the number of records to be returned by this query.
func (sarq *ScaAuthRoleQuery) Limit(limit int) *ScaAuthRoleQuery {
sarq.ctx.Limit = &limit
return sarq
}
// Offset to start from.
func (sarq *ScaAuthRoleQuery) Offset(offset int) *ScaAuthRoleQuery {
sarq.ctx.Offset = &offset
return sarq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (sarq *ScaAuthRoleQuery) Unique(unique bool) *ScaAuthRoleQuery {
sarq.ctx.Unique = &unique
return sarq
}
// Order specifies how the records should be ordered.
func (sarq *ScaAuthRoleQuery) Order(o ...scaauthrole.OrderOption) *ScaAuthRoleQuery {
sarq.order = append(sarq.order, o...)
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) {
nodes, err := sarq.Limit(1).All(setContextOp(ctx, sarq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{scaauthrole.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (sarq *ScaAuthRoleQuery) FirstX(ctx context.Context) *ScaAuthRole {
node, err := sarq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first ScaAuthRole ID from the query.
// Returns a *NotFoundError when no ScaAuthRole ID was found.
func (sarq *ScaAuthRoleQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = sarq.Limit(1).IDs(setContextOp(ctx, sarq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{scaauthrole.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (sarq *ScaAuthRoleQuery) FirstIDX(ctx context.Context) int64 {
id, err := sarq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single ScaAuthRole entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ScaAuthRole entity is found.
// Returns a *NotFoundError when no ScaAuthRole entities are found.
func (sarq *ScaAuthRoleQuery) Only(ctx context.Context) (*ScaAuthRole, error) {
nodes, err := sarq.Limit(2).All(setContextOp(ctx, sarq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{scaauthrole.Label}
default:
return nil, &NotSingularError{scaauthrole.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (sarq *ScaAuthRoleQuery) OnlyX(ctx context.Context) *ScaAuthRole {
node, err := sarq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only ScaAuthRole ID in the query.
// Returns a *NotSingularError when more than one ScaAuthRole ID is found.
// Returns a *NotFoundError when no entities are found.
func (sarq *ScaAuthRoleQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = sarq.Limit(2).IDs(setContextOp(ctx, sarq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{scaauthrole.Label}
default:
err = &NotSingularError{scaauthrole.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (sarq *ScaAuthRoleQuery) OnlyIDX(ctx context.Context) int64 {
id, err := sarq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of ScaAuthRoles.
func (sarq *ScaAuthRoleQuery) All(ctx context.Context) ([]*ScaAuthRole, error) {
ctx = setContextOp(ctx, sarq.ctx, ent.OpQueryAll)
if err := sarq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ScaAuthRole, *ScaAuthRoleQuery]()
return withInterceptors[[]*ScaAuthRole](ctx, sarq, qr, sarq.inters)
}
// AllX is like All, but panics if an error occurs.
func (sarq *ScaAuthRoleQuery) AllX(ctx context.Context) []*ScaAuthRole {
nodes, err := sarq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of ScaAuthRole IDs.
func (sarq *ScaAuthRoleQuery) IDs(ctx context.Context) (ids []int64, err error) {
if sarq.ctx.Unique == nil && sarq.path != nil {
sarq.Unique(true)
}
ctx = setContextOp(ctx, sarq.ctx, ent.OpQueryIDs)
if err = sarq.Select(scaauthrole.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (sarq *ScaAuthRoleQuery) IDsX(ctx context.Context) []int64 {
ids, err := sarq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (sarq *ScaAuthRoleQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, sarq.ctx, ent.OpQueryCount)
if err := sarq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, sarq, querierCount[*ScaAuthRoleQuery](), sarq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (sarq *ScaAuthRoleQuery) CountX(ctx context.Context) int {
count, err := sarq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (sarq *ScaAuthRoleQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, sarq.ctx, ent.OpQueryExist)
switch _, err := sarq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (sarq *ScaAuthRoleQuery) ExistX(ctx context.Context) bool {
exist, err := sarq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the ScaAuthRoleQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (sarq *ScaAuthRoleQuery) Clone() *ScaAuthRoleQuery {
if sarq == nil {
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(),
// 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.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ScaAuthRole.Query().
// GroupBy(scaauthrole.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (sarq *ScaAuthRoleQuery) GroupBy(field string, fields ...string) *ScaAuthRoleGroupBy {
sarq.ctx.Fields = append([]string{field}, fields...)
grbuild := &ScaAuthRoleGroupBy{build: sarq}
grbuild.flds = &sarq.ctx.Fields
grbuild.label = scaauthrole.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.ScaAuthRole.Query().
// Select(scaauthrole.FieldCreatedAt).
// Scan(ctx, &v)
func (sarq *ScaAuthRoleQuery) Select(fields ...string) *ScaAuthRoleSelect {
sarq.ctx.Fields = append(sarq.ctx.Fields, fields...)
sbuild := &ScaAuthRoleSelect{ScaAuthRoleQuery: sarq}
sbuild.label = scaauthrole.Label
sbuild.flds, sbuild.scan = &sarq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ScaAuthRoleSelect configured with the given aggregations.
func (sarq *ScaAuthRoleQuery) Aggregate(fns ...AggregateFunc) *ScaAuthRoleSelect {
return sarq.Select().Aggregate(fns...)
}
func (sarq *ScaAuthRoleQuery) prepareQuery(ctx context.Context) error {
for _, inter := range sarq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, sarq); err != nil {
return err
}
}
}
for _, f := range sarq.ctx.Fields {
if !scaauthrole.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if sarq.path != nil {
prev, err := sarq.path(ctx)
if err != nil {
return err
}
sarq.sql = prev
}
return nil
}
func (sarq *ScaAuthRoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ScaAuthRole, error) {
var (
nodes = []*ScaAuthRole{}
_spec = sarq.querySpec()
loadedTypes = [1]bool{
sarq.withScaAuthPermissionRule != nil,
}
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*ScaAuthRole).scanValues(nil, columns)
}
_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 {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, sarq.driver, _spec); err != nil {
return nil, err
}
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
if len(sarq.ctx.Fields) > 0 {
_spec.Unique = sarq.ctx.Unique != nil && *sarq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, sarq.driver, _spec)
}
func (sarq *ScaAuthRoleQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(scaauthrole.Table, scaauthrole.Columns, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64))
_spec.From = sarq.sql
if unique := sarq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if sarq.path != nil {
_spec.Unique = true
}
if fields := sarq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthrole.FieldID)
for i := range fields {
if fields[i] != scaauthrole.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := sarq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := sarq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := sarq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := sarq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (sarq *ScaAuthRoleQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(sarq.driver.Dialect())
t1 := builder.Table(scaauthrole.Table)
columns := sarq.ctx.Fields
if len(columns) == 0 {
columns = scaauthrole.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if sarq.sql != nil {
selector = sarq.sql
selector.Select(selector.Columns(columns...)...)
}
if sarq.ctx.Unique != nil && *sarq.ctx.Unique {
selector.Distinct()
}
for _, p := range sarq.predicates {
p(selector)
}
for _, p := range sarq.order {
p(selector)
}
if offset := sarq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := sarq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ScaAuthRoleGroupBy is the group-by builder for ScaAuthRole entities.
type ScaAuthRoleGroupBy struct {
selector
build *ScaAuthRoleQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (sargb *ScaAuthRoleGroupBy) Aggregate(fns ...AggregateFunc) *ScaAuthRoleGroupBy {
sargb.fns = append(sargb.fns, fns...)
return sargb
}
// Scan applies the selector query and scans the result into the given value.
func (sargb *ScaAuthRoleGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, sargb.build.ctx, ent.OpQueryGroupBy)
if err := sargb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthRoleQuery, *ScaAuthRoleGroupBy](ctx, sargb.build, sargb, sargb.build.inters, v)
}
func (sargb *ScaAuthRoleGroupBy) sqlScan(ctx context.Context, root *ScaAuthRoleQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(sargb.fns))
for _, fn := range sargb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*sargb.flds)+len(sargb.fns))
for _, f := range *sargb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*sargb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := sargb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// ScaAuthRoleSelect is the builder for selecting fields of ScaAuthRole entities.
type ScaAuthRoleSelect struct {
*ScaAuthRoleQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (sars *ScaAuthRoleSelect) Aggregate(fns ...AggregateFunc) *ScaAuthRoleSelect {
sars.fns = append(sars.fns, fns...)
return sars
}
// Scan applies the selector query and scans the result into the given value.
func (sars *ScaAuthRoleSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, sars.ctx, ent.OpQuerySelect)
if err := sars.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthRoleQuery, *ScaAuthRoleSelect](ctx, sars.ScaAuthRoleQuery, sars, sars.inters, v)
}
func (sars *ScaAuthRoleSelect) sqlScan(ctx context.Context, root *ScaAuthRoleQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(sars.fns))
for _, fn := range sars.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*sars.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := sars.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

View File

@@ -1,561 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/common/ent/predicate"
"schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule"
"schisandra-album-cloud-microservices/common/ent/scaauthrole"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthRoleUpdate is the builder for updating ScaAuthRole entities.
type ScaAuthRoleUpdate struct {
config
hooks []Hook
mutation *ScaAuthRoleMutation
}
// Where appends a list predicates to the ScaAuthRoleUpdate builder.
func (saru *ScaAuthRoleUpdate) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleUpdate {
saru.mutation.Where(ps...)
return saru
}
// SetUpdatedAt sets the "updated_at" field.
func (saru *ScaAuthRoleUpdate) SetUpdatedAt(t time.Time) *ScaAuthRoleUpdate {
saru.mutation.SetUpdatedAt(t)
return saru
}
// SetDeleted sets the "deleted" field.
func (saru *ScaAuthRoleUpdate) SetDeleted(i int8) *ScaAuthRoleUpdate {
saru.mutation.ResetDeleted()
saru.mutation.SetDeleted(i)
return saru
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (saru *ScaAuthRoleUpdate) SetNillableDeleted(i *int8) *ScaAuthRoleUpdate {
if i != nil {
saru.SetDeleted(*i)
}
return saru
}
// AddDeleted adds i to the "deleted" field.
func (saru *ScaAuthRoleUpdate) AddDeleted(i int8) *ScaAuthRoleUpdate {
saru.mutation.AddDeleted(i)
return saru
}
// ClearDeleted clears the value of the "deleted" field.
func (saru *ScaAuthRoleUpdate) ClearDeleted() *ScaAuthRoleUpdate {
saru.mutation.ClearDeleted()
return saru
}
// SetRoleName sets the "role_name" field.
func (saru *ScaAuthRoleUpdate) SetRoleName(s string) *ScaAuthRoleUpdate {
saru.mutation.SetRoleName(s)
return saru
}
// SetNillableRoleName sets the "role_name" field if the given value is not nil.
func (saru *ScaAuthRoleUpdate) SetNillableRoleName(s *string) *ScaAuthRoleUpdate {
if s != nil {
saru.SetRoleName(*s)
}
return saru
}
// SetRoleKey sets the "role_key" field.
func (saru *ScaAuthRoleUpdate) SetRoleKey(s string) *ScaAuthRoleUpdate {
saru.mutation.SetRoleKey(s)
return saru
}
// SetNillableRoleKey sets the "role_key" field if the given value is not nil.
func (saru *ScaAuthRoleUpdate) SetNillableRoleKey(s *string) *ScaAuthRoleUpdate {
if s != nil {
saru.SetRoleKey(*s)
}
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()
return withHooks(ctx, saru.sqlSave, saru.mutation, saru.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (saru *ScaAuthRoleUpdate) SaveX(ctx context.Context) int {
affected, err := saru.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (saru *ScaAuthRoleUpdate) Exec(ctx context.Context) error {
_, err := saru.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (saru *ScaAuthRoleUpdate) ExecX(ctx context.Context) {
if err := saru.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (saru *ScaAuthRoleUpdate) defaults() {
if _, ok := saru.mutation.UpdatedAt(); !ok {
v := scaauthrole.UpdateDefaultUpdatedAt()
saru.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (saru *ScaAuthRoleUpdate) check() error {
if v, ok := saru.mutation.Deleted(); ok {
if err := scaauthrole.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.deleted": %w`, err)}
}
}
if v, ok := saru.mutation.RoleName(); ok {
if err := scaauthrole.RoleNameValidator(v); err != nil {
return &ValidationError{Name: "role_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_name": %w`, err)}
}
}
if v, ok := saru.mutation.RoleKey(); ok {
if err := scaauthrole.RoleKeyValidator(v); err != nil {
return &ValidationError{Name: "role_key", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_key": %w`, err)}
}
}
return nil
}
func (saru *ScaAuthRoleUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := saru.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(scaauthrole.Table, scaauthrole.Columns, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64))
if ps := saru.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := saru.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthrole.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := saru.mutation.Deleted(); ok {
_spec.SetField(scaauthrole.FieldDeleted, field.TypeInt8, value)
}
if value, ok := saru.mutation.AddedDeleted(); ok {
_spec.AddField(scaauthrole.FieldDeleted, field.TypeInt8, value)
}
if saru.mutation.DeletedCleared() {
_spec.ClearField(scaauthrole.FieldDeleted, field.TypeInt8)
}
if value, ok := saru.mutation.RoleName(); ok {
_spec.SetField(scaauthrole.FieldRoleName, field.TypeString, value)
}
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}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
saru.mutation.done = true
return n, nil
}
// ScaAuthRoleUpdateOne is the builder for updating a single ScaAuthRole entity.
type ScaAuthRoleUpdateOne struct {
config
fields []string
hooks []Hook
mutation *ScaAuthRoleMutation
}
// SetUpdatedAt sets the "updated_at" field.
func (saruo *ScaAuthRoleUpdateOne) SetUpdatedAt(t time.Time) *ScaAuthRoleUpdateOne {
saruo.mutation.SetUpdatedAt(t)
return saruo
}
// SetDeleted sets the "deleted" field.
func (saruo *ScaAuthRoleUpdateOne) SetDeleted(i int8) *ScaAuthRoleUpdateOne {
saruo.mutation.ResetDeleted()
saruo.mutation.SetDeleted(i)
return saruo
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (saruo *ScaAuthRoleUpdateOne) SetNillableDeleted(i *int8) *ScaAuthRoleUpdateOne {
if i != nil {
saruo.SetDeleted(*i)
}
return saruo
}
// AddDeleted adds i to the "deleted" field.
func (saruo *ScaAuthRoleUpdateOne) AddDeleted(i int8) *ScaAuthRoleUpdateOne {
saruo.mutation.AddDeleted(i)
return saruo
}
// ClearDeleted clears the value of the "deleted" field.
func (saruo *ScaAuthRoleUpdateOne) ClearDeleted() *ScaAuthRoleUpdateOne {
saruo.mutation.ClearDeleted()
return saruo
}
// SetRoleName sets the "role_name" field.
func (saruo *ScaAuthRoleUpdateOne) SetRoleName(s string) *ScaAuthRoleUpdateOne {
saruo.mutation.SetRoleName(s)
return saruo
}
// SetNillableRoleName sets the "role_name" field if the given value is not nil.
func (saruo *ScaAuthRoleUpdateOne) SetNillableRoleName(s *string) *ScaAuthRoleUpdateOne {
if s != nil {
saruo.SetRoleName(*s)
}
return saruo
}
// SetRoleKey sets the "role_key" field.
func (saruo *ScaAuthRoleUpdateOne) SetRoleKey(s string) *ScaAuthRoleUpdateOne {
saruo.mutation.SetRoleKey(s)
return saruo
}
// SetNillableRoleKey sets the "role_key" field if the given value is not nil.
func (saruo *ScaAuthRoleUpdateOne) SetNillableRoleKey(s *string) *ScaAuthRoleUpdateOne {
if s != nil {
saruo.SetRoleKey(*s)
}
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...)
return saruo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (saruo *ScaAuthRoleUpdateOne) Select(field string, fields ...string) *ScaAuthRoleUpdateOne {
saruo.fields = append([]string{field}, fields...)
return saruo
}
// Save executes the query and returns the updated ScaAuthRole entity.
func (saruo *ScaAuthRoleUpdateOne) Save(ctx context.Context) (*ScaAuthRole, error) {
saruo.defaults()
return withHooks(ctx, saruo.sqlSave, saruo.mutation, saruo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (saruo *ScaAuthRoleUpdateOne) SaveX(ctx context.Context) *ScaAuthRole {
node, err := saruo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (saruo *ScaAuthRoleUpdateOne) Exec(ctx context.Context) error {
_, err := saruo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (saruo *ScaAuthRoleUpdateOne) ExecX(ctx context.Context) {
if err := saruo.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (saruo *ScaAuthRoleUpdateOne) defaults() {
if _, ok := saruo.mutation.UpdatedAt(); !ok {
v := scaauthrole.UpdateDefaultUpdatedAt()
saruo.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (saruo *ScaAuthRoleUpdateOne) check() error {
if v, ok := saruo.mutation.Deleted(); ok {
if err := scaauthrole.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.deleted": %w`, err)}
}
}
if v, ok := saruo.mutation.RoleName(); ok {
if err := scaauthrole.RoleNameValidator(v); err != nil {
return &ValidationError{Name: "role_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_name": %w`, err)}
}
}
if v, ok := saruo.mutation.RoleKey(); ok {
if err := scaauthrole.RoleKeyValidator(v); err != nil {
return &ValidationError{Name: "role_key", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_key": %w`, err)}
}
}
return nil
}
func (saruo *ScaAuthRoleUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthRole, err error) {
if err := saruo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(scaauthrole.Table, scaauthrole.Columns, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64))
id, ok := saruo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaAuthRole.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := saruo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthrole.FieldID)
for _, f := range fields {
if !scaauthrole.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != scaauthrole.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := saruo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := saruo.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthrole.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := saruo.mutation.Deleted(); ok {
_spec.SetField(scaauthrole.FieldDeleted, field.TypeInt8, value)
}
if value, ok := saruo.mutation.AddedDeleted(); ok {
_spec.AddField(scaauthrole.FieldDeleted, field.TypeInt8, value)
}
if saruo.mutation.DeletedCleared() {
_spec.ClearField(scaauthrole.FieldDeleted, field.TypeInt8)
}
if value, ok := saruo.mutation.RoleName(); ok {
_spec.SetField(scaauthrole.FieldRoleName, field.TypeString, value)
}
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
if err = sqlgraph.UpdateNode(ctx, saruo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scaauthrole.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
saruo.mutation.done = true
return _node, nil
}

View File

@@ -1,322 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"schisandra-album-cloud-microservices/common/ent/scaauthuser"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// 用户表
type ScaAuthUser struct {
config `json:"-"`
// ID of the ent.
// 自增ID
ID int64 `json:"id,omitempty"`
// 创建时间
CreatedAt time.Time `json:"created_at,omitempty"`
// 更新时间
UpdatedAt time.Time `json:"updated_at,omitempty"`
// 是否删除 0 未删除 1 已删除
Deleted int8 `json:"deleted,omitempty"`
// 唯一ID
UID string `json:"uid,omitempty"`
// 用户名
Username string `json:"username,omitempty"`
// 昵称
Nickname string `json:"nickname,omitempty"`
// 邮箱
Email string `json:"email,omitempty"`
// 电话
Phone string `json:"phone,omitempty"`
// 密码
Password string `json:"-"`
// 性别
Gender string `json:"gender,omitempty"`
// 头像
Avatar string `json:"avatar,omitempty"`
// 状态 0 正常 1 封禁
Status int8 `json:"status,omitempty"`
// 介绍
Introduce string `json:"introduce,omitempty"`
// 博客
Blog *string `json:"blog,omitempty"`
// 地址
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"`
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:
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:
values[i] = new(sql.NullString)
case scaauthuser.FieldCreatedAt, scaauthuser.FieldUpdatedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ScaAuthUser fields.
func (sau *ScaAuthUser) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case scaauthuser.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
sau.ID = int64(value.Int64)
case scaauthuser.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
sau.CreatedAt = value.Time
}
case scaauthuser.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
sau.UpdatedAt = value.Time
}
case scaauthuser.FieldDeleted:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field deleted", values[i])
} else if value.Valid {
sau.Deleted = int8(value.Int64)
}
case scaauthuser.FieldUID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field uid", values[i])
} else if value.Valid {
sau.UID = value.String
}
case scaauthuser.FieldUsername:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field username", values[i])
} else if value.Valid {
sau.Username = value.String
}
case scaauthuser.FieldNickname:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field nickname", values[i])
} else if value.Valid {
sau.Nickname = value.String
}
case scaauthuser.FieldEmail:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field email", values[i])
} else if value.Valid {
sau.Email = value.String
}
case scaauthuser.FieldPhone:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field phone", values[i])
} else if value.Valid {
sau.Phone = value.String
}
case scaauthuser.FieldPassword:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field password", values[i])
} else if value.Valid {
sau.Password = value.String
}
case scaauthuser.FieldGender:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field gender", values[i])
} else if value.Valid {
sau.Gender = value.String
}
case scaauthuser.FieldAvatar:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field avatar", values[i])
} else if value.Valid {
sau.Avatar = value.String
}
case scaauthuser.FieldStatus:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
sau.Status = int8(value.Int64)
}
case scaauthuser.FieldIntroduce:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field introduce", values[i])
} else if value.Valid {
sau.Introduce = value.String
}
case scaauthuser.FieldBlog:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field blog", values[i])
} else if value.Valid {
sau.Blog = new(string)
*sau.Blog = value.String
}
case scaauthuser.FieldLocation:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field location", values[i])
} else if value.Valid {
sau.Location = new(string)
*sau.Location = value.String
}
case scaauthuser.FieldCompany:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field company", values[i])
} else if value.Valid {
sau.Company = new(string)
*sau.Company = value.String
}
default:
sau.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ScaAuthUser.
// This includes values selected through modifiers, order, etc.
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.
func (sau *ScaAuthUser) Update() *ScaAuthUserUpdateOne {
return NewScaAuthUserClient(sau.config).UpdateOne(sau)
}
// Unwrap unwraps the ScaAuthUser entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (sau *ScaAuthUser) Unwrap() *ScaAuthUser {
_tx, ok := sau.config.driver.(*txDriver)
if !ok {
panic("ent: ScaAuthUser is not a transactional entity")
}
sau.config.driver = _tx.drv
return sau
}
// String implements the fmt.Stringer.
func (sau *ScaAuthUser) String() string {
var builder strings.Builder
builder.WriteString("ScaAuthUser(")
builder.WriteString(fmt.Sprintf("id=%v, ", sau.ID))
builder.WriteString("created_at=")
builder.WriteString(sau.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(sau.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("deleted=")
builder.WriteString(fmt.Sprintf("%v", sau.Deleted))
builder.WriteString(", ")
builder.WriteString("uid=")
builder.WriteString(sau.UID)
builder.WriteString(", ")
builder.WriteString("username=")
builder.WriteString(sau.Username)
builder.WriteString(", ")
builder.WriteString("nickname=")
builder.WriteString(sau.Nickname)
builder.WriteString(", ")
builder.WriteString("email=")
builder.WriteString(sau.Email)
builder.WriteString(", ")
builder.WriteString("phone=")
builder.WriteString(sau.Phone)
builder.WriteString(", ")
builder.WriteString("password=<sensitive>")
builder.WriteString(", ")
builder.WriteString("gender=")
builder.WriteString(sau.Gender)
builder.WriteString(", ")
builder.WriteString("avatar=")
builder.WriteString(sau.Avatar)
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", sau.Status))
builder.WriteString(", ")
builder.WriteString("introduce=")
builder.WriteString(sau.Introduce)
builder.WriteString(", ")
if v := sau.Blog; v != nil {
builder.WriteString("blog=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := sau.Location; v != nil {
builder.WriteString("location=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := sau.Company; v != nil {
builder.WriteString("company=")
builder.WriteString(*v)
}
builder.WriteByte(')')
return builder.String()
}
// ScaAuthUsers is a parsable slice of ScaAuthUser.
type ScaAuthUsers []*ScaAuthUser

View File

@@ -1,267 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scaauthuser
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the scaauthuser type in the database.
Label = "sca_auth_user"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldDeleted holds the string denoting the deleted field in the database.
FieldDeleted = "deleted"
// FieldUID holds the string denoting the uid field in the database.
FieldUID = "uid"
// FieldUsername holds the string denoting the username field in the database.
FieldUsername = "username"
// FieldNickname holds the string denoting the nickname field in the database.
FieldNickname = "nickname"
// FieldEmail holds the string denoting the email field in the database.
FieldEmail = "email"
// FieldPhone holds the string denoting the phone field in the database.
FieldPhone = "phone"
// FieldPassword holds the string denoting the password field in the database.
FieldPassword = "password"
// FieldGender holds the string denoting the gender field in the database.
FieldGender = "gender"
// FieldAvatar holds the string denoting the avatar field in the database.
FieldAvatar = "avatar"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// FieldIntroduce holds the string denoting the introduce field in the database.
FieldIntroduce = "introduce"
// FieldBlog holds the string denoting the blog field in the database.
FieldBlog = "blog"
// FieldLocation holds the string denoting the location field in the database.
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.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldDeleted,
FieldUID,
FieldUsername,
FieldNickname,
FieldEmail,
FieldPhone,
FieldPassword,
FieldGender,
FieldAvatar,
FieldStatus,
FieldIntroduce,
FieldBlog,
FieldLocation,
FieldCompany,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
DefaultUpdatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
// DefaultDeleted holds the default value on creation for the "deleted" field.
DefaultDeleted int8
// DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
DeletedValidator func(int8) error
// UIDValidator is a validator for the "uid" field. It is called by the builders before save.
UIDValidator func(string) error
// UsernameValidator is a validator for the "username" field. It is called by the builders before save.
UsernameValidator func(string) error
// NicknameValidator is a validator for the "nickname" field. It is called by the builders before save.
NicknameValidator func(string) error
// EmailValidator is a validator for the "email" field. It is called by the builders before save.
EmailValidator func(string) error
// PhoneValidator is a validator for the "phone" field. It is called by the builders before save.
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.
IntroduceValidator func(string) error
// BlogValidator is a validator for the "blog" field. It is called by the builders before save.
BlogValidator func(string) error
// LocationValidator is a validator for the "location" field. It is called by the builders before save.
LocationValidator func(string) error
// CompanyValidator is a validator for the "company" field. It is called by the builders before save.
CompanyValidator func(string) error
)
// OrderOption defines the ordering options for the ScaAuthUser queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByDeleted orders the results by the deleted field.
func ByDeleted(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeleted, opts...).ToFunc()
}
// ByUID orders the results by the uid field.
func ByUID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUID, opts...).ToFunc()
}
// ByUsername orders the results by the username field.
func ByUsername(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUsername, opts...).ToFunc()
}
// ByNickname orders the results by the nickname field.
func ByNickname(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldNickname, opts...).ToFunc()
}
// ByEmail orders the results by the email field.
func ByEmail(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEmail, opts...).ToFunc()
}
// ByPhone orders the results by the phone field.
func ByPhone(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPhone, opts...).ToFunc()
}
// ByPassword orders the results by the password field.
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPassword, opts...).ToFunc()
}
// ByGender orders the results by the gender field.
func ByGender(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldGender, opts...).ToFunc()
}
// ByAvatar orders the results by the avatar field.
func ByAvatar(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAvatar, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
// ByIntroduce orders the results by the introduce field.
func ByIntroduce(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIntroduce, opts...).ToFunc()
}
// ByBlog orders the results by the blog field.
func ByBlog(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldBlog, opts...).ToFunc()
}
// ByLocation orders the results by the location field.
func ByLocation(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLocation, opts...).ToFunc()
}
// ByCompany orders the results by the company field.
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),
)
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,618 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/common/ent/scaauthuser"
"schisandra-album-cloud-microservices/common/ent/scaauthuserdevice"
"schisandra-album-cloud-microservices/common/ent/scaauthusersocial"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserCreate is the builder for creating a ScaAuthUser entity.
type ScaAuthUserCreate struct {
config
mutation *ScaAuthUserMutation
hooks []Hook
}
// SetCreatedAt sets the "created_at" field.
func (sauc *ScaAuthUserCreate) SetCreatedAt(t time.Time) *ScaAuthUserCreate {
sauc.mutation.SetCreatedAt(t)
return sauc
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableCreatedAt(t *time.Time) *ScaAuthUserCreate {
if t != nil {
sauc.SetCreatedAt(*t)
}
return sauc
}
// SetUpdatedAt sets the "updated_at" field.
func (sauc *ScaAuthUserCreate) SetUpdatedAt(t time.Time) *ScaAuthUserCreate {
sauc.mutation.SetUpdatedAt(t)
return sauc
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableUpdatedAt(t *time.Time) *ScaAuthUserCreate {
if t != nil {
sauc.SetUpdatedAt(*t)
}
return sauc
}
// SetDeleted sets the "deleted" field.
func (sauc *ScaAuthUserCreate) SetDeleted(i int8) *ScaAuthUserCreate {
sauc.mutation.SetDeleted(i)
return sauc
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableDeleted(i *int8) *ScaAuthUserCreate {
if i != nil {
sauc.SetDeleted(*i)
}
return sauc
}
// SetUID sets the "uid" field.
func (sauc *ScaAuthUserCreate) SetUID(s string) *ScaAuthUserCreate {
sauc.mutation.SetUID(s)
return sauc
}
// SetUsername sets the "username" field.
func (sauc *ScaAuthUserCreate) SetUsername(s string) *ScaAuthUserCreate {
sauc.mutation.SetUsername(s)
return sauc
}
// SetNillableUsername sets the "username" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableUsername(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetUsername(*s)
}
return sauc
}
// SetNickname sets the "nickname" field.
func (sauc *ScaAuthUserCreate) SetNickname(s string) *ScaAuthUserCreate {
sauc.mutation.SetNickname(s)
return sauc
}
// SetNillableNickname sets the "nickname" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableNickname(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetNickname(*s)
}
return sauc
}
// SetEmail sets the "email" field.
func (sauc *ScaAuthUserCreate) SetEmail(s string) *ScaAuthUserCreate {
sauc.mutation.SetEmail(s)
return sauc
}
// SetNillableEmail sets the "email" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableEmail(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetEmail(*s)
}
return sauc
}
// SetPhone sets the "phone" field.
func (sauc *ScaAuthUserCreate) SetPhone(s string) *ScaAuthUserCreate {
sauc.mutation.SetPhone(s)
return sauc
}
// SetNillablePhone sets the "phone" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillablePhone(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetPhone(*s)
}
return sauc
}
// SetPassword sets the "password" field.
func (sauc *ScaAuthUserCreate) SetPassword(s string) *ScaAuthUserCreate {
sauc.mutation.SetPassword(s)
return sauc
}
// SetNillablePassword sets the "password" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillablePassword(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetPassword(*s)
}
return sauc
}
// SetGender sets the "gender" field.
func (sauc *ScaAuthUserCreate) SetGender(s string) *ScaAuthUserCreate {
sauc.mutation.SetGender(s)
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)
}
return sauc
}
// SetAvatar sets the "avatar" field.
func (sauc *ScaAuthUserCreate) SetAvatar(s string) *ScaAuthUserCreate {
sauc.mutation.SetAvatar(s)
return sauc
}
// SetNillableAvatar sets the "avatar" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableAvatar(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetAvatar(*s)
}
return sauc
}
// SetStatus sets the "status" field.
func (sauc *ScaAuthUserCreate) SetStatus(i int8) *ScaAuthUserCreate {
sauc.mutation.SetStatus(i)
return sauc
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableStatus(i *int8) *ScaAuthUserCreate {
if i != nil {
sauc.SetStatus(*i)
}
return sauc
}
// SetIntroduce sets the "introduce" field.
func (sauc *ScaAuthUserCreate) SetIntroduce(s string) *ScaAuthUserCreate {
sauc.mutation.SetIntroduce(s)
return sauc
}
// SetNillableIntroduce sets the "introduce" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableIntroduce(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetIntroduce(*s)
}
return sauc
}
// SetBlog sets the "blog" field.
func (sauc *ScaAuthUserCreate) SetBlog(s string) *ScaAuthUserCreate {
sauc.mutation.SetBlog(s)
return sauc
}
// SetNillableBlog sets the "blog" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableBlog(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetBlog(*s)
}
return sauc
}
// SetLocation sets the "location" field.
func (sauc *ScaAuthUserCreate) SetLocation(s string) *ScaAuthUserCreate {
sauc.mutation.SetLocation(s)
return sauc
}
// SetNillableLocation sets the "location" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableLocation(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetLocation(*s)
}
return sauc
}
// SetCompany sets the "company" field.
func (sauc *ScaAuthUserCreate) SetCompany(s string) *ScaAuthUserCreate {
sauc.mutation.SetCompany(s)
return sauc
}
// SetNillableCompany sets the "company" field if the given value is not nil.
func (sauc *ScaAuthUserCreate) SetNillableCompany(s *string) *ScaAuthUserCreate {
if s != nil {
sauc.SetCompany(*s)
}
return sauc
}
// SetID sets the "id" field.
func (sauc *ScaAuthUserCreate) SetID(i int64) *ScaAuthUserCreate {
sauc.mutation.SetID(i)
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
}
// Save creates the ScaAuthUser in the database.
func (sauc *ScaAuthUserCreate) Save(ctx context.Context) (*ScaAuthUser, error) {
sauc.defaults()
return withHooks(ctx, sauc.sqlSave, sauc.mutation, sauc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (sauc *ScaAuthUserCreate) SaveX(ctx context.Context) *ScaAuthUser {
v, err := sauc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sauc *ScaAuthUserCreate) Exec(ctx context.Context) error {
_, err := sauc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sauc *ScaAuthUserCreate) ExecX(ctx context.Context) {
if err := sauc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (sauc *ScaAuthUserCreate) defaults() {
if _, ok := sauc.mutation.CreatedAt(); !ok {
v := scaauthuser.DefaultCreatedAt()
sauc.mutation.SetCreatedAt(v)
}
if _, ok := sauc.mutation.UpdatedAt(); !ok {
v := scaauthuser.DefaultUpdatedAt()
sauc.mutation.SetUpdatedAt(v)
}
if _, ok := sauc.mutation.Deleted(); !ok {
v := scaauthuser.DefaultDeleted
sauc.mutation.SetDeleted(v)
}
if _, ok := sauc.mutation.Status(); !ok {
v := scaauthuser.DefaultStatus
sauc.mutation.SetStatus(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (sauc *ScaAuthUserCreate) check() error {
if _, ok := sauc.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ScaAuthUser.created_at"`)}
}
if _, ok := sauc.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ScaAuthUser.updated_at"`)}
}
if v, ok := sauc.mutation.Deleted(); ok {
if err := scaauthuser.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.deleted": %w`, err)}
}
}
if _, ok := sauc.mutation.UID(); !ok {
return &ValidationError{Name: "uid", err: errors.New(`ent: missing required field "ScaAuthUser.uid"`)}
}
if v, ok := sauc.mutation.UID(); ok {
if err := scaauthuser.UIDValidator(v); err != nil {
return &ValidationError{Name: "uid", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.uid": %w`, err)}
}
}
if v, ok := sauc.mutation.Username(); ok {
if err := scaauthuser.UsernameValidator(v); err != nil {
return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.username": %w`, err)}
}
}
if v, ok := sauc.mutation.Nickname(); ok {
if err := scaauthuser.NicknameValidator(v); err != nil {
return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.nickname": %w`, err)}
}
}
if v, ok := sauc.mutation.Email(); ok {
if err := scaauthuser.EmailValidator(v); err != nil {
return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.email": %w`, err)}
}
}
if v, ok := sauc.mutation.Phone(); ok {
if err := scaauthuser.PhoneValidator(v); err != nil {
return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.phone": %w`, err)}
}
}
if v, ok := sauc.mutation.Password(); ok {
if err := scaauthuser.PasswordValidator(v); err != nil {
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)}
}
}
if v, ok := sauc.mutation.Blog(); ok {
if err := scaauthuser.BlogValidator(v); err != nil {
return &ValidationError{Name: "blog", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.blog": %w`, err)}
}
}
if v, ok := sauc.mutation.Location(); ok {
if err := scaauthuser.LocationValidator(v); err != nil {
return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.location": %w`, err)}
}
}
if v, ok := sauc.mutation.Company(); ok {
if err := scaauthuser.CompanyValidator(v); err != nil {
return &ValidationError{Name: "company", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUser.company": %w`, err)}
}
}
return nil
}
func (sauc *ScaAuthUserCreate) sqlSave(ctx context.Context) (*ScaAuthUser, error) {
if err := sauc.check(); err != nil {
return nil, err
}
_node, _spec := sauc.createSpec()
if err := sqlgraph.CreateNode(ctx, sauc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
}
sauc.mutation.id = &_node.ID
sauc.mutation.done = true
return _node, nil
}
func (sauc *ScaAuthUserCreate) createSpec() (*ScaAuthUser, *sqlgraph.CreateSpec) {
var (
_node = &ScaAuthUser{config: sauc.config}
_spec = sqlgraph.NewCreateSpec(scaauthuser.Table, sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64))
)
if id, ok := sauc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := sauc.mutation.CreatedAt(); ok {
_spec.SetField(scaauthuser.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := sauc.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthuser.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := sauc.mutation.Deleted(); ok {
_spec.SetField(scaauthuser.FieldDeleted, field.TypeInt8, value)
_node.Deleted = value
}
if value, ok := sauc.mutation.UID(); ok {
_spec.SetField(scaauthuser.FieldUID, field.TypeString, value)
_node.UID = value
}
if value, ok := sauc.mutation.Username(); ok {
_spec.SetField(scaauthuser.FieldUsername, field.TypeString, value)
_node.Username = value
}
if value, ok := sauc.mutation.Nickname(); ok {
_spec.SetField(scaauthuser.FieldNickname, field.TypeString, value)
_node.Nickname = value
}
if value, ok := sauc.mutation.Email(); ok {
_spec.SetField(scaauthuser.FieldEmail, field.TypeString, value)
_node.Email = value
}
if value, ok := sauc.mutation.Phone(); ok {
_spec.SetField(scaauthuser.FieldPhone, field.TypeString, value)
_node.Phone = value
}
if value, ok := sauc.mutation.Password(); ok {
_spec.SetField(scaauthuser.FieldPassword, field.TypeString, value)
_node.Password = value
}
if value, ok := sauc.mutation.Gender(); ok {
_spec.SetField(scaauthuser.FieldGender, field.TypeString, value)
_node.Gender = value
}
if value, ok := sauc.mutation.Avatar(); ok {
_spec.SetField(scaauthuser.FieldAvatar, field.TypeString, value)
_node.Avatar = value
}
if value, ok := sauc.mutation.Status(); ok {
_spec.SetField(scaauthuser.FieldStatus, field.TypeInt8, value)
_node.Status = value
}
if value, ok := sauc.mutation.Introduce(); ok {
_spec.SetField(scaauthuser.FieldIntroduce, field.TypeString, value)
_node.Introduce = value
}
if value, ok := sauc.mutation.Blog(); ok {
_spec.SetField(scaauthuser.FieldBlog, field.TypeString, value)
_node.Blog = &value
}
if value, ok := sauc.mutation.Location(); ok {
_spec.SetField(scaauthuser.FieldLocation, field.TypeString, value)
_node.Location = &value
}
if value, ok := sauc.mutation.Company(); ok {
_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
}
// ScaAuthUserCreateBulk is the builder for creating many ScaAuthUser entities in bulk.
type ScaAuthUserCreateBulk struct {
config
err error
builders []*ScaAuthUserCreate
}
// Save creates the ScaAuthUser entities in the database.
func (saucb *ScaAuthUserCreateBulk) Save(ctx context.Context) ([]*ScaAuthUser, error) {
if saucb.err != nil {
return nil, saucb.err
}
specs := make([]*sqlgraph.CreateSpec, len(saucb.builders))
nodes := make([]*ScaAuthUser, len(saucb.builders))
mutators := make([]Mutator, len(saucb.builders))
for i := range saucb.builders {
func(i int, root context.Context) {
builder := saucb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ScaAuthUserMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, saucb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, saucb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, saucb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (saucb *ScaAuthUserCreateBulk) SaveX(ctx context.Context) []*ScaAuthUser {
v, err := saucb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (saucb *ScaAuthUserCreateBulk) Exec(ctx context.Context) error {
_, err := saucb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (saucb *ScaAuthUserCreateBulk) ExecX(ctx context.Context) {
if err := saucb.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,88 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"schisandra-album-cloud-microservices/common/ent/predicate"
"schisandra-album-cloud-microservices/common/ent/scaauthuser"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserDelete is the builder for deleting a ScaAuthUser entity.
type ScaAuthUserDelete struct {
config
hooks []Hook
mutation *ScaAuthUserMutation
}
// Where appends a list predicates to the ScaAuthUserDelete builder.
func (saud *ScaAuthUserDelete) Where(ps ...predicate.ScaAuthUser) *ScaAuthUserDelete {
saud.mutation.Where(ps...)
return saud
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (saud *ScaAuthUserDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, saud.sqlExec, saud.mutation, saud.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (saud *ScaAuthUserDelete) ExecX(ctx context.Context) int {
n, err := saud.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (saud *ScaAuthUserDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(scaauthuser.Table, sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64))
if ps := saud.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, saud.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
saud.mutation.done = true
return affected, err
}
// ScaAuthUserDeleteOne is the builder for deleting a single ScaAuthUser entity.
type ScaAuthUserDeleteOne struct {
saud *ScaAuthUserDelete
}
// Where appends a list predicates to the ScaAuthUserDelete builder.
func (saudo *ScaAuthUserDeleteOne) Where(ps ...predicate.ScaAuthUser) *ScaAuthUserDeleteOne {
saudo.saud.mutation.Where(ps...)
return saudo
}
// Exec executes the deletion query.
func (saudo *ScaAuthUserDeleteOne) Exec(ctx context.Context) error {
n, err := saudo.saud.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{scaauthuser.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (saudo *ScaAuthUserDeleteOne) ExecX(ctx context.Context) {
if err := saudo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,686 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"database/sql/driver"
"fmt"
"math"
"schisandra-album-cloud-microservices/common/ent/predicate"
"schisandra-album-cloud-microservices/common/ent/scaauthuser"
"schisandra-album-cloud-microservices/common/ent/scaauthuserdevice"
"schisandra-album-cloud-microservices/common/ent/scaauthusersocial"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// 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
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the ScaAuthUserQuery builder.
func (sauq *ScaAuthUserQuery) Where(ps ...predicate.ScaAuthUser) *ScaAuthUserQuery {
sauq.predicates = append(sauq.predicates, ps...)
return sauq
}
// Limit the number of records to be returned by this query.
func (sauq *ScaAuthUserQuery) Limit(limit int) *ScaAuthUserQuery {
sauq.ctx.Limit = &limit
return sauq
}
// Offset to start from.
func (sauq *ScaAuthUserQuery) Offset(offset int) *ScaAuthUserQuery {
sauq.ctx.Offset = &offset
return sauq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (sauq *ScaAuthUserQuery) Unique(unique bool) *ScaAuthUserQuery {
sauq.ctx.Unique = &unique
return sauq
}
// Order specifies how the records should be ordered.
func (sauq *ScaAuthUserQuery) Order(o ...scaauthuser.OrderOption) *ScaAuthUserQuery {
sauq.order = append(sauq.order, o...)
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) {
nodes, err := sauq.Limit(1).All(setContextOp(ctx, sauq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{scaauthuser.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (sauq *ScaAuthUserQuery) FirstX(ctx context.Context) *ScaAuthUser {
node, err := sauq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first ScaAuthUser ID from the query.
// Returns a *NotFoundError when no ScaAuthUser ID was found.
func (sauq *ScaAuthUserQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = sauq.Limit(1).IDs(setContextOp(ctx, sauq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{scaauthuser.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (sauq *ScaAuthUserQuery) FirstIDX(ctx context.Context) int64 {
id, err := sauq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single ScaAuthUser entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ScaAuthUser entity is found.
// Returns a *NotFoundError when no ScaAuthUser entities are found.
func (sauq *ScaAuthUserQuery) Only(ctx context.Context) (*ScaAuthUser, error) {
nodes, err := sauq.Limit(2).All(setContextOp(ctx, sauq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{scaauthuser.Label}
default:
return nil, &NotSingularError{scaauthuser.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (sauq *ScaAuthUserQuery) OnlyX(ctx context.Context) *ScaAuthUser {
node, err := sauq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only ScaAuthUser ID in the query.
// Returns a *NotSingularError when more than one ScaAuthUser ID is found.
// Returns a *NotFoundError when no entities are found.
func (sauq *ScaAuthUserQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = sauq.Limit(2).IDs(setContextOp(ctx, sauq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{scaauthuser.Label}
default:
err = &NotSingularError{scaauthuser.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (sauq *ScaAuthUserQuery) OnlyIDX(ctx context.Context) int64 {
id, err := sauq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of ScaAuthUsers.
func (sauq *ScaAuthUserQuery) All(ctx context.Context) ([]*ScaAuthUser, error) {
ctx = setContextOp(ctx, sauq.ctx, ent.OpQueryAll)
if err := sauq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ScaAuthUser, *ScaAuthUserQuery]()
return withInterceptors[[]*ScaAuthUser](ctx, sauq, qr, sauq.inters)
}
// AllX is like All, but panics if an error occurs.
func (sauq *ScaAuthUserQuery) AllX(ctx context.Context) []*ScaAuthUser {
nodes, err := sauq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of ScaAuthUser IDs.
func (sauq *ScaAuthUserQuery) IDs(ctx context.Context) (ids []int64, err error) {
if sauq.ctx.Unique == nil && sauq.path != nil {
sauq.Unique(true)
}
ctx = setContextOp(ctx, sauq.ctx, ent.OpQueryIDs)
if err = sauq.Select(scaauthuser.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (sauq *ScaAuthUserQuery) IDsX(ctx context.Context) []int64 {
ids, err := sauq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (sauq *ScaAuthUserQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, sauq.ctx, ent.OpQueryCount)
if err := sauq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, sauq, querierCount[*ScaAuthUserQuery](), sauq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (sauq *ScaAuthUserQuery) CountX(ctx context.Context) int {
count, err := sauq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (sauq *ScaAuthUserQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, sauq.ctx, ent.OpQueryExist)
switch _, err := sauq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (sauq *ScaAuthUserQuery) ExistX(ctx context.Context) bool {
exist, err := sauq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the ScaAuthUserQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (sauq *ScaAuthUserQuery) Clone() *ScaAuthUserQuery {
if sauq == nil {
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(),
// 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.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ScaAuthUser.Query().
// GroupBy(scaauthuser.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (sauq *ScaAuthUserQuery) GroupBy(field string, fields ...string) *ScaAuthUserGroupBy {
sauq.ctx.Fields = append([]string{field}, fields...)
grbuild := &ScaAuthUserGroupBy{build: sauq}
grbuild.flds = &sauq.ctx.Fields
grbuild.label = scaauthuser.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.ScaAuthUser.Query().
// Select(scaauthuser.FieldCreatedAt).
// Scan(ctx, &v)
func (sauq *ScaAuthUserQuery) Select(fields ...string) *ScaAuthUserSelect {
sauq.ctx.Fields = append(sauq.ctx.Fields, fields...)
sbuild := &ScaAuthUserSelect{ScaAuthUserQuery: sauq}
sbuild.label = scaauthuser.Label
sbuild.flds, sbuild.scan = &sauq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ScaAuthUserSelect configured with the given aggregations.
func (sauq *ScaAuthUserQuery) Aggregate(fns ...AggregateFunc) *ScaAuthUserSelect {
return sauq.Select().Aggregate(fns...)
}
func (sauq *ScaAuthUserQuery) prepareQuery(ctx context.Context) error {
for _, inter := range sauq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, sauq); err != nil {
return err
}
}
}
for _, f := range sauq.ctx.Fields {
if !scaauthuser.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if sauq.path != nil {
prev, err := sauq.path(ctx)
if err != nil {
return err
}
sauq.sql = prev
}
return nil
}
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,
}
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*ScaAuthUser).scanValues(nil, columns)
}
_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 {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, sauq.driver, _spec); err != nil {
return nil, err
}
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
if len(sauq.ctx.Fields) > 0 {
_spec.Unique = sauq.ctx.Unique != nil && *sauq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, sauq.driver, _spec)
}
func (sauq *ScaAuthUserQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(scaauthuser.Table, scaauthuser.Columns, sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64))
_spec.From = sauq.sql
if unique := sauq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if sauq.path != nil {
_spec.Unique = true
}
if fields := sauq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthuser.FieldID)
for i := range fields {
if fields[i] != scaauthuser.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := sauq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := sauq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := sauq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := sauq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (sauq *ScaAuthUserQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(sauq.driver.Dialect())
t1 := builder.Table(scaauthuser.Table)
columns := sauq.ctx.Fields
if len(columns) == 0 {
columns = scaauthuser.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if sauq.sql != nil {
selector = sauq.sql
selector.Select(selector.Columns(columns...)...)
}
if sauq.ctx.Unique != nil && *sauq.ctx.Unique {
selector.Distinct()
}
for _, p := range sauq.predicates {
p(selector)
}
for _, p := range sauq.order {
p(selector)
}
if offset := sauq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := sauq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ScaAuthUserGroupBy is the group-by builder for ScaAuthUser entities.
type ScaAuthUserGroupBy struct {
selector
build *ScaAuthUserQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (saugb *ScaAuthUserGroupBy) Aggregate(fns ...AggregateFunc) *ScaAuthUserGroupBy {
saugb.fns = append(saugb.fns, fns...)
return saugb
}
// Scan applies the selector query and scans the result into the given value.
func (saugb *ScaAuthUserGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, saugb.build.ctx, ent.OpQueryGroupBy)
if err := saugb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthUserQuery, *ScaAuthUserGroupBy](ctx, saugb.build, saugb, saugb.build.inters, v)
}
func (saugb *ScaAuthUserGroupBy) sqlScan(ctx context.Context, root *ScaAuthUserQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(saugb.fns))
for _, fn := range saugb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*saugb.flds)+len(saugb.fns))
for _, f := range *saugb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*saugb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := saugb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// ScaAuthUserSelect is the builder for selecting fields of ScaAuthUser entities.
type ScaAuthUserSelect struct {
*ScaAuthUserQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (saus *ScaAuthUserSelect) Aggregate(fns ...AggregateFunc) *ScaAuthUserSelect {
saus.fns = append(saus.fns, fns...)
return saus
}
// Scan applies the selector query and scans the result into the given value.
func (saus *ScaAuthUserSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, saus.ctx, ent.OpQuerySelect)
if err := saus.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthUserQuery, *ScaAuthUserSelect](ctx, saus.ScaAuthUserQuery, saus, saus.inters, v)
}
func (saus *ScaAuthUserSelect) sqlScan(ctx context.Context, root *ScaAuthUserQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(saus.fns))
for _, fn := range saus.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*saus.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := saus.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,311 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"schisandra-album-cloud-microservices/common/ent/scaauthuser"
"schisandra-album-cloud-microservices/common/ent/scaauthuserdevice"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// 用户设备表
type ScaAuthUserDevice struct {
config `json:"-"`
// ID of the ent.
// 主键ID
ID int64 `json:"id,omitempty"`
// 创建时间
CreatedAt time.Time `json:"created_at,omitempty"`
// 更新时间
UpdatedAt time.Time `json:"updated_at,omitempty"`
// 是否删除 0 未删除 1 已删除
Deleted int8 `json:"deleted,omitempty"`
// 用户ID
UserID string `json:"user_id,omitempty"`
// 登录IP
IP string `json:"ip,omitempty"`
// 地址
Location string `json:"location,omitempty"`
// 设备信息
Agent string `json:"agent,omitempty"`
// 浏览器
Browser string `json:"browser,omitempty"`
// 操作系统
OperatingSystem string `json:"operating_system,omitempty"`
// 浏览器版本
BrowserVersion string `json:"browser_version,omitempty"`
// 是否为手机 0否1是
Mobile int `json:"mobile,omitempty"`
// 是否为bot 0否1是
Bot int `json:"bot,omitempty"`
// 火狐版本
Mozilla string `json:"mozilla,omitempty"`
// 平台
Platform string `json:"platform,omitempty"`
// 引擎名称
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"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ScaAuthUserDevice) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case scaauthuserdevice.FieldID, scaauthuserdevice.FieldDeleted, scaauthuserdevice.FieldMobile, scaauthuserdevice.FieldBot:
values[i] = new(sql.NullInt64)
case scaauthuserdevice.FieldUserID, scaauthuserdevice.FieldIP, scaauthuserdevice.FieldLocation, scaauthuserdevice.FieldAgent, scaauthuserdevice.FieldBrowser, scaauthuserdevice.FieldOperatingSystem, scaauthuserdevice.FieldBrowserVersion, scaauthuserdevice.FieldMozilla, scaauthuserdevice.FieldPlatform, scaauthuserdevice.FieldEngineName, scaauthuserdevice.FieldEngineVersion:
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)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ScaAuthUserDevice fields.
func (saud *ScaAuthUserDevice) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case scaauthuserdevice.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
saud.ID = int64(value.Int64)
case scaauthuserdevice.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
saud.CreatedAt = value.Time
}
case scaauthuserdevice.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
saud.UpdatedAt = value.Time
}
case scaauthuserdevice.FieldDeleted:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field deleted", values[i])
} else if value.Valid {
saud.Deleted = int8(value.Int64)
}
case scaauthuserdevice.FieldUserID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field user_id", values[i])
} else if value.Valid {
saud.UserID = value.String
}
case scaauthuserdevice.FieldIP:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field ip", values[i])
} else if value.Valid {
saud.IP = value.String
}
case scaauthuserdevice.FieldLocation:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field location", values[i])
} else if value.Valid {
saud.Location = value.String
}
case scaauthuserdevice.FieldAgent:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field agent", values[i])
} else if value.Valid {
saud.Agent = value.String
}
case scaauthuserdevice.FieldBrowser:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field browser", values[i])
} else if value.Valid {
saud.Browser = value.String
}
case scaauthuserdevice.FieldOperatingSystem:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field operating_system", values[i])
} else if value.Valid {
saud.OperatingSystem = value.String
}
case scaauthuserdevice.FieldBrowserVersion:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field browser_version", values[i])
} else if value.Valid {
saud.BrowserVersion = value.String
}
case scaauthuserdevice.FieldMobile:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field mobile", values[i])
} else if value.Valid {
saud.Mobile = int(value.Int64)
}
case scaauthuserdevice.FieldBot:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field bot", values[i])
} else if value.Valid {
saud.Bot = int(value.Int64)
}
case scaauthuserdevice.FieldMozilla:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field mozilla", values[i])
} else if value.Valid {
saud.Mozilla = value.String
}
case scaauthuserdevice.FieldPlatform:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field platform", values[i])
} else if value.Valid {
saud.Platform = value.String
}
case scaauthuserdevice.FieldEngineName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field engine_name", values[i])
} else if value.Valid {
saud.EngineName = value.String
}
case scaauthuserdevice.FieldEngineVersion:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field engine_version", values[i])
} 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])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ScaAuthUserDevice.
// This includes values selected through modifiers, order, etc.
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.
func (saud *ScaAuthUserDevice) Update() *ScaAuthUserDeviceUpdateOne {
return NewScaAuthUserDeviceClient(saud.config).UpdateOne(saud)
}
// Unwrap unwraps the ScaAuthUserDevice entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (saud *ScaAuthUserDevice) Unwrap() *ScaAuthUserDevice {
_tx, ok := saud.config.driver.(*txDriver)
if !ok {
panic("ent: ScaAuthUserDevice is not a transactional entity")
}
saud.config.driver = _tx.drv
return saud
}
// String implements the fmt.Stringer.
func (saud *ScaAuthUserDevice) String() string {
var builder strings.Builder
builder.WriteString("ScaAuthUserDevice(")
builder.WriteString(fmt.Sprintf("id=%v, ", saud.ID))
builder.WriteString("created_at=")
builder.WriteString(saud.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(saud.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("deleted=")
builder.WriteString(fmt.Sprintf("%v", saud.Deleted))
builder.WriteString(", ")
builder.WriteString("user_id=")
builder.WriteString(saud.UserID)
builder.WriteString(", ")
builder.WriteString("ip=")
builder.WriteString(saud.IP)
builder.WriteString(", ")
builder.WriteString("location=")
builder.WriteString(saud.Location)
builder.WriteString(", ")
builder.WriteString("agent=")
builder.WriteString(saud.Agent)
builder.WriteString(", ")
builder.WriteString("browser=")
builder.WriteString(saud.Browser)
builder.WriteString(", ")
builder.WriteString("operating_system=")
builder.WriteString(saud.OperatingSystem)
builder.WriteString(", ")
builder.WriteString("browser_version=")
builder.WriteString(saud.BrowserVersion)
builder.WriteString(", ")
builder.WriteString("mobile=")
builder.WriteString(fmt.Sprintf("%v", saud.Mobile))
builder.WriteString(", ")
builder.WriteString("bot=")
builder.WriteString(fmt.Sprintf("%v", saud.Bot))
builder.WriteString(", ")
builder.WriteString("mozilla=")
builder.WriteString(saud.Mozilla)
builder.WriteString(", ")
builder.WriteString("platform=")
builder.WriteString(saud.Platform)
builder.WriteString(", ")
builder.WriteString("engine_name=")
builder.WriteString(saud.EngineName)
builder.WriteString(", ")
builder.WriteString("engine_version=")
builder.WriteString(saud.EngineVersion)
builder.WriteByte(')')
return builder.String()
}
// ScaAuthUserDevices is a parsable slice of ScaAuthUserDevice.
type ScaAuthUserDevices []*ScaAuthUserDevice

View File

@@ -1,239 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scaauthuserdevice
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the scaauthuserdevice type in the database.
Label = "sca_auth_user_device"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldDeleted holds the string denoting the deleted field in the database.
FieldDeleted = "deleted"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
// FieldIP holds the string denoting the ip field in the database.
FieldIP = "ip"
// FieldLocation holds the string denoting the location field in the database.
FieldLocation = "location"
// FieldAgent holds the string denoting the agent field in the database.
FieldAgent = "agent"
// FieldBrowser holds the string denoting the browser field in the database.
FieldBrowser = "browser"
// FieldOperatingSystem holds the string denoting the operating_system field in the database.
FieldOperatingSystem = "operating_system"
// FieldBrowserVersion holds the string denoting the browser_version field in the database.
FieldBrowserVersion = "browser_version"
// FieldMobile holds the string denoting the mobile field in the database.
FieldMobile = "mobile"
// FieldBot holds the string denoting the bot field in the database.
FieldBot = "bot"
// FieldMozilla holds the string denoting the mozilla field in the database.
FieldMozilla = "mozilla"
// FieldPlatform holds the string denoting the platform field in the database.
FieldPlatform = "platform"
// FieldEngineName holds the string denoting the engine_name field in the database.
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.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldDeleted,
FieldUserID,
FieldIP,
FieldLocation,
FieldAgent,
FieldBrowser,
FieldOperatingSystem,
FieldBrowserVersion,
FieldMobile,
FieldBot,
FieldMozilla,
FieldPlatform,
FieldEngineName,
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 {
if column == Columns[i] {
return true
}
}
for i := range ForeignKeys {
if column == ForeignKeys[i] {
return true
}
}
return false
}
var (
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
DefaultUpdatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
// DefaultDeleted holds the default value on creation for the "deleted" field.
DefaultDeleted int8
// DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
DeletedValidator func(int8) error
// UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
UserIDValidator func(string) error
// IPValidator is a validator for the "ip" field. It is called by the builders before save.
IPValidator func(string) error
// LocationValidator is a validator for the "location" field. It is called by the builders before save.
LocationValidator func(string) error
// AgentValidator is a validator for the "agent" field. It is called by the builders before save.
AgentValidator func(string) error
// BrowserValidator is a validator for the "browser" field. It is called by the builders before save.
BrowserValidator func(string) error
// OperatingSystemValidator is a validator for the "operating_system" field. It is called by the builders before save.
OperatingSystemValidator func(string) error
// BrowserVersionValidator is a validator for the "browser_version" field. It is called by the builders before save.
BrowserVersionValidator func(string) error
// MozillaValidator is a validator for the "mozilla" field. It is called by the builders before save.
MozillaValidator func(string) error
// PlatformValidator is a validator for the "platform" field. It is called by the builders before save.
PlatformValidator func(string) error
// EngineNameValidator is a validator for the "engine_name" field. It is called by the builders before save.
EngineNameValidator func(string) error
// EngineVersionValidator is a validator for the "engine_version" field. It is called by the builders before save.
EngineVersionValidator func(string) error
)
// OrderOption defines the ordering options for the ScaAuthUserDevice queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByDeleted orders the results by the deleted field.
func ByDeleted(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeleted, opts...).ToFunc()
}
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
// ByIP orders the results by the ip field.
func ByIP(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIP, opts...).ToFunc()
}
// ByLocation orders the results by the location field.
func ByLocation(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLocation, opts...).ToFunc()
}
// ByAgent orders the results by the agent field.
func ByAgent(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAgent, opts...).ToFunc()
}
// ByBrowser orders the results by the browser field.
func ByBrowser(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldBrowser, opts...).ToFunc()
}
// ByOperatingSystem orders the results by the operating_system field.
func ByOperatingSystem(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOperatingSystem, opts...).ToFunc()
}
// ByBrowserVersion orders the results by the browser_version field.
func ByBrowserVersion(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldBrowserVersion, opts...).ToFunc()
}
// ByMobile orders the results by the mobile field.
func ByMobile(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMobile, opts...).ToFunc()
}
// ByBot orders the results by the bot field.
func ByBot(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldBot, opts...).ToFunc()
}
// ByMozilla orders the results by the mozilla field.
func ByMozilla(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMozilla, opts...).ToFunc()
}
// ByPlatform orders the results by the platform field.
func ByPlatform(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPlatform, opts...).ToFunc()
}
// ByEngineName orders the results by the engine_name field.
func ByEngineName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEngineName, opts...).ToFunc()
}
// ByEngineVersion orders the results by the engine_version field.
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),
)
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,527 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/common/ent/scaauthuser"
"schisandra-album-cloud-microservices/common/ent/scaauthuserdevice"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserDeviceCreate is the builder for creating a ScaAuthUserDevice entity.
type ScaAuthUserDeviceCreate struct {
config
mutation *ScaAuthUserDeviceMutation
hooks []Hook
}
// SetCreatedAt sets the "created_at" field.
func (saudc *ScaAuthUserDeviceCreate) SetCreatedAt(t time.Time) *ScaAuthUserDeviceCreate {
saudc.mutation.SetCreatedAt(t)
return saudc
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (saudc *ScaAuthUserDeviceCreate) SetNillableCreatedAt(t *time.Time) *ScaAuthUserDeviceCreate {
if t != nil {
saudc.SetCreatedAt(*t)
}
return saudc
}
// SetUpdatedAt sets the "updated_at" field.
func (saudc *ScaAuthUserDeviceCreate) SetUpdatedAt(t time.Time) *ScaAuthUserDeviceCreate {
saudc.mutation.SetUpdatedAt(t)
return saudc
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (saudc *ScaAuthUserDeviceCreate) SetNillableUpdatedAt(t *time.Time) *ScaAuthUserDeviceCreate {
if t != nil {
saudc.SetUpdatedAt(*t)
}
return saudc
}
// SetDeleted sets the "deleted" field.
func (saudc *ScaAuthUserDeviceCreate) SetDeleted(i int8) *ScaAuthUserDeviceCreate {
saudc.mutation.SetDeleted(i)
return saudc
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (saudc *ScaAuthUserDeviceCreate) SetNillableDeleted(i *int8) *ScaAuthUserDeviceCreate {
if i != nil {
saudc.SetDeleted(*i)
}
return saudc
}
// SetUserID sets the "user_id" field.
func (saudc *ScaAuthUserDeviceCreate) SetUserID(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetUserID(s)
return saudc
}
// SetIP sets the "ip" field.
func (saudc *ScaAuthUserDeviceCreate) SetIP(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetIP(s)
return saudc
}
// SetLocation sets the "location" field.
func (saudc *ScaAuthUserDeviceCreate) SetLocation(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetLocation(s)
return saudc
}
// SetAgent sets the "agent" field.
func (saudc *ScaAuthUserDeviceCreate) SetAgent(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetAgent(s)
return saudc
}
// SetBrowser sets the "browser" field.
func (saudc *ScaAuthUserDeviceCreate) SetBrowser(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetBrowser(s)
return saudc
}
// SetOperatingSystem sets the "operating_system" field.
func (saudc *ScaAuthUserDeviceCreate) SetOperatingSystem(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetOperatingSystem(s)
return saudc
}
// SetBrowserVersion sets the "browser_version" field.
func (saudc *ScaAuthUserDeviceCreate) SetBrowserVersion(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetBrowserVersion(s)
return saudc
}
// SetMobile sets the "mobile" field.
func (saudc *ScaAuthUserDeviceCreate) SetMobile(i int) *ScaAuthUserDeviceCreate {
saudc.mutation.SetMobile(i)
return saudc
}
// SetBot sets the "bot" field.
func (saudc *ScaAuthUserDeviceCreate) SetBot(i int) *ScaAuthUserDeviceCreate {
saudc.mutation.SetBot(i)
return saudc
}
// SetMozilla sets the "mozilla" field.
func (saudc *ScaAuthUserDeviceCreate) SetMozilla(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetMozilla(s)
return saudc
}
// SetPlatform sets the "platform" field.
func (saudc *ScaAuthUserDeviceCreate) SetPlatform(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetPlatform(s)
return saudc
}
// SetEngineName sets the "engine_name" field.
func (saudc *ScaAuthUserDeviceCreate) SetEngineName(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetEngineName(s)
return saudc
}
// SetEngineVersion sets the "engine_version" field.
func (saudc *ScaAuthUserDeviceCreate) SetEngineVersion(s string) *ScaAuthUserDeviceCreate {
saudc.mutation.SetEngineVersion(s)
return saudc
}
// SetID sets the "id" field.
func (saudc *ScaAuthUserDeviceCreate) SetID(i int64) *ScaAuthUserDeviceCreate {
saudc.mutation.SetID(i)
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
}
// Save creates the ScaAuthUserDevice in the database.
func (saudc *ScaAuthUserDeviceCreate) Save(ctx context.Context) (*ScaAuthUserDevice, error) {
saudc.defaults()
return withHooks(ctx, saudc.sqlSave, saudc.mutation, saudc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (saudc *ScaAuthUserDeviceCreate) SaveX(ctx context.Context) *ScaAuthUserDevice {
v, err := saudc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (saudc *ScaAuthUserDeviceCreate) Exec(ctx context.Context) error {
_, err := saudc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (saudc *ScaAuthUserDeviceCreate) ExecX(ctx context.Context) {
if err := saudc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (saudc *ScaAuthUserDeviceCreate) defaults() {
if _, ok := saudc.mutation.CreatedAt(); !ok {
v := scaauthuserdevice.DefaultCreatedAt()
saudc.mutation.SetCreatedAt(v)
}
if _, ok := saudc.mutation.UpdatedAt(); !ok {
v := scaauthuserdevice.DefaultUpdatedAt()
saudc.mutation.SetUpdatedAt(v)
}
if _, ok := saudc.mutation.Deleted(); !ok {
v := scaauthuserdevice.DefaultDeleted
saudc.mutation.SetDeleted(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (saudc *ScaAuthUserDeviceCreate) check() error {
if _, ok := saudc.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ScaAuthUserDevice.created_at"`)}
}
if _, ok := saudc.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ScaAuthUserDevice.updated_at"`)}
}
if v, ok := saudc.mutation.Deleted(); ok {
if err := scaauthuserdevice.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.deleted": %w`, err)}
}
}
if _, ok := saudc.mutation.UserID(); !ok {
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "ScaAuthUserDevice.user_id"`)}
}
if v, ok := saudc.mutation.UserID(); ok {
if err := scaauthuserdevice.UserIDValidator(v); err != nil {
return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.user_id": %w`, err)}
}
}
if _, ok := saudc.mutation.IP(); !ok {
return &ValidationError{Name: "ip", err: errors.New(`ent: missing required field "ScaAuthUserDevice.ip"`)}
}
if v, ok := saudc.mutation.IP(); ok {
if err := scaauthuserdevice.IPValidator(v); err != nil {
return &ValidationError{Name: "ip", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.ip": %w`, err)}
}
}
if _, ok := saudc.mutation.Location(); !ok {
return &ValidationError{Name: "location", err: errors.New(`ent: missing required field "ScaAuthUserDevice.location"`)}
}
if v, ok := saudc.mutation.Location(); ok {
if err := scaauthuserdevice.LocationValidator(v); err != nil {
return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.location": %w`, err)}
}
}
if _, ok := saudc.mutation.Agent(); !ok {
return &ValidationError{Name: "agent", err: errors.New(`ent: missing required field "ScaAuthUserDevice.agent"`)}
}
if v, ok := saudc.mutation.Agent(); ok {
if err := scaauthuserdevice.AgentValidator(v); err != nil {
return &ValidationError{Name: "agent", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.agent": %w`, err)}
}
}
if _, ok := saudc.mutation.Browser(); !ok {
return &ValidationError{Name: "browser", err: errors.New(`ent: missing required field "ScaAuthUserDevice.browser"`)}
}
if v, ok := saudc.mutation.Browser(); ok {
if err := scaauthuserdevice.BrowserValidator(v); err != nil {
return &ValidationError{Name: "browser", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.browser": %w`, err)}
}
}
if _, ok := saudc.mutation.OperatingSystem(); !ok {
return &ValidationError{Name: "operating_system", err: errors.New(`ent: missing required field "ScaAuthUserDevice.operating_system"`)}
}
if v, ok := saudc.mutation.OperatingSystem(); ok {
if err := scaauthuserdevice.OperatingSystemValidator(v); err != nil {
return &ValidationError{Name: "operating_system", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.operating_system": %w`, err)}
}
}
if _, ok := saudc.mutation.BrowserVersion(); !ok {
return &ValidationError{Name: "browser_version", err: errors.New(`ent: missing required field "ScaAuthUserDevice.browser_version"`)}
}
if v, ok := saudc.mutation.BrowserVersion(); ok {
if err := scaauthuserdevice.BrowserVersionValidator(v); err != nil {
return &ValidationError{Name: "browser_version", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.browser_version": %w`, err)}
}
}
if _, ok := saudc.mutation.Mobile(); !ok {
return &ValidationError{Name: "mobile", err: errors.New(`ent: missing required field "ScaAuthUserDevice.mobile"`)}
}
if _, ok := saudc.mutation.Bot(); !ok {
return &ValidationError{Name: "bot", err: errors.New(`ent: missing required field "ScaAuthUserDevice.bot"`)}
}
if _, ok := saudc.mutation.Mozilla(); !ok {
return &ValidationError{Name: "mozilla", err: errors.New(`ent: missing required field "ScaAuthUserDevice.mozilla"`)}
}
if v, ok := saudc.mutation.Mozilla(); ok {
if err := scaauthuserdevice.MozillaValidator(v); err != nil {
return &ValidationError{Name: "mozilla", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.mozilla": %w`, err)}
}
}
if _, ok := saudc.mutation.Platform(); !ok {
return &ValidationError{Name: "platform", err: errors.New(`ent: missing required field "ScaAuthUserDevice.platform"`)}
}
if v, ok := saudc.mutation.Platform(); ok {
if err := scaauthuserdevice.PlatformValidator(v); err != nil {
return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.platform": %w`, err)}
}
}
if _, ok := saudc.mutation.EngineName(); !ok {
return &ValidationError{Name: "engine_name", err: errors.New(`ent: missing required field "ScaAuthUserDevice.engine_name"`)}
}
if v, ok := saudc.mutation.EngineName(); ok {
if err := scaauthuserdevice.EngineNameValidator(v); err != nil {
return &ValidationError{Name: "engine_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.engine_name": %w`, err)}
}
}
if _, ok := saudc.mutation.EngineVersion(); !ok {
return &ValidationError{Name: "engine_version", err: errors.New(`ent: missing required field "ScaAuthUserDevice.engine_version"`)}
}
if v, ok := saudc.mutation.EngineVersion(); ok {
if err := scaauthuserdevice.EngineVersionValidator(v); err != nil {
return &ValidationError{Name: "engine_version", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserDevice.engine_version": %w`, err)}
}
}
return nil
}
func (saudc *ScaAuthUserDeviceCreate) sqlSave(ctx context.Context) (*ScaAuthUserDevice, error) {
if err := saudc.check(); err != nil {
return nil, err
}
_node, _spec := saudc.createSpec()
if err := sqlgraph.CreateNode(ctx, saudc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
}
saudc.mutation.id = &_node.ID
saudc.mutation.done = true
return _node, nil
}
func (saudc *ScaAuthUserDeviceCreate) createSpec() (*ScaAuthUserDevice, *sqlgraph.CreateSpec) {
var (
_node = &ScaAuthUserDevice{config: saudc.config}
_spec = sqlgraph.NewCreateSpec(scaauthuserdevice.Table, sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64))
)
if id, ok := saudc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := saudc.mutation.CreatedAt(); ok {
_spec.SetField(scaauthuserdevice.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := saudc.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthuserdevice.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := saudc.mutation.Deleted(); ok {
_spec.SetField(scaauthuserdevice.FieldDeleted, field.TypeInt8, value)
_node.Deleted = value
}
if value, ok := saudc.mutation.UserID(); ok {
_spec.SetField(scaauthuserdevice.FieldUserID, field.TypeString, value)
_node.UserID = value
}
if value, ok := saudc.mutation.IP(); ok {
_spec.SetField(scaauthuserdevice.FieldIP, field.TypeString, value)
_node.IP = value
}
if value, ok := saudc.mutation.Location(); ok {
_spec.SetField(scaauthuserdevice.FieldLocation, field.TypeString, value)
_node.Location = value
}
if value, ok := saudc.mutation.Agent(); ok {
_spec.SetField(scaauthuserdevice.FieldAgent, field.TypeString, value)
_node.Agent = value
}
if value, ok := saudc.mutation.Browser(); ok {
_spec.SetField(scaauthuserdevice.FieldBrowser, field.TypeString, value)
_node.Browser = value
}
if value, ok := saudc.mutation.OperatingSystem(); ok {
_spec.SetField(scaauthuserdevice.FieldOperatingSystem, field.TypeString, value)
_node.OperatingSystem = value
}
if value, ok := saudc.mutation.BrowserVersion(); ok {
_spec.SetField(scaauthuserdevice.FieldBrowserVersion, field.TypeString, value)
_node.BrowserVersion = value
}
if value, ok := saudc.mutation.Mobile(); ok {
_spec.SetField(scaauthuserdevice.FieldMobile, field.TypeInt, value)
_node.Mobile = value
}
if value, ok := saudc.mutation.Bot(); ok {
_spec.SetField(scaauthuserdevice.FieldBot, field.TypeInt, value)
_node.Bot = value
}
if value, ok := saudc.mutation.Mozilla(); ok {
_spec.SetField(scaauthuserdevice.FieldMozilla, field.TypeString, value)
_node.Mozilla = value
}
if value, ok := saudc.mutation.Platform(); ok {
_spec.SetField(scaauthuserdevice.FieldPlatform, field.TypeString, value)
_node.Platform = value
}
if value, ok := saudc.mutation.EngineName(); ok {
_spec.SetField(scaauthuserdevice.FieldEngineName, field.TypeString, value)
_node.EngineName = value
}
if value, ok := saudc.mutation.EngineVersion(); ok {
_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
}
// ScaAuthUserDeviceCreateBulk is the builder for creating many ScaAuthUserDevice entities in bulk.
type ScaAuthUserDeviceCreateBulk struct {
config
err error
builders []*ScaAuthUserDeviceCreate
}
// Save creates the ScaAuthUserDevice entities in the database.
func (saudcb *ScaAuthUserDeviceCreateBulk) Save(ctx context.Context) ([]*ScaAuthUserDevice, error) {
if saudcb.err != nil {
return nil, saudcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(saudcb.builders))
nodes := make([]*ScaAuthUserDevice, len(saudcb.builders))
mutators := make([]Mutator, len(saudcb.builders))
for i := range saudcb.builders {
func(i int, root context.Context) {
builder := saudcb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ScaAuthUserDeviceMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, saudcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, saudcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, saudcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (saudcb *ScaAuthUserDeviceCreateBulk) SaveX(ctx context.Context) []*ScaAuthUserDevice {
v, err := saudcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (saudcb *ScaAuthUserDeviceCreateBulk) Exec(ctx context.Context) error {
_, err := saudcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (saudcb *ScaAuthUserDeviceCreateBulk) ExecX(ctx context.Context) {
if err := saudcb.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,88 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"schisandra-album-cloud-microservices/common/ent/predicate"
"schisandra-album-cloud-microservices/common/ent/scaauthuserdevice"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserDeviceDelete is the builder for deleting a ScaAuthUserDevice entity.
type ScaAuthUserDeviceDelete struct {
config
hooks []Hook
mutation *ScaAuthUserDeviceMutation
}
// Where appends a list predicates to the ScaAuthUserDeviceDelete builder.
func (saudd *ScaAuthUserDeviceDelete) Where(ps ...predicate.ScaAuthUserDevice) *ScaAuthUserDeviceDelete {
saudd.mutation.Where(ps...)
return saudd
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (saudd *ScaAuthUserDeviceDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, saudd.sqlExec, saudd.mutation, saudd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (saudd *ScaAuthUserDeviceDelete) ExecX(ctx context.Context) int {
n, err := saudd.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (saudd *ScaAuthUserDeviceDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(scaauthuserdevice.Table, sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64))
if ps := saudd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, saudd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
saudd.mutation.done = true
return affected, err
}
// ScaAuthUserDeviceDeleteOne is the builder for deleting a single ScaAuthUserDevice entity.
type ScaAuthUserDeviceDeleteOne struct {
saudd *ScaAuthUserDeviceDelete
}
// Where appends a list predicates to the ScaAuthUserDeviceDelete builder.
func (sauddo *ScaAuthUserDeviceDeleteOne) Where(ps ...predicate.ScaAuthUserDevice) *ScaAuthUserDeviceDeleteOne {
sauddo.saudd.mutation.Where(ps...)
return sauddo
}
// Exec executes the deletion query.
func (sauddo *ScaAuthUserDeviceDeleteOne) Exec(ctx context.Context) error {
n, err := sauddo.saudd.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{scaauthuserdevice.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (sauddo *ScaAuthUserDeviceDeleteOne) ExecX(ctx context.Context) {
if err := sauddo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,614 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"schisandra-album-cloud-microservices/common/ent/predicate"
"schisandra-album-cloud-microservices/common/ent/scaauthuser"
"schisandra-album-cloud-microservices/common/ent/scaauthuserdevice"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// 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
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the ScaAuthUserDeviceQuery builder.
func (saudq *ScaAuthUserDeviceQuery) Where(ps ...predicate.ScaAuthUserDevice) *ScaAuthUserDeviceQuery {
saudq.predicates = append(saudq.predicates, ps...)
return saudq
}
// Limit the number of records to be returned by this query.
func (saudq *ScaAuthUserDeviceQuery) Limit(limit int) *ScaAuthUserDeviceQuery {
saudq.ctx.Limit = &limit
return saudq
}
// Offset to start from.
func (saudq *ScaAuthUserDeviceQuery) Offset(offset int) *ScaAuthUserDeviceQuery {
saudq.ctx.Offset = &offset
return saudq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (saudq *ScaAuthUserDeviceQuery) Unique(unique bool) *ScaAuthUserDeviceQuery {
saudq.ctx.Unique = &unique
return saudq
}
// Order specifies how the records should be ordered.
func (saudq *ScaAuthUserDeviceQuery) Order(o ...scaauthuserdevice.OrderOption) *ScaAuthUserDeviceQuery {
saudq.order = append(saudq.order, o...)
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) {
nodes, err := saudq.Limit(1).All(setContextOp(ctx, saudq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{scaauthuserdevice.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (saudq *ScaAuthUserDeviceQuery) FirstX(ctx context.Context) *ScaAuthUserDevice {
node, err := saudq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first ScaAuthUserDevice ID from the query.
// Returns a *NotFoundError when no ScaAuthUserDevice ID was found.
func (saudq *ScaAuthUserDeviceQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = saudq.Limit(1).IDs(setContextOp(ctx, saudq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{scaauthuserdevice.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (saudq *ScaAuthUserDeviceQuery) FirstIDX(ctx context.Context) int64 {
id, err := saudq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single ScaAuthUserDevice entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ScaAuthUserDevice entity is found.
// Returns a *NotFoundError when no ScaAuthUserDevice entities are found.
func (saudq *ScaAuthUserDeviceQuery) Only(ctx context.Context) (*ScaAuthUserDevice, error) {
nodes, err := saudq.Limit(2).All(setContextOp(ctx, saudq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{scaauthuserdevice.Label}
default:
return nil, &NotSingularError{scaauthuserdevice.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (saudq *ScaAuthUserDeviceQuery) OnlyX(ctx context.Context) *ScaAuthUserDevice {
node, err := saudq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only ScaAuthUserDevice ID in the query.
// Returns a *NotSingularError when more than one ScaAuthUserDevice ID is found.
// Returns a *NotFoundError when no entities are found.
func (saudq *ScaAuthUserDeviceQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = saudq.Limit(2).IDs(setContextOp(ctx, saudq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{scaauthuserdevice.Label}
default:
err = &NotSingularError{scaauthuserdevice.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (saudq *ScaAuthUserDeviceQuery) OnlyIDX(ctx context.Context) int64 {
id, err := saudq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of ScaAuthUserDevices.
func (saudq *ScaAuthUserDeviceQuery) All(ctx context.Context) ([]*ScaAuthUserDevice, error) {
ctx = setContextOp(ctx, saudq.ctx, ent.OpQueryAll)
if err := saudq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ScaAuthUserDevice, *ScaAuthUserDeviceQuery]()
return withInterceptors[[]*ScaAuthUserDevice](ctx, saudq, qr, saudq.inters)
}
// AllX is like All, but panics if an error occurs.
func (saudq *ScaAuthUserDeviceQuery) AllX(ctx context.Context) []*ScaAuthUserDevice {
nodes, err := saudq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of ScaAuthUserDevice IDs.
func (saudq *ScaAuthUserDeviceQuery) IDs(ctx context.Context) (ids []int64, err error) {
if saudq.ctx.Unique == nil && saudq.path != nil {
saudq.Unique(true)
}
ctx = setContextOp(ctx, saudq.ctx, ent.OpQueryIDs)
if err = saudq.Select(scaauthuserdevice.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (saudq *ScaAuthUserDeviceQuery) IDsX(ctx context.Context) []int64 {
ids, err := saudq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (saudq *ScaAuthUserDeviceQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, saudq.ctx, ent.OpQueryCount)
if err := saudq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, saudq, querierCount[*ScaAuthUserDeviceQuery](), saudq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (saudq *ScaAuthUserDeviceQuery) CountX(ctx context.Context) int {
count, err := saudq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (saudq *ScaAuthUserDeviceQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, saudq.ctx, ent.OpQueryExist)
switch _, err := saudq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (saudq *ScaAuthUserDeviceQuery) ExistX(ctx context.Context) bool {
exist, err := saudq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the ScaAuthUserDeviceQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (saudq *ScaAuthUserDeviceQuery) Clone() *ScaAuthUserDeviceQuery {
if saudq == nil {
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(),
// 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.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ScaAuthUserDevice.Query().
// GroupBy(scaauthuserdevice.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (saudq *ScaAuthUserDeviceQuery) GroupBy(field string, fields ...string) *ScaAuthUserDeviceGroupBy {
saudq.ctx.Fields = append([]string{field}, fields...)
grbuild := &ScaAuthUserDeviceGroupBy{build: saudq}
grbuild.flds = &saudq.ctx.Fields
grbuild.label = scaauthuserdevice.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.ScaAuthUserDevice.Query().
// Select(scaauthuserdevice.FieldCreatedAt).
// Scan(ctx, &v)
func (saudq *ScaAuthUserDeviceQuery) Select(fields ...string) *ScaAuthUserDeviceSelect {
saudq.ctx.Fields = append(saudq.ctx.Fields, fields...)
sbuild := &ScaAuthUserDeviceSelect{ScaAuthUserDeviceQuery: saudq}
sbuild.label = scaauthuserdevice.Label
sbuild.flds, sbuild.scan = &saudq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ScaAuthUserDeviceSelect configured with the given aggregations.
func (saudq *ScaAuthUserDeviceQuery) Aggregate(fns ...AggregateFunc) *ScaAuthUserDeviceSelect {
return saudq.Select().Aggregate(fns...)
}
func (saudq *ScaAuthUserDeviceQuery) prepareQuery(ctx context.Context) error {
for _, inter := range saudq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, saudq); err != nil {
return err
}
}
}
for _, f := range saudq.ctx.Fields {
if !scaauthuserdevice.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if saudq.path != nil {
prev, err := saudq.path(ctx)
if err != nil {
return err
}
saudq.sql = prev
}
return nil
}
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,
}
)
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 {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, saudq.driver, _spec); err != nil {
return nil, err
}
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
if len(saudq.ctx.Fields) > 0 {
_spec.Unique = saudq.ctx.Unique != nil && *saudq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, saudq.driver, _spec)
}
func (saudq *ScaAuthUserDeviceQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(scaauthuserdevice.Table, scaauthuserdevice.Columns, sqlgraph.NewFieldSpec(scaauthuserdevice.FieldID, field.TypeInt64))
_spec.From = saudq.sql
if unique := saudq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if saudq.path != nil {
_spec.Unique = true
}
if fields := saudq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthuserdevice.FieldID)
for i := range fields {
if fields[i] != scaauthuserdevice.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := saudq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := saudq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := saudq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := saudq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (saudq *ScaAuthUserDeviceQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(saudq.driver.Dialect())
t1 := builder.Table(scaauthuserdevice.Table)
columns := saudq.ctx.Fields
if len(columns) == 0 {
columns = scaauthuserdevice.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if saudq.sql != nil {
selector = saudq.sql
selector.Select(selector.Columns(columns...)...)
}
if saudq.ctx.Unique != nil && *saudq.ctx.Unique {
selector.Distinct()
}
for _, p := range saudq.predicates {
p(selector)
}
for _, p := range saudq.order {
p(selector)
}
if offset := saudq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := saudq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ScaAuthUserDeviceGroupBy is the group-by builder for ScaAuthUserDevice entities.
type ScaAuthUserDeviceGroupBy struct {
selector
build *ScaAuthUserDeviceQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (saudgb *ScaAuthUserDeviceGroupBy) Aggregate(fns ...AggregateFunc) *ScaAuthUserDeviceGroupBy {
saudgb.fns = append(saudgb.fns, fns...)
return saudgb
}
// Scan applies the selector query and scans the result into the given value.
func (saudgb *ScaAuthUserDeviceGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, saudgb.build.ctx, ent.OpQueryGroupBy)
if err := saudgb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthUserDeviceQuery, *ScaAuthUserDeviceGroupBy](ctx, saudgb.build, saudgb, saudgb.build.inters, v)
}
func (saudgb *ScaAuthUserDeviceGroupBy) sqlScan(ctx context.Context, root *ScaAuthUserDeviceQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(saudgb.fns))
for _, fn := range saudgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*saudgb.flds)+len(saudgb.fns))
for _, f := range *saudgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*saudgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := saudgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// ScaAuthUserDeviceSelect is the builder for selecting fields of ScaAuthUserDevice entities.
type ScaAuthUserDeviceSelect struct {
*ScaAuthUserDeviceQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (sauds *ScaAuthUserDeviceSelect) Aggregate(fns ...AggregateFunc) *ScaAuthUserDeviceSelect {
sauds.fns = append(sauds.fns, fns...)
return sauds
}
// Scan applies the selector query and scans the result into the given value.
func (sauds *ScaAuthUserDeviceSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, sauds.ctx, ent.OpQuerySelect)
if err := sauds.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthUserDeviceQuery, *ScaAuthUserDeviceSelect](ctx, sauds.ScaAuthUserDeviceQuery, sauds, sauds.inters, v)
}
func (sauds *ScaAuthUserDeviceSelect) sqlScan(ctx context.Context, root *ScaAuthUserDeviceQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(sauds.fns))
for _, fn := range sauds.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*sauds.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := sauds.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,212 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"schisandra-album-cloud-microservices/common/ent/scaauthuser"
"schisandra-album-cloud-microservices/common/ent/scaauthusersocial"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// 用户第三方登录信息
type ScaAuthUserSocial struct {
config `json:"-"`
// ID of the ent.
// 主键ID
ID int64 `json:"id,omitempty"`
// 创建时间
CreatedAt time.Time `json:"created_at,omitempty"`
// 更新时间
UpdatedAt time.Time `json:"updated_at,omitempty"`
// 是否删除 0 未删除 1 已删除
Deleted int8 `json:"deleted,omitempty"`
// 用户ID
UserID string `json:"user_id,omitempty"`
// 第三方用户的 open id
OpenID string `json:"open_id,omitempty"`
// 第三方用户来源
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"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ScaAuthUserSocial) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case scaauthusersocial.FieldID, scaauthusersocial.FieldDeleted, scaauthusersocial.FieldStatus:
values[i] = new(sql.NullInt64)
case scaauthusersocial.FieldUserID, scaauthusersocial.FieldOpenID, scaauthusersocial.FieldSource:
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)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ScaAuthUserSocial fields.
func (saus *ScaAuthUserSocial) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case scaauthusersocial.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
saus.ID = int64(value.Int64)
case scaauthusersocial.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
saus.CreatedAt = value.Time
}
case scaauthusersocial.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
saus.UpdatedAt = value.Time
}
case scaauthusersocial.FieldDeleted:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field deleted", values[i])
} else if value.Valid {
saus.Deleted = int8(value.Int64)
}
case scaauthusersocial.FieldUserID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field user_id", values[i])
} else if value.Valid {
saus.UserID = value.String
}
case scaauthusersocial.FieldOpenID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field open_id", values[i])
} else if value.Valid {
saus.OpenID = value.String
}
case scaauthusersocial.FieldSource:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field source", values[i])
} else if value.Valid {
saus.Source = value.String
}
case scaauthusersocial.FieldStatus:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} 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])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ScaAuthUserSocial.
// This includes values selected through modifiers, order, etc.
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.
func (saus *ScaAuthUserSocial) Update() *ScaAuthUserSocialUpdateOne {
return NewScaAuthUserSocialClient(saus.config).UpdateOne(saus)
}
// Unwrap unwraps the ScaAuthUserSocial entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (saus *ScaAuthUserSocial) Unwrap() *ScaAuthUserSocial {
_tx, ok := saus.config.driver.(*txDriver)
if !ok {
panic("ent: ScaAuthUserSocial is not a transactional entity")
}
saus.config.driver = _tx.drv
return saus
}
// String implements the fmt.Stringer.
func (saus *ScaAuthUserSocial) String() string {
var builder strings.Builder
builder.WriteString("ScaAuthUserSocial(")
builder.WriteString(fmt.Sprintf("id=%v, ", saus.ID))
builder.WriteString("created_at=")
builder.WriteString(saus.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(saus.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("deleted=")
builder.WriteString(fmt.Sprintf("%v", saus.Deleted))
builder.WriteString(", ")
builder.WriteString("user_id=")
builder.WriteString(saus.UserID)
builder.WriteString(", ")
builder.WriteString("open_id=")
builder.WriteString(saus.OpenID)
builder.WriteString(", ")
builder.WriteString("source=")
builder.WriteString(saus.Source)
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", saus.Status))
builder.WriteByte(')')
return builder.String()
}
// ScaAuthUserSocials is a parsable slice of ScaAuthUserSocial.
type ScaAuthUserSocials []*ScaAuthUserSocial

View File

@@ -1,153 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scaauthusersocial
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the scaauthusersocial type in the database.
Label = "sca_auth_user_social"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldDeleted holds the string denoting the deleted field in the database.
FieldDeleted = "deleted"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
// FieldOpenID holds the string denoting the open_id field in the database.
FieldOpenID = "open_id"
// FieldSource holds the string denoting the source field in the database.
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.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldDeleted,
FieldUserID,
FieldOpenID,
FieldSource,
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 {
if column == Columns[i] {
return true
}
}
for i := range ForeignKeys {
if column == ForeignKeys[i] {
return true
}
}
return false
}
var (
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
DefaultUpdatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
// DefaultDeleted holds the default value on creation for the "deleted" field.
DefaultDeleted int8
// DeletedValidator is a validator for the "deleted" field. It is called by the builders before save.
DeletedValidator func(int8) error
// UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
UserIDValidator func(string) error
// OpenIDValidator is a validator for the "open_id" field. It is called by the builders before save.
OpenIDValidator func(string) error
// SourceValidator is a validator for the "source" field. It is called by the builders before save.
SourceValidator func(string) error
// DefaultStatus holds the default value on creation for the "status" field.
DefaultStatus int
)
// OrderOption defines the ordering options for the ScaAuthUserSocial queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByDeleted orders the results by the deleted field.
func ByDeleted(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeleted, opts...).ToFunc()
}
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
// ByOpenID orders the results by the open_id field.
func ByOpenID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOpenID, opts...).ToFunc()
}
// BySource orders the results by the source field.
func BySource(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSource, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
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),
)
}

View File

@@ -1,494 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package scaauthusersocial
import (
"schisandra-album-cloud-microservices/common/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldID, id))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldCreatedAt, v))
}
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldUpdatedAt, v))
}
// Deleted applies equality check predicate on the "deleted" field. It's identical to DeletedEQ.
func Deleted(v int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldDeleted, v))
}
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
func UserID(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldUserID, v))
}
// OpenID applies equality check predicate on the "open_id" field. It's identical to OpenIDEQ.
func OpenID(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldOpenID, v))
}
// Source applies equality check predicate on the "source" field. It's identical to SourceEQ.
func Source(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldSource, v))
}
// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
func Status(v int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldStatus, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldCreatedAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldUpdatedAt, v))
}
// DeletedEQ applies the EQ predicate on the "deleted" field.
func DeletedEQ(v int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldDeleted, v))
}
// DeletedNEQ applies the NEQ predicate on the "deleted" field.
func DeletedNEQ(v int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldDeleted, v))
}
// DeletedIn applies the In predicate on the "deleted" field.
func DeletedIn(vs ...int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIn(FieldDeleted, vs...))
}
// DeletedNotIn applies the NotIn predicate on the "deleted" field.
func DeletedNotIn(vs ...int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldDeleted, vs...))
}
// DeletedGT applies the GT predicate on the "deleted" field.
func DeletedGT(v int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGT(FieldDeleted, v))
}
// DeletedGTE applies the GTE predicate on the "deleted" field.
func DeletedGTE(v int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldDeleted, v))
}
// DeletedLT applies the LT predicate on the "deleted" field.
func DeletedLT(v int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLT(FieldDeleted, v))
}
// DeletedLTE applies the LTE predicate on the "deleted" field.
func DeletedLTE(v int8) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldDeleted, v))
}
// DeletedIsNil applies the IsNil predicate on the "deleted" field.
func DeletedIsNil() predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIsNull(FieldDeleted))
}
// DeletedNotNil applies the NotNil predicate on the "deleted" field.
func DeletedNotNil() predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotNull(FieldDeleted))
}
// UserIDEQ applies the EQ predicate on the "user_id" field.
func UserIDEQ(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldUserID, v))
}
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
func UserIDNEQ(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldUserID, v))
}
// UserIDIn applies the In predicate on the "user_id" field.
func UserIDIn(vs ...string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIn(FieldUserID, vs...))
}
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
func UserIDNotIn(vs ...string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldUserID, vs...))
}
// UserIDGT applies the GT predicate on the "user_id" field.
func UserIDGT(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGT(FieldUserID, v))
}
// UserIDGTE applies the GTE predicate on the "user_id" field.
func UserIDGTE(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldUserID, v))
}
// UserIDLT applies the LT predicate on the "user_id" field.
func UserIDLT(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLT(FieldUserID, v))
}
// UserIDLTE applies the LTE predicate on the "user_id" field.
func UserIDLTE(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldUserID, v))
}
// UserIDContains applies the Contains predicate on the "user_id" field.
func UserIDContains(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldContains(FieldUserID, v))
}
// UserIDHasPrefix applies the HasPrefix predicate on the "user_id" field.
func UserIDHasPrefix(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldHasPrefix(FieldUserID, v))
}
// UserIDHasSuffix applies the HasSuffix predicate on the "user_id" field.
func UserIDHasSuffix(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldHasSuffix(FieldUserID, v))
}
// UserIDEqualFold applies the EqualFold predicate on the "user_id" field.
func UserIDEqualFold(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEqualFold(FieldUserID, v))
}
// UserIDContainsFold applies the ContainsFold predicate on the "user_id" field.
func UserIDContainsFold(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldContainsFold(FieldUserID, v))
}
// OpenIDEQ applies the EQ predicate on the "open_id" field.
func OpenIDEQ(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldOpenID, v))
}
// OpenIDNEQ applies the NEQ predicate on the "open_id" field.
func OpenIDNEQ(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldOpenID, v))
}
// OpenIDIn applies the In predicate on the "open_id" field.
func OpenIDIn(vs ...string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIn(FieldOpenID, vs...))
}
// OpenIDNotIn applies the NotIn predicate on the "open_id" field.
func OpenIDNotIn(vs ...string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldOpenID, vs...))
}
// OpenIDGT applies the GT predicate on the "open_id" field.
func OpenIDGT(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGT(FieldOpenID, v))
}
// OpenIDGTE applies the GTE predicate on the "open_id" field.
func OpenIDGTE(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldOpenID, v))
}
// OpenIDLT applies the LT predicate on the "open_id" field.
func OpenIDLT(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLT(FieldOpenID, v))
}
// OpenIDLTE applies the LTE predicate on the "open_id" field.
func OpenIDLTE(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldOpenID, v))
}
// OpenIDContains applies the Contains predicate on the "open_id" field.
func OpenIDContains(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldContains(FieldOpenID, v))
}
// OpenIDHasPrefix applies the HasPrefix predicate on the "open_id" field.
func OpenIDHasPrefix(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldHasPrefix(FieldOpenID, v))
}
// OpenIDHasSuffix applies the HasSuffix predicate on the "open_id" field.
func OpenIDHasSuffix(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldHasSuffix(FieldOpenID, v))
}
// OpenIDEqualFold applies the EqualFold predicate on the "open_id" field.
func OpenIDEqualFold(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEqualFold(FieldOpenID, v))
}
// OpenIDContainsFold applies the ContainsFold predicate on the "open_id" field.
func OpenIDContainsFold(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldContainsFold(FieldOpenID, v))
}
// SourceEQ applies the EQ predicate on the "source" field.
func SourceEQ(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldSource, v))
}
// SourceNEQ applies the NEQ predicate on the "source" field.
func SourceNEQ(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldSource, v))
}
// SourceIn applies the In predicate on the "source" field.
func SourceIn(vs ...string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIn(FieldSource, vs...))
}
// SourceNotIn applies the NotIn predicate on the "source" field.
func SourceNotIn(vs ...string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldSource, vs...))
}
// SourceGT applies the GT predicate on the "source" field.
func SourceGT(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGT(FieldSource, v))
}
// SourceGTE applies the GTE predicate on the "source" field.
func SourceGTE(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldSource, v))
}
// SourceLT applies the LT predicate on the "source" field.
func SourceLT(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLT(FieldSource, v))
}
// SourceLTE applies the LTE predicate on the "source" field.
func SourceLTE(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLTE(FieldSource, v))
}
// SourceContains applies the Contains predicate on the "source" field.
func SourceContains(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldContains(FieldSource, v))
}
// SourceHasPrefix applies the HasPrefix predicate on the "source" field.
func SourceHasPrefix(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldHasPrefix(FieldSource, v))
}
// SourceHasSuffix applies the HasSuffix predicate on the "source" field.
func SourceHasSuffix(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldHasSuffix(FieldSource, v))
}
// SourceEqualFold applies the EqualFold predicate on the "source" field.
func SourceEqualFold(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEqualFold(FieldSource, v))
}
// SourceContainsFold applies the ContainsFold predicate on the "source" field.
func SourceContainsFold(v string) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldContainsFold(FieldSource, v))
}
// StatusEQ applies the EQ predicate on the "status" field.
func StatusEQ(v int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldEQ(FieldStatus, v))
}
// StatusNEQ applies the NEQ predicate on the "status" field.
func StatusNEQ(v int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNEQ(FieldStatus, v))
}
// StatusIn applies the In predicate on the "status" field.
func StatusIn(vs ...int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldIn(FieldStatus, vs...))
}
// StatusNotIn applies the NotIn predicate on the "status" field.
func StatusNotIn(vs ...int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldNotIn(FieldStatus, vs...))
}
// StatusGT applies the GT predicate on the "status" field.
func StatusGT(v int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGT(FieldStatus, v))
}
// StatusGTE applies the GTE predicate on the "status" field.
func StatusGTE(v int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldGTE(FieldStatus, v))
}
// StatusLT applies the LT predicate on the "status" field.
func StatusLT(v int) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.FieldLT(FieldStatus, v))
}
// StatusLTE applies the LTE predicate on the "status" field.
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...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.ScaAuthUserSocial) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.ScaAuthUserSocial) predicate.ScaAuthUserSocial {
return predicate.ScaAuthUserSocial(sql.NotPredicates(p))
}

View File

@@ -1,382 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/common/ent/scaauthuser"
"schisandra-album-cloud-microservices/common/ent/scaauthusersocial"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserSocialCreate is the builder for creating a ScaAuthUserSocial entity.
type ScaAuthUserSocialCreate struct {
config
mutation *ScaAuthUserSocialMutation
hooks []Hook
}
// SetCreatedAt sets the "created_at" field.
func (sausc *ScaAuthUserSocialCreate) SetCreatedAt(t time.Time) *ScaAuthUserSocialCreate {
sausc.mutation.SetCreatedAt(t)
return sausc
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (sausc *ScaAuthUserSocialCreate) SetNillableCreatedAt(t *time.Time) *ScaAuthUserSocialCreate {
if t != nil {
sausc.SetCreatedAt(*t)
}
return sausc
}
// SetUpdatedAt sets the "updated_at" field.
func (sausc *ScaAuthUserSocialCreate) SetUpdatedAt(t time.Time) *ScaAuthUserSocialCreate {
sausc.mutation.SetUpdatedAt(t)
return sausc
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (sausc *ScaAuthUserSocialCreate) SetNillableUpdatedAt(t *time.Time) *ScaAuthUserSocialCreate {
if t != nil {
sausc.SetUpdatedAt(*t)
}
return sausc
}
// SetDeleted sets the "deleted" field.
func (sausc *ScaAuthUserSocialCreate) SetDeleted(i int8) *ScaAuthUserSocialCreate {
sausc.mutation.SetDeleted(i)
return sausc
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (sausc *ScaAuthUserSocialCreate) SetNillableDeleted(i *int8) *ScaAuthUserSocialCreate {
if i != nil {
sausc.SetDeleted(*i)
}
return sausc
}
// SetUserID sets the "user_id" field.
func (sausc *ScaAuthUserSocialCreate) SetUserID(s string) *ScaAuthUserSocialCreate {
sausc.mutation.SetUserID(s)
return sausc
}
// SetOpenID sets the "open_id" field.
func (sausc *ScaAuthUserSocialCreate) SetOpenID(s string) *ScaAuthUserSocialCreate {
sausc.mutation.SetOpenID(s)
return sausc
}
// SetSource sets the "source" field.
func (sausc *ScaAuthUserSocialCreate) SetSource(s string) *ScaAuthUserSocialCreate {
sausc.mutation.SetSource(s)
return sausc
}
// SetStatus sets the "status" field.
func (sausc *ScaAuthUserSocialCreate) SetStatus(i int) *ScaAuthUserSocialCreate {
sausc.mutation.SetStatus(i)
return sausc
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (sausc *ScaAuthUserSocialCreate) SetNillableStatus(i *int) *ScaAuthUserSocialCreate {
if i != nil {
sausc.SetStatus(*i)
}
return sausc
}
// SetID sets the "id" field.
func (sausc *ScaAuthUserSocialCreate) SetID(i int64) *ScaAuthUserSocialCreate {
sausc.mutation.SetID(i)
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
}
// Save creates the ScaAuthUserSocial in the database.
func (sausc *ScaAuthUserSocialCreate) Save(ctx context.Context) (*ScaAuthUserSocial, error) {
sausc.defaults()
return withHooks(ctx, sausc.sqlSave, sausc.mutation, sausc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (sausc *ScaAuthUserSocialCreate) SaveX(ctx context.Context) *ScaAuthUserSocial {
v, err := sausc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sausc *ScaAuthUserSocialCreate) Exec(ctx context.Context) error {
_, err := sausc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sausc *ScaAuthUserSocialCreate) ExecX(ctx context.Context) {
if err := sausc.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (sausc *ScaAuthUserSocialCreate) defaults() {
if _, ok := sausc.mutation.CreatedAt(); !ok {
v := scaauthusersocial.DefaultCreatedAt()
sausc.mutation.SetCreatedAt(v)
}
if _, ok := sausc.mutation.UpdatedAt(); !ok {
v := scaauthusersocial.DefaultUpdatedAt()
sausc.mutation.SetUpdatedAt(v)
}
if _, ok := sausc.mutation.Deleted(); !ok {
v := scaauthusersocial.DefaultDeleted
sausc.mutation.SetDeleted(v)
}
if _, ok := sausc.mutation.Status(); !ok {
v := scaauthusersocial.DefaultStatus
sausc.mutation.SetStatus(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (sausc *ScaAuthUserSocialCreate) check() error {
if _, ok := sausc.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ScaAuthUserSocial.created_at"`)}
}
if _, ok := sausc.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ScaAuthUserSocial.updated_at"`)}
}
if v, ok := sausc.mutation.Deleted(); ok {
if err := scaauthusersocial.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.deleted": %w`, err)}
}
}
if _, ok := sausc.mutation.UserID(); !ok {
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "ScaAuthUserSocial.user_id"`)}
}
if v, ok := sausc.mutation.UserID(); ok {
if err := scaauthusersocial.UserIDValidator(v); err != nil {
return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.user_id": %w`, err)}
}
}
if _, ok := sausc.mutation.OpenID(); !ok {
return &ValidationError{Name: "open_id", err: errors.New(`ent: missing required field "ScaAuthUserSocial.open_id"`)}
}
if v, ok := sausc.mutation.OpenID(); ok {
if err := scaauthusersocial.OpenIDValidator(v); err != nil {
return &ValidationError{Name: "open_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.open_id": %w`, err)}
}
}
if _, ok := sausc.mutation.Source(); !ok {
return &ValidationError{Name: "source", err: errors.New(`ent: missing required field "ScaAuthUserSocial.source"`)}
}
if v, ok := sausc.mutation.Source(); ok {
if err := scaauthusersocial.SourceValidator(v); err != nil {
return &ValidationError{Name: "source", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.source": %w`, err)}
}
}
if _, ok := sausc.mutation.Status(); !ok {
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "ScaAuthUserSocial.status"`)}
}
return nil
}
func (sausc *ScaAuthUserSocialCreate) sqlSave(ctx context.Context) (*ScaAuthUserSocial, error) {
if err := sausc.check(); err != nil {
return nil, err
}
_node, _spec := sausc.createSpec()
if err := sqlgraph.CreateNode(ctx, sausc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
if _spec.ID.Value != _node.ID {
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
}
sausc.mutation.id = &_node.ID
sausc.mutation.done = true
return _node, nil
}
func (sausc *ScaAuthUserSocialCreate) createSpec() (*ScaAuthUserSocial, *sqlgraph.CreateSpec) {
var (
_node = &ScaAuthUserSocial{config: sausc.config}
_spec = sqlgraph.NewCreateSpec(scaauthusersocial.Table, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64))
)
if id, ok := sausc.mutation.ID(); ok {
_node.ID = id
_spec.ID.Value = id
}
if value, ok := sausc.mutation.CreatedAt(); ok {
_spec.SetField(scaauthusersocial.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := sausc.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthusersocial.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := sausc.mutation.Deleted(); ok {
_spec.SetField(scaauthusersocial.FieldDeleted, field.TypeInt8, value)
_node.Deleted = value
}
if value, ok := sausc.mutation.UserID(); ok {
_spec.SetField(scaauthusersocial.FieldUserID, field.TypeString, value)
_node.UserID = value
}
if value, ok := sausc.mutation.OpenID(); ok {
_spec.SetField(scaauthusersocial.FieldOpenID, field.TypeString, value)
_node.OpenID = value
}
if value, ok := sausc.mutation.Source(); ok {
_spec.SetField(scaauthusersocial.FieldSource, field.TypeString, value)
_node.Source = value
}
if value, ok := sausc.mutation.Status(); ok {
_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
}
// ScaAuthUserSocialCreateBulk is the builder for creating many ScaAuthUserSocial entities in bulk.
type ScaAuthUserSocialCreateBulk struct {
config
err error
builders []*ScaAuthUserSocialCreate
}
// Save creates the ScaAuthUserSocial entities in the database.
func (sauscb *ScaAuthUserSocialCreateBulk) Save(ctx context.Context) ([]*ScaAuthUserSocial, error) {
if sauscb.err != nil {
return nil, sauscb.err
}
specs := make([]*sqlgraph.CreateSpec, len(sauscb.builders))
nodes := make([]*ScaAuthUserSocial, len(sauscb.builders))
mutators := make([]Mutator, len(sauscb.builders))
for i := range sauscb.builders {
func(i int, root context.Context) {
builder := sauscb.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ScaAuthUserSocialMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, sauscb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, sauscb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
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)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, sauscb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (sauscb *ScaAuthUserSocialCreateBulk) SaveX(ctx context.Context) []*ScaAuthUserSocial {
v, err := sauscb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (sauscb *ScaAuthUserSocialCreateBulk) Exec(ctx context.Context) error {
_, err := sauscb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sauscb *ScaAuthUserSocialCreateBulk) ExecX(ctx context.Context) {
if err := sauscb.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,88 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"schisandra-album-cloud-microservices/common/ent/predicate"
"schisandra-album-cloud-microservices/common/ent/scaauthusersocial"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserSocialDelete is the builder for deleting a ScaAuthUserSocial entity.
type ScaAuthUserSocialDelete struct {
config
hooks []Hook
mutation *ScaAuthUserSocialMutation
}
// Where appends a list predicates to the ScaAuthUserSocialDelete builder.
func (sausd *ScaAuthUserSocialDelete) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialDelete {
sausd.mutation.Where(ps...)
return sausd
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (sausd *ScaAuthUserSocialDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, sausd.sqlExec, sausd.mutation, sausd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (sausd *ScaAuthUserSocialDelete) ExecX(ctx context.Context) int {
n, err := sausd.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (sausd *ScaAuthUserSocialDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(scaauthusersocial.Table, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64))
if ps := sausd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, sausd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
sausd.mutation.done = true
return affected, err
}
// ScaAuthUserSocialDeleteOne is the builder for deleting a single ScaAuthUserSocial entity.
type ScaAuthUserSocialDeleteOne struct {
sausd *ScaAuthUserSocialDelete
}
// Where appends a list predicates to the ScaAuthUserSocialDelete builder.
func (sausdo *ScaAuthUserSocialDeleteOne) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialDeleteOne {
sausdo.sausd.mutation.Where(ps...)
return sausdo
}
// Exec executes the deletion query.
func (sausdo *ScaAuthUserSocialDeleteOne) Exec(ctx context.Context) error {
n, err := sausdo.sausd.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{scaauthusersocial.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (sausdo *ScaAuthUserSocialDeleteOne) ExecX(ctx context.Context) {
if err := sausdo.Exec(ctx); err != nil {
panic(err)
}
}

View File

@@ -1,614 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"schisandra-album-cloud-microservices/common/ent/predicate"
"schisandra-album-cloud-microservices/common/ent/scaauthuser"
"schisandra-album-cloud-microservices/common/ent/scaauthusersocial"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// 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
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the ScaAuthUserSocialQuery builder.
func (sausq *ScaAuthUserSocialQuery) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialQuery {
sausq.predicates = append(sausq.predicates, ps...)
return sausq
}
// Limit the number of records to be returned by this query.
func (sausq *ScaAuthUserSocialQuery) Limit(limit int) *ScaAuthUserSocialQuery {
sausq.ctx.Limit = &limit
return sausq
}
// Offset to start from.
func (sausq *ScaAuthUserSocialQuery) Offset(offset int) *ScaAuthUserSocialQuery {
sausq.ctx.Offset = &offset
return sausq
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (sausq *ScaAuthUserSocialQuery) Unique(unique bool) *ScaAuthUserSocialQuery {
sausq.ctx.Unique = &unique
return sausq
}
// Order specifies how the records should be ordered.
func (sausq *ScaAuthUserSocialQuery) Order(o ...scaauthusersocial.OrderOption) *ScaAuthUserSocialQuery {
sausq.order = append(sausq.order, o...)
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) {
nodes, err := sausq.Limit(1).All(setContextOp(ctx, sausq.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{scaauthusersocial.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (sausq *ScaAuthUserSocialQuery) FirstX(ctx context.Context) *ScaAuthUserSocial {
node, err := sausq.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first ScaAuthUserSocial ID from the query.
// Returns a *NotFoundError when no ScaAuthUserSocial ID was found.
func (sausq *ScaAuthUserSocialQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = sausq.Limit(1).IDs(setContextOp(ctx, sausq.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{scaauthusersocial.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (sausq *ScaAuthUserSocialQuery) FirstIDX(ctx context.Context) int64 {
id, err := sausq.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single ScaAuthUserSocial entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ScaAuthUserSocial entity is found.
// Returns a *NotFoundError when no ScaAuthUserSocial entities are found.
func (sausq *ScaAuthUserSocialQuery) Only(ctx context.Context) (*ScaAuthUserSocial, error) {
nodes, err := sausq.Limit(2).All(setContextOp(ctx, sausq.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{scaauthusersocial.Label}
default:
return nil, &NotSingularError{scaauthusersocial.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (sausq *ScaAuthUserSocialQuery) OnlyX(ctx context.Context) *ScaAuthUserSocial {
node, err := sausq.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only ScaAuthUserSocial ID in the query.
// Returns a *NotSingularError when more than one ScaAuthUserSocial ID is found.
// Returns a *NotFoundError when no entities are found.
func (sausq *ScaAuthUserSocialQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = sausq.Limit(2).IDs(setContextOp(ctx, sausq.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{scaauthusersocial.Label}
default:
err = &NotSingularError{scaauthusersocial.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (sausq *ScaAuthUserSocialQuery) OnlyIDX(ctx context.Context) int64 {
id, err := sausq.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of ScaAuthUserSocials.
func (sausq *ScaAuthUserSocialQuery) All(ctx context.Context) ([]*ScaAuthUserSocial, error) {
ctx = setContextOp(ctx, sausq.ctx, ent.OpQueryAll)
if err := sausq.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*ScaAuthUserSocial, *ScaAuthUserSocialQuery]()
return withInterceptors[[]*ScaAuthUserSocial](ctx, sausq, qr, sausq.inters)
}
// AllX is like All, but panics if an error occurs.
func (sausq *ScaAuthUserSocialQuery) AllX(ctx context.Context) []*ScaAuthUserSocial {
nodes, err := sausq.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of ScaAuthUserSocial IDs.
func (sausq *ScaAuthUserSocialQuery) IDs(ctx context.Context) (ids []int64, err error) {
if sausq.ctx.Unique == nil && sausq.path != nil {
sausq.Unique(true)
}
ctx = setContextOp(ctx, sausq.ctx, ent.OpQueryIDs)
if err = sausq.Select(scaauthusersocial.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (sausq *ScaAuthUserSocialQuery) IDsX(ctx context.Context) []int64 {
ids, err := sausq.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (sausq *ScaAuthUserSocialQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, sausq.ctx, ent.OpQueryCount)
if err := sausq.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, sausq, querierCount[*ScaAuthUserSocialQuery](), sausq.inters)
}
// CountX is like Count, but panics if an error occurs.
func (sausq *ScaAuthUserSocialQuery) CountX(ctx context.Context) int {
count, err := sausq.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (sausq *ScaAuthUserSocialQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, sausq.ctx, ent.OpQueryExist)
switch _, err := sausq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (sausq *ScaAuthUserSocialQuery) ExistX(ctx context.Context) bool {
exist, err := sausq.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the ScaAuthUserSocialQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (sausq *ScaAuthUserSocialQuery) Clone() *ScaAuthUserSocialQuery {
if sausq == nil {
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(),
// 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.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ScaAuthUserSocial.Query().
// GroupBy(scaauthusersocial.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (sausq *ScaAuthUserSocialQuery) GroupBy(field string, fields ...string) *ScaAuthUserSocialGroupBy {
sausq.ctx.Fields = append([]string{field}, fields...)
grbuild := &ScaAuthUserSocialGroupBy{build: sausq}
grbuild.flds = &sausq.ctx.Fields
grbuild.label = scaauthusersocial.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.ScaAuthUserSocial.Query().
// Select(scaauthusersocial.FieldCreatedAt).
// Scan(ctx, &v)
func (sausq *ScaAuthUserSocialQuery) Select(fields ...string) *ScaAuthUserSocialSelect {
sausq.ctx.Fields = append(sausq.ctx.Fields, fields...)
sbuild := &ScaAuthUserSocialSelect{ScaAuthUserSocialQuery: sausq}
sbuild.label = scaauthusersocial.Label
sbuild.flds, sbuild.scan = &sausq.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a ScaAuthUserSocialSelect configured with the given aggregations.
func (sausq *ScaAuthUserSocialQuery) Aggregate(fns ...AggregateFunc) *ScaAuthUserSocialSelect {
return sausq.Select().Aggregate(fns...)
}
func (sausq *ScaAuthUserSocialQuery) prepareQuery(ctx context.Context) error {
for _, inter := range sausq.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, sausq); err != nil {
return err
}
}
}
for _, f := range sausq.ctx.Fields {
if !scaauthusersocial.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if sausq.path != nil {
prev, err := sausq.path(ctx)
if err != nil {
return err
}
sausq.sql = prev
}
return nil
}
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,
}
)
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 {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, sausq.driver, _spec); err != nil {
return nil, err
}
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
if len(sausq.ctx.Fields) > 0 {
_spec.Unique = sausq.ctx.Unique != nil && *sausq.ctx.Unique
}
return sqlgraph.CountNodes(ctx, sausq.driver, _spec)
}
func (sausq *ScaAuthUserSocialQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(scaauthusersocial.Table, scaauthusersocial.Columns, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64))
_spec.From = sausq.sql
if unique := sausq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if sausq.path != nil {
_spec.Unique = true
}
if fields := sausq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthusersocial.FieldID)
for i := range fields {
if fields[i] != scaauthusersocial.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := sausq.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := sausq.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := sausq.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := sausq.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (sausq *ScaAuthUserSocialQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(sausq.driver.Dialect())
t1 := builder.Table(scaauthusersocial.Table)
columns := sausq.ctx.Fields
if len(columns) == 0 {
columns = scaauthusersocial.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if sausq.sql != nil {
selector = sausq.sql
selector.Select(selector.Columns(columns...)...)
}
if sausq.ctx.Unique != nil && *sausq.ctx.Unique {
selector.Distinct()
}
for _, p := range sausq.predicates {
p(selector)
}
for _, p := range sausq.order {
p(selector)
}
if offset := sausq.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := sausq.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ScaAuthUserSocialGroupBy is the group-by builder for ScaAuthUserSocial entities.
type ScaAuthUserSocialGroupBy struct {
selector
build *ScaAuthUserSocialQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (sausgb *ScaAuthUserSocialGroupBy) Aggregate(fns ...AggregateFunc) *ScaAuthUserSocialGroupBy {
sausgb.fns = append(sausgb.fns, fns...)
return sausgb
}
// Scan applies the selector query and scans the result into the given value.
func (sausgb *ScaAuthUserSocialGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, sausgb.build.ctx, ent.OpQueryGroupBy)
if err := sausgb.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthUserSocialQuery, *ScaAuthUserSocialGroupBy](ctx, sausgb.build, sausgb, sausgb.build.inters, v)
}
func (sausgb *ScaAuthUserSocialGroupBy) sqlScan(ctx context.Context, root *ScaAuthUserSocialQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(sausgb.fns))
for _, fn := range sausgb.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*sausgb.flds)+len(sausgb.fns))
for _, f := range *sausgb.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*sausgb.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := sausgb.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// ScaAuthUserSocialSelect is the builder for selecting fields of ScaAuthUserSocial entities.
type ScaAuthUserSocialSelect struct {
*ScaAuthUserSocialQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (sauss *ScaAuthUserSocialSelect) Aggregate(fns ...AggregateFunc) *ScaAuthUserSocialSelect {
sauss.fns = append(sauss.fns, fns...)
return sauss
}
// Scan applies the selector query and scans the result into the given value.
func (sauss *ScaAuthUserSocialSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, sauss.ctx, ent.OpQuerySelect)
if err := sauss.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*ScaAuthUserSocialQuery, *ScaAuthUserSocialSelect](ctx, sauss.ScaAuthUserSocialQuery, sauss, sauss.inters, v)
}
func (sauss *ScaAuthUserSocialSelect) sqlScan(ctx context.Context, root *ScaAuthUserSocialQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(sauss.fns))
for _, fn := range sauss.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*sauss.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := sauss.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}

View File

@@ -1,605 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"schisandra-album-cloud-microservices/common/ent/predicate"
"schisandra-album-cloud-microservices/common/ent/scaauthuser"
"schisandra-album-cloud-microservices/common/ent/scaauthusersocial"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// ScaAuthUserSocialUpdate is the builder for updating ScaAuthUserSocial entities.
type ScaAuthUserSocialUpdate struct {
config
hooks []Hook
mutation *ScaAuthUserSocialMutation
}
// Where appends a list predicates to the ScaAuthUserSocialUpdate builder.
func (sausu *ScaAuthUserSocialUpdate) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialUpdate {
sausu.mutation.Where(ps...)
return sausu
}
// SetUpdatedAt sets the "updated_at" field.
func (sausu *ScaAuthUserSocialUpdate) SetUpdatedAt(t time.Time) *ScaAuthUserSocialUpdate {
sausu.mutation.SetUpdatedAt(t)
return sausu
}
// SetDeleted sets the "deleted" field.
func (sausu *ScaAuthUserSocialUpdate) SetDeleted(i int8) *ScaAuthUserSocialUpdate {
sausu.mutation.ResetDeleted()
sausu.mutation.SetDeleted(i)
return sausu
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (sausu *ScaAuthUserSocialUpdate) SetNillableDeleted(i *int8) *ScaAuthUserSocialUpdate {
if i != nil {
sausu.SetDeleted(*i)
}
return sausu
}
// AddDeleted adds i to the "deleted" field.
func (sausu *ScaAuthUserSocialUpdate) AddDeleted(i int8) *ScaAuthUserSocialUpdate {
sausu.mutation.AddDeleted(i)
return sausu
}
// ClearDeleted clears the value of the "deleted" field.
func (sausu *ScaAuthUserSocialUpdate) ClearDeleted() *ScaAuthUserSocialUpdate {
sausu.mutation.ClearDeleted()
return sausu
}
// SetUserID sets the "user_id" field.
func (sausu *ScaAuthUserSocialUpdate) SetUserID(s string) *ScaAuthUserSocialUpdate {
sausu.mutation.SetUserID(s)
return sausu
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (sausu *ScaAuthUserSocialUpdate) SetNillableUserID(s *string) *ScaAuthUserSocialUpdate {
if s != nil {
sausu.SetUserID(*s)
}
return sausu
}
// SetOpenID sets the "open_id" field.
func (sausu *ScaAuthUserSocialUpdate) SetOpenID(s string) *ScaAuthUserSocialUpdate {
sausu.mutation.SetOpenID(s)
return sausu
}
// SetNillableOpenID sets the "open_id" field if the given value is not nil.
func (sausu *ScaAuthUserSocialUpdate) SetNillableOpenID(s *string) *ScaAuthUserSocialUpdate {
if s != nil {
sausu.SetOpenID(*s)
}
return sausu
}
// SetSource sets the "source" field.
func (sausu *ScaAuthUserSocialUpdate) SetSource(s string) *ScaAuthUserSocialUpdate {
sausu.mutation.SetSource(s)
return sausu
}
// SetNillableSource sets the "source" field if the given value is not nil.
func (sausu *ScaAuthUserSocialUpdate) SetNillableSource(s *string) *ScaAuthUserSocialUpdate {
if s != nil {
sausu.SetSource(*s)
}
return sausu
}
// SetStatus sets the "status" field.
func (sausu *ScaAuthUserSocialUpdate) SetStatus(i int) *ScaAuthUserSocialUpdate {
sausu.mutation.ResetStatus()
sausu.mutation.SetStatus(i)
return sausu
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (sausu *ScaAuthUserSocialUpdate) SetNillableStatus(i *int) *ScaAuthUserSocialUpdate {
if i != nil {
sausu.SetStatus(*i)
}
return sausu
}
// AddStatus adds i to the "status" field.
func (sausu *ScaAuthUserSocialUpdate) AddStatus(i int) *ScaAuthUserSocialUpdate {
sausu.mutation.AddStatus(i)
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()
return withHooks(ctx, sausu.sqlSave, sausu.mutation, sausu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (sausu *ScaAuthUserSocialUpdate) SaveX(ctx context.Context) int {
affected, err := sausu.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (sausu *ScaAuthUserSocialUpdate) Exec(ctx context.Context) error {
_, err := sausu.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sausu *ScaAuthUserSocialUpdate) ExecX(ctx context.Context) {
if err := sausu.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (sausu *ScaAuthUserSocialUpdate) defaults() {
if _, ok := sausu.mutation.UpdatedAt(); !ok {
v := scaauthusersocial.UpdateDefaultUpdatedAt()
sausu.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (sausu *ScaAuthUserSocialUpdate) check() error {
if v, ok := sausu.mutation.Deleted(); ok {
if err := scaauthusersocial.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.deleted": %w`, err)}
}
}
if v, ok := sausu.mutation.UserID(); ok {
if err := scaauthusersocial.UserIDValidator(v); err != nil {
return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.user_id": %w`, err)}
}
}
if v, ok := sausu.mutation.OpenID(); ok {
if err := scaauthusersocial.OpenIDValidator(v); err != nil {
return &ValidationError{Name: "open_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.open_id": %w`, err)}
}
}
if v, ok := sausu.mutation.Source(); ok {
if err := scaauthusersocial.SourceValidator(v); err != nil {
return &ValidationError{Name: "source", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.source": %w`, err)}
}
}
return nil
}
func (sausu *ScaAuthUserSocialUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := sausu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(scaauthusersocial.Table, scaauthusersocial.Columns, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64))
if ps := sausu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := sausu.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthusersocial.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := sausu.mutation.Deleted(); ok {
_spec.SetField(scaauthusersocial.FieldDeleted, field.TypeInt8, value)
}
if value, ok := sausu.mutation.AddedDeleted(); ok {
_spec.AddField(scaauthusersocial.FieldDeleted, field.TypeInt8, value)
}
if sausu.mutation.DeletedCleared() {
_spec.ClearField(scaauthusersocial.FieldDeleted, field.TypeInt8)
}
if value, ok := sausu.mutation.UserID(); ok {
_spec.SetField(scaauthusersocial.FieldUserID, field.TypeString, value)
}
if value, ok := sausu.mutation.OpenID(); ok {
_spec.SetField(scaauthusersocial.FieldOpenID, field.TypeString, value)
}
if value, ok := sausu.mutation.Source(); ok {
_spec.SetField(scaauthusersocial.FieldSource, field.TypeString, value)
}
if value, ok := sausu.mutation.Status(); ok {
_spec.SetField(scaauthusersocial.FieldStatus, field.TypeInt, value)
}
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}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
sausu.mutation.done = true
return n, nil
}
// ScaAuthUserSocialUpdateOne is the builder for updating a single ScaAuthUserSocial entity.
type ScaAuthUserSocialUpdateOne struct {
config
fields []string
hooks []Hook
mutation *ScaAuthUserSocialMutation
}
// SetUpdatedAt sets the "updated_at" field.
func (sausuo *ScaAuthUserSocialUpdateOne) SetUpdatedAt(t time.Time) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.SetUpdatedAt(t)
return sausuo
}
// SetDeleted sets the "deleted" field.
func (sausuo *ScaAuthUserSocialUpdateOne) SetDeleted(i int8) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.ResetDeleted()
sausuo.mutation.SetDeleted(i)
return sausuo
}
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableDeleted(i *int8) *ScaAuthUserSocialUpdateOne {
if i != nil {
sausuo.SetDeleted(*i)
}
return sausuo
}
// AddDeleted adds i to the "deleted" field.
func (sausuo *ScaAuthUserSocialUpdateOne) AddDeleted(i int8) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.AddDeleted(i)
return sausuo
}
// ClearDeleted clears the value of the "deleted" field.
func (sausuo *ScaAuthUserSocialUpdateOne) ClearDeleted() *ScaAuthUserSocialUpdateOne {
sausuo.mutation.ClearDeleted()
return sausuo
}
// SetUserID sets the "user_id" field.
func (sausuo *ScaAuthUserSocialUpdateOne) SetUserID(s string) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.SetUserID(s)
return sausuo
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableUserID(s *string) *ScaAuthUserSocialUpdateOne {
if s != nil {
sausuo.SetUserID(*s)
}
return sausuo
}
// SetOpenID sets the "open_id" field.
func (sausuo *ScaAuthUserSocialUpdateOne) SetOpenID(s string) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.SetOpenID(s)
return sausuo
}
// SetNillableOpenID sets the "open_id" field if the given value is not nil.
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableOpenID(s *string) *ScaAuthUserSocialUpdateOne {
if s != nil {
sausuo.SetOpenID(*s)
}
return sausuo
}
// SetSource sets the "source" field.
func (sausuo *ScaAuthUserSocialUpdateOne) SetSource(s string) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.SetSource(s)
return sausuo
}
// SetNillableSource sets the "source" field if the given value is not nil.
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableSource(s *string) *ScaAuthUserSocialUpdateOne {
if s != nil {
sausuo.SetSource(*s)
}
return sausuo
}
// SetStatus sets the "status" field.
func (sausuo *ScaAuthUserSocialUpdateOne) SetStatus(i int) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.ResetStatus()
sausuo.mutation.SetStatus(i)
return sausuo
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableStatus(i *int) *ScaAuthUserSocialUpdateOne {
if i != nil {
sausuo.SetStatus(*i)
}
return sausuo
}
// AddStatus adds i to the "status" field.
func (sausuo *ScaAuthUserSocialUpdateOne) AddStatus(i int) *ScaAuthUserSocialUpdateOne {
sausuo.mutation.AddStatus(i)
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...)
return sausuo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (sausuo *ScaAuthUserSocialUpdateOne) Select(field string, fields ...string) *ScaAuthUserSocialUpdateOne {
sausuo.fields = append([]string{field}, fields...)
return sausuo
}
// Save executes the query and returns the updated ScaAuthUserSocial entity.
func (sausuo *ScaAuthUserSocialUpdateOne) Save(ctx context.Context) (*ScaAuthUserSocial, error) {
sausuo.defaults()
return withHooks(ctx, sausuo.sqlSave, sausuo.mutation, sausuo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (sausuo *ScaAuthUserSocialUpdateOne) SaveX(ctx context.Context) *ScaAuthUserSocial {
node, err := sausuo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (sausuo *ScaAuthUserSocialUpdateOne) Exec(ctx context.Context) error {
_, err := sausuo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (sausuo *ScaAuthUserSocialUpdateOne) ExecX(ctx context.Context) {
if err := sausuo.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (sausuo *ScaAuthUserSocialUpdateOne) defaults() {
if _, ok := sausuo.mutation.UpdatedAt(); !ok {
v := scaauthusersocial.UpdateDefaultUpdatedAt()
sausuo.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (sausuo *ScaAuthUserSocialUpdateOne) check() error {
if v, ok := sausuo.mutation.Deleted(); ok {
if err := scaauthusersocial.DeletedValidator(v); err != nil {
return &ValidationError{Name: "deleted", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.deleted": %w`, err)}
}
}
if v, ok := sausuo.mutation.UserID(); ok {
if err := scaauthusersocial.UserIDValidator(v); err != nil {
return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.user_id": %w`, err)}
}
}
if v, ok := sausuo.mutation.OpenID(); ok {
if err := scaauthusersocial.OpenIDValidator(v); err != nil {
return &ValidationError{Name: "open_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.open_id": %w`, err)}
}
}
if v, ok := sausuo.mutation.Source(); ok {
if err := scaauthusersocial.SourceValidator(v); err != nil {
return &ValidationError{Name: "source", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.source": %w`, err)}
}
}
return nil
}
func (sausuo *ScaAuthUserSocialUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthUserSocial, err error) {
if err := sausuo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(scaauthusersocial.Table, scaauthusersocial.Columns, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64))
id, ok := sausuo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaAuthUserSocial.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := sausuo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, scaauthusersocial.FieldID)
for _, f := range fields {
if !scaauthusersocial.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != scaauthusersocial.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := sausuo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := sausuo.mutation.UpdatedAt(); ok {
_spec.SetField(scaauthusersocial.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := sausuo.mutation.Deleted(); ok {
_spec.SetField(scaauthusersocial.FieldDeleted, field.TypeInt8, value)
}
if value, ok := sausuo.mutation.AddedDeleted(); ok {
_spec.AddField(scaauthusersocial.FieldDeleted, field.TypeInt8, value)
}
if sausuo.mutation.DeletedCleared() {
_spec.ClearField(scaauthusersocial.FieldDeleted, field.TypeInt8)
}
if value, ok := sausuo.mutation.UserID(); ok {
_spec.SetField(scaauthusersocial.FieldUserID, field.TypeString, value)
}
if value, ok := sausuo.mutation.OpenID(); ok {
_spec.SetField(scaauthusersocial.FieldOpenID, field.TypeString, value)
}
if value, ok := sausuo.mutation.Source(); ok {
_spec.SetField(scaauthusersocial.FieldSource, field.TypeString, value)
}
if value, ok := sausuo.mutation.Status(); ok {
_spec.SetField(scaauthusersocial.FieldStatus, field.TypeInt, value)
}
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
if err = sqlgraph.UpdateNode(ctx, sausuo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{scaauthusersocial.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
sausuo.mutation.done = true
return _node, nil
}

View File

@@ -1,31 +0,0 @@
package mixin
import (
"time"
"entgo.io/ent"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/mixin"
)
type DefaultMixin struct {
mixin.Schema
}
func (DefaultMixin) Fields() []ent.Field {
return []ent.Field{
field.Time("created_at").
Immutable().
Default(time.Now).
Comment("创建时间"),
field.Time("updated_at").
Default(time.Now).
Comment("更新时间").
UpdateDefault(time.Now),
field.Int8("deleted").
Default(0).
Max(1).
Optional().
Comment("是否删除 0 未删除 1 已删除"),
}
}

View File

@@ -1,73 +0,0 @@
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// ScaAuthPermissionRule holds the schema definition for the ScaAuthPermissionRule entity.
type ScaAuthPermissionRule struct {
ent.Schema
}
// Fields of the ScaAuthPermissionRule.
func (ScaAuthPermissionRule) Fields() []ent.Field {
return []ent.Field{
field.Int64("id").
SchemaType(map[string]string{
dialect.MySQL: "bigint(20) unsigned",
}).
Unique(),
field.String("ptype").
MaxLen(100).
Nillable(),
field.String("v0").
MaxLen(100).
Nillable(),
field.String("v1").
MaxLen(100).
Nillable(),
field.String("v2").
MaxLen(100).
Optional().
Nillable(),
field.String("v3").
MaxLen(100).
Optional().
Nillable(),
field.String("v4").
MaxLen(100).
Optional().
Nillable(),
field.String("v5").
MaxLen(100).
Optional().
Nillable().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(),
}
}
// Annotations of the ScaAuthPermissionRule.
func (ScaAuthPermissionRule) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.WithComments(true),
schema.Comment("角色权限规则表"),
entsql.Annotation{
Table: "sca_auth_permission_rule",
},
}
}

View File

@@ -1,67 +0,0 @@
package schema
import (
"entgo.io/ent"
"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/common/ent/schema/mixin"
)
// ScaAuthRole holds the schema definition for the ScaAuthRole entity.
type ScaAuthRole struct {
ent.Schema
}
func (ScaAuthRole) Mixin() []ent.Mixin {
return []ent.Mixin{
mixin.DefaultMixin{},
}
}
// Fields of the ScaAuthRole.
func (ScaAuthRole) Fields() []ent.Field {
return []ent.Field{
field.Int64("id").
SchemaType(map[string]string{
dialect.MySQL: "bigint(20)",
}).
Unique().
Comment("主键ID"),
field.String("role_name").
MaxLen(32).
Comment("角色名称"),
field.String("role_key").
MaxLen(64).
Comment("角色关键字").
Annotations(
entsql.WithComments(true),
),
}
}
// Edges of the ScaAuthRole.
func (ScaAuthRole) Edges() []ent.Edge {
return []ent.Edge{
edge.To("sca_auth_permission_rule", ScaAuthPermissionRule.Type),
}
}
// Indexes of the ScaAuthRole.
func (ScaAuthRole) Indexes() []ent.Index {
return nil
}
// Annotations of the ScaAuthRole.
func (ScaAuthRole) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.WithComments(true),
schema.Comment("角色表"),
entsql.Annotation{
Table: "sca_auth_role",
},
}
}

View File

@@ -1,125 +0,0 @@
package schema
import (
"entgo.io/ent"
"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"
"schisandra-album-cloud-microservices/common/ent/schema/mixin"
)
// ScaAuthUser holds the schema definition for the ScaAuthUser entity.
type ScaAuthUser struct {
ent.Schema
}
func (ScaAuthUser) Mixin() []ent.Mixin {
return []ent.Mixin{
mixin.DefaultMixin{},
}
}
// Fields of the ScaAuthUser.
func (ScaAuthUser) Fields() []ent.Field {
return []ent.Field{
field.Int64("id").
SchemaType(map[string]string{
dialect.MySQL: "bigint(20)",
}).
Unique().
Comment("自增ID"),
field.String("uid").
MaxLen(20).
Unique().
Comment("唯一ID"),
field.String("username").
MaxLen(32).
Optional().
Comment("用户名"),
field.String("nickname").
MaxLen(32).
Optional().
Comment("昵称"),
field.String("email").
MaxLen(32).
Optional().
Comment("邮箱"),
field.String("phone").
MaxLen(32).
Optional().
Comment("电话"),
field.String("password").
MaxLen(64).
Optional().
Sensitive().
Comment("密码"),
field.String("gender").
MaxLen(32).
Optional().
Comment("性别"),
field.String("avatar").
Optional().
Comment("头像"),
field.Int8("status").
Default(0).
Optional().
Comment("状态 0 正常 1 封禁"),
field.String("introduce").
MaxLen(255).
Optional().
Comment("介绍"),
field.String("blog").
MaxLen(30).
Nillable().
Optional().
Comment("博客"),
field.String("location").
MaxLen(50).
Nillable().
Optional().
Comment("地址"),
field.String("company").
MaxLen(50).
Nillable().
Optional().
Comment("公司").
Annotations(
entsql.WithComments(true),
),
}
}
// 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),
}
}
// Indexes of the ScaAuthUser.
func (ScaAuthUser) Indexes() []ent.Index {
return []ent.Index{
index.Fields("id").
Unique(),
index.Fields("uid").
Unique(),
index.Fields("phone").
Unique(),
}
}
// Annotations of the ScaAuthUser.
func (ScaAuthUser) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.WithComments(true),
schema.Comment("用户表"),
entsql.Annotation{
Table: "sca_auth_user",
},
}
}

View File

@@ -1,103 +0,0 @@
package schema
import (
"entgo.io/ent"
"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"
"schisandra-album-cloud-microservices/common/ent/schema/mixin"
)
// ScaAuthUserDevice holds the schema definition for the ScaAuthUserDevice entity.
type ScaAuthUserDevice struct {
ent.Schema
}
func (ScaAuthUserDevice) Mixin() []ent.Mixin {
return []ent.Mixin{
mixin.DefaultMixin{},
}
}
// Fields of the ScaAuthUserDevice.
func (ScaAuthUserDevice) Fields() []ent.Field {
return []ent.Field{
field.Int64("id").
SchemaType(map[string]string{
dialect.MySQL: "bigint(20)",
}).
Unique().
Comment("主键ID"),
field.String("user_id").
MaxLen(20).
Comment("用户ID"),
field.String("ip").
MaxLen(20).
Comment("登录IP"),
field.String("location").
MaxLen(20).
Comment("地址"),
field.String("agent").
MaxLen(255).
Comment("设备信息"),
field.String("browser").
MaxLen(20).
Comment("浏览器"),
field.String("operating_system").
MaxLen(20).
Comment("操作系统"),
field.String("browser_version").
MaxLen(20).
Comment("浏览器版本"),
field.Int("mobile").
Comment("是否为手机 0否1是"),
field.Int("bot").
Comment("是否为bot 0否1是"),
field.String("mozilla").
MaxLen(10).
Comment("火狐版本"),
field.String("platform").
MaxLen(20).
Comment("平台"),
field.String("engine_name").
MaxLen(20).
Comment("引擎名称"),
field.String("engine_version").
MaxLen(20).
Comment("引擎版本").Annotations(
entsql.WithComments(true),
),
}
}
// 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(),
}
}
// Indexes of the ScaAuthUserDevice.
func (ScaAuthUserDevice) Indexes() []ent.Index {
return []ent.Index{
index.Fields("id").
Unique(),
}
}
// Annotations of the ScaAuthUserDevice.
func (ScaAuthUserDevice) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.WithComments(true),
schema.Comment("用户设备表"),
entsql.Annotation{
Table: "sca_auth_user_device",
},
}
}

View File

@@ -1,82 +0,0 @@
package schema
import (
"entgo.io/ent"
"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"
"schisandra-album-cloud-microservices/common/ent/schema/mixin"
)
// ScaAuthUserSocial holds the schema definition for the ScaAuthUserSocial entity.
type ScaAuthUserSocial struct {
ent.Schema
}
func (ScaAuthUserSocial) Mixin() []ent.Mixin {
return []ent.Mixin{
mixin.DefaultMixin{},
}
}
// Fields of the ScaAuthUserSocial.
func (ScaAuthUserSocial) Fields() []ent.Field {
return []ent.Field{
field.Int64("id").
SchemaType(map[string]string{
dialect.MySQL: "bigint(20)",
}).
Unique().
Comment("主键ID"),
field.String("user_id").
MaxLen(20).
Comment("用户ID"),
field.String("open_id").
MaxLen(50).
Comment("第三方用户的 open id"),
field.String("source").
MaxLen(10).
Comment("第三方用户来源"),
field.Int("status").
Default(0).
Comment("状态 0正常 1 封禁").Annotations(
entsql.WithComments(true),
),
}
}
// 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(),
}
}
// Indexes of the ScaAuthUserSocial.
func (ScaAuthUserSocial) Indexes() []ent.Index {
return []ent.Index{
index.Fields("id").
Unique(),
index.Fields("user_id").
Unique(),
index.Fields("open_id").
Unique(),
}
}
// Annotations of the ScaAuthUserSocial.
func (ScaAuthUserSocial) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.WithComments(true),
schema.Comment("用户第三方登录信息"),
entsql.Annotation{
Table: "sca_auth_user_social",
},
}
}

View File

@@ -1,222 +0,0 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"sync"
"entgo.io/ent/dialect"
)
// Tx is a transactional client that is created by calling Client.Tx().
type Tx struct {
config
// ScaAuthPermissionRule is the client for interacting with the ScaAuthPermissionRule builders.
ScaAuthPermissionRule *ScaAuthPermissionRuleClient
// ScaAuthRole is the client for interacting with the ScaAuthRole builders.
ScaAuthRole *ScaAuthRoleClient
// ScaAuthUser is the client for interacting with the ScaAuthUser builders.
ScaAuthUser *ScaAuthUserClient
// ScaAuthUserDevice is the client for interacting with the ScaAuthUserDevice builders.
ScaAuthUserDevice *ScaAuthUserDeviceClient
// ScaAuthUserSocial is the client for interacting with the ScaAuthUserSocial builders.
ScaAuthUserSocial *ScaAuthUserSocialClient
// lazily loaded.
client *Client
clientOnce sync.Once
// ctx lives for the life of the transaction. It is
// the same context used by the underlying connection.
ctx context.Context
}
type (
// Committer is the interface that wraps the Commit method.
Committer interface {
Commit(context.Context, *Tx) error
}
// The CommitFunc type is an adapter to allow the use of ordinary
// function as a Committer. If f is a function with the appropriate
// signature, CommitFunc(f) is a Committer that calls f.
CommitFunc func(context.Context, *Tx) error
// CommitHook defines the "commit middleware". A function that gets a Committer
// and returns a Committer. For example:
//
// hook := func(next ent.Committer) ent.Committer {
// return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error {
// // Do some stuff before.
// if err := next.Commit(ctx, tx); err != nil {
// return err
// }
// // Do some stuff after.
// return nil
// })
// }
//
CommitHook func(Committer) Committer
)
// Commit calls f(ctx, m).
func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error {
return f(ctx, tx)
}
// Commit commits the transaction.
func (tx *Tx) Commit() error {
txDriver := tx.config.driver.(*txDriver)
var fn Committer = CommitFunc(func(context.Context, *Tx) error {
return txDriver.tx.Commit()
})
txDriver.mu.Lock()
hooks := append([]CommitHook(nil), txDriver.onCommit...)
txDriver.mu.Unlock()
for i := len(hooks) - 1; i >= 0; i-- {
fn = hooks[i](fn)
}
return fn.Commit(tx.ctx, tx)
}
// OnCommit adds a hook to call on commit.
func (tx *Tx) OnCommit(f CommitHook) {
txDriver := tx.config.driver.(*txDriver)
txDriver.mu.Lock()
txDriver.onCommit = append(txDriver.onCommit, f)
txDriver.mu.Unlock()
}
type (
// Rollbacker is the interface that wraps the Rollback method.
Rollbacker interface {
Rollback(context.Context, *Tx) error
}
// The RollbackFunc type is an adapter to allow the use of ordinary
// function as a Rollbacker. If f is a function with the appropriate
// signature, RollbackFunc(f) is a Rollbacker that calls f.
RollbackFunc func(context.Context, *Tx) error
// RollbackHook defines the "rollback middleware". A function that gets a Rollbacker
// and returns a Rollbacker. For example:
//
// hook := func(next ent.Rollbacker) ent.Rollbacker {
// return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error {
// // Do some stuff before.
// if err := next.Rollback(ctx, tx); err != nil {
// return err
// }
// // Do some stuff after.
// return nil
// })
// }
//
RollbackHook func(Rollbacker) Rollbacker
)
// Rollback calls f(ctx, m).
func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error {
return f(ctx, tx)
}
// Rollback rollbacks the transaction.
func (tx *Tx) Rollback() error {
txDriver := tx.config.driver.(*txDriver)
var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error {
return txDriver.tx.Rollback()
})
txDriver.mu.Lock()
hooks := append([]RollbackHook(nil), txDriver.onRollback...)
txDriver.mu.Unlock()
for i := len(hooks) - 1; i >= 0; i-- {
fn = hooks[i](fn)
}
return fn.Rollback(tx.ctx, tx)
}
// OnRollback adds a hook to call on rollback.
func (tx *Tx) OnRollback(f RollbackHook) {
txDriver := tx.config.driver.(*txDriver)
txDriver.mu.Lock()
txDriver.onRollback = append(txDriver.onRollback, f)
txDriver.mu.Unlock()
}
// Client returns a Client that binds to current transaction.
func (tx *Tx) Client() *Client {
tx.clientOnce.Do(func() {
tx.client = &Client{config: tx.config}
tx.client.init()
})
return tx.client
}
func (tx *Tx) init() {
tx.ScaAuthPermissionRule = NewScaAuthPermissionRuleClient(tx.config)
tx.ScaAuthRole = NewScaAuthRoleClient(tx.config)
tx.ScaAuthUser = NewScaAuthUserClient(tx.config)
tx.ScaAuthUserDevice = NewScaAuthUserDeviceClient(tx.config)
tx.ScaAuthUserSocial = NewScaAuthUserSocialClient(tx.config)
}
// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation.
// The idea is to support transactions without adding any extra code to the builders.
// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance.
// Commit and Rollback are nop for the internal builders and the user must call one
// of them in order to commit or rollback the transaction.
//
// If a closed transaction is embedded in one of the generated entities, and the entity
// applies a query, for example: ScaAuthPermissionRule.QueryXXX(), the query will be executed
// through the driver which created this transaction.
//
// Note that txDriver is not goroutine safe.
type txDriver struct {
// the driver we started the transaction from.
drv dialect.Driver
// tx is the underlying transaction.
tx dialect.Tx
// completion hooks.
mu sync.Mutex
onCommit []CommitHook
onRollback []RollbackHook
}
// newTx creates a new transactional driver.
func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) {
tx, err := drv.Tx(ctx)
if err != nil {
return nil, err
}
return &txDriver{tx: tx, drv: drv}, nil
}
// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls
// from the internal builders. Should be called only by the internal builders.
func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil }
// Dialect returns the dialect of the driver we started the transaction from.
func (tx *txDriver) Dialect() string { return tx.drv.Dialect() }
// Close is a nop close.
func (*txDriver) Close() error { return nil }
// Commit is a nop commit for the internal builders.
// User must call `Tx.Commit` in order to commit the transaction.
func (*txDriver) Commit() error { return nil }
// Rollback is a nop rollback for the internal builders.
// User must call `Tx.Rollback` in order to rollback the transaction.
func (*txDriver) Rollback() error { return nil }
// Exec calls tx.Exec.
func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error {
return tx.tx.Exec(ctx, query, args, v)
}
// Query calls tx.Query.
func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error {
return tx.tx.Query(ctx, query, args, v)
}
var _ dialect.Driver = (*txDriver)(nil)

View File

@@ -0,0 +1,51 @@
package jwt
import (
"context"
"time"
"github.com/golang-jwt/jwt/v5"
"github.com/zeromicro/go-zero/core/logc"
)
type AccessJWTPayload struct {
UserID *string `json:"user_id"`
Type *string `json:"type" default:"access"`
}
type AccessJWTClaims struct {
AccessJWTPayload
jwt.RegisteredClaims
}
func GenerateAccessToken(secret string, payload AccessJWTPayload) string {
claims := AccessJWTClaims{
AccessJWTPayload: payload,
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Minute * 15)),
IssuedAt: jwt.NewNumericDate(time.Now()),
NotBefore: jwt.NewNumericDate(time.Now()),
},
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
accessToken, err := token.SignedString([]byte(secret))
if err != nil {
logc.Error(context.Background(), err)
return ""
}
return accessToken
}
// ParseAccessToken parses a JWT token and returns the payload
func ParseAccessToken(secret string, tokenString string) *AccessJWTPayload {
token, err := jwt.ParseWithClaims(tokenString, &AccessJWTClaims{}, func(token *jwt.Token) (interface{}, error) {
return []byte(secret), nil
})
if err != nil {
logc.Error(context.Background(), err)
return nil
}
if claims, ok := token.Claims.(*AccessJWTClaims); ok && token.Valid {
return &claims.AccessJWTPayload
}
return nil
}

View File

@@ -0,0 +1,52 @@
package jwt
import (
"context"
"time"
"github.com/golang-jwt/jwt/v5"
"github.com/zeromicro/go-zero/core/logc"
)
type RefreshJWTPayload struct {
UserID *string `json:"user_id"`
Type *string `json:"type" default:"refresh"`
}
type RefreshJWTClaims struct {
RefreshJWTPayload
jwt.RegisteredClaims
}
// GenerateRefreshToken generates a JWT token with the given payload, and returns the accessToken and refreshToken
func GenerateRefreshToken(secret string, payload RefreshJWTPayload, days time.Duration) string {
refreshClaims := RefreshJWTClaims{
RefreshJWTPayload: payload,
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(time.Now().Add(days)),
IssuedAt: jwt.NewNumericDate(time.Now()),
NotBefore: jwt.NewNumericDate(time.Now()),
},
}
refreshToken := jwt.NewWithClaims(jwt.SigningMethodHS256, refreshClaims)
refreshTokenString, err := refreshToken.SignedString([]byte(secret))
if err != nil {
logc.Error(context.Background(), err)
return ""
}
return refreshTokenString
}
// ParseRefreshToken parses a JWT token and returns the payload
func ParseRefreshToken(secret string, refreshTokenString string) *RefreshJWTPayload {
token, err := jwt.ParseWithClaims(refreshTokenString, &RefreshJWTClaims{}, func(token *jwt.Token) (interface{}, error) {
return []byte(secret), nil
})
if err != nil {
logc.Error(context.Background(), err)
return nil
}
if claims, ok := token.Claims.(*RefreshJWTClaims); ok && token.Valid {
return &claims.RefreshJWTPayload
}
return nil
}

20
common/utils/encrypt.go Normal file
View File

@@ -0,0 +1,20 @@
package utils
import "golang.org/x/crypto/bcrypt"
// Encrypt 加密
func Encrypt(val string) (string, error) {
// 使用bcrypt库的GenerateFromPassword函数进行哈希处理
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(val), bcrypt.DefaultCost)
if err != nil {
return "", err
}
return string(hashedPassword), err
}
// Verify 验证
func Verify(hashedVal string, val string) bool {
// 使用bcrypt库的CompareHashAndPassword函数比较密码
err := bcrypt.CompareHashAndPassword([]byte(hashedVal), []byte(val))
return err == nil
}

View File

@@ -0,0 +1,683 @@
package utils
import (
"crypto/sha256"
"encoding/base64"
"encoding/hex"
"errors"
"math"
"regexp"
"strconv"
"strings"
)
type Options struct {
Theme int
Part int
}
var svgStart = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 231 231\">"
var svgEnd = "</svg>"
var env = "<path d=\"M33.83,33.83a115.5,115.5,0,1,1,0,163.34,115.49,115.49,0,0,1,0-163.34Z\" style=\"fill:#01;\"/>"
var head = "<path d=\"m115.5 51.75a63.75 63.75 0 0 0-10.5 126.63v14.09a115.5 115.5 0 0 0-53.729 19.027 115.5 115.5 0 0 0 128.46 0 115.5 115.5 0 0 0-53.729-19.029v-14.084a63.75 63.75 0 0 0 53.25-62.881 63.75 63.75 0 0 0-63.65-63.75 63.75 63.75 0 0 0-0.09961 0z\" style=\"fill:#000;\"/>"
// Themes
var themes [16][3]map[string][]string
// Shapes
var sp [16]map[string]string
func init() {
// Robo
themes[0][0] = map[string][]string{
"env": {"#ff2f2b"},
"clo": {"#fff", "#000"},
"head": {"#fff"},
"mouth": {"#fff", "#000", "#000"},
"eyes": {"#000", "none", "#0ff"},
"top": {"#fff", "#fff"},
}
themes[0][1] = map[string][]string{
"env": {"#ff1ec1"},
"clo": {"#000", "#fff"},
"head": {"#ffc1c1"},
"mouth": {"#fff", "#000", "#000"},
"eyes": {"#FF2D00", "#fff", "none"},
"top": {"#a21d00", "#fff"},
}
themes[0][2] = map[string][]string{
"env": {"#0079b1"},
"clo": {"#0e00b1", "#d1fffe"},
"head": {"#f5aa77"},
"mouth": {"#fff", "#000", "#000"},
"eyes": {"#0c00de", "#fff", "none"},
"top": {"#acfffd", "#acfffd"},
}
// Girl
themes[1][0] = map[string][]string{
"env": {"#a50000"},
"clo": {"#f06", "#8e0039"},
"head": {"#85492C"},
"mouth": {"#000"},
"eyes": {"#000", "#ff9809"},
"top": {"#ff9809", "#ff9809", "none", "none"},
}
themes[1][1] = map[string][]string{
"env": {"#40E83B"},
"clo": {"#00650b", "#62ce5a"},
"head": {"#f7c1a6"},
"mouth": {"#6e1c1c"},
"eyes": {"#000", "#ff833b"},
"top": {"#67FFCC", "none", "none", "#ecff3b"},
}
themes[1][2] = map[string][]string{
"env": {"#ff2c2c"},
"clo": {"#fff", "#000"},
"head": {"#ffce8b"},
"mouth": {"#000"},
"eyes": {"#000", "#0072ff"},
"top": {"#ff9809", "none", "#ffc809", "none"},
}
// Blonde
themes[2][0] = map[string][]string{
"env": {"#ff7520"},
"clo": {"#d12823"},
"head": {"#fee3c5"},
"mouth": {"#d12823"},
"eyes": {"#000", "none"},
"top": {"#000", "none", "none", "#FFCC00", "red"},
}
themes[2][1] = map[string][]string{
"env": {"#ff9700"},
"clo": {"#000"},
"head": {"#d2ad6d"},
"mouth": {"#000"},
"eyes": {"#000", "#00ffdc"},
"top": {"#fdff00", "#fdff00", "none", "none", "none"},
}
themes[2][2] = map[string][]string{
"env": {"#26a7ff"},
"clo": {"#d85cd7"},
"head": {"#542e02"},
"mouth": {"#f70014"},
"eyes": {"#000", "magenta"},
"top": {"#FFCC00", "#FFCC00", "#FFCC00", "#ff0000", "yellow"},
}
// Evilnormie
themes[3][0] = map[string][]string{
"env": {"#6FC30E"},
"clo": {"#b4e1fa", "#5b5d6e", "#515262", "#a0d2f0", "#a0d2f0"},
"head": {"#fae3b9"},
"mouth": {"#fff", "#000"},
"eyes": {"#000"},
"top": {"#8eff45", "#8eff45", "none", "none"},
}
themes[3][1] = map[string][]string{
"env": {"#00a58c"},
"clo": {"#000", "#5b00", "#5100", "#a000", "#a000"},
"head": {"#FAD2B9"},
"mouth": {"#fff", "#000"},
"eyes": {"#000"},
"top": {"#FFC600", "none", "#FFC600", "none"},
}
themes[3][2] = map[string][]string{
"env": {"#ff501f"},
"clo": {"#000", "#ff0000", "#ff0000", "#7d7d7d", "#7d7d7d"},
"head": {"#fff3dc"},
"mouth": {"#d2001b", "none"},
"eyes": {"#000"},
"top": {"#D2001B", "none", "none", "#D2001B"},
}
// Country
themes[4][0] = map[string][]string{
"env": {"#fc0"},
"clo": {"#901e0e", "#ffbe1e", "#ffbe1e", "#c55f54"},
"head": {"#f8d9ad"},
"mouth": {"#000", "none", "#000", "none"},
"eyes": {"#000"},
"top": {"#583D00", "#AF892E", "#462D00", "#a0a0a0"},
}
themes[4][1] = map[string][]string{
"env": {"#386465"},
"clo": {"#fff", "#333", "#333", "#333"},
"head": {"#FFD79D"},
"mouth": {"#000", "#000", "#000", "#000"},
"eyes": {"#000"},
"top": {"#27363C", "#5DCAD4", "#314652", "#333"},
}
themes[4][2] = map[string][]string{
"env": {"#DFFF00"},
"clo": {"#304267", "#aab0b1", "#aab0b1", "#aab0b1"},
"head": {"#e6b876"},
"mouth": {"#50230a", "#50230a", "#50230a", "#50230a"},
"eyes": {"#000"},
"top": {"#333", "#afafaf", "#222", "#6d3a1d"},
}
// Johnyold
themes[5][0] = map[string][]string{
"env": {"#a09300"},
"clo": {"#c7d4e2", "#435363", "#435363", "#141720", "#141720", "#e7ecf2", "#e7ecf2"},
"head": {"#f5d4a6"},
"mouth": {"#000", "#cf9f76"},
"eyes": {"#000", "#000", "#000", "#000", "#000", "#000", "#fff", "#fff", "#fff", "#fff", "#000", "#000"},
"top": {"none", "#fdff00"},
}
themes[5][1] = map[string][]string{
"env": {"#b3003e"},
"clo": {"#000", "#435363", "#435363", "#000", "none", "#e7ecf2", "#e7ecf2"},
"head": {"#f5d4a6"},
"mouth": {"#000", "#af9f94"},
"eyes": {"#9ff3ffdb", "#000", "#9ff3ffdb", "#000", "#2f508a", "#000", "#000", "#000", "none", "none", "none", "none"},
"top": {"#ff9a00", "#ff9a00"},
}
themes[5][2] = map[string][]string{
"env": {"#884f00"},
"clo": {"#ff0000", "#fff", "#fff", "#141720", "#141720", "#e7ecf2", "#e7ecf2"},
"head": {"#c57b14"},
"mouth": {"#000", "#cf9f76"},
"eyes": {"none", "#000", "none", "#000", "#5a0000", "#000", "#000", "#000", "none", "none", "none", "none"},
"top": {"#efefef", "none"},
}
// Asian
themes[6][0] = map[string][]string{
"env": {"#8acf00"},
"clo": {"#ee2829", "#ff0"},
"head": {"#ffce73"},
"mouth": {"#fff", "#000"},
"eyes": {"#000"},
"top": {"#000", "#000", "none", "#000", "#ff4e4e", "#000"},
}
themes[6][1] = map[string][]string{
"env": {"#00d2a3"},
"clo": {"#0D0046", "#ffce73"},
"head": {"#ffce73"},
"mouth": {"#000", "none"},
"eyes": {"#000"},
"top": {"#000", "#000", "#000", "none", "#ffb358", "#000", "none", "none"},
}
themes[6][2] = map[string][]string{
"env": {"#ff184e"},
"clo": {"#000", "none"},
"head": {"#ffce73"},
"mouth": {"#ff0000", "none"},
"eyes": {"#000"},
"top": {"none", "none", "none", "none", "none", "#ffc107", "none", "none"},
}
// Punk
themes[7][0] = map[string][]string{
"env": {"#00deae"},
"clo": {"#ff0000"},
"head": {"#ffce94"},
"mouth": {"#f73b6c", "#000"},
"eyes": {"#e91e63", "#000", "#e91e63", "#000", "#000", "#000"},
"top": {"#dd104f", "#dd104f", "#f73b6c", "#dd104f"},
}
themes[7][1] = map[string][]string{
"env": {"#181284"},
"clo": {"#491f49", "#ff9809", "#491f49"},
"head": {"#f6ba97"},
"mouth": {"#ff9809", "#000"},
"eyes": {"#c4ffe4", "#000", "#c4ffe4", "#000", "#000", "#000"},
"top": {"none", "none", "#d6f740", "#516303"},
}
themes[7][2] = map[string][]string{
"env": {"#bcf700"},
"clo": {"#ff14e4", "#000", "#14fffd"},
"head": {"#7b401e"},
"mouth": {"#666", "#000"},
"eyes": {"#00b5b4", "#000", "#00b5b4", "#000", "#000", "#000"},
"top": {"#14fffd", "#14fffd", "#14fffd", "#0d3a62"},
}
// Afrohair
themes[8][0] = map[string][]string{
"env": {"#0df"},
"clo": {"#571e57", "#ff0"},
"head": {"#f2c280"},
"mouth": {"#ff0000"},
"eyes": {"#795548", "#000"},
"top": {"#de3b00", "none"},
}
themes[8][1] = map[string][]string{
"env": {"#B400C2"},
"clo": {"#0D204A", "#00ffdf"},
"head": {"#ca8628"},
"mouth": {"#1a1a1a"},
"eyes": {"#cbbdaf", "#000"},
"top": {"#000", "#000"},
}
themes[8][2] = map[string][]string{
"env": {"#ffe926"},
"clo": {"#00d6af", "#000"},
"head": {"#8c5100"},
"mouth": {"#7d0000"},
"eyes": {"none", "#000"},
"top": {"#f7f7f7", "none"},
}
// Normie female
themes[9][0] = map[string][]string{
"env": {"#4aff0c"},
"clo": {"#101010", "#fff", "#fff"},
"head": {"#dbbc7f"},
"mouth": {"#000"},
"eyes": {"#000", "none", "none"},
"top": {"#531148", "#531148", "#531148", "none"},
}
themes[9][1] = map[string][]string{
"env": {"#FFC107"},
"clo": {"#033c58", "#fff", "#fff"},
"head": {"#dbc97f"},
"mouth": {"#000"},
"eyes": {"none", "#fff", "#000"},
"top": {"#FFEB3B", "#FFEB3B", "none", "#FFEB3B"},
}
themes[9][2] = map[string][]string{
"env": {"#FF9800"},
"clo": {"#b40000", "#fff", "#fff"},
"head": {"#E2AF6B"},
"mouth": {"#000"},
"eyes": {"none", "#fff", "#000"},
"top": {"#ec0000", "#ec0000", "none", "none"},
}
// Older
themes[10][0] = map[string][]string{
"env": {"#104c8c"},
"clo": {"#354B65", "#3D8EBB", "#89D0DA", "#00FFFD"},
"head": {"#cc9a5c"},
"mouth": {"#222", "#fff"},
"eyes": {"#000", "#000"},
"top": {"#fff", "#fff", "none"},
}
themes[10][1] = map[string][]string{
"env": {"#0DC15C"},
"clo": {"#212121", "#fff", "#212121", "#fff"},
"head": {"#dca45f"},
"mouth": {"#111", "#633b1d"},
"eyes": {"#000", "#000"},
"top": {"none", "#792B74", "#792B74"},
}
themes[10][2] = map[string][]string{
"env": {"#ffe500"},
"clo": {"#1e5e80", "#fff", "#1e5e80", "#fff"},
"head": {"#e8bc86"},
"mouth": {"#111", "none"},
"eyes": {"#000", "#000"},
"top": {"none", "none", "#633b1d"},
}
// Firehair
themes[11][0] = map[string][]string{
"env": {"#4a3f73"},
"clo": {"#e6e9ee", "#f1543f", "#ff7058", "#fff", "#fff"},
"head": {"#b27e5b"},
"mouth": {"#191919", "#191919"},
"eyes": {"#000", "#000", "#57FFFD"},
"top": {"#ffc", "#ffc", "#ffc"},
}
themes[11][1] = map[string][]string{
"env": {"#00a08d"},
"clo": {"#FFBA32", "#484848", "#4e4e4e", "#fff", "#fff"},
"head": {"#ab5f2c"},
"mouth": {"#191919", "#191919"},
"eyes": {"#000", "#ff23fa63", "#000"},
"top": {"#ff90f4", "#ff90f4", "#ff90f4"},
}
themes[11][2] = map[string][]string{
"env": {"#22535d"},
"clo": {"#000", "#ff2500", "#ff2500", "#fff", "#fff"},
"head": {"#a76c44"},
"mouth": {"#191919", "#191919"},
"eyes": {"#000", "none", "#000"},
"top": {"none", "#00efff", "none"},
}
// Blond
themes[12][0] = map[string][]string{
"env": {"#2668DC"},
"clo": {"#2385c6", "#b8d0e0", "#b8d0e0"},
"head": {"#ad8a60"},
"mouth": {"#000", "#4d4d4d"},
"eyes": {"#7fb5a2", "#d1eddf", "#301e19"},
"top": {"#fff510", "#fff510"},
}
themes[12][1] = map[string][]string{
"env": {"#643869"},
"clo": {"#D67D1B", "#b8d0e0", "#b8d0e0"},
"head": {"#CC985A", "none0000"},
"mouth": {"#000", "#ececec"},
"eyes": {"#1f2644", "#9b97ce", "#301e19"},
"top": {"#00eaff", "none"},
}
themes[12][2] = map[string][]string{
"env": {"#F599FF"},
"clo": {"#2823C6", "#b8d0e0", "#b8d0e0"},
"head": {"#C7873A"},
"mouth": {"#000", "#4d4d4d"},
"eyes": {"#581b1b", "#FF8B8B", "#000"},
"top": {"none", "#9c0092"},
}
// Ateam
themes[13][0] = map[string][]string{
"env": {"#d10084"},
"clo": {"#efedee", "#00a1e0", "#00a1e0", "#efedee", "#ffce1c"},
"head": {"#b35f49"},
"mouth": {"#3a484a", "#000"},
"eyes": {"#000"},
"top": {"#000", "none", "#000", "none"},
}
themes[13][1] = map[string][]string{
"env": {"#E6C117"},
"clo": {"#efedee", "#ec0033", "#ec0033", "#efedee", "#f2ff05"},
"head": {"#ffc016"},
"mouth": {"#4a3737", "#000"},
"eyes": {"#000"},
"top": {"#ffe900", "#ffe900", "none", "#ffe900"},
}
themes[13][2] = map[string][]string{
"env": {"#1d8c00"},
"clo": {"#e000cb", "#fff", "#fff", "#e000cb", "#ffce1c"},
"head": {"#b96438"},
"mouth": {"#000", "#000"},
"eyes": {"#000"},
"top": {"#53ffff", "#53ffff", "none", "none"},
}
// Rasta
themes[14][0] = map[string][]string{
"env": {"#fc0065"},
"clo": {"#708913", "#fdea14", "#708913", "#fdea14", "#708913"},
"head": {"#DEA561"},
"mouth": {"#444", "#000"},
"eyes": {"#000"},
"top": {"#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f", "#32393f"},
}
themes[14][1] = map[string][]string{
"env": {"#81f72e"},
"clo": {"#ff0000", "#ffc107", "#ff0000", "#ffc107", "#ff0000"},
"head": {"#ef9831"},
"mouth": {"#6b0000", "#000"},
"eyes": {"#000"},
"top": {"#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "#FFFAAD", "none", "none", "none", "none"},
}
themes[14][2] = map[string][]string{
"env": {"#00D872"},
"clo": {"#590D00", "#FD1336", "#590D00", "#FD1336", "#590D00"},
"head": {"#c36c00"},
"mouth": {"#56442b", "#000"},
"eyes": {"#000"},
"top": {"#004E4C", "#004E4C", "#004E4C", "#004E4C", "#004E4C", "#004E4C", "#004E4C", "#004E4C", "#004E4C", "none", "none", "none", "none", "none", "none", "none", "none"},
}
// Meta
themes[15][0] = map[string][]string{
"env": {"#111"},
"clo": {"#000", "#00FFFF"},
"head": {"#755227"},
"mouth": {"#fff", "#000"},
"eyes": {"black", "#008a", "aqua"},
"top": {"#fff", "#fff", "#fff", "#fff", "#fff"},
}
themes[15][1] = map[string][]string{
"env": {"#00D0D4"},
"clo": {"#000", "#fff"},
"head": {"#755227"},
"mouth": {"#fff", "#000"},
"eyes": {"black", "#1df7ffa3", "#fcff2c"},
"top": {"#fff539", "none", "#fff539", "none", "#fff539"},
}
themes[15][2] = map[string][]string{
"env": {"#DC75FF"},
"clo": {"#000", "#FFBDEC"},
"head": {"#997549"},
"mouth": {"#fff", "#000"},
"eyes": {"black", "black", "aqua"},
"top": {"#00fffd", "none", "none", "none", "none"},
}
// Robo
sp[0] = map[string]string{
"clo": "<path d=\"m141.74 195a114.93 114.93 0 0 1 37.912 16.45l0.07 0.05c-1.17 0.79-2.3601 1.55-3.5601 2.29a115.55 115.55 0 0 1-120.95 0.21q-2.0001-1.23-4.0002-2.54a114.79 114.79 0 0 1 38.002-16.5 116.21 116.21 0 0 1 15.791-2.49v-14.57c1.32 0.22 2.6501 0.39 4.0002 0.51 2.0001 0.19 4.0002 0.28 6.1202 0.29a64.333 64.33 0 0 0 8.8804-0.62c0.67003-0.09 1.3401-0.2 2.0001-0.31v14.69a118 118 0 0 1 15.741 2.54z\" style=\"fill:#fff;\"/><path d=\"m79.292 212a3.4601 3.46 0 0 0 3.8902 5.07 3.3801 3.38 0 0 0 2.1001-1.61 3.4701 3.47 0 0 0-1.2801-4.72 3.4201 3.42 0 0 0-2.6201-0.34 3.5101 3.51 0 0 0-2.0901 1.6zm60.122 0.46a3.4901 3.49 0 0 0 1.21 4.7h0.06a3.4601 3.46 0 0 0 4.7202-1.27l0.07-0.13a3.4601 3.46 0 0 0-1.34-4.6 3.4601 3.46 0 0 0-2.5801-0.32 3.5301 3.53 0 0 0-2.1001 1.61zm9.8004 5.7 5.8602 5.87c-1.39 0.5-2.7901 1-4.2102 1.44l-4.4802-4.47a7.5203 7.52 0 0 1-1.9401 0.81 7.8303 7.83 0 0 1-6.0002-0.79 7.8703 7.87 0 0 1-2.9201-10.69v-0.07a7.8903 7.89 0 0 1 10.77-2.88l0.12 0.07a7.8603 7.86 0 0 1 2.7901 10.62v0.07zm-37.701-2.36-9.5004 9.51v4.9c-1.35-0.16-2.6801-0.33-4.0002-0.54v-6l0.58002-0.58 10.1-10.09a7.8703 7.87 0 1 1 2.8401 2.86zm7.3203-5.91a3.4601 3.46 0 1 0-1.6101 2.1 3.3801 3.38 0 0 0 1.6101-2.1zm-29.741 7.82 3.0901 3.1 0.59002 0.59v7.36c-1.3401-0.26-2.6801-0.55-4.0002-0.87v-4.84l-2.5101-2.51a7.5203 7.52 0 0 1-1.9401 0.81 7.8803 7.88 0 1 1 1.9101-14.43 7.8703 7.87 0 0 1 2.8901 10.75z\" style=\"fill:#1a1a1a;\"/>",
"mouth": "<path d=\"m94.19 136.84h42.632a3.7801 3.78 0 0 1 3.7802 3.78v3.22a15.231 15.23 0 0 1-15.211 15.16h-19.781a15.251 15.25 0 0 1-15.221-15.16v-3.22a3.8002 3.8 0 0 1 3.7802-3.78z\" style=\"fill:#fff;stroke-linecap:round;stroke-linejoin:round;stroke-width:3px;stroke:#1a1a1a;\"/><path d=\"m130.96 136.84v21.16m-30.911-21.16v21.16m10.34-21.16v22.16m10.31-22.2v22.2\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:3px;stroke:#1a1a1a;\"/>",
"eyes": "<path d=\"m83.739 83.92h63.533a19.101 19.1 0 0 1 19.051 19 19.111 19.11 0 0 1-19.051 19h-63.533a19.091 19.09 0 0 1-19.001-19 19.091 19.09 0 0 1 19.001-19z\" style=\"fill:#1a1a1a;\"/><path d=\"m140.23 93.54a9.3804 9.38 0 1 0 9.3804 9.38 9.3804 9.38 0 0 0-9.3804-9.38zm-49.402 0a9.3804 9.38 0 1 0 9.3804 9.38 9.3904 9.39 0 0 0-9.3804-9.38z\" style=\"fill:#e6e7e8;\"/><rect x=\"79.795\" y=\"98.627\" width=\"71.471\" height=\"8.5859\" ry=\"4.2929\" style=\"fill:#b3b3b3;\"/>",
"top": "<path d=\"m32.902 67.662c-0.36295 1.7227-6.2342 30.695 5.6133 52.596 4.5843 8.4743 9.0081 13.239 12.75 15.893a67.7 67.7 0 0 1-3.4688-21.35 67.7 67.7 0 0 1 2.332-17.658c-4.4914-2.4646-10.868-6.9012-13.834-13.52-4.1626-9.285-3.6155-14.673-3.3926-15.961zm165.19 0c0.22292 1.2882 0.77005 6.6759-3.3926 15.961-2.9664 6.6183-9.3426 11.055-13.834 13.52a67.7 67.7 0 0 1 2.332 17.658 67.7 67.7 0 0 1-3.4688 21.35c3.7419-2.6532 8.1657-7.4183 12.75-15.893 11.847-21.9 5.9762-50.873 5.6133-52.596z\" style=\"fill:#fff;\"/><path d=\"m115.73 13.191c-7.3787-0.13351-13.509 5.7888-13.631 13.168-0.10128 5.8827 3.4508 10.518 8.0566 12.52 1.061 0.46115 2.1869 0.78009 3.3418 0.95703v8.4291c0.66778-0.02035 1.3358-0.03077 2.0039-0.03125 0.66547-9e-5 1.3309 0.0097 1.9961 0.0293v-8.4115c2.6002-0.38406 5.1586-1.5484 7.3086-3.625 4.2322-4.0878 4.9991-9.8755 3.1582-14.549-1.8407-4.6726-6.3502-8.3834-12.232-8.4863z\" style=\"fill:#fff;\"/>",
}
// Girl
sp[1] = map[string]string{
"clo": "<path d=\"m141.75 195a114.79 114.79 0 0 1 38 16.5 115.53 115.53 0 0 1-128.46 0 114.79 114.79 0 0 1 38-16.5c0 10.76 11.75 19.48 26.25 19.48s26.25-8.72 26.25-19.48z\" style=\"fill:#1a1a1a;\"/><path d=\"m92.502 194.27v0.70391c0 4.3033 2.4373 8.2583 6.3807 11.183 4.2199 3.1204 10.106 5.0508 16.661 5.0508 6.548 0 12.434-1.9303 16.654-5.0508 3.9434-2.9245 6.388-6.8795 6.388-11.183v-0.67489c1.0768 0.21771 2.1463 0.44994 3.2158 0.69666h-7e-3c1.0695 0.24672 2.1318 0.50798 3.1867 0.791-0.27648 6.103-3.6524 11.553-8.9708 15.493-5.2821 3.9114-12.521 6.328-20.466 6.328-7.9449 0-15.184-2.4165-20.474-6.328-5.333-3.9477-8.7089-9.4194-8.9708-15.544 1.055-0.27577 2.1099-0.53702 3.1722-0.78376 1.0695-0.23947 2.1463-0.46443 3.2304-0.68213z\" style=\"fill:#b3b3b3;\"/>",
"mouth": "<path d=\"m100.35 143.85a7.67 7.67 0 0 0 7.58 7.7v0a7.66 7.66 0 0 0 7.57-7.7 7.66 7.66 0 0 0 7.57 7.7v0a7.67 7.67 0 0 0 7.58-7.7\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:6.3998px;stroke:#333;\"/>",
"eyes": "<path d=\"m78.73 111a10.9 10.9 0 0 1 15.19 0m43.16 0a10.9 10.9 0 0 1 15.19 0\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:6.1999px;stroke:#333;\"/><path d=\"m79.804 123.74h7.07m57.273 0h7.05\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:5.9998px;stroke:#b8b8b8;\"/>",
"top": "<path d=\"m57.534 142.03c-6.9383-31.75-0.57294-52.577 14.174-62.344 22.562-12.283 62.082-12.222 83.484-1.8846 21.348 11.177 22.124 37.396 18.498 63.733 8.1279-14.155 13.164-31.598 14.085-48.902 1.0828-11.795-1.1756-18.866-7.4833-27.972-26.465-37.685-103.45-31.56-129.66-2.8372-7.8504 9.4615-9.6006 17.478-9.275 26.667 1.0024 18.667 6.9688 38.508 16.18 53.54z\" style=\"fill:#b3b3b3;\"/><path d=\"m111.26 3.0423c-6.013 0.1128-12.629 2.6924-15.291 7.9082-1.1676 3.2383-1.6758 6.2069-1.6758 8.8926 0.89228-0.2661 1.8005-0.5164 2.7266-0.7441 3.7502-1.0672 7.4851-1.7135 11.129-1.9981 1.1007-0.086 2.1953-0.1391 3.2773-0.1601h2e-3c5.6969-0.1133 11.09 0.6603 15.904 2.0527 0.0552-3.042-0.70696-5.9824-2.1738-8.5-1.8411-3.1599-4.7033-5.5568-8.4297-6.8262-1.6883-0.4952-3.5163-0.662-5.4688-0.625zm3.0664 17.449c-0.69317-0.01-1.3919-0.01-2.0938 0h-2e-3c-1.1591 0.019-2.3326 0.064-3.5117 0.1386-3.9035 0.246-7.9025 0.8061-11.92 1.7285-15.159 3.0075-26.469 9.9279-22.068 19.682 22.891-8.7773 52.315-10.403 76.023-2.2129 2.1414-9.5529-14.939-19.081-36.428-19.34z\" style=\"fill:#b3b3b3;\"/><path d=\"m165.62 16.981c-0.8575 0-1.9406 0.54389-3.3476 1.3574-7.3382 4.7652-13.452 10.867-19.516 18.363 9.2734 2.1825 17.903 5.6706 25.213 10.604 1.1512-9.1263 1.9137-18.503 0.055-26.996-0.57-2.4184-1.3017-3.3267-2.4043-3.3281zm-104.09 1.6934c-1.1026 0-1.8342 0.91165-2.4043 3.3301-1.8794 8.5869-1.0806 18.078 0.092 27.299 7.0559-4.6638 15.687-8.3667 25.111-10.984-6.043-7.4601-12.139-13.537-19.451-18.285-1.407-0.81353-2.4901-1.3605-3.3477-1.3594z\" style=\"fill:#b3b3b3;\"/><path d=\"m162.45 16.686c-2.3175 2e-3 -4.6276 0.57608-6.8926 1.668-8.4768 6.0155-11.113 13.349-10.133 19.787 10.323 2.7077 19.762 7.0658 27.346 13.279 9.848-4.9363 11.32-17.137 4.6152-25.852-4.7104-6.1222-9.8371-8.8878-14.936-8.8828zm-97.318 4.1387c-2.4569 0.0556-5.1642 0.54474-8.1172 1.5176-13.487 4.4433-19.06 21.215-3.6484 31.84 7.2476-6.0694 16.961-10.896 27.892-14.229 0.2193-3.3241-0.3201-7.0817-1.8691-11.236-2.8049-4.8445-7.2233-7.721-13.221-7.8906-0.3408-0.01-0.6861-0.01-1.0371-2e-3z\" style=\"fill:#b3b3b3;\"/>",
}
// Blonde
sp[2] = map[string]string{
"clo": "<path d=\"m141.75 195a114.79 114.79 0 0 1 38 16.5 115.53 115.53 0 0 1-128.46 0 114.79 114.79 0 0 1 38-16.5c0 10.76 11.75 19.48 26.25 19.48s26.25-8.72 26.25-19.48z\" style=\"fill:#5a5a5a;\"/>",
"mouth": "<path d=\"m115.5 161.71c-8.24 0-14.46-4.15-19.19-11.25 3.37-2.44 6.51-4.57 10-6.79a5.25 5.25 0 0 1 5.48-0.17 28.19 28.19 0 0 1 3.68 2.75 28.19 28.19 0 0 1 3.68-2.75 5.25 5.25 0 0 1 5.48 0.17c3.52 2.22 6.66 4.35 10 6.79-4.74 7.1-11 11.25-19.19 11.25z\" style=\"fill:#5a5a5a;\"/>",
"eyes": "<path d=\"m172.7 90.75h-6.54c-0.14-0.1-0.26-0.22-0.4-0.3-4.48-2.76-22.75-2.11-33.71 1.2-1 0.3-1.91 0.61-2.75 0.94-1.8937 0.79244-3.8739 1.3597-5.9 1.69-5.5051 0.79002-10.403 0.79002-15.908 0-2.0261-0.33034-4.0063-0.89756-5.9-1.69-0.84-0.33-1.76-0.64-2.75-0.94-11-3.31-29.23-4-33.71-1.2-0.13832 0.08869-0.2688 0.18906-0.39 0.3h-6.55c-1.1046 0-2 0.89543-2 2v4.66c-0.0013 0.98185 0.49088 1.8986 1.31 2.44l1.9 1.27c0.59238 0.38889 0.93475 1.0622 0.9 1.77-0.14175 5.4854 0.88072 10.939 3 16 3.58 8.38 16 10.9 24.93 10.9 2.6976 0.0771 5.3921-0.2361 8-0.93 4.35-1.43 8.24-7.36 10.45-12.42 1.7607-3.8506 2.7493-8.009 2.91-12.24 7.3e-4 -0.7138 0.38183-1.3731 1-1.73 3.2281-1.951 6.5798-1.951 9.8079 0 0.61817 0.3569 0.99927 1.0162 1 1.73 0.16067 4.231 1.1493 8.3894 2.91 12.24 2.21 5.06 6.1 11 10.45 12.42 2.6079 0.6939 5.3024 1.0071 8 0.93 8.92 0 21.35-2.52 24.93-10.9 2.1193-5.0614 3.1418-10.515 3-16-0.0348-0.70778 0.30762-1.3811 0.9-1.77l1.9-1.27c0.81913-0.54136 1.3113-1.4582 1.31-2.44v-4.6c0.0336-1.1048-0.83521-2.0274-1.94-2.06z\" style=\"fill:#1a1a1a;stroke-linecap:round;stroke-linejoin:round;stroke-width:2.5;stroke:#b3b3b3;\"/>",
"top": "<path d=\"m124.22 13.61c-19.783 0-36.945 8.0887-39.695 24.106-15.332 0.23539-31.831 2.7712-41.663 15.782-6.0238 7.9604-7.0402 19.901-6.8476 31.724 0.46007 28.503 10.742 64.228-4.3012 89.714 16.584 5.7777 43.086 10.742 73.59 11.662v-8.6558c-1.851-0.35308-3.6592-0.78105-5.4353-1.2732-30.953-8.4632-50.672-36.635-47.259-68.669 1.5514-10.603 4.6221-19.665 10.025-27.69 5.3818-7.9925 13.267-15.717 23.892-21.41 0.40658 0.72757 1.9901 3.5843 2.4074 4.3012 7.5003 12.775 17.986 23.849 33.157 26.866 12.433 2.4609 23.849 3.4666 36.346 1.1555 4.2584-0.78106 10.667-2.3967 14.851-2.4181 14.861 33.404-1.0806 75.035-40.668 87.457-2.2255 0.70616-4.5258 1.316-6.8904 1.8189 0 2.707-0.0428 5.6493-0.0642 8.5274 23.603-0.72757 48.682-4.0444 72.874-11.234-18.521-32.152 0.81315-89.083-10.036-121.46-9.0731-26.973-38.85-40.315-64.282-40.305z\" style=\"fill:#c5c5c5;\"/><path d=\"m33.147 172.32c-2.6535 5.1143-6.088 9.9504-10.1 12.411 7.8427 10.453 17.387 19.516 28.257 26.781 16.038-10.731 35.629-17.055 54-18.606v-9.0089c-30.065-0.94155-56.108-5.8847-72.157-11.577zm164.06 0.55637c-23.731 7.0723-48.361 10.325-71.525 11.042-0.0321 3.1242-0.0535 6.2377-0.0107 9.0517 19.227 1.7226 37.908 7.8534 53.989 18.542 0.0107 0 0.0107 0 0.0214 0.0107 10.731-7.1686 20.179-16.081 27.958-26.374-4.2798-2.3967-7.832-6.9653-10.432-12.272z\" style=\"fill:#c5c5c5;\"/><path d=\"m50.02 46.5c-2.9297 1.9143-6.1313 3.8826-10.154 7.9805-14.091 14.359-16.145 27.701-6.1406 44.018 4.2049 6.8583 6.1414 13.706-0.24609 20.5-7.7143 8.1957-21.559 4.2912-21.537 16.061 0.0214 8.613 15.063 7.9178 22.531 13.984 3.7662 3.0707 5.0836 8.3992 2.0664 12.508-4.2156 5.7456-16.006 7.3715-22.629 8.9336 5.8811 10.843 13.45 20.638 22.355 29.033l0.0039 0.0234 0.0059-0.0137c2e-3 2e-3 0.0038 4e-3 0.0059 6e-3 0.0034-0.0112 0.0063-0.0219 0.0098-0.0332 14.775-12.218 20.268-20.965 49.461-28.434-17.404-10.258-30.68-27.122-24.143-35.34 4.4123-5.5444 5.6612-7.8633 6.4062-12.078 2.3582-13.339-10.208-22.335-9.2363-32.715 1.9432-8.2346 11.379-11.173 16.947-15.115 5.4577-3.9082 9.8014-8.7695 10.799-16.918-13.558-4.8896-17.609-5.8617-36.506-12.4zm140.87 19.357c-3.4404-0.91243-23.311 122.43 4.4121 133.14 8.9661-8.5809 16.552-18.584 22.404-29.658 0-0.31029-25.133-3.9922-25.979-14.018-0.10699-1.1769 0.11822-1.4855 0.86718-2.502 6.6764-9.2122 30.716-11.416 29.646-23.496-0.27818-3.1563-4.1617-5.2334-6.7402-6.4531-12.155-5.767-32.942-9.6494-15.031-24.543 9.2122-7.3505 10.43-8.4323 0.59766-14.691-9.4583-6.0238-9.394-11.993-9.7578-16.326-0.0767-0.93035-0.22089-1.4003-0.41992-1.4531z\" style=\"fill:#c5c5c5;\"/><path d=\"m133.83 39.909c-11.33 1.393-9.5492 16.204-2e-3 16.643-4.5102 10.717 9.0165 16.181 14.441 8.3125 6.562 8.6765 18.596 0.94751 14.457-8.3125 11.718-1.5381 9.2769-16.099 0-16.643 4.503-10.867-9.4883-16.101-14.457-8.3301-6.8832-9.0411-18.509-0.47321-14.439 8.3301z\" style=\"fill:#333;\"/><path d=\"m153.86 48.222c0-3.0528-2.5184-5.5648-5.5791-5.5648-3.0783 0-5.5793 2.512-5.5793 5.5648 0 3.0703 2.501 5.5648 5.5793 5.5648 3.0606 0 5.5791-2.4946 5.5791-5.5648z\" style=\"fill:#f9f9f9;\"/>",
}
// Guy
sp[3] = map[string]string{
"clo": "<path d=\"m141.75 195c13.563 3.1499 26.439 8.7409 38 16.5-38.873 26.001-89.587 26.001-128.46 0 11.561-7.7591 24.437-13.35 38-16.5 8.4869 8.8011 26.21 25.619 26.21 25.619s17.603-16.972 26.25-25.619z\" style=\"fill:#d6d6d6;\"/><path d=\"m109 230.81 1.6836-14.33h9.6328l1.6836 14.33c-2.16 0.12-4.33 0.19-6.51 0.19s-4.35-0.07-6.51-0.19z\" style=\"fill:#5e5e5e;\"/><path d=\"m124.17 210.6h-17.349v5.53a3.8828 3.29 0 0 0 3.8828 3.29h9.583a3.8828 3.29 0 0 0 3.8828-3.29z\" style=\"fill:#535353;\"/><path d=\"m140.57 190.36-25.066 20.245c5.9686 3.2455 11.597 7.0814 16.8 11.45 1.5989 1.3338 3.9762 1.1189 5.31-0.48 0.21005-0.25749 0.38802-0.53956 0.52999-0.84l10.826-23.805-4-6c-0.90256-1.351-2.7298-1.7137-4.08-0.81-0.11612 0.0786-0.22641 0.16549-0.33 0.26z\" style=\"fill:#c6c6c6;\"/><path d=\"m90.434 190.36 25.066 20.245c-5.9686 3.2455-11.597 7.0814-16.8 11.45-1.5989 1.3338-3.9762 1.1189-5.31-0.48-0.21005-0.25749-0.38802-0.53956-0.52999-0.84l-10.826-23.805 4-6c0.90256-1.351 2.7298-1.7137 4.08-0.81 0.11612 0.0786 0.22641 0.16549 0.33 0.26z\" style=\"fill:#c6c6c6;\"/>",
"mouth": "<path d=\"m136.21 147.09a21.77 21.77 0 0 1-40.13 0z\" style=\"fill:#fff;stroke-linecap:round;stroke-linejoin:round;stroke-width:3.4999px;stroke:#000;\"/>",
"eyes": "<path d=\"m145.39 104.7-11.52 11.2h17.26m-65.52-11.2 11.52 11.2h-17.26\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:5.4998px;stroke:#000;\"/>",
"top": "<path d=\"m43.891 77.836c-5.1124 28.237 2.1347 61.004 24.792 81.332-6.2362-12.503-9.5362-33.948-9.4887-45.458-0.50203-37.473 41.439-46.335 56.149-17.614 18.8-31.2 52.825-16.872 54.062 13.714 0.56018 13.844-0.43568 25.598-7.0962 48.966 18.372-12.47 28.012-53.959 23.545-80.941-47.486-2.2552-94.831-2.5724-141.96 0z\" style=\"fill:#1a1a1a;\"/><path d=\"m111.26 12.782c-18.508 0.0791-32.594 3.6163-32.594 3.6163 24.513 5.6002 32.807 10.504 31.743 19.835-0.87227 9.702-11.092 10.875-20.811 11.554-5.2548 0.36414-10.949 0.71523-16.391 1.7525-11.862 2.2818-19.946 4.3736-24.447 11.956-1.7012 2.8662-3.7945 10.428-4.8689 16.34h141.96c-5.7242-38.563-32.557-65.073-74.595-65.054z\" style=\"fill:#1a1a1a;\"/><path d=\"m73.292 44.77c-11.788 2.2816-18.923 5.5444-23.394 13.126-2.8484 6.7586-4.8454 13.238-6.0072 19.939h141.96c-1.9772-14.576-6.8677-28.248-19.277-32.098-28.834-6.3308-63.774-6.3553-93.285-0.96761z\" style=\"fill:#1a1a1a;\"/><path d=\"m165.95 35.642c-11.178 21.829-91.89 19.36-103.98 2.3011-9.703 12.267-15.605 25.883-18.079 39.892h141.96c-3.0096-17.158-9.7424-32.688-19.902-42.193z\" style=\"fill:#1a1a1a;\"/>",
}
// Country
sp[4] = map[string]string{
"clo": "<path d=\"m141.75 195a114.79 114.79 0 0 1 38 16.5 115.53 115.53 0 0 1-128.46 0 114.79 114.79 0 0 1 38-16.5l15.71 15.75h21z\" style=\"fill:#949494;\"/><path d=\"m115.45 211.34-10.55 10.54a2.51 2.51 0 0 1-3.5599 0 2 2 0 0 1-0.26999-0.30994l-18.48-25.4 5.8901-5.8899a2.52 2.52 0 0 1 3.5199-0.0791l23.49 21.14z\" style=\"fill:#c0c0c0;\"/><path d=\"m115.45 211.34 10.55 10.54a2.51 2.51 0 0 0 3.5599 0 2 2 0 0 0 0.26999-0.30994l18.48-25.4-5.8901-5.8899a2.52 2.52 0 0 0-3.4699-0.089l-23.49 21.14z\" style=\"fill:#c0c0c0;\"/><path d=\"m158.41 199.58-10.11-3.2401v29.93q5.1601-1.5299 10.11-3.51zm-75.82 26.66v-29.9l-10.1 3.2401v23.14c3.2901 1.3199 6.67 2.4999 10.1 3.5199z\" style=\"fill:#7c7c7c;\"/>",
"mouth": "<path d=\"m118.05 148.38c-1.5064 0.59192-2.595 2.0264-2.6191 3.9863-0.0574 1.3977 0.53421 3.5611 3.6758 5.7949 8.0544 4.9446 21.507 3.6862 21.255-7.1658-4.664 4.8219-10.021 5.6377-14.773 0.73907-1.2328-1.1599-2.3694-2.4032-3.9294-3.1408-1.0946-0.50424-2.2257-0.61071-3.6096-0.21337z\" style=\"fill:#333;\"/><path d=\"m133.61 154.93c3.0731-0.48816 5.5702-2.8457 5.4438-4.5059-0.47801-4.8311-5.7317-3.0917-4.3369-0.31405-2.8103-1.4445-1.8343-3.8862 0.50427-4.7324 2.0509-0.79942 5.0937 0.34314 6.2002 2.6376 2.2229 7.3422-3.4376 11.68-10.384 12.561z\" style=\"fill:#333;\"/><path d=\"m112.81 148.38c1.5064 0.59192 2.595 2.0264 2.6191 3.9863 0.0574 1.3977-0.53421 3.5611-3.6758 5.7949-8.0544 4.9446-21.507 3.6862-21.255-7.1658 4.664 4.8219 10.021 5.6377 14.773 0.73907 1.2328-1.1599 2.3694-2.4032 3.9294-3.1408 1.0946-0.50424 2.2257-0.61071 3.6096-0.21337z\" style=\"fill:#333;\"/><path d=\"m97.252 154.93c-3.0731-0.48816-5.5702-2.8457-5.4438-4.5059 0.47801-4.8311 5.7317-3.0917 4.3369-0.31405 2.8103-1.4445 1.8343-3.8862-0.50427-4.7324-2.0509-0.79942-5.0937 0.34314-6.2002 2.6376-2.2229 7.3422 3.4376 11.68 10.384 12.561z\" style=\"fill:#333;\"/>",
"eyes": "<path d=\"m131.64 114.09 7.5801-7.5801 7.5801 7.5801m-62.6 0 7.5801-7.5801 7.5799 7.5801\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:6.4998px;stroke:#000;\"/>",
"top": "<path d=\"m137.38 11.148c-12.23 1.9593-18.511 14.606-43.436 9.4915-11.285-3.2054-16.406-3.573-20.389 0.58594-4.1548 4.3384-7.033 12.435-9.8184 21.706-2.1354 7.4136-3.7187 14.381-4.7461 21.646h112.7c-3.4878-24.293-10.822-43.281-25.182-51.061-3.5314-1.623-6.5274-2.2959-9.1289-2.3613z\" style=\"fill:#b3b3b3;\"/><path d=\"m114.37 43.383c-19.445 0.088-38.524 2.0724-52.379 5.6992-1.2766 4.5795-2.4317 10.169-3.2285 16.807h113.11c-0.83731-6.0107-1.9164-11.674-3.3184-16.924-15.229-3.8842-34.873-5.6693-54.18-5.582z\" style=\"fill:#e6e6e6;\"/><path d=\"m115.5 55.773c-58.39 0-105.73 15.476-105.73 34.57h0.0312c0 11.295 16.496 21.319 42.126 27.627-0.10331-7.7704 2.788-21.904 5.2734-31.031 6.0935-1.7168 6.9294-1.8971 13.167-2.9919 14.874-2.8256 29.99-4.2037 45.133-4.1153 15.143-0.0884 30.259 1.2897 45.133 4.1153 6.2372 1.0947 7.2065 1.2751 13.3 2.9919 2.4854 9.1267 5.3768 23.26 5.2734 31.031 25.63-6.3082 41.993-16.332 41.993-27.627h0.0312c0-19.093-47.34-34.57-105.73-34.57z\" style=\"fill:#818181;\"/><path d=\"m72.088 83.533c-6.9765 1.1147-13.357 2.856-18.439 4.3477-1.1861 7.415-2.0038 18.858-1.8926 26.293 4.3278-0.62795 10.155-1.3644 13.295-1.6465-0.40554 0.30198 2.7344-17.827 7.0371-28.994zm86.824 0c4.3028 11.167 7.4426 29.296 7.0371 28.994 3.1396 0.28213 8.9671 1.0185 13.295 1.6465 0.11119-7.4351-0.70652-18.878-1.8926-26.293-5.0822-1.4916-11.463-3.2329-18.439-4.3477z\" style=\"fill:#434343;\"/>",
}
// Geeknot
sp[5] = map[string]string{
"clo": "<path d=\"m141.75 194.98a114.79 114.78 0 0 1 38 16.498 115.53 115.52 0 0 1-128.46 0 114.79 114.78 0 0 1 38-16.498l15.71 15.748h21z\" style=\"fill:#d2d2d2;\"/><path d=\"m70 200.88v20.77c-2.22-0.95325-4.3999-1.9698-6.5399-3.0496h-0.10088v-14.621c2.17-1.1 4.39-2.1399 6.64-3.0996z\" style=\"fill:#505050;\"/><path d=\"m161 200.88v20.77c1.9-0.80986 3.7702-1.6798 5.6201-2.5898l0.0989-0.0494 0.82005-0.40997h0.10088v-14.621c-2.17-1.1-4.39-2.1399-6.6402-3.0996z\" style=\"fill:#505050;\"/><polygon transform=\"matrix(1 0 0 .99987 4e-5 -3e-5)\" points=\"97.32 201.93 115.5 223.72 133.68 201.93\" style=\"fill:#171717;\"/><path d=\"m111.2 230.88 1.31-16.908c0.32992 1.2798 5.6399 1.2798 5.9999 0l1.3201 16.938c-1.4301 0.0494-2.8601 0.089-4.3 0.089s-2.87 0-4.3-0.089z\" style=\"fill:#171717;\"/><path d=\"m115.49 201.79v0.0692l-7.55 12.678-7.0001 11.809-19.19-26.487c0.60999-0.42995 1.22-0.89985 1.8001-1.3899a52 51.993 0 0 0 10.07-10.619l21.79 13.878z\" style=\"fill:#ebebeb;\"/><path d=\"m149.24 199.86-19.08 26.517-7.0001-11.809-7.57-12.678-0.0593-0.10086 21.94-13.998a52.21 52.203 0 0 0 10.08 10.699c0.58013 0.47009 1.1502 0.92002 1.7301 1.3399z\" style=\"fill:#ebebeb;\"/>",
"mouth": "<path d=\"m122.83 151.88a10.49 10.489 0 0 1-14.66 0\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:6.1996px;stroke:#333;\"/>",
"eyes": "<path d=\"m70.959 94.985h35.031c2.4086 1e-5 4.3612 1.9523 4.3612 4.3606l-2.5864 17.511c-0.3515 2.3799-1.7218 4.3606-3.8457 4.3606h-30.9c-2.1239-1e-5 -3.8457-1.9523-3.8457-4.3606l-2.5864-17.511c1e-5 -2.4082 1.9526-4.3606 4.3612-4.3606z\" style=\"fill:#1a1a1a;stroke-linecap:round;stroke-linejoin:round;stroke-width:3.0045px;stroke:#333;\"/><path d=\"m160.05 94.985h-35.031c-2.4086 1e-5 -4.3612 1.9523-4.3612 4.3606l2.5864 17.511c0.35149 2.3799 1.7218 4.3606 3.8457 4.3606h30.9c2.1239-1e-5 3.8457-1.9523 3.8457-4.3606l2.5864-17.511c-1e-5 -2.4082-1.9526-4.3606-4.3612-4.3606z\" style=\"fill:#1a1a1a;stroke-linecap:round;stroke-linejoin:round;stroke-width:3.0045px;stroke:#333;\"/><path d=\"m90.607 102.35a4.6337 4.6332 0 1 0 4.6892 4.6337 4.6337 4.6332 0 0 0-4.6892-4.6337zm49.72 0a4.6337 4.6332 0 1 0 4.6444 4.6337 4.6337 4.6332 0 0 0-4.6444-4.6337z\" style=\"fill:#1a1a1a;\"/><path d=\"m70.66 94.985h-11.775\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:3.0045px;stroke:#333;\"/><path d=\"m172.13 94.985h-19.484\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:3.0045px;stroke:#333;\"/><path d=\"m109.32 106.2c4.2045-2.427 9.3036-1.913 12.353-0.0258\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:3.0045px;stroke:#333;\"/><path d=\"m148.33 109.79-5.7626-8.2324\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:4;stroke:#fff;\"/><path d=\"m156.27 105-2.403-3.4328\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:4;stroke:#fff;\"/><path d=\"m82.748 114.34-8.9489-12.784\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:4;stroke:#fff;\"/><path d=\"m91.408 109.79-5.7626-8.2324\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:4;stroke:#fff;\"/>",
"top": "<path d=\"m41.835 75.131c-2.8674 12.582 1.2304 27.241 6.0238 39.031 0.25861 0.63658 0.51208 1.3075 0.79989 1.9683 0.71726 1.658 2.1184 3.9751 3.0038 3.9266 0.56895-0.0312 0.71637-1.5512 1.0228-3.1562 2.1988-19.097 8.8981-27.915 15.636-38.107 2.8783-4.0645 3.8616-7.2293 1.0644-9.9325-6.3236-3.5596-14.924-2.8574-21.367-0.67406-3.2312 1.4765-5.2427 3.4773-6.1842 6.9439zm125.65-8.5679c7.65-0.70616 19.714-0.1307 21.694 8.5679 1.455 6.4083 0.26915 17.747-1.0542 24.579-1.1961 5.3203-3.8066 14.231-7.8782 19.75-0.5565 0.44544-0.96888 0.13656-1.4159-1.1606-0.90692-3.0353-1.4298-7.8372-2.2556-10.727-3.4822-12.79-8.2195-21.875-14.429-29.94-5.5782-6.8415-4.2152-9.7207 5.3393-11.069z\" style=\"fill:#4d4d4d;\"/><path d=\"m112.27 73.826c-18.585-7.5217-34.987-14.797-48.939 5.018-4.9752 7.083-3.7876 8.8056-4.9217 0.0749-1.637-12.476-4.7505-34.174 1.9259-45.194 7.6822-12.7 19.323-13.128 31.039-5.3818 10.796 7.7784 24.277 14.647 38.015 12.219 12.732-2.2576 15.835-7.7464 15.707-19.912-0.0215-2.6-0.0963-5.2106-0.2033-7.7999 13.631 3.9267 24.609 14.776 26.513 29.049 0.88804 6.6336 0.26749 12.722-1.9259 19.013-5.9702 17.108-30.119 20.896-45.74 16.841-3.9588-1.0378-7.6822-2.4181-11.47-3.9267z\" style=\"fill:#4d4d4d;\"/>",
}
// Asian
sp[6] = map[string]string{
"clo": "<path d=\"m115.5 231a115 115 0 0 0 64.23-19.5 114.79 114.79 0 0 0-38-16.5l-2.41-9a125.19 125.19 0 0 0-13.32-2.28v8.75q3.52 0.32 7 0.84l-17.5 17.48-17.5-17.48q3.45-0.52 7-0.84v-8.75a125.55 125.55 0 0 0-13.34 2.28l-2.41 9a114.79 114.79 0 0 0-38 16.5 114.94 114.94 0 0 0 64.25 19.5z\" style=\"fill:#646464;\"/><path d=\"m132.98 193.33-36.185 36.155-2.4-0.42 36.108-36.081z\" style=\"fill:#e3e3e3;\"/>",
"mouth": "<path d=\"m127.84 146.73c-2.24 8.93-6.92 15.08-12.34 15.08s-10.1-6.15-12.34-15.08z\" style=\"fill:#fff;stroke-linecap:round;stroke-linejoin:round;stroke-width:2.9999px;stroke:#1a1a1a;\"/>",
"eyes": "<path d=\"m129.31 114.14 20-5.37m-47.66 5.37-20-5.37\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:4.9998px;stroke:#1a1a1a;\"/>",
"top": "<path d=\"m169.65 90.998c3.137 11.94 4.9371 36.484-3.4118 58.213l5.129 3.1164c10.044-15.199 14.959-39.163 13.943-61.33z\" style=\"fill:#1a1a1a;\"/><path d=\"m45.081 90.989c-0.88085 4.9304-0.87534 14.953-0.15027 21.75 2.1318 19.98 16.671 42.505 16.671 42.505l5.7352-4.4331s-13.244-31.348-6.0571-52.751c0.52108-1.5517 0.95592-2.916 1.3462-4.1835z\" style=\"fill:#1a1a1a;\"/><path d=\"m117 3.4883c-8.2136-0.19887-19.13 7.933-18.494 9.3516 1.6214 3.6186 11.176 22.55 11.889 23.963h10.148c2.6022-6.3102 11.32-26.531 11.32-26.531s-4.1382-4.138-12.416-6.4375c-0.77605-0.21556-1.5976-0.32513-2.4473-0.3457z\" style=\"fill:#1a1a1a;\"/><path d=\"m115.95 4.5428c-3.1563 0-6.3123 0.57462-9.2165 1.715-5.8084 2.2817-10.532 6.808-12.779 12.245v-5e-3c-1.8166 4.397-2.0233 9.3441-0.58058 13.857 0.69352 2.1687 1.7693 4.2296 3.1533 6.0968h38.893c0.71032-0.95769 1.3441-1.9641 1.8787-3.0144 2.6811-5.2673 2.9296-11.542 0.67253-16.975-2.257-5.4337-6.9893-9.9522-12.802-12.224-2.9064-1.1335-6.0633-1.6987-9.2196-1.6956z\" style=\"fill:#1a1a1a;\"/><path d=\"m92.512 28.125c0.13387 1.4318 0.41877 2.8511 0.85962 4.2306 1.4429 4.5127 4.5278 8.5654 8.6411 11.353 4.1135 2.7873 9.2311 4.2913 14.336 4.2165 5.1052-0.0764 10.168-1.7333 14.181-4.6419 2.8754-2.0834 5.2132-4.7932 6.7665-7.8447 1.2005-2.3586 1.9085-4.9188 2.127-7.5156-15.037-2.6407-31.421-3.4671-46.912 0.20253z\" style=\"fill:#b3b3b3;\"/><path d=\"m34.426 90.63c14.714 4.0779 22.683 6.4085 45.254 7.4257 2.5318-18.185 4.6689-28.672 10.023-38.352 3.2025 13.403 3.8346 25.22 2.9106 42.253l11.172-0.23161c1.4706-11.886 3.8989-29.213 2.1636-42.021 10.416 12.631 11.373 23.624 13.077 39.726 30.174-0.76004 59.808-4.5121 77.845-10.128-10.76-38.608-41.475-55.66-80.38-56.104-38.182-0.45134-74.543 22.405-82.065 57.432z\" style=\"fill:#1a1a1a;\"/>",
}
// Punk
sp[7] = map[string]string{
"clo": "<path d=\"m88.18 194.11c-4.2079 1.021-8.3545 2.2792-12.42 3.7695v26.072a115.5 115.5 0 0 0 79.48 0v-26.072c-4.0858-1.4904-8.2529-2.7486-12.48-3.7695v8.7051c0 9.3888-7.6112 17-17 17h-20.58c-9.3888 0-17-7.6112-17-17v-8.7051z\" style=\"fill:#efefef;\"/>",
"mouth": "<polygon points=\"121.61 160.74 109.39 160.74 115.5 171.31\" style=\"fill:#797979;\"/><path d=\"m132.64 144.06a34.42 34.42 0 0 1-34.24 0\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:5.9998px;stroke:#000;\"/>",
"eyes": "<path d=\"m170.25 100c1.69 9.62-4.79 29.23-22.4 29.23-6.81 0-15-3.66-20.23-10-4.34-5.33-7.56-12.87-6.2-19.45 1.63-7.89 7.07-11.45 14.67-12.92a68.16 68.16 0 0 1 12.52-1c10.77 0 19.78 3.61 21.64 14.22z\" style=\"fill:#565656;stroke-width:3.99px;stroke:#000;\"/><path d=\"m60.75 100c-1.69 9.62 4.79 29.23 22.4 29.23 6.81 0 15-3.66 20.23-10 4.34-5.33 7.56-12.87 6.2-19.45-1.63-7.89-7.07-11.45-14.67-12.92a68.16 68.16 0 0 0-12.52-1c-10.77 0-19.78 3.61-21.64 14.22z\" style=\"fill:#565656;stroke-width:3.99px;stroke:#000;\"/><line x1=\"100.2\" x2=\"130.8\" y1=\"87.92\" y2=\"87.92\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:3.99px;stroke:#000;\"/><path d=\"m109.87 101.73c0-2.59 2.52-4.69 5.63-4.69s5.63 2.1 5.63 4.69\" style=\"fill:none;stroke-width:3.99px;stroke:#000;\"/>",
"top": "<path d=\"m30.622 70.381c2.0971-3.9374 4.6649-7.9604 7.6822-12.037 3.0172-4.0765 6.0987-7.6929 9.2229-10.817l22.897 22.897c-4.4402 4.4403-8.2278 9.5439-11.213 15.14z\" style=\"fill:#999;\"/><path d=\"m160.58 70.423 22.907-22.897c3.1242 3.1242 6.2056 6.7406 9.2229 10.817 3.0065 4.0765 5.5744 8.0994 7.6715 12.037l-28.578 15.182c-2.9851-5.5958-6.7727-10.689-11.224-15.14z\" style=\"fill:#999;\"/><path d=\"m92.411 15.247c3.8197-0.87736 7.6715-1.5407 11.534-1.9794 4.0765-0.46007 7.9282-0.69546 11.555-0.69546 1.53 0 3.1563 0.0428 4.8682 0.1391l1.851 22.255 5.767-21.57c3.1028 0.37449 6.0666 0.86666 8.8912 1.4658l-10.55 49.763c-1.9259-0.41729-3.702-0.70617-5.3176-0.87736-1.423-0.14979-3.2633-0.22468-5.5102-0.22468-2.2362 0-4.237 0.10699-5.981 0.29958-1.9473 0.22469-3.8732 0.55636-5.767 0.99504z\" style=\"fill:#999;\"/><path d=\"m92.411 15.247c1.9152-0.43869 4.023-0.84526 6.3233-1.2304 2.065-0.34238 4.1514-0.62057 6.2698-0.84525l5.1785 50.565c-1.0913 0.10699-2.1827 0.25679-3.2954 0.43868-0.86665 0.14979-1.9152 0.36378-3.1349 0.64196z\" style=\"fill:#4d4d4d;\"/>",
}
// Afrohair
sp[8] = map[string]string{
"clo": "<path d=\"m141.89 195a114.79 114.79 0 0 1 38 16.5 115.55 115.55 0 0 1-128.47 0 114.79 114.79 0 0 1 38-16.5l15.75 15.75h21z\" style=\"fill:#353535;\"/><path d=\"m146.4 196.14-17.4 17.44-1.17 1.17h-24.34l-1.18-1.17-17.43-17.44c1.49-0.41 3-0.79 4.51-1.14l4.67-1 12.74 12.74h17.69l12.73-12.74 4.67 1c1.52 0.35 3 0.73 4.51 1.14z\" style=\"fill:#919191;\"/>",
"mouth": "<path d=\"m115.68 160.64c7.08 0 13.11-4.93 15.46-11.84a2.14 2.14 0 0 0-1.51-2.6101 2.3 2.3 0 0 0-0.73995-0.0593h-26.42a2.12 2.12 0 0 0-2.31 1.9099 1.85 1.85 0 0 0 0.0593 0.73995c2.3401 6.9301 8.3802 11.86 15.46 11.86z\" style=\"fill:#2f2f2f;\"/>",
"eyes": "<path d=\"m145.38 95.628c-5.1601 2.2597-11.03 2.2597-16.19 0m-47.29 1.75c5.1755-2.2694 11.065-2.2694 16.24 0\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:5.9998px;stroke:#5e5e5e;\"/><path d=\"m90.016 106.28c-4.4506-0.0105-6.6902 5.3657-3.5508 8.5195 3.1394 3.1539 8.5252 0.93887 8.5352-3.5117 0.0063-2.7522-2.2204-4.9898-4.9727-4.9961l-0.011719-0.01172zm47.281 0c-4.4506-0.0105-6.6902 5.3657-3.5508 8.5195 3.1394 3.1539 8.5252 0.93887 8.5352-3.5117 6e-3 -2.7522-2.2204-4.9898-4.9727-4.9961l-0.01171-0.01172z\" style=\"fill:#1a1a1a;\"/>",
"top": "<path d=\"m108.37 22.019c-6.2698-12.829-17.151-13.396-18.949 1.1769-11.448-9.4583-26.021-4.483-20.361 12.422-12.251-7.9282-24.919 1.7761-17.076 20.853-27.08 2.3646-22.715 24.726-10.111 31.435-9.9002 3.3566-10.701 9.4006-8.464 14.497 2.6574 4.7842 9.0126 6.4737 11.545 9.6519-6.624 0.59419-8.4112 5.6011-5.7404 9.5192 1.6896 2.4787 5.2756 4.2218 8.5971 5.5455 1.0485 0.40658 3.702 1.2732 3.9053 2.4181 0.18744 1.2156-6.7884 3.0055-5.7281 5.2612 0.60648 1.4227 1.7764 2.7151 2.6466 3.7156 1.2807 1.6595 10.755 8.0351 9.4583 4.2049-1.0271-3.7234-2.2148-7.4682-3.1456-11.192-1.1662-5.3069-1.7868-10.721-1.102-16.156 1.4223-5.455 5.069-4.4265 7.7837-8.3588 3.5264-5.7505 2.0296-11.614 2.124-13.575 0.107-1.7868 1.5407-1.1876 3.1884-1.4337 4.3868-0.64196 7.0081-2.1185 8.8377-6.2698 0.77035-1.9259 0.62057-9.7578 0.52426-11.78 0.36378-4.6328 4.1835 0 6.548 0.64196 3.2633 0.88805 6.8797 0.21399 9.0731-2.5037 1.7547-2.3753 2.0864-2.8888 4.6114-0.80245 2.6856 2.2148 4.0979 3.1349 7.6929 3.274 5.5637 0.20329 8.7735-6.2698 11.32-5.6386 3.5201 0.87735 3.6057 5.4567 10.261 4.8682 2.386-0.20329 3.8304-0.86665 5.4032-2.6428 0.88805-0.99505 1.958-2.5037 3.4345-2.6214 1.4658-0.1177 2.3218 2.3646 3.0065 3.4452 1.1926 2.6755 4.0295 3.6513 6.2377 3.3168 1.958-0.17119 3.854-1.4115 5.4268-2.4707 0.99679-0.66102 1.8284-0.81128 1.9256 0.2071 0.29592 2.2271 0.0862 7.7025 0.1596 8.4821 0.10556 8.4609 5.37 10.569 13.223 10.333-0.31871 3.7464 0.0583 11.28 5.4353 14.562 3.9481 2.7604 6.6657 1.2732 6.7299 7.8534 7e-3 6.1914-0.43693 13.061-1.2946 18.189-0.69547 4.0444-1.2412 6.4838-2.5251 10.378-0.64196 1.9152-0.81315 1.9687 1.4123 1.0699 7.1472-3.1456 10.539-11.48 8.3562-18.842-0.43869-2.0436 0.84525-1.7226 2.8781-2.6106 9.5248-4.2363 8.1264-11.335-0.75967-14.273 11.988-3.0926 13.886-8.9002 6.6871-15.375 7.3077-5.9168 3.6378-16.177-2.8032-16.991 12.422-7.0937 5.7349-22.062-5.1036-18.499 4.1728-12.037-5.5637-26.203-21.121-16.894 6.9653-11.373 2.065-22.661-12.101-10.785-3.4559-18.382-15.14-16.584-23.902-5.018 0.09435-20.075-16.001-17.42-18.146-2.5892z\" style=\"fill:#1a1a1a;\"/><path d=\"m5.4353 80.502c7.4468 9.1373 15.632 8.8912 15.632 8.8912s-6.0772 3.7983-6.8369 9.8755c-0.75966 6.088 4.5579 9.6295 8.0994 10.646 3.5522 1.0058 7.0937-2.7925 7.0937-2.7925s-5.8312 10.646-1.5193 15.964c4.3012 5.3176 11.908 3.0386 11.908 3.0386s-5.3283 10.132 1.0057 14.187c5.8312 3.7234 18.542 7.6715 20.511 8.2706-6.0666-9.7472-9.576-21.249-9.576-33.575v-0.0428c0-35.201 28.546-63.747 63.747-63.747 35.212 0 63.758 28.546 63.758 63.747 0 12.476-3.5843 24.116-9.7899 33.949h0.53496s13.931-1.0057 16.21-9.3727c2.279-8.3562 0.75967-9.8756 0.75967-9.8756s10.635 2.0329 13.417-7.5966l2.7926-9.6295s10.132 0 10.892-7.083c0.75963-7.0937-7.0295-12.411-7.0295-12.411s11.459 0.82385 14.498-10.453c1.0164-3.7555 0.83456-8.2171 0.1391-12.497-17.665-41.161-58.569-69.995-106.18-69.995-30.632 0-60.034 12.187-81.679 33.831v0.0107c-13.171 13.171-22.833 29.22-28.386 46.66z\" style=\"fill:#1a1a1a;\"/>",
}
// Normie Female
sp[9] = map[string]string{
"clo": "<path d=\"m141.75 195a114.79 114.79 0 0 1 38 16.5 115.53 115.53 0 0 1-128.46 0 114.79 114.79 0 0 1 38-16.5l13.85 13.85v-1.2h17.86v3.1h5z\" style=\"fill:#333;\"/><polygon points=\"115.36 207.65 123.37 224.2 148.3 196.86 143.08 189.95\" style=\"fill:#fff;\"/><polygon points=\"115.36 207.65 107.35 224.2 82.42 196.86 87.63 189.95\" style=\"fill:#fff;\"/>",
"mouth": "<path d=\"m126.28 149.82c-6.16 2.43-15.52 2.42-21.56 0\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:5.9998px;stroke:#1c1c1c;\"/>",
"eyes": "<path d=\"m83.527 103.98v10h10v-10h-10zm53.945 0v10h10v-10h-10z\" style=\"fill:#1a1a1a;\"/><path d=\"m56.621 94.906v11.688h5.3418v6.4922h5.3418v6.1055h5.3223v6.2324h26.846v-6.2324h5.3047v-6.1055h5.1445v-6.0039h11.154v6.0039h5.1446v6.1055h5.3066v6.2324h26.846v-6.2324h5.3203v-6.1055h5.3438v-6.4922h5.3418v-11.688z\" style=\"fill:#1a1a1a;\"/><path d=\"m67.387 100.65v5.9394h5.1992v-5.9394zm5.1992 5.9394v6.4922h5.4238v-6.4922zm5.4238 0h5.1992v-5.9394h-5.1992zm5.1992 0v6.4922h5.4258v-6.4922zm5.4258 6.4922v6.1055h5.1426v-6.1055zm-10.625 0v6.1055h5.1445v-6.1055zm48.281-12.432v5.9394h5.1992v-5.9394zm5.1992 5.9394v6.4922h5.4238v-6.4922zm5.4238 0h5.1992v-5.9394h-5.1992zm5.1992 0v6.4922h5.4258v-6.4922zm5.4258 6.4922v6.1055h5.1426v-6.1055zm-10.625 0v6.1055h5.1445v-6.1055z\" style=\"fill:#fff;\"/>",
"top": "<path d=\"m157.79 67.5a61.31 61.31 0 0 1-42.79 17.43h-55.7c18.16-37.74 68.27-46.85 98.49-17.43z\" style=\"fill:#4d4d4d;\"/><path d=\"m122.93 7.0078c-10.503-0.15729-21.09 1.6448-29.545 5.4316-17.141 7.8999-32.169 23.297-43.973 38.779-5.1703 6.8631-8.7779 13.46-8.1855 18.395 0.93114 12.312 10.372 26.483 11.068 36.9 15.663-72.081 105.99-70.452 124.91-7.0525l4e-3 0.0156c5.616-10.926 8.0682-20.188 8.352-27.653 0.43654-15.607-7.8088-21.149-21.735-28.249 1.7934-3.7704 1.7273-7.5023 2.0625-10.154-0.79964-7.8568-3.6796-13.51-10.43-17.758-5.9434-3.7404-13.06-6.0867-18.463-7.2266-4.5319-0.87895-9.2901-1.3562-14.064-1.4277z\" style=\"fill:#4d4d4d;\"/><path d=\"m42.426 75.338c0.52158 18.689 10.557 74.338-18.115 101.25 12.38 10.603 28.352 19.061 46.025 24.594 11.032-4.6874 22.88-7.4147 34.817-8.5046l0.0633-14.477c-22.49-4.3813-40.766-18.898-48.862-39.967-8.096-21.07-4.7931-44.72 9.2478-62.393zm124.67 2.7207c7.8997 10.886 11.743 24.64 11.787 37.441-0.36632 30.178-22.389 57.576-53.12 62.708l0.0238 14.471c12.282 1.1216 24.518 3.9888 35.825 8.9128 15.488-5.1448 30.007-13.325 42.396-25.043-13.136-22.051-23.282-63.045-18.694-101.55z\" style=\"fill:#4d4d4d;\"/><path d=\"m143.61 46.383c-11.639 0.12482-20.998 1.8906-20.998 1.8906l-9 3.5059c0.63003-0.0191 1.2603-0.0289 1.8906-0.0293h0.0996c35.169 0.055 60.959 27.235 63.283 63.383 7.4e-4 31.157-22.742 57.213-53.106 63.079l-0.0216 14.498c11.567 1.0563 23.154 3.6067 33.887 8.0463 35.952-15.315 55.082-52.303 36.709-68.279-5.018-7.9035-10.44-15.409-9.5544-23.03 5.0545-50.452 0.39626-63.561-43.189-63.064zm-69.966 21.09c-15.286 3.244-17.096 3.73-31.734 6.6953 3.0304 13.081 3.0583 22.274 1.2085 30.012-3.8004 11.361-8.9712 19.787-12.286 28.764-6.8823 22.459-2.9157 31.982 12.093 46.165 8.6595 8.0693 19.861 16.209 30.939 20.647 2.669-1.0316 5.3729-1.9628 8.106-2.792 7.4979-2.275 15.388-3.6535 23.206-4.3673l0.0433-14.393c-23.933-4.5937-44.283-21.98-50.77-45.817-6.3319-23.265 0.51104-48.752 19.195-64.914z\" style=\"fill:#4d4d4d;\"/>",
}
// Older
sp[10] = map[string]string{
"clo": "<path d=\"m141.75 195a114.79 114.79 0 0 1 38 16.5 115.53 115.53 0 0 1-128.46 0 114.79 114.79 0 0 1 38-16.5l15.71 15.75h21z\" style=\"fill:#666;\"/><path d=\"m89.291 195a114.79 114.79 0 0 0-38.002 16.5 115.53 115.53 0 0 0 38.002 16.482zm52.434 0v32.982a115.53 115.53 0 0 0 38-16.482 114.79 114.79 0 0 0-38-16.5z\" style=\"fill:#999;\"/><path d=\"m157.15 199.75c0.2548 7.4501 1.54 14.855 4.9512 21.432a115.53 115.53 0 0 0 17.619-9.6797 114.79 114.79 0 0 0-22.57-11.752zm-83.295 2e-3a114.79 114.79 0 0 0-22.57 11.75 115.53 115.53 0 0 0 17.621 9.6797c3.411-6.5765 4.6944-13.98 4.9492-21.43z\" style=\"fill:#ccc;\"/><path d=\"m99.197 204.97v2e-3l16.302 16.301 16.301-16.301v-2e-3z\" style=\"fill:#fff;\"/>",
"mouth": "<path d=\"m100.19 152.09c2.8726 4.0616 9.8095 4.7232 15.119-0.45432 5.0656 4.5134 11.167 5.6898 15.495 0.31458\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:5.8949;stroke:#333;\"/><path d=\"m109.67 135.53c-0.9758 0.0743-2.05 0.45327-3.1485 0.99414-4.3235 2.1399-7.3862 4.2557-10.639 7.1406-0.6251 0.5715 0.1168 0.77785 1.4238 0.87304 5.6967 0.0536 14.384 0.41404 15.098-0.875 1.9251-2.0788 1.7969-5.3303-0.1816-7.3008-0.701-0.67533-1.5769-0.90632-2.5527-0.83203zm11.656 0c-0.9758-0.0743-1.8517 0.1567-2.5527 0.83203-1.9785 1.9705-2.1067 5.222-0.1817 7.3008 0.7142 1.289 9.401 0.9286 15.098 0.875 1.307-0.0952 2.0489-0.30154 1.4238-0.87304-3.2524-2.8849-6.3151-5.0007-10.639-7.1406-1.0985-0.54087-2.1727-0.91985-3.1485-0.99414z\" style=\"fill:#333;\"/>",
"eyes": "<path d=\"m97.56 107.84a10.63 10.63 0 0 1-15 0.13l-0.13-0.13\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:6.3px;stroke:#000;\"/><path d=\"m148.59 107.84a10.63 10.63 0 0 1-15 0.13l-0.13-0.13\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:6.3px;stroke:#000;\"/>",
"top": "<path d=\"m41.668 87.073c-9.2319-0.0231-11.63 6.5104 2.2676 17.66-14.015 1.1231-4.3662 16.457 4.875 24.66 4.0686 3.0199 6.4647 5.4657 5.5078 1.1348-1.2079-4.9178-1.8184-9.9634-1.8184-15.027 3.26e-4 -7.5692 1.2547-15.016 3.7883-22.183 0.57048-1.7876 1.0689-2.0306-0.37721-2.6839-5.5405-2.4478-10.375-3.5511-14.243-3.5608z\" style=\"fill:#ccc;\"/><path d=\"m185.48 89.513c-2.4418-0.11189-5.4618 0.81187-9.5148 3.2121-1.314 0.81729-0.70075 1.995-0.32301 3.2653 3.194 10.982 3.8215 22.462 1.2538 33.628-0.31613 1.688-0.47649 3.569 2.6953 1.3516 7.7016-5.371 19.17-18.734 16.918-26.105-1.4251-3.9177-11.4-0.35546-11.4-0.35546s4.987-4.2755 5.3437-9.6191c0.20048-3.0057-1.5237-5.2189-4.9726-5.377z\" style=\"fill:#ccc;\"/><path d=\"m91.689 36.108c-3.7298-7.3864-9.5859-10.504-17.578-6.7891-9.5194 4.5907-15.629 18.444-13.416 29.232 0 0-8.5511-4.9878-18.17-3.5625-19.623 8.094-1.4102 29.869 10.817 37.342 2.075 1.297 2.5792 1.7432 3.4291-0.37685 2.6746-6.5374 6.1886-12.722 11.297-17.709 4.1039 8.7427 14.629 4.1809 20.006-0.14062 4.4873 9.6838 10.377 6.3535 15.377 3.4785 4.0764 7.8829 10.756 7.25 17.631 0.0625 4.875 4.5625 14.713 4.1867 15.555-3.426 8.4753 2.6244 14.012 10.437 22.962-1.4764 8.8552 6.8221 14.407 16.853 17.122 27.51 0.34 1.554 1.175 0.85565 2.2212 0.44315 10.255-4.286 22.842-15.749 15.705-23.975-3.5623-3.5623-13.539-2.1387-13.539-2.1387s6.77-7.1233 9.2637-18.168c2.4936-11.043-23.514-4.9883-23.514-4.9883s7.4818-5.6993 12.113-13.537c4.6314-7.8378-2.4943-11.756-11.045-11.043-8.5496 0.71204-17.1 7.4805-17.1 7.4805s3.3946-7.8055-3.5625-12.826c-9.5935-6.9234-23.869 6.4121-23.869 6.4121-4.2562-26.835-24.872-6.386-31.707 8.1953z\" style=\"fill:#ccc;\"/>",
}
// Firehair
sp[11] = map[string]string{
"clo": "<path d=\"m116 203.13c-0.12 0-0.25 0.12-0.49 0.12s-0.25-0.12-0.49-0.12zm-27.29-8c0.87-0.25 1.72-0.47 2.56-0.69a32.37 32.37 0 0 0 0.3 8.57 21.5 21.5 0 0 0 7 6.88c6.41-6 16.8-6.64 16.8-6.64s10.5 0.58 17 6.69a21.61 21.61 0 0 0 6.93-6.66 32.34 32.34 0 0 0 0.35-8.84l2.13 0.56a114.79 114.79 0 0 1 38 16.5 115.53 115.53 0 0 1-128.46 0 114.64 114.64 0 0 1 37.38-16.37z\" style=\"fill:#e9e9e9;\"/><path d=\"m126.15 206-3.92 7.83h-13.46l-3.92-7.83a36.59 36.59 0 0 1 10.65-2.7 35.66 35.66 0 0 1 10.65 2.7z\" style=\"fill:#818181;\"/><path d=\"m124.54 230.65-2.18-16.74h-13.47l-2.19 16.76c2.9 0.22 5.84 0.33 8.8 0.33s6.06-0.12 9-0.35z\" style=\"fill:#989898;\"/><path d=\"m134.84 186s0.86 9.8-19.34 17.26c0 0 15.79 0.86 20.57 11.76 0.12 0.49 9.3-23.26-1.23-29z\" style=\"fill:#fff;\"/><path d=\"m96.16 186c-10.41 5.76-1.35 29.39-1.1 29 4.65-10.78 20.56-11.76 20.56-11.76-20.32-7.45-19.46-17.24-19.46-17.24z\" style=\"fill:#fff;\"/>",
"mouth": "<path d=\"m118.57 165.14a8.66 8.66 0 0 0-2.76-4.23h-0.62a8 8 0 0 0-2.76 4.22c-0.52 1.89 2.07 10.61 2.76 12.53h0.62c0.64-1.76 3.19-10.82 2.76-12.52z\" style=\"fill:#333;\"/><path d=\"m102.81 152.24a2.4921 2.4921 0 1 1 1.19-4.84l0.21 0.06a37.1 37.1 0 0 0 5.43 1.12 44.52 44.52 0 0 0 11.76 0 37.1 37.1 0 0 0 5.43-1.12 2.4903 2.4903 0 0 1 1.59 4.72l-0.21 0.06a43.08 43.08 0 0 1-6.15 1.29 48.55 48.55 0 0 1-13.08 0 42.79 42.79 0 0 1-6.17-1.29z\" style=\"fill:#333;\"/>",
"eyes": "<path d=\"m86.851 100.39a4.94 4.94 0 1 0 4.9297 5 5 5 0 0 0-4.9297-5zm57.221 0a4.94 4.94 0 1 0 4.9394 4.9394 4.94 4.94 0 0 0-4.9394-4.9394z\" style=\"fill:#333;\"/><path d=\"m86.207 89.365c-25.504 0-21.503 6.8561-21.035 19.596 0.80177 18.121 17.763 16.514 21.201 16.639 14.758-0.041 20.518-8.227 22.951-22.932 1.8166-10.731-9.251-13.174-23.117-13.303zm58.598 0c-13.866 0.1284-24.936 2.5717-23.119 13.303 2.4332 14.705 8.1936 22.891 22.951 22.932 3.4383-0.125 20.399 1.4828 21.201-16.639 0-18.965-0.47958-19.596-21.033-19.596z\" style=\"fill:#4d4d4d;\"/><path d=\"m169.87 90.255a0.51 0.51 0 0 0-0.43991-0.52 167.64 167.64 0 0 0-22.6-1.6801c-12 0-27.47 3.7601-30.17 3.7601h-2.4c-1.2499 0-5.29-0.80996-10.45-1.6801a124.35 124.35 0 0 0-19.72-2.08 166.18 166.18 0 0 0-19.31 1.24c-1.56 0.17999-2.69 0.35009-3.2899 0.44009a0.51 0.51 0 0 0-0.44007 0.52l-0.091 6.4501a0.57 0.57 0 0 0 0.33012 0.52l0.73994 0.23992c1.08 0.41992 1.0001 19.85 6.78 24.71 3.4401 2.8599 6.51 4.4899 19.42 4.4899 7.4699 0 12.17-1.9999 16.63-8 3.21-4.32 6.0999-14.55 6.0999-14.55 0.82006-4.07 3.7702-4.52 4.43-4.5801h0.12068c0.11078 0 3.66 0.0593 4.57 4.5801 0 0 2.8599 10.22 6.0699 14.54 4.4601 5.9999 9.1601 8 16.63 8 12.91 0 16-1.63 19.42-4.4901 5.7898-4.86 5.6998-24.29 6.78-24.71l0.73994-0.23993a0.57 0.57 0 0 0 0.32996-0.52l-0.12068-6.4501zm-65 23c-1.9101 4.5-6.8 10.29-13.7 10.64-20.7 0.99985-21.65-4.7401-23-9.3201a31.45 31.45 0 0 1-1.2099-13.18c0.53997-4.5799 1.7-7.2699 3.7801-8.6201a9.3 9.3 0 0 1 4.3499-1.51 85.07 85.07 0 0 1 11.4-0.52 59.23 59.23 0 0 1 9.2099 0.69999c7.37 1.2 12.35 3.7001 12.35 6.1601a46.12 46.12 0 0 1-3.23 15.64zm58 1.3201c-1.34 4.5799-2.29 10.36-23 9.3201-6.91-0.3501-11.81-6.1401-13.71-10.64a46.35 46.35 0 0 1-3.22-15.64c0-3.39 9.43-6.8599 21.56-6.8599 12.13 0 14 0.89996 15.75 1.9999 2.08 1.3502 3.2398 4 3.77 8.6201a31.23 31.23 0 0 1-1.1601 13.17z\" style=\"fill:#333;\"/>",
"top": "<path d=\"m156.1 15.879c-0.38556 5.3015-1.7049 9.4762-3.6602 12.76-0.41226 23.773-9.2343 35.229-15.154 42.797l15.062-4.6641c-0.66253 2.8135-2.4628 7.156-0.34766 12.137 1.6334-2.3144 7.9395-5.807 13-3.3477-0.43442 3.5532-0.95271 7.094-1.4512 10.639l8.9648 0.85937c0.83453 3.8792 0.51719 9.3449-0.59961 11.736l5.5508 2.0098c0.20764 2.7646 0.10001 5.4906-0.74609 8.875 8.4545-1.7225 14.213-4.3896 19.641-13.188 2.8639-4.7524 4.9018-10.483 4.7305-17.242-4.1612 4.916-9.6484 7.2485-15.26 10.109 6.507-11.065 8.8648-22.768 8.1367-30.58-7.3456 10.251-11.649 13.06-19.918 16.9 1.2386-11.4 5.5249-18.582 12.461-27.27-11.392-1.3025-16.301 1.4749-24.891 6.4395 4.5466-14.036 2.2208-26.679-5.5195-38.971zm-117.76 28.682c9.3378 3.6366 19.581 9.0234 21.129 18.549-7.6182 0.0414-14.897-3.5072-20.242-7.1894-0.15967 8.2309 2.8451 12.252 6.7734 19.08-7.2127 1.6129-12.084 4.8315-17.471 9.4805 7.2948-0.15715 12.299-1.0502 16.891 4.2793-6.0512 5.0164-11.99 10.79-11.99 19.24 9.257-6.1688 12.495-5.9486 21.137-2.2012 1.2906-8.0996 2.3978-14.872 2.7869-16.435 2.4719-0.73247 3.5247-0.94807 5.9221-1.2938-2.1556-7.4281 1.0996-9.5176 2.4141-11.6l7.543 1.5059c-3.9093-6.1699 2.6565-12.483 7.1445-15.51-4.4474-7.2082-5.6649-11.558-7.377-16.797-11.198-8.2947-23.895-6.2742-34.66-1.1094z\" style=\"fill:#f9f9f9;\"/><path d=\"m101.9 7.6408c-10.047 6.2416-12.441 28.646-12.131 33.289-6.9249-5.8258-7.8992-13.75-7.7695-19.203-9.6235 6.0158-10.666 14.421-9 23.943 1.1061 5.1411 2.3972 10.461 7.377 16.797 2e-3 -1e-3 4e-3 -3e-3 6e-3 -4e-3 2.7742 2.8742 5.4644 5.5941 8.3477 8.3574 0.41187-6.971 0.45449-13.622 7.1856-15.824 3.9532 2.8169 7.4123 5.9388 11.084 9.1035l10.559-10.25c5.6447 3.961 5.4531 6.5652 6.5215 14.104 2.153-1.7546 8.719-9.0037 15.844-10.139 0.98706 4.1261-0.99388 10.308-2.6387 13.621 0 0 14.32-11.846 15.195-27.971 0.33968-6.2599 0.2237-11.146-0.041-14.826-3.2125 5.5652-8.7118 8.7799-13.789 10.15-4.2715-9.2486-2.4785-21.435-0.48047-29.309-12.21 3.0195-20.932 18.337-22.172 25.07-9.2678-7.397-13.605-16.146-14.098-26.91z\" style=\"fill:#f9f9f9;\"/>",
}
// Blond
sp[12] = map[string]string{
"clo": "<path d=\"m141.75 195a114.79 114.79 0 0 1 38 16.5 115.53 115.53 0 0 1-128.46 0 114.79 114.79 0 0 1 38-16.5l26.23 13 26.27-13z\" style=\"fill:#131111;\"/><polygon points=\"115.5 208.03 115.5 207.74 82.72 188.91 80.45 198.86 101.46 222.72\" style=\"fill:#cbcbcb;\"/><polygon points=\"115.5 208.03 115.5 207.74 148.28 188.91 150.55 198.86 129.54 222.72\" style=\"fill:#cbcbcb;\"/>",
"mouth": "<path d=\"m123.07 154.05a10.61 10.61 0 0 1-15 0.14l-0.14-0.14\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:6.3px;stroke:#000;\"/><path d=\"m120.1 142.22 0.19-0.11c3-1.87 5.45-2.4 7.3-1.46 2.15 1.1 3.12 3.84 4.84 5.5a5.18 5.18 0 0 0 6.68 0.73m-28.21-4.66-0.19-0.11c-3-1.87-5.45-2.4-7.3-1.46-2.15 1.1-3.12 3.84-4.84 5.5a5.18 5.18 0 0 1-6.68 0.73\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:5.9998px;stroke:#4d4d4d;\"/>",
"eyes": "<path d=\"m161.73 86.016h-92.51c-3.37 0-6.0001 2.3998-6.0001 5.2999v28.45c0 3.0002 2.74 5.3001 6.0001 5.3001h32.36c7.0901 0 7.44-19.43 13.82-19.43s6.8801 19.44 13.83 19.44h32.36c3.37 0 5.9999-2.4 5.9999-5.3001v-28.46c0.14043-2.9001-2.6-5.2999-5.9-5.2999z\" style=\"fill:#8f8f8f;\"/><path d=\"m161.73 86.016h-92.51c-3.37 0-6.0001 2.3998-6.0001 5.2999v28.45l104.55-28.45c0-2.9001-2.74-5.2999-5.9999-5.2999z\" style=\"fill:#e3e3e3;\"/><path d=\"m161.73 86.016h-92.51c-3.37 0-6.0001 2.3998-6.0001 5.2999v28.45c0 3.0002 2.74 5.3001 6.0001 5.3001h32.36c7.0901 0 7.44-19.43 13.82-19.43s6.8801 19.44 13.83 19.44h32.36c3.37 0 5.9999-2.4 5.9999-5.3001v-28.46c0.14043-2.9001-2.6-5.2999-5.9-5.2999z\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:4.0026px;stroke:#232323;\"/>",
"top": "<path d=\"m69.834 33.826c-8.2001-0.0626-16.444 2.6753-23.152 7.7038-8.5298 6.9899-12.159 19.61-12.329 32.68-0.2041 15.476 1.6092 34.752 1.7464 51.915 0.10414 13.047 0.53485 25.984-2.9197 33.995-2.4994 5.81-9.0955 9.6006-16.196 12.311 7.9599 2.8301 25.009 2.8094 33.58 1.5393 10.8-1.59 17.238-6.5294 17.159-22.699-0.0911-15.93-1.3894-29.23-1.559-45.83-0.3208-11.983-1.569-24.291 4.9774-33.987 4.2139-6.1265 10.452-10.521 17.116-13.588 3.9292-1.8575 8.0384-3.3083 12.263-4.3297-6.8718-13.574-18.732-19.618-30.687-19.709z\" style=\"fill:#b3b3b3;\"/><path d=\"m90.8 76.246c11.918-17.125 31.996-23.218 49.743-17.488 11.81 3.9496 20.692 13.389 22.313 28.237 0.51051 6.2098 0.63413 12.445 0.37007 18.67-0.23973 11.2-0.72946 23.82-1.0995 34.08-0.82005 22.43 0.0593 35.1 24.589 36.3 8.5635 0.32122 17.137-0.22845 25.59-1.6405h-0.0198c-10.74-3.3799-17.98-15.609-19.3-26.289-1.29-10.41-0.6098-23.43-0.7898-38.091-0.1701-14.96 1.0398-29.819 0.28008-42.089-1.414-22.777-14.947-38.505-34.126-45.152-27.813-7.35-51.083 0.091-61.672 17.343-5.4698 8.9112-7.7413 20.07-5.8788 36.121z\" style=\"fill:#b3b3b3;\"/>",
}
// Ateam
sp[13] = map[string]string{
"clo": "<path d=\"M61.11,205.59l3.49,3.69-6.26,6.6A115.45,115.45,0,0,0,72,222.51v-22a115.19,115.19,0,0,0-10.85,5.1Z\" style=\"fill:#eee;\"/><path d=\"M93.24,228.85V199l-4-4A114.43,114.43,0,0,0,72,200.49v22a114.43,114.43,0,0,0,21.28,6.34Z\" style=\"fill:#787878;\"/><path d=\"m159 222.51v-22a114.63 114.63 0 0 0-17.25-5.51l-4 4v29.86a114.16 114.16 0 0 0 21.25-6.35z\" style=\"fill:#787878;\"/><path d=\"m169.89 205.59-3.49 3.69 6.26 6.6a115.45 115.45 0 0 1-13.66 6.63v-22a115.19 115.19 0 0 1 10.85 5.1z\" style=\"fill:#eee;\"/><path d=\"M115.5,219.62A28.5,28.5,0,0,1,87.25,195c2.93-.74,5.92-1.36,8.94-1.87a19.41,19.41,0,0,0,38.62,0c3,.51,6,1.13,8.94,1.87a28.49,28.49,0,0,1-28.25,24.63Z\" style=\"fill:#c9c9c9;\"/>",
"mouth": "<path d=\"m115.5 153.93a14 14 0 0 1-10.5-4.69 3.4209 3.4209 0 0 1 5-4.67l0.08 0.08 0.08 0.09a7.35 7.35 0 0 0 10.39 0.37l0.37-0.37a3.4206 3.4206 0 1 1 5.23 4.41l-0.08 0.09a14 14 0 0 1-10.53 4.69z\" /><path d=\"m115.27 127.32c-7.6627-0.03-15.251 1.4419-20.646 5.1465-7.62 5.33-9.9053 11.512-14.127 18.109-3.4379 5.2447-9.326 10.024-13.467 6.334 25.425 29.755 71.409 29.786 96.875 0.0664-6.8104 3.9305-11.545-2.47-13.508-6.4004-10.697-17.605-14.115-22.656-35.127-23.256zm-0.26758 8.3984c7.457 0.0802 14.986 1.2966 17.146 5.9522 2.5765 11.319-7.5878 17.454-16.681 17.515-6.09-0.05-12.2-2.3802-15.26-7.7402-6.36-11.16 3.6349-15.607 14.795-15.727z\" style=\"fill:#404040;\"/>",
"eyes": "<path d=\"m91.72 97.36v11.4m47.56-11.4v11.4\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:7.9999px;stroke:#333;\"/>",
"top": "<path d=\"m52.107 57.293c-1.3411 14.839-3.8707 52.771 1.3145 72.715-0.67572-43.829 12.389-70.177 62.078-70.187 49.689 0.010061 62.754 26.359 62.078 70.187 5.1852-19.944 2.6556-57.876 1.3145-72.715h-63.393-63.393z\" style=\"fill:#4d4d4d;\"/><path d=\"m52.339 30.629c-1.3825 24.448-2.1216 45.905-1.4497 66.517 9.4643-48.304 112.77-54.916 129.22 0 0.67191-20.612-0.3798-47.256-1.4928-66.517-32.241 14.296-91.346 18.861-126.28 0z\" style=\"fill:#4d4d4d;\"/><path d=\"m115.5 24.92c-22.25 0-44.5 4.2296-56.72 12.69-3.32 2.3-5.0602 6.4392-5.5903 10.269-0.45275 3.23-0.84043 6.7561-1.1785 10.461h126.98c-0.33704-3.7047-0.72492-7.2306-1.1775-10.461-0.53009-3.8301-2.2697-7.9992-5.5897-10.269-12.22-8.4601-34.47-12.69-56.72-12.69z\" style=\"fill:#4d4d4d;\"/><path d=\"m76.521 39.139c21.233 3.3965 33.116-13.392 37.59-31.72 4.3614 17.158 14.175 34.968 36.577 31.584-33.921 20.594-57.646 11.594-74.167 0.1345z\" style=\"fill:#4d4d4d;\"/>",
}
// Rasta
sp[14] = map[string]string{
"clo": "<path d=\"m91.92 194.41a101.47 101.47 0 0 1 23.58 17.09 101.47 101.47 0 0 1 23.58-17.09c0.89 0.19 1.78 0.38 2.67 0.59a114.79 114.79 0 0 1 38 16.5 115.53 115.53 0 0 1-128.46 0 114.79 114.79 0 0 1 38-16.5c0.88-0.21 1.78-0.4 2.67-0.59z\" style=\"fill:#757575;\"/><path d=\"m73.65 199.82c16.59 8.23 28.72 18.91 34.27 30.93a114.86 114.86 0 0 1-56.65-19.25 115.06 115.06 0 0 1 22.38-11.68z\" style=\"fill:#d8d8d8;\"/><path d=\"m60.63 205.85c12.35 5.94 21.93 13.44 27.59 21.91a114.7 114.7 0 0 1-36.95-16.26q4.53-3 9.36-5.65z\" style=\"fill:#757575;\"/><path d=\"m157.35 199.82c-16.6 8.23-28.72 18.91-34.27 30.93a114.86 114.86 0 0 0 56.65-19.25 115.06 115.06 0 0 0-22.38-11.68z\" style=\"fill:#d8d8d8;\"/><path d=\"m170.37 205.85c-12.35 5.94-21.93 13.44-27.59 21.91a114.7 114.7 0 0 0 36.95-16.26q-4.53-3-9.36-5.65z\" style=\"fill:#757575;\"/>",
"mouth": "<path d=\"m115.5 131c-17.71 0.65-27 9.41-29.61 23.69-1 5.62-0.43 7.06 2.76 7.17 22.76 0.76 22.23 18.21 26.85 18.89 4.62-0.68 4.09-18.13 26.85-18.89 3.19-0.11 3.79-1.55 2.76-7.17-2.62-14.28-11.9-23-29.61-23.69zm0 29.31c-10 0-18-5-18-11.17s8.08-11.17 18-11.17 18 5 18 11.17-8.08 11.17-18 11.17z\" style=\"fill:#333;\"/><path d=\"m123.54 148.46a11.53 11.53 0 0 1-16.09 0\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:6.7998px;stroke:#000;\"/>",
"eyes": "<path d=\"m133 108.17h14.17m-63.26 0h14.09m-20.69-8.93a21.31 21.31 0 0 1 27.29 0m21.8 0a21.31 21.31 0 0 1 27.29 0\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:4.8243px;stroke:#000;\"/>",
"top": "<path d=\"m115.5 51.75c-38.702 5.3101-54.215 18.038-59.863 35.101\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/><path d=\"m115.5 51.75c-7.8393 3.6337-5.5974 16.583-14.341 23.452\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/><path d=\"m111.35 48.614c-22.634-6.9181-42.457-3.1988-55.733 2.5105\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/><path d=\"m115.47 54.008c0.1965-6.7774-0.1436-26.309 0.05-38.184\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/><path d=\"m68.874 28.177c34.115-3.382 41.987 13.321 45.17 19.602\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/><path d=\"m116.49 48.69c2.8876-6.3019 10.358-21.518 43.469-22.326\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/><path d=\"m116.92 51.766c1.5094 6.3991 3.4988 15.595 10.088 23.058\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/><path d=\"m113.81 51.532c22.03-7.8674 46.709-7.3614 59.444-2.0465\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/><path d=\"m114.53 52.278c36.226 4.8583 52.414 17.092 59.373 33.347\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/><path d=\"m55.637 86.851c-4.1213 12.452-2.9877 27.213-1.777 43.084\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/><path d=\"m55.614 51.124c-13.422 5.5019-21.908 16.409-24.712 28.774-1.8322 8.4632-1.9809 18.156-1.6096 28.486\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/><path d=\"m173.26 49.486c24.917 10.399 26.707 36.537 27.209 59.62\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/><path d=\"m173.9 85.625c5.4042 12.625 5.2413 27.675 4.5745 43.58\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/><path d=\"m53.86 129.93c1.293 16.951 2.6738 35.169-2.1664 53.193\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/><path d=\"m29.292 108.38c0.6173 17.177 2.6722 36.119 0.8158 54.108\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/><path d=\"m200.47 109.11c0.3586 18.529-1.2751 36.94 1.9231 48.985\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/><path d=\"m178.48 129.2c-0.7279 17.362-2.0563 35.743 2.6011 53.099\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:12;stroke:#333;\"/>",
}
// Meta
sp[15] = map[string]string{
"clo": "<path d=\"m141.75 195a114.79 114.79 0 0 1 38 16.5 115.53 115.53 0 0 1-128.46 0 114.79 114.79 0 0 1 38-16.5 115.77 115.77 0 0 1 15.71-2.53v-14.09a63.8 63.8 0 0 0 21 0v14.09a116.6 116.6 0 0 1 15.75 2.53z\" style=\"fill:#1a1a1a;\"/><path d=\"m60.984 205.66 6.2675 2.2051 3.4074-6.819 2.8018-1.1353-3.9911 7.9907 27.222-3.0857 3.2541-11.739 2.1451-0.2692-3.2833 11.819 20.393-1.6011-14.191-15.945v-2.4379l17.606-5.7274 3.3855-0.473v1.47l-19.167 6.2295 14.731 16.542 19.839-7.7432 3.3636 0.8223-21.371 8.34 20.532 13.842 2.6777-21.687 1.9481 0.5604-2.7726 22.378 0.0584 0.0364 8.5075 4.9923-2.4807 0.85145-6.4718-3.7916-1.2987 6.0622-2.1524 0.53125 1.3425-6.2804-17.037 8.8348-5.0271 0.35661 21.59-11.193-20.962-14.133-7.5006 25.457-2.0721-0.0364 7.6392-25.915-21.05 1.652 9.0109 24.052-1.4155-0.0946-0.49615-0.0437-0.073-7e-3 -0.2043-0.0145-8.3688-22.342-10.127 19.242-1.9846-0.52399 10.514-19.962-26.04 2.9547 13.425 16.418-3.4438-1.0625-12.083-14.781-8.1645 5.9675-1.9043-1.077 8.128-5.9385-6.9898-2.4598 2.3348-1.2881zm92.509-7.2556 14.228 20.093-1.8095 0.89514-15.614-22.043z\" style=\"fill:#b2b2b2;\"/>",
"mouth": "<path d=\"m97.06 144.59a20.15 20.15 0 0 0 36.88 4.53z\" style=\"fill:#fff;stroke-linecap:round;stroke-linejoin:round;stroke-width:2.9999px;stroke:#000;\"/>",
"eyes": "<line x1=\"85.29\" x2=\"85.29\" y1=\"98.73\" y2=\"109.79\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:8.7999px;stroke:#000;\"/><path d=\"m108.28 72.16h62.18c9.19 0 13.32 1.21 14.71 8.52 3.61 18.95 2.2 33.49-0.44 43.75a65.07 65.07 0 0 1-5.89 14.78 73.52 73.52 0 0 1-7.06 10.26c-1.8 2.27-5.17 1.21-4.19-1.09 0.14-0.47 0.27-1 0.4-1.48a14.29 14.29 0 0 0 0.52-6.62 12.52 12.52 0 0 0-3.88-6.3c-4.17-3.9-12.81-8.71-32.53-13.66-6.4-1.6-10.69-2.24-11.76-2.79a7.08 7.08 0 0 1-3.85-6.31v-9c0-2.39 0.18-4.55-1.56-6.57s-4.16-2.13-6.65-2.14a6 6 0 0 1-6-6v-9.35a6 6 0 0 1 6-6z\" style=\"fill:#1a1a1a;\"/><path d=\"m135.9 98.73v9.27m15.22-9.29v9.29\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:7.7998px;stroke:#b2b2b2;\"/>",
"top": "<path d=\"m109.99 15.57c-13.46 3.6301-19.789 11.95-24.069 24.08-6.9996-7-8.7307-10.82-7.5606-21.43a41 41 0 0 0-9.2698 24.988c0.0366 7.6776 5.6462 13.939 12.697 15.297-13.315 5.8106-15.258 22.033-14.045 33.524 5.7687-11.861 14.254-20.981 27.258-22.951-0.43017 6.6-2.5099 10.22-7.29 17.66 18.29-2.8601 25.119-7.8199 37.15-18.24 0.46001 0 1.0001 0.089 1.4606 0.12058-0.33023 3.5601-1.0906 6.5598-5.0004 12.46 9.5298-1.32 14.721-5.8006 17.539-11.671 8.8862 0.95314 15.836 6.785 21.26 14.818 1.928-15.211-4.4766-26.6-19.807-34.036 1.4167-2.6974 8.0143-11.925 17.661-15.721-1.424-0.28569-2.8883-0.49486-4.4033-0.61125-5.71-0.41992-13.62-0.99982-24.89 4.1703 2.8501-8.5101 10.21-11 18.05-13.12-15.131-1.2501-28.61-2.5898-40.53 8.1801-1.8997-6.21-0.18055-12.54 3.7889-17.52z\" style=\"fill:#111;\"/><path d=\"m172.63 69.954c1.2292 14.064 0.93841 29.96 0.34635 45.169 1.7887 6.796 3.0379 13.235 3.8842 18.388l0.13973-0.011c1.0001 6.56 2.3597 13.18 3.2698 19.73 2.0002-6.5699 2.5303-18.25 3.2405-25.43 1.2597-13 1.8296-29.311-0.43017-41.931-0.85041-4.72-2.0007-7.6896-2.0007-8.4796 4.6205 3.5601 8.6606 9.2204 13.001 14.15-0.6751-3.4318-1.347-6.6004-2.0567-9.5273-4.047-5.7183-13.726-12.154-19.393-12.06z\" style=\"fill:#111;\"/><path d=\"m157.97 34.471c-10.339 2.7579-17.715 13.543-19.132 16.24 15.33 7.4361 20.783 17.96 21.278 33.517 5.9534 8.8179 10.066 20.289 12.857 30.895 0.87636-13.178 1.8186-27.726 0.26566-44.28 2.5698 0.44857 9.1372 1.3934 18.781 11.17-2.1158-8.7321-4.5671-15.31-8.4539-20.283-4.5598-5.8401-10.999-10.431-23.809-13 9.6502-3.34 16.27-0.76993 25.5 2.1301-8.1388-7.4315-16.474-14.219-27.287-16.389z\" style=\"fill:#111;\"/><path d=\"m61.473 73.354c-7.256-0.77501-13.024 2.3746-16.262 5.3879 0.73789-0.45409 1.3868-0.74208 1.8489-0.74208 0 0-1.5198 10.359-1.6197 11.519-1.56 19.73 0.99957 43.401 6.37 62.471 1.3099 4.6899 1.1895 3.0893 1.8898-0.9107 1.7526-10.061 3.3891-24.703 6.9739-38.864-5.068-17.627-4.2508-32.403 0.79937-38.861z\" style=\"fill:#111;\"/><path d=\"m69.09 43.21c-0.0253 1.0803-8e-3 2.1612 0.0523 3.2402-3.8402 0-12.46 0.71984-16 2.1598-4.4504 1.8001-8.48 5.4801-11.67 11.83 7.2999-3.94 11.899-3.8502 16.66-1.8102-10.39 3.45-19.52 11.37-20.32 26.9 1.1456-1.5053 4.6079-4.9789 7.1393-6.6285 0.09-0.0587 0.17427-0.10556 0.26167-0.15946 3.7141-2.3211 9.0494-5.1247 15.181-4.9553-5.0501 6.4577-6.6824 20.434 0.28207 38.428 1.7866-7.0567 4.0574-13.994 7.0681-20.184-1e-3 -11.664 2.0764-27.774 15.391-33.585-7.0508-2.1538-12.709-7.991-14.043-15.236z\" style=\"fill:#111;\"/>",
}
}
func SvgCode(avatarId string, sansEnv bool, opts *Options) (svg string, err error) {
if avatarId == "" {
err = errors.New("avatar id is required")
return
}
h := sha256.New()
h.Write([]byte(avatarId))
sum := h.Sum(nil)
s := hex.EncodeToString(sum)
reg := regexp.MustCompile("[0-9]")
hash := reg.FindAllString(s, -1)[0:12]
var p = make(map[string][2]int, 6)
var num int
num, err = strconv.Atoi(strings.Join(hash[:2], ""))
if err != nil {
num = 0
}
p["env"] = getKey(int(math.Floor(.47*float64(num)+.5)), opts)
num, err = strconv.Atoi(strings.Join(hash[2:4], ""))
if err != nil {
num = 0
}
p["clo"] = getKey(int(math.Floor(.47*float64(num)+.5)), opts)
num, err = strconv.Atoi(strings.Join(hash[4:6], ""))
if err != nil {
num = 0
}
p["head"] = getKey(int(math.Floor(.47*float64(num)+.5)), opts)
num, err = strconv.Atoi(strings.Join(hash[6:8], ""))
if err != nil {
num = 0
}
p["mouth"] = getKey(int(math.Floor(.47*float64(num)+.5)), opts)
num, err = strconv.Atoi(strings.Join(hash[8:10], ""))
if err != nil {
num = 0
}
p["eyes"] = getKey(int(math.Floor(.47*float64(num)+.5)), opts)
num, err = strconv.Atoi(strings.Join(hash[10:], ""))
if err != nil {
num = 0
}
p["top"] = getKey(int(math.Floor(.47*float64(num)+.5)), opts)
var final = make(map[string]string, 6)
for k, v := range p {
colors := themes[v[0]][v[1]][k]
var svgPart string
if k == "env" {
svgPart = env
} else if k == "head" {
svgPart = head
} else {
svgPart = sp[v[0]][k]
}
reg := regexp.MustCompile("#(.*?)+(;)")
match := reg.FindAllString(svgPart, -1)
for i, rm := range match {
svgPart = strings.Replace(svgPart, rm, colors[i]+";", 1)
}
final[k] = svgPart
}
var builder strings.Builder
builder.WriteString(svgStart)
builder.WriteString(final["env"])
builder.WriteString(final["head"])
builder.WriteString(final["clo"])
builder.WriteString(final["top"])
builder.WriteString(final["eyes"])
builder.WriteString(final["mouth"])
builder.WriteString(svgEnd)
svg = builder.String()
return
}
func getKey(v int, opts *Options) [2]int {
if opts != nil {
return [2]int{opts.Part, opts.Theme}
}
if v > 31 {
return [2]int{v - 32, 2}
} else if v > 15 {
return [2]int{v - 16, 1}
} else {
return [2]int{v, 0}
}
}
// GenerateAvatar generates an avatar for the given user ID.
func GenerateAvatar(userId string) (baseImg string) {
svg, err := SvgCode(userId, true, nil)
if err != nil {
return "data:image/svg+xml;charset=utf-8;base64,PHN2ZyB0PSIxNzMwNDUwODA4NDIwIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjkyMDMiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNOTc0LjU5NjU0NiA1MDUuOTYwNTg0YzAgMjU1LjQ4NDg0My0yMDcuMTA3NTczIDQ2Ni40MjA0NzctNDYyLjU5NjU0NiA0NjYuNDIwNDc3LTI1NS40ODg5NzMgMC00NjIuNTk2NTQ2LTIxMC45MzU2MzQtNDYyLjU5NjU0Ni00NjYuNDIwNDc3QzQ5LjQwMzQ1NCAyNTAuNDcxNjEyIDI1Ni41MTEwMjcgNDMuMzU5OTA5IDUxMiA0My4zNTk5MDljMjU1LjQ4ODk3MyAwIDQ2Mi41OTY1NDYgMjA3LjExMTcwMyA0NjIuNTk2NTQ2IDQ2Mi42MDA2NzV6IiBmaWxsPSIjRkZFNTc4IiBwLWlkPSI5MjA0Ij48L3BhdGg+PHBhdGggZD0iTTUxMiAxMDAzLjM1MjQyNGMtMjcyLjE1NTY5NiAwLTQ5My41Njc5MDktMjIzLjEzMDA5Mi00OTMuNTY3OTA5LTQ5Ny4zOTE4NEMxOC40MzIwOTEgMjMzLjgwNDg4OCAyMzkuODQ0MzA0IDEyLjM4ODU0NSA1MTIgMTIuMzg4NTQ1czQ5My41Njc5MDkgMjIxLjQxNjM0MyA0OTMuNTY3OTA5IDQ5My41Njc5MWMwIDI3NC4yNjU4NzgtMjIxLjQxMjIxNCA0OTcuMzk1OTctNDkzLjU2NzkwOSA0OTcuMzk1OTY5ek01MTIgNzQuMzMxMjczQzI3My45OTk1MjQgNzQuMzMxMjczIDgwLjM3NDgxOCAyNjcuOTYwMTA4IDgwLjM3NDgxOCA1MDUuOTYwNTg0YzAgMjQwLjExMDY1OCAxOTMuNjI4ODM2IDQzNS40NDkxMTMgNDMxLjYyNTE4MiA0MzUuNDQ5MTEzczQzMS42MjUxODItMTk1LjM0MjU4NCA0MzEuNjI1MTgyLTQzNS40NDkxMTNDOTQzLjYyNTE4MiAyNjcuOTYwMTA4IDc1MC4wMDA0NzYgNzQuMzMxMjczIDUxMiA3NC4zMzEyNzN6IiBmaWxsPSIjNkU2RTk2IiBwLWlkPSI5MjA1Ij48L3BhdGg+PHBhdGggZD0iTTUxMS43OTc2NTQgNDMuMzU5OTA5Yy0yMzUuMDY4NTIgMC00MjkuMTc2Mzc5IDE3NS4zMzkyMTMtNDU4LjY5ODI4NCA0MDIuMzYzNDM4IDEuMDk0MzIyIDIuMTUxNDc3IDEuNzI2MTM3IDMuMjg3MDk0IDEuNzI2MTM4IDMuMjg3MDk0aDI1MC42MDM3NTZsNDIuMDUwODUzLTE4MC4wODgxNTYgMzguMjMxMDUxIDE4MC4wODgxNTZoNTg1LjE4OTQ2MkM5NDIuODMyMzE1IDIyMC4zOTYzNTMgNzQ3Ljk5NzY2MSA0My4zNTk5MDkgNTExLjc5NzY1NCA0My4zNTk5MDl6IiBmaWxsPSIjOUM5Q0JDIiBwLWlkPSI5MjA2Ij48L3BhdGg+PHBhdGggZD0iTTI1MC4wNTY1OTUgNjA5LjE4MTk0NWE4MC4yODYwMzMgNjguODE0MjQgOTAgMSAwIDEzNy42Mjg0ODEgMCA4MC4yODYwMzMgNjguODE0MjQgOTAgMSAwLTEzNy42Mjg0ODEgMFoiIGZpbGw9IiM2RTZFOTYiIHAtaWQ9IjkyMDciPjwvcGF0aD48cGF0aCBkPSJNNjMzLjMyOTI4NCA2MDkuMTgxOTQ1YTgwLjI4NjAzMyA2OC44MTAxMTEgOTAgMSAwIDEzNy42MjAyMjIgMCA4MC4yODYwMzMgNjguODEwMTExIDkwIDEgMC0xMzcuNjIwMjIyIDBaIiBmaWxsPSIjNkU2RTk2IiBwLWlkPSI5MjA4Ij48L3BhdGg+PHBhdGggZD0iTTEwMDUuOTA2NTI5IDQ3OS45ODE4MDRIMzYwLjYyNDM2M2wtMTQuNTg1NDQ3LTY4LjY5NDQ4NC0xNi4wMzkwMzcgNjguNjk0NDg0SDM2LjY2MzlsLTguOTE5NzUyLTE1LjkzOTkyOHMtMC44MjU5MDMtMS40NzAxMDctMi4yNDIzMjctNC4yNjE2NmwtNC4zNTI1MDktOC41NDM5NjcgMS4yMzQ3MjUtOS41MDYxNDNDNTQuMjE0MzQgMTk2Ljk2NTQ4NCAyNjQuNjEzMTM2IDEyLjM4ODU0NSA1MTEuNzk3NjU0IDEyLjM4ODU0NWMyNDguOTY0MzM5IDAgNDU5LjU0ODk2MyAxODYuMDg0MjExIDQ4OS44NDcyMTYgNDMyLjg0NzUxOWw0LjI2MTY1OSAzNC43NDU3NHogbS01OTUuMTEyNjg2LTYxLjk0MjcyN2g1MjMuNjU5Njg2Qzg5My41MjE3NzUgMjE5LjgwMTcwMyA3MTcuNjYyMjQzIDc0LjMzMTI3MyA1MTEuNzk3NjU0IDc0LjMzMTI3MyAzMDYuNDM2ODY2IDc0LjMzMTI3MyAxMzAuMTEwNjk4IDIxOS45ODc1MzEgODkuMTM3NjQ5IDQxOC4wMzkwNzdoMTkxLjcxMjc0MWwzNi40NjM2MTgtMTU2LjE1NzYxNSA2MC40NTYxMDIgMC42MTExNjggMzMuMDIzNzMzIDE1NS41NDY0NDd6IiBmaWxsPSIjNkU2RTk2IiBwLWlkPSI5MjA5Ij48L3BhdGg+PC9zdmc+"
}
svgBytes := []byte(svg)
return "data:image/svg+xml;base64," + base64.StdEncoding.EncodeToString(svgBytes)
}

View File

@@ -0,0 +1,90 @@
package utils
import (
"encoding/base64"
"errors"
"io"
"regexp"
"strings"
"sync"
)
var wg sync.WaitGroup
// GetMimeType 获取 MIME 类型
func GetMimeType(data []byte) string {
if len(data) < 4 {
return "application/octet-stream" // 默认类型
}
// 判断 JPEG
if data[0] == 0xFF && data[1] == 0xD8 {
return "image/jpeg"
}
// 判断 PNG
if len(data) >= 8 && data[0] == 0x89 && data[1] == 0x50 && data[2] == 0x4E && data[3] == 0x47 &&
data[4] == 0x0D && data[5] == 0x0A && data[6] == 0x1A && data[7] == 0x0A {
return "image/png"
}
// 判断 GIF
if len(data) >= 6 && data[0] == 'G' && data[1] == 'I' && data[2] == 'F' {
return "image/gif"
}
// 判断 WEBP
if len(data) >= 12 && data[0] == 0x52 && data[1] == 0x49 && data[2] == 0x46 && data[3] == 0x46 &&
data[8] == 0x57 && data[9] == 0x45 && data[10] == 0x42 && data[11] == 0x50 {
return "image/webp"
}
// 判断svg
if len(data) >= 4 && data[0] == '<' && data[1] == '?' && data[2] == 'x' && data[3] == 'm' {
return "image/svg+xml"
}
// 判断JPG
if len(data) >= 3 && data[0] == 0xFF && data[1] == 0xD8 && data[2] == 0xFF {
return "image/jpeg"
}
return "application/octet-stream" // 默认类型
}
// ProcessImages 处理图片,将 base64 字符串转换为字节数组
func ProcessImages(images []string) ([][]byte, error) {
var imagesData [][]byte
dataChan := make(chan []byte, len(images)) // 创建一个带缓冲的 channel
re := regexp.MustCompile(`^data:image/\w+;base64,`)
for _, img := range images {
wg.Add(1) // 增加 WaitGroup 的计数
go func(img string) {
defer wg.Done() // 函数结束时减少计数
imgWithoutPrefix := re.ReplaceAllString(img, "")
data, err := Base64ToBytes(imgWithoutPrefix)
if err != nil {
return // 出错时直接返回
}
dataChan <- data // 将结果发送到 channel
}(img)
}
wg.Wait() // 等待所有 goroutine 完成
close(dataChan) // 关闭 channel
for data := range dataChan { // 收集所有结果
imagesData = append(imagesData, data)
}
return imagesData, nil
}
// Base64ToBytes 将base64字符串转换为字节数组
func Base64ToBytes(base64Str string) ([]byte, error) {
reader := base64.NewDecoder(base64.StdEncoding, strings.NewReader(base64Str))
data, err := io.ReadAll(reader)
if err != nil {
return nil, errors.New("failed to decode base64 string")
}
return data, nil
}

39
common/utils/match.go Normal file
View File

@@ -0,0 +1,39 @@
package utils
import "regexp"
// IsEmail 判断是否为邮箱
func IsEmail(email string) bool {
// 邮箱的正则表达式
emailRegex := `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`
match, _ := regexp.MatchString(emailRegex, email)
return match
}
// IsPhone 判断是否为手机号
func IsPhone(phone string) bool {
// 手机号的正则表达式,这里以中国大陆的手机号为例
phoneRegex := `^1[3-9]\d{9}$`
match, _ := regexp.MatchString(phoneRegex, phone)
return match
}
// IsUsername 用户名的正则表达式
func IsUsername(username string) bool {
/**
1.用户名仅能使用数字,大小写字母和下划线。
2.用户名中的数字必须在最后。 数字可以有零个或多个。
3.用户名不能以数字开头。 用户名字母可以是小写字母和大写字母。
4.用户名长度必须至少为3个字符。 两位用户名只能使用字母最多20个字符
*/
phoneRegex := `^[a-zA-Z_]{2,18}[0-9]*$`
match, _ := regexp.MatchString(phoneRegex, username)
return match
}
// IsPassword 密码的正则表达式
func IsPassword(password string) bool {
phoneRegex := `^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{6,18}$`
match, _ := regexp.MatchString(phoneRegex, password)
return match
}