178 lines
6.0 KiB
Go
178 lines
6.0 KiB
Go
// 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"
|
|
)
|
|
|
|
// ScaAuthRole is the model entity for the ScaAuthRole schema.
|
|
type ScaAuthRole struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
// 主键ID
|
|
ID int64 `json:"id,omitempty"`
|
|
// 角色名称
|
|
RoleName string `json:"role_name,omitempty"`
|
|
// 角色关键字
|
|
RoleKey string `json:"role_key,omitempty"`
|
|
// 创建时间
|
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
|
// 更新时间
|
|
UpdateAt time.Time `json:"update_at,omitempty"`
|
|
// 是否删除 0 未删除 1已删除
|
|
Deleted int `json:"deleted,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.FieldUpdateAt:
|
|
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.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
|
|
}
|
|
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.FieldUpdateAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field update_at", values[i])
|
|
} else if value.Valid {
|
|
sar.UpdateAt = 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 = int(value.Int64)
|
|
}
|
|
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("role_name=")
|
|
builder.WriteString(sar.RoleName)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("role_key=")
|
|
builder.WriteString(sar.RoleKey)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(sar.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("update_at=")
|
|
builder.WriteString(sar.UpdateAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("deleted=")
|
|
builder.WriteString(fmt.Sprintf("%v", sar.Deleted))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// ScaAuthRoles is a parsable slice of ScaAuthRole.
|
|
type ScaAuthRoles []*ScaAuthRole
|