diff --git a/prisma/migrations/20261014150000_c0_rename_ltc/migration.sql b/prisma/migrations/20261014150000_c0_rename_ltc/migration.sql new file mode 100644 index 0000000..ae9d29c --- /dev/null +++ b/prisma/migrations/20261014150000_c0_rename_ltc/migration.sql @@ -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`; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 55d2719..1ccd272 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -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") } diff --git a/src/common/tenant-template.ts b/src/common/tenant-template.ts index 5498cfe..7f0965a 100644 --- a/src/common/tenant-template.ts +++ b/src/common/tenant-template.ts @@ -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 { diff --git a/src/prisma/prisma.service.ts b/src/prisma/prisma.service.ts index bed4316..f0f0237 100644 --- a/src/prisma/prisma.service.ts +++ b/src/prisma/prisma.service.ts @@ -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']);