🚧 Refactor basic services
This commit is contained in:
174
internal/models/ent/keybinding.go
Normal file
174
internal/models/ent/keybinding.go
Normal file
@@ -0,0 +1,174 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"voidraft/internal/models/ent/keybinding"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// KeyBinding is the model entity for the KeyBinding schema.
|
||||
type KeyBinding 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"`
|
||||
// 快捷键命令
|
||||
Command string `json:"command"`
|
||||
// 所属扩展标识符
|
||||
Extension string `json:"extension,omitempty"`
|
||||
// 是否启用
|
||||
Enabled bool `json:"enabled"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*KeyBinding) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case keybinding.FieldEnabled:
|
||||
values[i] = new(sql.NullBool)
|
||||
case keybinding.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case keybinding.FieldCreatedAt, keybinding.FieldUpdatedAt, keybinding.FieldDeletedAt, keybinding.FieldKey, keybinding.FieldCommand, keybinding.FieldExtension:
|
||||
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 KeyBinding fields.
|
||||
func (_m *KeyBinding) 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 keybinding.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 keybinding.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 keybinding.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 keybinding.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 keybinding.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 keybinding.FieldCommand:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field command", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Command = value.String
|
||||
}
|
||||
case keybinding.FieldExtension:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field extension", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Extension = value.String
|
||||
}
|
||||
case keybinding.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
|
||||
}
|
||||
default:
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the KeyBinding.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (_m *KeyBinding) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this KeyBinding.
|
||||
// Note that you need to call KeyBinding.Unwrap() before calling this method if this KeyBinding
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (_m *KeyBinding) Update() *KeyBindingUpdateOne {
|
||||
return NewKeyBindingClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the KeyBinding 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 *KeyBinding) Unwrap() *KeyBinding {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: KeyBinding is not a transactional entity")
|
||||
}
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (_m *KeyBinding) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("KeyBinding(")
|
||||
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("command=")
|
||||
builder.WriteString(_m.Command)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("extension=")
|
||||
builder.WriteString(_m.Extension)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("enabled=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Enabled))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// KeyBindings is a parsable slice of KeyBinding.
|
||||
type KeyBindings []*KeyBinding
|
||||
Reference in New Issue
Block a user