refactor: update config structure and data layer for Watermill CQRS

This commit is contained in:
向宁 2026-05-25 20:33:20 +08:00
parent 11315fd00b
commit 1cd46bc6db
2 changed files with 45 additions and 33 deletions

View File

@ -1,21 +1,21 @@
server:
http:
addr: 0.0.0.0:8080
addr: 0.0.0.0:8090
timeout: 30s
grpc:
addr: 0.0.0.0:9000
addr: 0.0.0.0:9090
timeout: 30s
data:
database:
driver: postgres
source: "postgres://postgres:postgres@localhost:5432/file_system?sslmode=disable"
source: "postgres://rag:rag123@localhost:5432/file_system?sslmode=disable"
s3:
endpoint: "http://192.168.1.154:9000"
access_key: "${RUSTFS_ACCESS_KEY_ID}"
secret_key: "${RUSTFS_SECRET_ACCESS_KEY}"
endpoint: "http://localhost:9000"
access_key: "minioadmin"
secret_key: "minioadmin"
region: "us-east-1"
auth:
jwt_key: "RagJwtSecretKey2026MustBeAtLeast32CharsLong!"
grpc_addr: "rag-backend:50051"
grpc_addr: "localhost:50051"

View File

@ -83,44 +83,56 @@ var ProviderSet = wire.NewSet(NewData, NewFileRepo, NewFolderRepo, NewFileMetaRe
// FolderPO maps to the "folders" table.
type FolderPO struct {
ID string `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"`
ParentID *string `gorm:"type:uuid;index:idx_folders_parent"`
Name string `gorm:"type:varchar(255);not null"`
OwnerID string `gorm:"type:varchar(36);not null;index:idx_folders_owner"`
CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"`
ID string `gorm:"primaryKey;type:uuid;default:gen_random_uuid();comment:主键ID"`
ParentID *string `gorm:"type:uuid;index:idx_folders_parent;comment:父文件夹ID"`
Name string `gorm:"type:varchar(255);not null;comment:文件夹名称"`
OwnerID string `gorm:"type:varchar(36);not null;index:idx_folders_owner;comment:所有者ID"`
CreatedBy string `gorm:"type:varchar(36);not null;default:'';comment:创建人ID"`
CreatedAt time.Time `gorm:"autoCreateTime;comment:创建时间"`
UpdatedBy string `gorm:"type:varchar(36);not null;default:'';comment:更新人ID"`
UpdatedAt time.Time `gorm:"autoUpdateTime;comment:更新时间"`
IsDeleted bool `gorm:"not null;default:false;comment:是否软删除"`
OperatorIP string `gorm:"type:varchar(500);comment:操作人IP地址"`
}
func (FolderPO) TableName() string { return "folders" }
// FileMetaPO maps to the "files" table.
type FileMetaPO struct {
ID string `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"`
FolderID string `gorm:"type:uuid;index:idx_files_folder"`
Name string `gorm:"type:varchar(255);not null"`
S3Key string `gorm:"type:varchar(512);not null;index:idx_files_s3_key"`
S3Bucket string `gorm:"type:varchar(255);not null"`
Size int64 `gorm:"default:0"`
ContentType string `gorm:"type:varchar(255);default:'application/octet-stream'"`
OwnerID string `gorm:"type:varchar(36);not null;index:idx_files_owner"`
CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"`
ID string `gorm:"primaryKey;type:uuid;default:gen_random_uuid();comment:主键ID"`
FolderID string `gorm:"type:uuid;index:idx_files_folder;comment:所属文件夹ID"`
Name string `gorm:"type:varchar(255);not null;comment:文件名称"`
S3Key string `gorm:"type:varchar(512);not null;index:idx_files_s3_key;comment:S3对象键"`
S3Bucket string `gorm:"type:varchar(255);not null;comment:S3存储桶名称"`
Size int64 `gorm:"default:0;comment:文件大小(字节)"`
ContentType string `gorm:"type:varchar(255);default:'application/octet-stream';comment:文件MIME类型"`
OwnerID string `gorm:"type:varchar(36);not null;index:idx_files_owner;comment:所有者ID"`
CreatedBy string `gorm:"type:varchar(36);not null;default:'';comment:创建人ID"`
CreatedAt time.Time `gorm:"autoCreateTime;comment:创建时间"`
UpdatedBy string `gorm:"type:varchar(36);not null;default:'';comment:更新人ID"`
UpdatedAt time.Time `gorm:"autoUpdateTime;comment:更新时间"`
IsDeleted bool `gorm:"not null;default:false;comment:是否软删除"`
OperatorIP string `gorm:"type:varchar(500);comment:操作人IP地址"`
}
func (FileMetaPO) TableName() string { return "files" }
// ShareLinkPO maps to the "share_links" table.
type ShareLinkPO struct {
ID string `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"`
ResourceType string `gorm:"type:varchar(10);not null"`
ResourceID string `gorm:"type:uuid;not null"`
Token string `gorm:"type:varchar(32);not null;uniqueIndex:idx_share_token"`
Password *string `gorm:"type:varchar(255)"`
ExpiresAt *time.Time `gorm:"type:timestamptz"`
DownloadCount int `gorm:"default:0"`
MaxDownloads *int
CreatedBy string `gorm:"type:varchar(36);not null"`
CreatedAt time.Time `gorm:"autoCreateTime"`
ID string `gorm:"primaryKey;type:uuid;default:gen_random_uuid();comment:主键ID"`
ResourceType string `gorm:"type:varchar(10);not null;comment:资源类型folder/file"`
ResourceID string `gorm:"type:uuid;not null;comment:资源ID"`
Token string `gorm:"type:varchar(32);not null;uniqueIndex:idx_share_token;comment:分享令牌"`
Password *string `gorm:"type:varchar(255);comment:访问密码"`
ExpiresAt *time.Time `gorm:"type:timestamptz;comment:过期时间"`
DownloadCount int `gorm:"default:0;comment:下载次数"`
MaxDownloads *int `gorm:"comment:最大下载次数"`
CreatedBy string `gorm:"type:varchar(36);not null;comment:创建人ID"`
CreatedAt time.Time `gorm:"autoCreateTime;comment:创建时间"`
UpdatedBy string `gorm:"type:varchar(36);not null;default:'';comment:更新人ID"`
UpdatedAt time.Time `gorm:"autoUpdateTime;comment:更新时间"`
IsDeleted bool `gorm:"not null;default:false;comment:是否软删除"`
OperatorIP string `gorm:"type:varchar(500);comment:操作人IP地址"`
}
func (ShareLinkPO) TableName() string { return "share_links" }