Files
bj_power/bj_power_mes/schema/attachment.go
T
SunYF 1f7a42fc38 refactor(mes): 移除工位接驳台绑定逻辑,改为独立dock主数据
- 移除station表的hasDock、dockCode字段及相关代码
- 新增dock表注释及关联逻辑,支持一个工位绑定多个接驳台
- 更新工位相关的seed、logic、schema及前端代码,适配新的接驳台管理方式
- 新增SQL注释固化脚本,完善MES表注释
2026-10-08 13:09:53 +08:00

56 lines
2.4 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.
package schema
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
)
// Attachment 业务附件:图纸 / 照片 / 文档等,按 bizType+bizId 关联业务单据。
// 存储落地约定(2026-09-19 统一方案):<Upload.Dir>/年/月/日/<文件类型大写枚举>/<uuid>.<ext>,
// 库内 filePath 只存相对路径(如 2026/09/19/INSPECTION_PHOTO/xxx.jpg),不存绝对路径。
type Attachment struct {
ent.Schema
}
func (Attachment) Annotations() []schema.Annotation {
return []schema.Annotation{entsql.Annotation{Table: "attachment"}, entsql.WithComments(true), schema.Comment("Attachment 业务附件:图纸 / 照片 / 文档等,按 bizType+bizId 关联业务单据。")}
}
func (Attachment) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.String("bizType").MaxLen(40).Comment("业务类型 work_order/material/process_flow/inspection"),
field.String("bizId").MaxLen(64).Comment("业务ID"),
field.String("fileName").MaxLen(255).Comment("原始文件名"),
field.String("filePath").MaxLen(255).Comment("上传目录相对路径"),
field.Int("fileSize").Default(0).Comment("字节数"),
field.String("uploader").Default("").MaxLen(64).Comment("上传人"),
field.Time("createdAt").Default(time.Now).Immutable(),
// 文件类型(大写枚举):决定存储目录分层,与 bizType(业务对象)正交
field.String("fileType").Default("OTHER").MaxLen(32).Comment("文件类型 大写枚举 PROCESS_PDF/INSPECTION_PHOTO/..."),
field.String("fileExt").Default("").MaxLen(16).Comment("扩展名(小写,不含点)"),
field.String("fileMd5").Default("").MaxLen(64).Comment("文件MD5(秒传/去重)"),
field.String("mimeType").Default("").MaxLen(128).Comment("MIME类型"),
// 归档 / 逻辑删除:物理文件由归档任务统一处理,库内保留索引可追溯
field.Bool("archived").Default(false).Comment("是否已归档"),
field.Int64("archivedAt").Default(0).Comment("归档时间(unix秒)"),
field.Bool("deleted").Default(false).Comment("逻辑删除"),
field.Int64("deletedAt").Default(0).Comment("删除时间(unix秒)"),
field.String("deletedBy").Default("").MaxLen(64).Comment("删除人"),
}
}
func (Attachment) Indexes() []ent.Index {
return []ent.Index{
index.Fields("bizType", "bizId"),
index.Fields("createdAt"),
index.Fields("fileType"),
index.Fields("fileMd5"),
}
}