Files
workspace/code/fms/sql/fms_files.sql
T
2026-09-14 22:49:48 +08:00

71 lines
4.5 KiB
Transact-SQL
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.
/* ============================================================================
文件表:bf_files(文件记录)/ bf_files_category(文件分类)
----------------------------------------------------------------------------
文件统一由文件服务托管:本地模式由后端写盘后落库,OSS 模式由前端取号直传后
回调落库;业务表不存文件二进制,只通过 father 关联宿主业务主键。
主键为应用层雪花(subid),不使用 identity —— OSS 直传链路由前端先取号。
结构说明见《FMS新系统核心表结构设计.md》第 15 节。
============================================================================ */
/* ----------------------------------------------------------------------------
1. 文件分类(先建,被 bf_files.mx_cate_id 引用)
---------------------------------------------------------------------------- */
drop table if exists dbo.bf_files_category;
GO
create table dbo.bf_files_category (
b_id bigint not null primary key, -- 主键(雪花,新增行由前端 nextIdApi 生成)
b_module_id varchar(50) null, -- 归属模块(s_module.b_id);NULL = 通用分类
b_name nvarchar(50) not null, -- 分类名称
b_i18n varchar(150) null, -- 多语言资源键(s_i18n.b_key)
b_files_type varchar(50) null, -- 允许的扩展名(逗号分隔,空 = 不限;预留)
b_xh int not null default 0, -- 显示顺序
b_canuse tinyint not null default 1, -- 是否启用(0/1)
b_bz nvarchar(200) null, -- 备注
b_created_by varchar(50) null, -- 创建人(用户账号)
b_created_at datetime2 null, -- 创建时间
b_updated_by varchar(50) null, -- 最后修改人
b_updated_at datetime2 null -- 最后修改时间
);
GO
create index ix_bf_files_category_module
on dbo.bf_files_category (b_module_id, b_canuse, b_xh, b_id);
GO
/* ----------------------------------------------------------------------------
2. 文件记录
---------------------------------------------------------------------------- */
drop table if exists dbo.bf_files;
GO
create table dbo.bf_files (
subid bigint not null primary key, -- 文件主键(雪花,应用层取号:本地由后端、OSS 直传由前端先取号)
father bigint null, -- 宿主业务主键(业务表 b_id),列表按它聚合
mx_filename nvarchar(500) null, -- 原始文件名(含扩展名,展示与下载用)
mx_filesize varchar(50) null, -- 文件大小(字节,字符串存储)
mx_fileext varchar(50) null, -- 扩展名(小写、不含点)
mx_mapfilename nvarchar(500) null, -- 访问地址:本地为 {url-prefix}/{org}/{yyyy}/{MM}/{dd}/{uuid}.{ext},OSS 为完整 URL
mx_moduleid varchar(50) null, -- 业务模块编码(s_module.b_id)
mx_cate_id bigint null, -- 文件分类(bf_files_category.b_id)
mx_xh int not null default 0, -- 排序号(保留;当前实现固定 0,列表按 subid 倒序)
mx_sh tinyint not null default 0, -- 审核标识(保留;当前实现固定 0)
mx_shuser_id varchar(50) null, -- 审核人(保留)
mx_shdatetime datetime2 null, -- 审核时间(保留)
mx_cutfilename nvarchar(500) null, -- 缩略图地址(保留)
mx_cutfilesize varchar(50) null, -- 缩略图大小(保留)
mx_orderid varchar(50) null, -- 排序组(保留)
mx_bz nvarchar(500) null, -- 备注(保留)
mx_inputuser_id varchar(50) null, -- 上传人(用户账号)
mx_inputdatetime datetime2 null, -- 上传时间
mx_updateuser_id varchar(50) null, -- 最后修改人
mx_updatedatetime datetime2 null -- 最后修改时间
);
GO
create index ix_bf_files_host
on dbo.bf_files (father, mx_moduleid, mx_cate_id, mx_xh, subid);
GO