feat: add import list & calendar

This commit is contained in:
Simon Ding
2024-09-02 23:47:19 +08:00
parent ca414a73ff
commit 361556228b
36 changed files with 3863 additions and 344 deletions

164
ent/importlist.go Normal file
View File

@@ -0,0 +1,164 @@
// Code generated by ent, DO NOT EDIT.
package ent
import (
"encoding/json"
"fmt"
"polaris/ent/importlist"
"polaris/ent/schema"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// ImportList is the model entity for the ImportList schema.
type ImportList struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
// Type holds the value of the "type" field.
Type importlist.Type `json:"type,omitempty"`
// URL holds the value of the "url" field.
URL string `json:"url,omitempty"`
// Qulity holds the value of the "qulity" field.
Qulity string `json:"qulity,omitempty"`
// StorageID holds the value of the "storage_id" field.
StorageID int `json:"storage_id,omitempty"`
// Settings holds the value of the "settings" field.
Settings schema.ImportListSettings `json:"settings,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ImportList) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case importlist.FieldSettings:
values[i] = new([]byte)
case importlist.FieldID, importlist.FieldStorageID:
values[i] = new(sql.NullInt64)
case importlist.FieldName, importlist.FieldType, importlist.FieldURL, importlist.FieldQulity:
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 ImportList fields.
func (il *ImportList) 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 importlist.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
il.ID = int(value.Int64)
case importlist.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
il.Name = value.String
}
case importlist.FieldType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field type", values[i])
} else if value.Valid {
il.Type = importlist.Type(value.String)
}
case importlist.FieldURL:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field url", values[i])
} else if value.Valid {
il.URL = value.String
}
case importlist.FieldQulity:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field qulity", values[i])
} else if value.Valid {
il.Qulity = value.String
}
case importlist.FieldStorageID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field storage_id", values[i])
} else if value.Valid {
il.StorageID = int(value.Int64)
}
case importlist.FieldSettings:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field settings", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &il.Settings); err != nil {
return fmt.Errorf("unmarshal field settings: %w", err)
}
}
default:
il.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ImportList.
// This includes values selected through modifiers, order, etc.
func (il *ImportList) Value(name string) (ent.Value, error) {
return il.selectValues.Get(name)
}
// Update returns a builder for updating this ImportList.
// Note that you need to call ImportList.Unwrap() before calling this method if this ImportList
// was returned from a transaction, and the transaction was committed or rolled back.
func (il *ImportList) Update() *ImportListUpdateOne {
return NewImportListClient(il.config).UpdateOne(il)
}
// Unwrap unwraps the ImportList 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 (il *ImportList) Unwrap() *ImportList {
_tx, ok := il.config.driver.(*txDriver)
if !ok {
panic("ent: ImportList is not a transactional entity")
}
il.config.driver = _tx.drv
return il
}
// String implements the fmt.Stringer.
func (il *ImportList) String() string {
var builder strings.Builder
builder.WriteString("ImportList(")
builder.WriteString(fmt.Sprintf("id=%v, ", il.ID))
builder.WriteString("name=")
builder.WriteString(il.Name)
builder.WriteString(", ")
builder.WriteString("type=")
builder.WriteString(fmt.Sprintf("%v", il.Type))
builder.WriteString(", ")
builder.WriteString("url=")
builder.WriteString(il.URL)
builder.WriteString(", ")
builder.WriteString("qulity=")
builder.WriteString(il.Qulity)
builder.WriteString(", ")
builder.WriteString("storage_id=")
builder.WriteString(fmt.Sprintf("%v", il.StorageID))
builder.WriteString(", ")
builder.WriteString("settings=")
builder.WriteString(fmt.Sprintf("%v", il.Settings))
builder.WriteByte(')')
return builder.String()
}
// ImportLists is a parsable slice of ImportList.
type ImportLists []*ImportList