|
| 1 | +# Notification Center Implementation Plan |
| 2 | + |
| 3 | +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. |
| 4 | +
|
| 5 | +**Goal:** Build database-managed notification scenes, channel templates, send records, and manual retry APIs in `base-sysadmin`. |
| 6 | + |
| 7 | +**Architecture:** Follow the existing Spring Boot and MyBatis-Plus feature package style. Add focused `po`, `form`, `vo`, `dao`, `service`, and `rest` classes under `notification`, then route sends through database templates and existing SMS/email providers. |
| 8 | + |
| 9 | +**Tech Stack:** Java 17, Spring Boot, MyBatis-Plus, JUnit 5, AssertJ, Mockito, MySQL DDL scripts. |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +### Task 1: Notification Persistence Model |
| 14 | + |
| 15 | +**Files:** |
| 16 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/model/po/NotificationScene.java` |
| 17 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/model/po/NotificationTemplateConfig.java` |
| 18 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/model/po/NotificationRecord.java` |
| 19 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/enums/NotificationSendStatus.java` |
| 20 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/dao/NotificationSceneMapper.java` |
| 21 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/dao/NotificationTemplateMapper.java` |
| 22 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/dao/NotificationRecordMapper.java` |
| 23 | +- Modify: `src/main/resources/db/os-base-sysadmin-ddl.sql` |
| 24 | +- Modify: `src/main/resources/db/os-base-sysadmin-db.sql` |
| 25 | + |
| 26 | +- [ ] Add PO classes with `@TableName`, Lombok builders, and fields matching the DDL. |
| 27 | +- [ ] Add mapper interfaces extending `BaseMapper`. |
| 28 | +- [ ] Add DDL for scene, template, and record tables. |
| 29 | +- [ ] Add seed rows for login captcha SMS/email scene templates. |
| 30 | +- [ ] Run `mvn -DskipTests compile`. |
| 31 | + |
| 32 | +### Task 2: Notification Management Services |
| 33 | + |
| 34 | +**Files:** |
| 35 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/service/INotificationSceneService.java` |
| 36 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/service/INotificationTemplateConfigService.java` |
| 37 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/service/INotificationRecordService.java` |
| 38 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/service/impl/NotificationSceneService.java` |
| 39 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/service/impl/NotificationTemplateConfigService.java` |
| 40 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/service/impl/NotificationRecordService.java` |
| 41 | + |
| 42 | +- [ ] Implement scene CRUD by `sceneCode`, enabled listing, and validation. |
| 43 | +- [ ] Implement template CRUD by id and lookup by `sceneCode + channel`. |
| 44 | +- [ ] Implement record creation, query by id, page query, and retry counter updates. |
| 45 | +- [ ] Run focused service tests. |
| 46 | + |
| 47 | +### Task 3: Runtime Send Flow |
| 48 | + |
| 49 | +**Files:** |
| 50 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/model/form/NotificationSendForm.java` |
| 51 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/model/vo/NotificationSendResponse.java` |
| 52 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/model/vo/NotificationPageData.java` |
| 53 | +- Modify: `src/main/java/io/github/opensabre/sysadmin/notification/service/INotificationService.java` |
| 54 | +- Modify: `src/main/java/io/github/opensabre/sysadmin/notification/service/NotificationServiceManager.java` |
| 55 | +- Modify: `src/main/java/io/github/opensabre/sysadmin/notification/service/impl/SmsNotificationService.java` |
| 56 | +- Modify: `src/main/java/io/github/opensabre/sysadmin/notification/service/impl/EmailNotificationService.java` |
| 57 | + |
| 58 | +- [ ] Add content-based `sendContent(target, title, content)` support to channel services. |
| 59 | +- [ ] Add template rendering with named placeholders `{name}`. |
| 60 | +- [ ] Add send-by-scene logic that selects explicit channel or first enabled template by sort. |
| 61 | +- [ ] Persist success and failure records. |
| 62 | +- [ ] Implement manual retry for failed records. |
| 63 | + |
| 64 | +### Task 4: REST APIs |
| 65 | + |
| 66 | +**Files:** |
| 67 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/rest/NotificationSceneController.java` |
| 68 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/rest/NotificationTemplateController.java` |
| 69 | +- Create: `src/main/java/io/github/opensabre/sysadmin/notification/rest/NotificationRecordController.java` |
| 70 | +- Modify: `src/main/java/io/github/opensabre/sysadmin/notification/rest/NotificationController.java` |
| 71 | + |
| 72 | +- [ ] Add scene CRUD endpoints. |
| 73 | +- [ ] Add template CRUD endpoints. |
| 74 | +- [ ] Add send endpoint using `NotificationSendForm`. |
| 75 | +- [ ] Add record page/detail/retry endpoints. |
| 76 | +- [ ] Keep controller naming consistent with existing modules. |
| 77 | + |
| 78 | +### Task 5: Verification |
| 79 | + |
| 80 | +**Files:** |
| 81 | +- Create: `src/test/java/io/github/opensabre/sysadmin/notification/service/NotificationServiceManagerTest.java` |
| 82 | +- Create: `src/test/java/io/github/opensabre/sysadmin/notification/model/NotificationModelTest.java` |
| 83 | + |
| 84 | +- [ ] Test named placeholder rendering. |
| 85 | +- [ ] Test default template selection by sort. |
| 86 | +- [ ] Test failure record creation when the channel service throws. |
| 87 | +- [ ] Test retry rejects non-failed records. |
| 88 | +- [ ] Run `mvn -Dtest=NotificationServiceManagerTest,NotificationModelTest test`. |
| 89 | +- [ ] Run `mvn clean package -DskipTests`. |
0 commit comments