zhangying před 2 týdny
rodič
revize
2ecd82e44e
1 změnil soubory, kde provedl 85 přidání a 150 odebrání
  1. 85 150
      .docs/260624-消息与待办模块设计开发文档.md

+ 85 - 150
.docs/260624-消息与待办模块设计开发文档.md

@@ -2,10 +2,8 @@
 
 ## 一、概述
 
-本文档记录了消息通知模块和待办模块的数据库设计、后端接口与实现,以及其他业务模块(面试、录用)对这两个模块的调用示例。
-
-- **消息通知模块**:为系统提供统一的消息发送能力,支持给企业/人员发送通知消息,记录接收人关联并更新最后通知时间。
-- **待办模块**:为系统提供待办事项的创建与查询能力,支持给企业/人员生成待办,前端可通过目标页面路径进行跳转。
+- **消息通知模块**:统一的消息发送能力,支持给企业/人员发送通知消息,记录接收人关联。
+- **待办模块**:统一的待办创建与查询能力,支持给企业/人员生成待办,前端可通过目标页面路径进行跳转。
 
 ---
 
@@ -89,180 +87,117 @@ ALTER TABLE todo_target ADD STATUS VARCHAR(20) DEFAULT '0';
 COMMENT ON COLUMN todo_target.STATUS IS '状态: 0待处理 1已完成 2已取消';
 ```
 
-### 2.3 表结构对比
-
-| 特性 | notification_record | todo_record |
-|------|-------------------|-------------|
-| 主信息 | 主题、内容、发送人 | 标题、内容、发起人 |
-| 时间 | 推送时间、过期时间 | 创建时间、完成时间、过期时间 |
-| 主表状态 | 0未读/1已读 | 0待处理/1已完成/2已取消 |
-| 跳转字段 | 无 | TARGET_PAGE、DATA_ID、PATH_PARAMS |
-| 接收人关联表 | notification_target | todo_target |
-| 关联表状态 | 0未读/1已读 | 0待处理/1已完成/2已取消 |
-
-> 注:两个模块的接收人关联表均通过 ALTER 方式后增了 STATUS 字段,用于独立记录每个接收人的处理状态(消息为已读/未读,待办为处理进度)。
-
 ---
 
-## 三、后端模块设计
-
-### 3.1 消息通知模块
-
-**包路径**:`org.jeecg.modules.zjrs.notification`
-
-**实体映射**:
-
-| 表 | 实体 | 说明 |
-|----|------|------|
-| notification_record | NotificationRecord.java | 主实体,含 expireTime、status |
-| notification_target | NotificationTarget.java | 关联实体,含 status |
-
-**文件变更**:
-
-| 文件 | 操作 | 说明 |
-|------|------|------|
-| `entity/NotificationRecord.java` | 修改 | 新增 `expireTime`、`status` 字段 |
-| `entity/NotificationTarget.java` | 修改 | 新增 `status` 字段 |
-| `service/INotificationRecordService.java` | 修改 | 新增 `sendMessage()` 方法 |
-| `service/impl/NotificationRecordServiceImpl.java` | 修改 | 实现 `sendMessage()`,含事务写主表、关联表、更新状态表 |
+## 三、消息通知模块使用说明
 
-**`sendMessage()` 方法说明**:
+### 3.1 引入 Service
 
+```java
+@Autowired
+private INotificationRecordService notificationRecordService;
 ```
-入参:
-  - moduleType : 来源模块(如 "interview", "offer")
-  - subject    : 消息主题
-  - content    : 消息内容
-  - senderId   : 推送人用户ID
-  - sender     : 推送人姓名
-  - expireTime : 过期时间(可为null)
-  - targets    : 接收人列表(List<NotificationTarget>)
-
-执行流程:
-  1. 构建消息主记录,STATUS 默认 "0"(未读)
-  2. 保存主记录
-  3. 遍历接收人,逐条写入 notification_target
-  4. 根据 targetType 更新 enterprise_status_local 或 personal_status_local 的 last_notice_time
-```
-
-### 3.2 待办模块
-
-**包路径**:`org.jeecg.modules.zjrs.todo`
-
-**实体映射**:
 
-| 表 | 实体 | 说明 |
-|----|------|------|
-| todo_record | TodoRecord.java | 主实体,含 status、completeTime、expireTime 及跳转字段 |
-| todo_target | TodoTarget.java | 关联实体,含 status |
+### 3.2 方法签名
 
