c670b9e454
- 确定性领域引擎(分类/评分/分级/红线/费用/裁决)+LLM(通义千问)语言理解 - 6步评估向导、服务端草稿持久化(跨设备/编辑草稿保护) - 工作流(草稿→风控→管理层)、RBAC、报告导出、校准、客户/费率/红线/最低工资管理 - 专业图标体系替换全部emoji、看板美化 - 生产化:API_BASE可配置(同源反代)、auth密钥惰性读取修复RBAC - 444单测+204前端测试+51 e2e
70 lines
2.1 KiB
TypeScript
70 lines
2.1 KiB
TypeScript
/**
|
|
* 行业分区五类必备内容类别(Req 14.1, 14.4)。
|
|
*
|
|
* 合法行业分区须同时具备以下全部五类内容;缺任一类即视为不完备,拒绝创建。
|
|
*/
|
|
|
|
import type { IndustryPartition } from '../domain/knowledge.js';
|
|
|
|
/**
|
|
* 行业分区内容类别标识(面向用户的可读名称,用于校验错误中指明缺失类别)。
|
|
*/
|
|
export type PartitionCategory =
|
|
| 'Indicator'
|
|
| '权重模板'
|
|
| 'Redline'
|
|
| '典型案例'
|
|
| '追问话术';
|
|
|
|
/** 五类必备内容类别的全部取值(顺序对齐 Req 14.1 表述)。 */
|
|
export const PARTITION_CATEGORY_VALUES = [
|
|
'Indicator',
|
|
'权重模板',
|
|
'Redline',
|
|
'典型案例',
|
|
'追问话术',
|
|
] as const satisfies readonly PartitionCategory[];
|
|
|
|
/**
|
|
* 各类别到其在 {@link IndustryPartition} 中承载字段的映射。
|
|
*
|
|
* 校验时据此读取对应集合:集合为空(或缺失)即认定该类别缺失。
|
|
*/
|
|
const CATEGORY_FIELDS: ReadonlyArray<{
|
|
readonly category: PartitionCategory;
|
|
readonly field: keyof IndustryPartition;
|
|
}> = [
|
|
{ category: 'Indicator', field: 'indicators' },
|
|
{ category: '权重模板', field: 'weightTemplates' },
|
|
{ category: 'Redline', field: 'redlines' },
|
|
{ category: '典型案例', field: 'cases' },
|
|
{ category: '追问话术', field: 'askPrompts' },
|
|
];
|
|
|
|
/**
|
|
* 找出某行业分区缺失的内容类别(Req 14.1, 14.4)。
|
|
*
|
|
* 判定规则:对应字段不是数组、或为空数组,即视为该类别缺失。
|
|
*
|
|
* @returns 缺失类别列表(顺序对齐 {@link PARTITION_CATEGORY_VALUES});为空表示五类齐备。
|
|
*/
|
|
export function findMissingCategories(
|
|
partition: IndustryPartition,
|
|
): PartitionCategory[] {
|
|
const missing: PartitionCategory[] = [];
|
|
for (const { category, field } of CATEGORY_FIELDS) {
|
|
const value = partition[field];
|
|
if (!Array.isArray(value) || value.length === 0) {
|
|
missing.push(category);
|
|
}
|
|
}
|
|
return missing;
|
|
}
|
|
|
|
/**
|
|
* 判断某行业分区是否五类内容齐备(不缺任一类)。
|
|
*/
|
|
export function isPartitionComplete(partition: IndustryPartition): boolean {
|
|
return findMissingCategories(partition).length === 0;
|
|
}
|