Files
Home-Vue-Go/internal/ent/contact.go
T
2026-01-28 13:25:18 +08:00

159 lines
4.9 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 (
"fmt"
"home-vue-go/internal/ent/contact"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// Contact is the model entity for the Contact schema.
type Contact struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// 联系方式类型(Email, Github, 支付宝, 微信等)
Type string `json:"type,omitempty"`
// 图标类名
Icon string `json:"icon,omitempty"`
// 链接URLmailto:或https://
URL string `json:"url,omitempty"`
// 二维码图片URL或路径
QrCode string `json:"qr_code,omitempty"`
// 悬停颜色
HoverColor string `json:"hover_color,omitempty"`
// 排序顺序
SortOrder int `json:"sort_order,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Contact) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case contact.FieldID, contact.FieldSortOrder:
values[i] = new(sql.NullInt64)
case contact.FieldType, contact.FieldIcon, contact.FieldURL, contact.FieldQrCode, contact.FieldHoverColor:
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 Contact fields.
func (_m *Contact) 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 contact.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 contact.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 = value.String
}
case contact.FieldIcon:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field icon", values[i])
} else if value.Valid {
_m.Icon = value.String
}
case contact.FieldURL:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field url", values[i])
} else if value.Valid {
_m.URL = value.String
}
case contact.FieldQrCode:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field qr_code", values[i])
} else if value.Valid {
_m.QrCode = value.String
}
case contact.FieldHoverColor:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field hover_color", values[i])
} else if value.Valid {
_m.HoverColor = value.String
}
case contact.FieldSortOrder:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field sort_order", values[i])
} else if value.Valid {
_m.SortOrder = int(value.Int64)
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Contact.
// This includes values selected through modifiers, order, etc.
func (_m *Contact) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this Contact.
// Note that you need to call Contact.Unwrap() before calling this method if this Contact
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *Contact) Update() *ContactUpdateOne {
return NewContactClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the Contact 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 *Contact) Unwrap() *Contact {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: Contact is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *Contact) String() string {
var builder strings.Builder
builder.WriteString("Contact(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("type=")
builder.WriteString(_m.Type)
builder.WriteString(", ")
builder.WriteString("icon=")
builder.WriteString(_m.Icon)
builder.WriteString(", ")
builder.WriteString("url=")
builder.WriteString(_m.URL)
builder.WriteString(", ")
builder.WriteString("qr_code=")
builder.WriteString(_m.QrCode)
builder.WriteString(", ")
builder.WriteString("hover_color=")
builder.WriteString(_m.HoverColor)
builder.WriteString(", ")
builder.WriteString("sort_order=")
builder.WriteString(fmt.Sprintf("%v", _m.SortOrder))
builder.WriteByte(')')
return builder.String()
}
// Contacts is a parsable slice of Contact.
type Contacts []*Contact