Files

173 lines
5.5 KiB
Go
Raw Permalink Normal View History

// Code generated by ent, DO NOT EDIT.
package ent
import (
"bj_power_mes/ent/attachment"
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// Attachment is the model entity for the Attachment schema.
type Attachment struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// 业务类型 work_order/material/process_flow/inspection
BizType string `json:"bizType,omitempty"`
// 业务ID
BizId string `json:"bizId,omitempty"`
// 原始文件名
FileName string `json:"fileName,omitempty"`
// 上传目录相对路径
FilePath string `json:"filePath,omitempty"`
// 字节数
FileSize int `json:"fileSize,omitempty"`
// 上传人
Uploader string `json:"uploader,omitempty"`
// CreatedAt holds the value of the "createdAt" field.
CreatedAt time.Time `json:"createdAt,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Attachment) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case attachment.FieldID, attachment.FieldFileSize:
values[i] = new(sql.NullInt64)
case attachment.FieldBizType, attachment.FieldBizId, attachment.FieldFileName, attachment.FieldFilePath, attachment.FieldUploader:
values[i] = new(sql.NullString)
case attachment.FieldCreatedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Attachment fields.
func (_m *Attachment) 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 attachment.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 attachment.FieldBizType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field bizType", values[i])
} else if value.Valid {
_m.BizType = value.String
}
case attachment.FieldBizId:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field bizId", values[i])
} else if value.Valid {
_m.BizId = value.String
}
case attachment.FieldFileName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field fileName", values[i])
} else if value.Valid {
_m.FileName = value.String
}
case attachment.FieldFilePath:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field filePath", values[i])
} else if value.Valid {
_m.FilePath = value.String
}
case attachment.FieldFileSize:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field fileSize", values[i])
} else if value.Valid {
_m.FileSize = int(value.Int64)
}
case attachment.FieldUploader:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field uploader", values[i])
} else if value.Valid {
_m.Uploader = value.String
}
case attachment.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field createdAt", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Attachment.
// This includes values selected through modifiers, order, etc.
func (_m *Attachment) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this Attachment.
// Note that you need to call Attachment.Unwrap() before calling this method if this Attachment
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *Attachment) Update() *AttachmentUpdateOne {
return NewAttachmentClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the Attachment 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 *Attachment) Unwrap() *Attachment {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: Attachment is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *Attachment) String() string {
var builder strings.Builder
builder.WriteString("Attachment(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("bizType=")
builder.WriteString(_m.BizType)
builder.WriteString(", ")
builder.WriteString("bizId=")
builder.WriteString(_m.BizId)
builder.WriteString(", ")
builder.WriteString("fileName=")
builder.WriteString(_m.FileName)
builder.WriteString(", ")
builder.WriteString("filePath=")
builder.WriteString(_m.FilePath)
builder.WriteString(", ")
builder.WriteString("fileSize=")
builder.WriteString(fmt.Sprintf("%v", _m.FileSize))
builder.WriteString(", ")
builder.WriteString("uploader=")
builder.WriteString(_m.Uploader)
builder.WriteString(", ")
builder.WriteString("createdAt=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}
// Attachments is a parsable slice of Attachment.
type Attachments []*Attachment