-**文件变更**:
-
-| 文件 | 操作 | 说明 |
-|------|------|------|
-| `entity/TodoRecord.java` | 新建 | 待办主表实体,包含跳转字段 |
-| `entity/TodoTarget.java` | 新建 | 待办接收人关联实体,含 status |
-| `mapper/TodoRecordMapper.java` | 新建 | MyBatis Plus Mapper |
-| `mapper/TodoTargetMapper.java` | 新建 | MyBatis Plus Mapper |
-| `mapper/xml/TodoRecordMapper.xml` | 新建 | Mapper XML(空) |
-| `service/ITodoRecordService.java` | 新建 | 接口包含 `createTodo()`、`queryMyList()` |
-| `service/impl/TodoRecordServiceImpl.java` | 新建 | 实现,含事务写主表和关联表 |
-| `controller/TodoController.java` | 新建 | `GET /todo/myList` 分页查询当前用户待办 |
-
-**`createTodo()` 方法说明**:
-
-```
-入参:
-  - moduleType : 来源模块
-  - subject    : 待办标题
-  - content    : 待办内容
-  - creatorId  : 发起人用户ID
-  - creator    : 发起人姓名
-  - targetPage : 前端路由路径(如 "pages/personal/my-jobs/index")
-  - dataId     : 关联的业务数据主键ID
-  - pathParams : 路径参数(如 "fromTab=2")
-  - targets    : 接收人列表
-
-执行流程:
-  1. 构建待办主记录,STATUS 默认 "0"(待处理)
-  2. 保存主记录
-  3. 遍历接收人,逐条写入 todo_target
+```java
+NotificationRecord sendMessage(
+    String moduleType,      // 来源模块(如 "interview", "offer")
+    String subject,         // 消息主题
+    String content,         // 消息内容
+    String senderId,        // 推送人用户ID(系统发起可传空字符串)
+    String sender,          // 推送人姓名
+    Date expireTime,        // 过期时间(不传则传 null)
+    List<NotificationTarget> targets   // 接收人列表
+);
 ```
 
-**`queryMyList()` 方法说明**:
+### 3.3 调用示例
 
-```
-入参:
-  - targetId   : 用户ID
-  - targetType : 用户类型(personal/enterprise)
-  - keyword    : 关键字(模糊匹配标题)
-  - moduleType : 来源模块过滤
-  - status     : 状态过滤
-  - pageNo     : 页码
-  - pageSize   : 每页条数
-
-执行流程:
-  1. 从 todo_target 查出当前用户的所有待办ID
-  2. 根据 ID 列表分页查询 todo_record,支持 keyword/moduleType/status 过滤
-  3. 遍历结果,填充每条的 targets 列表及目标名称
+```java
+// 构建接收人
+NotificationTarget target = new NotificationTarget();
+target.setTargetType("enterprise");       // personal / enterprise
+target.setTargetId(enterprise.getId());
+
+// 计算过期时间:当前时间 + 1天
+Calendar cal = Calendar.getInstance();
+cal.add(Calendar.DAY_OF_MONTH, 1);
+Date expireTime = cal.getTime();
+
+// 发送通知
+notificationRecordService.sendMessage(
+    "interview",                              // moduleType
+    "面试反馈通知",                           // subject
+    String.format("求职者【%s】已确认参加面试【%s】",
+        personalName, postName),              // content
+    "",                                       // senderId(系统发起)
+    personalName,                             // sender
+    expireTime,                               // expireTime
+    Collections.singletonList(target)         // targets
+);
 ```
 
 ---
 
-## 四、业务模块调用示例
+## 四、待办模块使用说明
 
-### 4.1 面试模块
+### 4.1 引入 Service
 
-**文件变更**:
-
-| 文件 | 操作 | 说明 |
-|------|------|------|
-| `interview/service/IInterviewRecordService.java` | 修改 | 新增 attendInterview、notAttendInterview、passInterview、failInterview、offerJob 方法 |
-| `interview/service/impl/InterviewRecordServiceImpl.java` | 修改 | 实现上述方法,调用 sendMessage 和 createTodo |
-| `interview/controller/InterviewRecordController.java` | 修改 | 4个接口改为委托 service |
+```java
+@Autowired
+private ITodoRecordService todoRecordService;
+```
 
