package handler import ( "fmt" "net/http" "net/url" "os" "path/filepath" "strconv" "strings" "time" "bj_power_mes/common/httpx" "bj_power_mes/ent" "bj_power_mes/internal/logic" "bj_power_mes/internal/svc" "github.com/zeromicro/go-zero/rest/pathvar" ) // ---------- 附件(统一存储方案) ---------- // // 落盘:/年/月/日/<文件类型大写枚举>/. // 库内:filePath 只存相对路径;下载/预览按 id 提供,避免中文与多级路径问题。 // attachmentRow 附件返回视图(前端友好:附可直接预览/下载的 URL)。 type attachmentRow struct { ID int `json:"id"` BizType string `json:"bizType"` BizID string `json:"bizId"` FileType string `json:"fileType"` FileName string `json:"fileName"` FilePath string `json:"filePath"` FileSize int `json:"fileSize"` FileExt string `json:"fileExt"` MimeType string `json:"mimeType"` Uploader string `json:"uploader"` Archived bool `json:"archived"` Deleted bool `json:"deleted"` DeletedBy string `json:"deletedBy"` CreatedAt int64 `json:"createdAt"` URL string `json:"url"` PreviewURL string `json:"previewUrl"` } func toAttachmentRow(a *ent.Attachment) *attachmentRow { // 预览走公开直链(文件名不可枚举:UUID + 日期目录),/