🚧 Refactor basic services
This commit is contained in:
168
internal/models/ent/extension.go
Normal file
168
internal/models/ent/extension.go
Normal file
@@ -0,0 +1,168 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"voidraft/internal/models/ent/extension"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Extension is the model entity for the Extension schema.
|
||||
type Extension struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// 创建时间
|
||||
CreatedAt string `json:"created_at"`
|
||||
// 最后更新时间
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
// 删除时间,NULL表示未删除
|
||||
DeletedAt *string `json:"deleted_at,omitempty"`
|
||||
// 扩展标识符
|
||||
Key string `json:"key"`
|
||||
// 是否启用
|
||||
Enabled bool `json:"enabled"`
|
||||
// 扩展配置
|
||||
Config map[string]interface{} `json:"config"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Extension) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case extension.FieldConfig:
|
||||
values[i] = new([]byte)
|
||||
case extension.FieldEnabled:
|
||||
values[i] = new(sql.NullBool)
|
||||
case extension.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case extension.FieldCreatedAt, extension.FieldUpdatedAt, extension.FieldDeletedAt, extension.FieldKey:
|
||||
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 Extension fields.
|
||||
func (_m *Extension) 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 extension.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
_m.ID = int(value.Int64)
|
||||
case extension.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.CreatedAt = value.String
|
||||
}
|
||||
case extension.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.UpdatedAt = value.String
|
||||
}
|
||||
case extension.FieldDeletedAt:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.DeletedAt = new(string)
|
||||
*_m.DeletedAt = value.String
|
||||
}
|
||||
case extension.FieldKey:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field key", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Key = value.String
|
||||
}
|
||||
case extension.FieldEnabled:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field enabled", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Enabled = value.Bool
|
||||
}
|
||||
case extension.FieldConfig:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field config", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &_m.Config); err != nil {
|
||||
return fmt.Errorf("unmarshal field config: %w", err)
|
||||
}
|
||||
}
|
||||
default:
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Extension.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (_m *Extension) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Extension.
|
||||
// Note that you need to call Extension.Unwrap() before calling this method if this Extension
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (_m *Extension) Update() *ExtensionUpdateOne {
|
||||
return NewExtensionClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Extension 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 (_m *Extension) Unwrap() *Extension {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Extension is not a transactional entity")
|
||||
}
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (_m *Extension) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Extension(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(_m.CreatedAt)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(_m.UpdatedAt)
|
||||
builder.WriteString(", ")
|
||||
if v := _m.DeletedAt; v != nil {
|
||||
builder.WriteString("deleted_at=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("key=")
|
||||
builder.WriteString(_m.Key)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("enabled=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Enabled))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("config=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Config))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// Extensions is a parsable slice of Extension.
|
||||
type Extensions []*Extension
|
||||
Reference in New Issue
Block a user