You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

3.6 KiB

status
accepted

dict_item.level 通用档位列 + job_title/contact_source 内置种子(联系人图谱字典前置)

Context

customer-contact-graph effort 票 02(spec §2.6,spec):A4-4-2 客户详情联系人图谱需要「标准职务」字典树(类别 → 职务,档位 10/6/3 作为联系人等级的初始值,spec 拍板 D1/D3)与「联系人来源」字典(四项,W-01 销号)。crm-customer 的 customer_contact 已留位 job_title_id/job_title_category/job_title_level 四列但字典侧无对应数据源。方向约束:crm-dict 是被依赖方(crm-customer → crm-dict 既有依赖方向),且 ADR-0015 种子框架已支持两级树(industry parentId 先例)。

Considered Options

  • A:档位留在 crm-customer 侧硬编码映射(字典只管名称树,档位由代码按职务 code 推导)——映射散落业务代码,产品调档位(如董事长 10→9)要改代码发版;否。
  • B(选中):dict_item 加通用 level 列(int 可空),种子携带档位——档位是字典项元数据,管理员可视化维护;仅 job_title 组实际使用,其他组留空,不另建专表。
  • C:独立 job_title_level 专表——单组数据一张表,过度设计;违背「字典是字段-分组绑定的唯一数据源」既有语言(CONTEXT.md「字段-分组绑定」);否。

Decision

  1. dict_item.level INT(通用列,无组别约束)comment '档位 1–10(仅 job_title 组职务项使用,空=无档)';Entity/DTO 均透出,ItemSeed record 扩第 7 参 level(保留 5/6 参便捷构造,旧种子零改动),upsertItem insert/update 双分支同步。
  2. 种子组 job_title(两级树):一级类别 5 项(executive/purchase/marketing/hr/other),二级职务 9 项带档位:chairman(10)/shareholder(10)/purchase_manager(6)/purchase_specialist(3)/marketing_manager(6)/marketing_specialist(3)/hr_manager(6)/bid_officer(3)/other_job(无档落右侧栏)。二级兜底 code 用 other_job(名「其他职务」)——组内 code 与名称双重唯一性校验(20260909 v3)下不能与一级 other 同名同码。
  3. 种子组 contact_source(扁平 4 项):group_meeting(组会)/group_activity(组局)/referral(转介绍)/other(其他),与 customer_contact.source 列注释口径一致(W-01 销号)。
  4. 零新端点:前端职务树走既有 GET /api/dict/item/tree?groupCode=job_title,来源下拉走 GET /api/dict/item/enabled-list?groupCode=contact_source——level 字段经 DTO 自然透出。
  5. 档位语义边界(spec D1)dict_item.level 只是等级初始值;图谱拖格子定级写的是 customer_contact.level(业务数据),永不回写字典——字典侧对图谱编辑无感知,等级真值双值模型在 crm-customer 域内自洽。

Consequences

  • 内置分组 25→27、内置项 235→253;ref_count 预建行同步 +18(种子框架既有口径,无需额外动作)。
  • H2 测试 Schema 与 DictDataInitializerTest 断言随动(27 组/253 项/职务树结构/chairman=10/other_job 无档)。
  • 无迁移脚本:MySQL 环境 ddl-auto: update 自动加列;老库 job_title 首跑种子即建组。
  • crm-customer 图谱端(票 03/04)按 (group_code=job_title, item_code) 取档位作初始值,level_source 区分字典跟随/手工锁定(spec D2)。
  • 决策来源:customer-contact-graph 票 01 grilling 拍板 D1/D3/D12 + 票 02 执行(other_job 命名系 fail-fast 校验实测驱动的执行拍板)。