-**调用链路**:
+### 4.2 方法签名
 
-| 接口 | 触发 | 行为 |
-|------|------|------|
-| `PUT /interviewRecord/attend` | 求职者确认参加 | 状态改"参加" → 通知企业「求职者已确认参加面试」 |
-| `PUT /interviewRecord/notAttend` | 求职者不参加 | 状态改"不参加" → 通知企业「求职者已不参加面试」 |
-| `PUT /interviewRecord/pass` | 企业面试通过 | 状态改"通过" → 通知求职者「面试已通过」 |
-| `PUT /interviewRecord/fail` | 企业面试不通过 | 状态改"不通过" → 通知求职者「面试未通过」 |
-| `POST /interviewRecord/offer` | 企业发起录用 | 创建录用记录 → 生成待办「录用通知」给求职者 |
+```java
+TodoRecord createTodo(
+    String moduleType,      // 来源模块(如 "offer")
+    String subject,         // 待办标题
+    String content,         // 待办内容
+    String creatorId,       // 发起人用户ID(系统发起可传空字符串)
+    String creator,         // 发起人姓名
+    String targetPage,      // 前端路由路径
+    String dataId,          // 关联的业务数据主键ID
+    String pathParams,      // 路径参数
+    List<TodoTarget> targets                 // 接收人列表
+);
+```
 
-**待办配置(发起录用时)**:
+### 4.3 调用示例
 
 ```java
+// 构建接收人
+TodoTarget target = new TodoTarget();
+target.setTargetType("personal");       // personal / enterprise
+target.setTargetId(personal.getId());
+
+// 生成待办
 todoRecordService.createTodo(
     "offer",                              // moduleType
     "录用通知",                           // subject
-    "您已被【XX公司】的【Java开发】岗位录用...",  // content
+    String.format("您已被【%s】的【%s】岗位录用,请前往查看并确认签约",
+        enterpriseName, postName),        // content
     "",                                   // creatorId(系统发起)
-    record.getEnterpriseName(),           // creator
+    enterpriseName,                       // creator
     "pages/personal/my-jobs/index",       // targetPage
-    employmentOffer.getId(),              // dataId
+    offerId,                              // dataId
     "fromTab=2",                          // pathParams
-    Collections.singletonList(target)     // 接收人:求职者
+    Collections.singletonList(target)     // targets
 );
 ```
 
-### 4.2 录用模块
-
-**文件变更**:
+### 4.4 接收人列表(批量发送)
 
-| 文件 | 操作 | 说明 |
-|------|------|------|
-| `offer/service/IEmploymentOfferService.java` | 修改 | 新增 confirmOffer、rejectOffer 方法 |
-| `offer/service/impl/EmploymentOfferServiceImpl.java` | 修改 | 实现,调用 sendMessage |
-| `offer/controller/EmploymentOfferController.java` | 修改 | 2个接口改为委托 service |
+两个模块都支持批量发送,`targets` 参数可以传入多个接收人:
 
-**调用链路**:
-
-| 接口 | 触发 | 行为 |
-|------|------|------|
-| `PUT /employmentOffer/confirm` | 求职者确认签约 | 状态改"已签约" → 通知企业「求职者已确认签约」 |
-| `PUT /employmentOffer/reject` | 求职者拒绝录用 | 状态改"已拒绝" → 通知企业「求职者已拒绝录用」 |
+```java
+List<TodoTarget> targets = Arrays.asList(
+    new TodoTarget().setTargetType("personal").setTargetId(id1),
+    new TodoTarget().setTargetType("enterprise").setTargetId(id2)
+);
+```
 
 ---
 
@@ -270,14 +205,14 @@ todoRecordService.createTodo(
 
 | 场景 | 过期时间计算 |
 |------|-------------|
-| 面试通知(求职者反馈) | 面试时间 + 1天 |
-| 面试结果通知 | 面试时间 + 1天 |
-| 录用反馈通知 | 无过期(null) |
+| 面试通知(求职者反馈给企业) | 面试时间 + 1天 |
+| 面试结果通知(企业回传给求职者) | 面试时间 + 1天 |
 | 录用待办 | 无过期(null) |
+| 录用反馈通知 | 无过期(null) |
 
 ---
 
-## 六、模块分类(moduleType)
+## 六、moduleType 取值约定
 
 | moduleType 值 | 说明 |
 |--------------|------|