230 lines
8.0 KiB
Go
230 lines
8.0 KiB
Go
// 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"
|
|
)
|
|
|
|
// ScaAuthPermissionRule is the model entity for the ScaAuthPermissionRule schema.
|
|
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
|