Files
voidraft/internal/models/ent/theme.go
2025-12-14 02:19:50 +08:00

167 lines
5.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"encoding/json"
"fmt"
"strings"
"voidraft/internal/models/ent/theme"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// Theme is the model entity for the Theme schema.
type Theme 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"`
// 主题类型
Type theme.Type `json:"type"`
// 主题颜色配置
Colors map[string]interface{} `json:"colors"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Theme) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case theme.FieldColors:
values[i] = new([]byte)
case theme.FieldID:
values[i] = new(sql.NullInt64)
case theme.FieldCreatedAt, theme.FieldUpdatedAt, theme.FieldDeletedAt, theme.FieldKey, theme.FieldType:
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 Theme fields.
func (_m *Theme) 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 theme.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 theme.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 theme.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 theme.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 theme.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 theme.FieldType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field type", values[i])
} else if value.Valid {
_m.Type = theme.Type(value.String)
}
case theme.FieldColors:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field colors", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &_m.Colors); err != nil {
return fmt.Errorf("unmarshal field colors: %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 Theme.
// This includes values selected through modifiers, order, etc.
func (_m *Theme) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this Theme.
// Note that you need to call Theme.Unwrap() before calling this method if this Theme
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *Theme) Update() *ThemeUpdateOne {
return NewThemeClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the Theme 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 *Theme) Unwrap() *Theme {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: Theme is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *Theme) String() string {
var builder strings.Builder
builder.WriteString("Theme(")
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("type=")
builder.WriteString(fmt.Sprintf("%v", _m.Type))
builder.WriteString(", ")
builder.WriteString("colors=")
builder.WriteString(fmt.Sprintf("%v", _m.Colors))
builder.WriteByte(')')
return builder.String()
}
// Themes is a parsable slice of Theme.
type Themes []*Theme