refactor: 将数据库从MongoDB迁移至PostgreSQL

This commit is contained in:
2026-03-18 13:17:59 +08:00
parent 16723e5b5e
commit 3ed275bd7e
14 changed files with 268 additions and 210 deletions

View File

@@ -1,20 +1,31 @@
package entity
import (
"oss/consts"
"gitea.com/red-future/common/beans"
)
// File 存储文件实体
type File struct {
beans.MongoBaseDO `bson:",inline"` // 嵌入基础字段Id, Creator, CreatedAt, Updater, UpdatedAt, TenantId, IsDeleted
// 基础信息
FileURL string `bson:"fileURL" json:"fileURL"` // 图URL
FileSize int `bson:"fileSize" json:"fileSize"`
beans.SQLBaseDO `orm:",inherit"` // 嵌入基础字段Id, Bid, Creator, CreatedAt, Updater, UpdatedAt, Deleter, DeletedAt, IsDeleted
// 业务字段
Bid string `orm:"bid" json:"bid"`
TenantId uint64 `orm:"tenant_id" json:"tenantId"` // 租户ID
FileURL string `orm:"file_url" json:"fileURL"` // 文件URL
FileSize int `orm:"file_size" json:"fileSize"`
}
// CollectionName 存储集合名称
func (File) CollectionName() string {
return consts.FileCollection
type fileCol struct {
beans.SQLBaseCol
Bid string
TenantId string
FileURL string
FileSize string
}
var FileCol = fileCol{
SQLBaseCol: beans.DefSQLBaseCol,
Bid: "bid",
TenantId: "tenant_id",
FileURL: "file_url",
FileSize: "file_size",
}