195 lines
6.4 KiB
Go
195 lines
6.4 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"gitserver.in/patialtech/rano/db/ent/accesscontrol"
|
|
)
|
|
|
|
// AccessControl is the model entity for the AccessControl schema.
|
|
type AccessControl struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int64 `json:"id,omitempty"`
|
|
// CreatedAt holds the value of the "created_at" field.
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
// UpdatedAt holds the value of the "updated_at" field.
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
|
// 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"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*AccessControl) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case accesscontrol.FieldID:
|
|
values[i] = new(sql.NullInt64)
|
|
case accesscontrol.FieldPtype, accesscontrol.FieldV0, accesscontrol.FieldV1, accesscontrol.FieldV2, accesscontrol.FieldV3, accesscontrol.FieldV4, accesscontrol.FieldV5:
|
|
values[i] = new(sql.NullString)
|
|
case accesscontrol.FieldCreatedAt, accesscontrol.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 AccessControl fields.
|
|
func (ac *AccessControl) 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 accesscontrol.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
ac.ID = int64(value.Int64)
|
|
case accesscontrol.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 {
|
|
ac.CreatedAt = value.Time
|
|
}
|
|
case accesscontrol.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 {
|
|
ac.UpdatedAt = value.Time
|
|
}
|
|
case accesscontrol.FieldPtype:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field ptype", values[i])
|
|
} else if value.Valid {
|
|
ac.Ptype = value.String
|
|
}
|
|
case accesscontrol.FieldV0:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field v0", values[i])
|
|
} else if value.Valid {
|
|
ac.V0 = value.String
|
|
}
|
|
case accesscontrol.FieldV1:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field v1", values[i])
|
|
} else if value.Valid {
|
|
ac.V1 = value.String
|
|
}
|
|
case accesscontrol.FieldV2:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field v2", values[i])
|
|
} else if value.Valid {
|
|
ac.V2 = value.String
|
|
}
|
|
case accesscontrol.FieldV3:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field v3", values[i])
|
|
} else if value.Valid {
|
|
ac.V3 = value.String
|
|
}
|
|
case accesscontrol.FieldV4:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field v4", values[i])
|
|
} else if value.Valid {
|
|
ac.V4 = value.String
|
|
}
|
|
case accesscontrol.FieldV5:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field v5", values[i])
|
|
} else if value.Valid {
|
|
ac.V5 = value.String
|
|
}
|
|
default:
|
|
ac.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the AccessControl.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (ac *AccessControl) Value(name string) (ent.Value, error) {
|
|
return ac.selectValues.Get(name)
|
|
}
|
|
|
|
// Update returns a builder for updating this AccessControl.
|
|
// Note that you need to call AccessControl.Unwrap() before calling this method if this AccessControl
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (ac *AccessControl) Update() *AccessControlUpdateOne {
|
|
return NewAccessControlClient(ac.config).UpdateOne(ac)
|
|
}
|
|
|
|
// Unwrap unwraps the AccessControl 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 (ac *AccessControl) Unwrap() *AccessControl {
|
|
_tx, ok := ac.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: AccessControl is not a transactional entity")
|
|
}
|
|
ac.config.driver = _tx.drv
|
|
return ac
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (ac *AccessControl) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("AccessControl(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", ac.ID))
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(ac.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("updated_at=")
|
|
builder.WriteString(ac.UpdatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("ptype=")
|
|
builder.WriteString(ac.Ptype)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("v0=")
|
|
builder.WriteString(ac.V0)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("v1=")
|
|
builder.WriteString(ac.V1)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("v2=")
|
|
builder.WriteString(ac.V2)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("v3=")
|
|
builder.WriteString(ac.V3)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("v4=")
|
|
builder.WriteString(ac.V4)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("v5=")
|
|
builder.WriteString(ac.V5)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// AccessControls is a parsable slice of AccessControl.
|
|
type AccessControls []*AccessControl
|