You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

203 lines
7.0 KiB
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/dictionary"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/dictionarydetail"
"git.noahlan.cn/noahlan/ntool-biz/core/orm/nent/types"
)
// 字典详情表
type DictionaryDetail struct {
config `json:"-"`
// ID of the ent.
// Primary Key | 主键
ID int64 `json:"id,omitempty"`
// Status | 状态
Status types.Status `json:"status,omitempty"`
// Sort number | 排序号
Sort uint32 `json:"sort,omitempty"`
// optimistic lock | 乐观锁
Version int64 `json:"version,omitempty"`
// The title shown in the ui | 展示名称 建议配合i18n
Title string `json:"title,omitempty"`
// key | 键
Key string `json:"key,omitempty"`
// value | 值
Value string `json:"value,omitempty"`
// Dictionary ID | 字典ID
DictionaryID int64 `json:"dictionary_id,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the DictionaryDetailQuery when eager-loading is set.
Edges DictionaryDetailEdges `json:"edges"`
selectValues sql.SelectValues
}
// DictionaryDetailEdges holds the relations/edges for other nodes in the graph.
type DictionaryDetailEdges struct {
// Dictionary holds the value of the dictionary edge.
Dictionary *Dictionary `json:"dictionary,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// DictionaryOrErr returns the Dictionary value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e DictionaryDetailEdges) DictionaryOrErr() (*Dictionary, error) {
if e.loadedTypes[0] {
if e.Dictionary == nil {
// Edge was loaded but was not found.
return nil, &NotFoundError{label: dictionary.Label}
}
return e.Dictionary, nil
}
return nil, &NotLoadedError{edge: "dictionary"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*DictionaryDetail) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case dictionarydetail.FieldID, dictionarydetail.FieldSort, dictionarydetail.FieldVersion, dictionarydetail.FieldDictionaryID:
values[i] = new(sql.NullInt64)
case dictionarydetail.FieldStatus, dictionarydetail.FieldTitle, dictionarydetail.FieldKey, dictionarydetail.FieldValue:
values[i] = new(sql.NullString)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the DictionaryDetail fields.
func (dd *DictionaryDetail) 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 dictionarydetail.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
dd.ID = int64(value.Int64)
case dictionarydetail.FieldStatus:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
dd.Status = types.Status(value.String)
}
case dictionarydetail.FieldSort:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field sort", values[i])
} else if value.Valid {
dd.Sort = uint32(value.Int64)
}
case dictionarydetail.FieldVersion:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field version", values[i])
} else if value.Valid {
dd.Version = value.Int64
}
case dictionarydetail.FieldTitle:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field title", values[i])
} else if value.Valid {
dd.Title = value.String
}
case dictionarydetail.FieldKey:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field key", values[i])
} else if value.Valid {
dd.Key = value.String
}
case dictionarydetail.FieldValue:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field value", values[i])
} else if value.Valid {
dd.Value = value.String
}
case dictionarydetail.FieldDictionaryID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field dictionary_id", values[i])
} else if value.Valid {
dd.DictionaryID = value.Int64
}
default:
dd.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// GetValue returns the ent.Value that was dynamically selected and assigned to the DictionaryDetail.
// This includes values selected through modifiers, order, etc.
func (dd *DictionaryDetail) GetValue(name string) (ent.Value, error) {
return dd.selectValues.Get(name)
}
// QueryDictionary queries the "dictionary" edge of the DictionaryDetail entity.
func (dd *DictionaryDetail) QueryDictionary() *DictionaryQuery {
return NewDictionaryDetailClient(dd.config).QueryDictionary(dd)
}
// Update returns a builder for updating this DictionaryDetail.
// Note that you need to call DictionaryDetail.Unwrap() before calling this method if this DictionaryDetail
// was returned from a transaction, and the transaction was committed or rolled back.
func (dd *DictionaryDetail) Update() *DictionaryDetailUpdateOne {
return NewDictionaryDetailClient(dd.config).UpdateOne(dd)
}
// Unwrap unwraps the DictionaryDetail 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 (dd *DictionaryDetail) Unwrap() *DictionaryDetail {
_tx, ok := dd.config.driver.(*txDriver)
if !ok {
panic("ent: DictionaryDetail is not a transactional entity")
}
dd.config.driver = _tx.drv
return dd
}
// String implements the fmt.Stringer.
func (dd *DictionaryDetail) String() string {
var builder strings.Builder
builder.WriteString("DictionaryDetail(")
builder.WriteString(fmt.Sprintf("id=%v, ", dd.ID))
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", dd.Status))
builder.WriteString(", ")
builder.WriteString("sort=")
builder.WriteString(fmt.Sprintf("%v", dd.Sort))
builder.WriteString(", ")
builder.WriteString("version=")
builder.WriteString(fmt.Sprintf("%v", dd.Version))
builder.WriteString(", ")
builder.WriteString("title=")
builder.WriteString(dd.Title)
builder.WriteString(", ")
builder.WriteString("key=")
builder.WriteString(dd.Key)
builder.WriteString(", ")
builder.WriteString("value=")
builder.WriteString(dd.Value)
builder.WriteString(", ")
builder.WriteString("dictionary_id=")
builder.WriteString(fmt.Sprintf("%v", dd.DictionaryID))
builder.WriteByte(')')
return builder.String()
}
// DictionaryDetails is a parsable slice of DictionaryDetail.
type DictionaryDetails []*DictionaryDetail