feat(aihr): add owner identity profiles for realtime practice

- remove owner-impatient persona; owner-calm renamed to 业主
- aihr_realtime_owner_profile table (tenant+project unique, enabled,
  version) with formal migration
- admin CRUD under moderator role gate; project code validated against
  org snapshot and project name taken from snapshot authoritatively
- employee endpoint returns display-safe fields plus defaultProfileId
  from the employee's own community; profile body never exposed
- session creation renders {community}/{profile} server-side; client
  text can never enter instructions; invalid profileId rejected,
  default resolution fails closed
- duplicate create returns 409
This commit is contained in:
2026-08-05 03:18:50 +08:00
parent 83fb657b1b
commit d9ff43eae3
12 changed files with 867 additions and 28 deletions
@@ -0,0 +1,24 @@
-- Realtime practice owner identity profiles (content operations data).
-- Additive and idempotent on MySQL 8. Profiles are authored by tenant moderators from the
-- admin console; only enabled=1 rows are visible to employees and eligible for realtime
-- session rendering. The unique key keeps one profile per (tenant, project_code).
CREATE TABLE IF NOT EXISTS `aihr_realtime_owner_profile` (
`id` bigint NOT NULL AUTO_INCREMENT,
`tenant_id` varchar(20) NOT NULL COMMENT '租户ID',
`project_code` varchar(50) NOT NULL COMMENT '项目编码(小区=项目编码,须存在于本租户组织快照)',
`project_name` varchar(100) NOT NULL COMMENT '项目名称冗余显示名,写入时取自组织快照',
`age_range` varchar(50) DEFAULT NULL COMMENT '业主年龄段,如 30-45岁',
`income_level` varchar(50) DEFAULT NULL COMMENT '收入水平描述,如 中等收入',
`family_structure` varchar(100) DEFAULT NULL COMMENT '家庭结构描述,如 三口之家有学龄儿童',
`concerns` varchar(500) DEFAULT NULL COMMENT '核心关注点;只进服务端画像渲染,不下发员工端列表',
`enabled` tinyint NOT NULL DEFAULT 1 COMMENT '内容运营开关;仅 enabled=1 对员工可见并可渲染进会话',
`version` int NOT NULL DEFAULT 0 COMMENT '内容版本,编辑递增',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_aihr_realtime_owner_profile` (`tenant_id`, `project_code`),
KEY `idx_aihr_realtime_owner_profile_enabled` (`tenant_id`, `enabled`, `id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
COMMENT='实时陪练业主身份档案;画像属内容运营数据,enabled=1 才对员工可见';