181 lines
6.0 KiB
Go
181 lines
6.0 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|||
|
|
|
||
|
|
package ent
|
||
|
|
|
||
|
|
import (
|
||
|
|
"bj_power_wms/ent/attachment"
|
||
|
|
"fmt"
|
||
|
|
"strings"
|
||
|
|
|
||
|
|
"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"`
|
||
|
|
// 业务类型 inbound/material/inspection/semi/outbound
|
||
|
|
BizType string `json:"bizType,omitempty"`
|
||
|
|
// 业务对象标识(单号/编码/ID)
|
||
|
|
BizID string `json:"bizId,omitempty"`
|
||
|
|
// 原始文件名(含扩展名)
|
||
|
|
FileName string `json:"fileName,omitempty"`
|
||
|
|
// 磁盘相对文件名(uuid+ext)
|
||
|
|
FilePath string `json:"filePath,omitempty"`
|
||
|
|
// 文件大小(字节)
|
||
|
|
FileSize int64 `json:"fileSize,omitempty"`
|
||
|
|
// MIME 类型
|
||
|
|
MimeType string `json:"mimeType,omitempty"`
|
||
|
|
// 上传人
|
||
|
|
UploadedBy string `json:"uploadedBy,omitempty"`
|
||
|
|
// CreatedAt holds the value of the "created_at" field.
|
||
|
|
CreatedAt int64 `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, attachment.FieldCreatedAt:
|
||
|
|
values[i] = new(sql.NullInt64)
|
||
|
|
case attachment.FieldBizType, attachment.FieldBizID, attachment.FieldFileName, attachment.FieldFilePath, attachment.FieldMimeType, attachment.FieldUploadedBy:
|
||
|
|
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 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 biz_type", 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 biz_id", 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 file_name", 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 file_path", 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 file_size", values[i])
|
||
|
|
} else if value.Valid {
|
||
|
|
_m.FileSize = value.Int64
|
||
|
|
}
|
||
|
|
case attachment.FieldMimeType:
|
||
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||
|
|
return fmt.Errorf("unexpected type %T for field mime_type", values[i])
|
||
|
|
} else if value.Valid {
|
||
|
|
_m.MimeType = value.String
|
||
|
|
}
|
||
|
|
case attachment.FieldUploadedBy:
|
||
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||
|
|
return fmt.Errorf("unexpected type %T for field uploaded_by", values[i])
|
||
|
|
} else if value.Valid {
|
||
|
|
_m.UploadedBy = value.String
|
||
|
|
}
|
||
|
|
case attachment.FieldCreatedAt:
|
||
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||
|
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||
|
|
} else if value.Valid {
|
||
|
|
_m.CreatedAt = 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 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("biz_type=")
|
||
|
|
builder.WriteString(_m.BizType)
|
||
|
|
builder.WriteString(", ")
|
||
|
|
builder.WriteString("biz_id=")
|
||
|
|
builder.WriteString(_m.BizID)
|
||
|
|
builder.WriteString(", ")
|
||
|
|
builder.WriteString("file_name=")
|
||
|
|
builder.WriteString(_m.FileName)
|
||
|
|
builder.WriteString(", ")
|
||
|
|
builder.WriteString("file_path=")
|
||
|
|
builder.WriteString(_m.FilePath)
|
||
|
|
builder.WriteString(", ")
|
||
|
|
builder.WriteString("file_size=")
|
||
|
|
builder.WriteString(fmt.Sprintf("%v", _m.FileSize))
|
||
|
|
builder.WriteString(", ")
|
||
|
|
builder.WriteString("mime_type=")
|
||
|
|
builder.WriteString(_m.MimeType)
|
||
|
|
builder.WriteString(", ")
|
||
|
|
builder.WriteString("uploaded_by=")
|
||
|
|
builder.WriteString(_m.UploadedBy)
|
||
|
|
builder.WriteString(", ")
|
||
|
|
builder.WriteString("created_at=")
|
||
|
|
builder.WriteString(fmt.Sprintf("%v", _m.CreatedAt))
|
||
|
|
builder.WriteByte(')')
|
||
|
|
return builder.String()
|
||
|
|
}
|
||
|
|
|
||
|
|
// Attachments is a parsable slice of Attachment.
|
||
|
|
type Attachments []*Attachment
|