refactor(c0): 业务表去 sys_ 前缀改业务领域命名,字典复用脚手架

- ltc_agency/ltc_staff;svc_national/svc_local/svc_mapping/svc_org;loc_config
- 删 sys_dict_abnormal_type/sys_dict_photo_tier,异常分类/拍照分档改为内置字典(abnormal_type/photo_tier)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
liuyun 2026-10-14 14:44:58 +08:00
parent aa95586a55
commit 239dec912c
4 changed files with 36 additions and 28 deletions

View File

@ -0,0 +1,12 @@
-- 业务表重命名:去 sys_ 前缀,恢复业务领域语义命名
ALTER TABLE `sys_agency` RENAME TO `ltc_agency`;
ALTER TABLE `sys_staff` RENAME TO `ltc_staff`;
ALTER TABLE `sys_svc_national` RENAME TO `svc_national`;
ALTER TABLE `sys_svc_local` RENAME TO `svc_local`;
ALTER TABLE `sys_svc_mapping` RENAME TO `svc_mapping`;
ALTER TABLE `sys_svc_org` RENAME TO `svc_org`;
ALTER TABLE `sys_loc_config` RENAME TO `loc_config`;
-- 业务字典改用脚手架 sys_dict_type / sys_dict_item(异常分类、拍照分档作为内置字典 seed)
DROP TABLE IF EXISTS `sys_dict_abnormal_type`;
DROP TABLE IF EXISTS `sys_dict_photo_tier`;

View File

@ -319,7 +319,7 @@ model Agency {
updatedAt DateTime @updatedAt @map("updated_at")
deletedAt DateTime? @map("deleted_at")
@@map("sys_agency")
@@map("ltc_agency")
}
/// 人员(护理员/医护/组长,账号在 User,staff.user_id 关联 user.id)
@ -349,7 +349,7 @@ model Staff {
deletedAt DateTime? @map("deleted_at")
@@index([tenantCode, name])
@@map("sys_staff")
@@map("ltc_staff")
}
/// 国家基准库 L1(全局,36 项)
@ -364,7 +364,7 @@ model SvcNational {
isMedical Boolean @default(false) @map("is_medical")
version Int @default(1)
@@map("sys_svc_national")
@@map("svc_national")
}
/// 属地目录 L2(全局,昆明 45 项 / 州市引用 L1)
@ -381,7 +381,7 @@ model SvcLocal {
mapStatus String @default("mapped") @map("map_status") @db.VarChar(20)
@@index([locCode])
@@map("sys_svc_local")
@@map("svc_local")
}
/// 属地↔国家映射 L3(全局,机构不可见)
@ -394,7 +394,7 @@ model SvcMapping {
status String @default("confirmed") @db.VarChar(20)
@@index([locId])
@@map("sys_svc_mapping")
@@map("svc_mapping")
}
/// 机构项目库 L4(租户级:机构勾选+配价)
@ -413,27 +413,7 @@ model SvcOrg {
deletedAt DateTime? @map("deleted_at")
@@index([tenantCode, srcType])
@@map("sys_svc_org")
}
/// 异常分类字典(全局)
model DictAbnormalType {
id String @id @default(uuid(7)) @db.VarChar(36)
code String @unique @db.VarChar(50)
name String @db.VarChar(50)
sort Int @default(0)
@@map("sys_dict_abnormal_type")
}
/// 拍照分档字典(全局)
model DictPhotoTier {
id String @id @default(uuid(7)) @db.VarChar(36)
code String @unique @db.VarChar(20)
name String @db.VarChar(50)
tier String @db.VarChar(10)
@@map("sys_dict_photo_tier")
@@map("svc_org")
}
/// 统筹区配置(全局)
@ -443,5 +423,5 @@ model LocConfig {
svcSource String @map("svc_source") @db.VarChar(10)
itemCountRule String? @map("item_count_rule") @db.VarChar(100)
@@map("sys_loc_config")
@@map("loc_config")
}

View File

@ -162,6 +162,22 @@ export const DICTS: { code: string; name: string; items: { label: string; value:
{ label: '成功', value: 'success', colorType: 'success', sort: 1 },
{ label: '失败', value: 'fail', colorType: 'danger', sort: 2 },
] },
{ code: 'abnormal_type', name: '异常分类', items: [
{ label: '压疮', value: 'pressure_sore', colorType: 'danger', sort: 1 },
{ label: '呛咳', value: 'choking', colorType: 'danger', sort: 2 },
{ label: '跌倒', value: 'fall', colorType: 'danger', sort: 3 },
{ label: '发热', value: 'fever', colorType: 'warning', sort: 4 },
{ label: '皮肤破损', value: 'skin_break', colorType: 'warning', sort: 5 },
{ label: '情绪异常', value: 'mood_abnormal', colorType: 'warning', sort: 6 },
{ label: '进食困难', value: 'eat_difficulty', colorType: 'warning', sort: 7 },
{ label: '排泄异常', value: 'excretion_abnormal', colorType: 'info', sort: 8 },
{ label: '其他', value: 'other', colorType: 'info', sort: 9 },
] },
{ code: 'photo_tier', name: '拍照分档', items: [
{ label: '必拍', value: 'must', colorType: 'danger', sort: 1 },
{ label: '可拍', value: 'optional', colorType: 'warning', sort: 2 },
{ label: '免拍', value: 'free', colorType: 'success', sort: 3 },
] },
];
export interface InitTenantOptions {

View File

@ -3,7 +3,7 @@ import { PrismaClient } from '@prisma/client';
import { getRequestContext } from '../common/context/request-context.js';
/** 不带 tenantCode 的模型(租户表自身)。 */
const TENANT_FREE = new Set(['Tenant', 'Agency', 'SvcNational', 'SvcLocal', 'SvcMapping', 'DictAbnormalType', 'DictPhotoTier', 'LocConfig']);
const TENANT_FREE = new Set(['Tenant', 'Agency', 'SvcNational', 'SvcLocal', 'SvcMapping', 'LocConfig']);
/** 软删模型:读操作统一注入 deletedAt IS NULL。 */
const SOFT_DELETE = new Set(['User', 'Role', 'Resource', 'Org', 'DictType', 'DictItem', 'Config', 'Notice', 'Staff', 'SvcOrg']);
const READ_OPS = new Set(['findMany', 'findFirst', 'findUnique', 'count', 'aggregate', 'groupBy']);