Skip to content

solo模式修复优化#1

Open
dyhack wants to merge 1 commit intomasterfrom
doubao-code-2.0
Open

solo模式修复优化#1
dyhack wants to merge 1 commit intomasterfrom
doubao-code-2.0

Conversation

@dyhack
Copy link
Owner

@dyhack dyhack commented Mar 6, 2026

No description provided.

@qodo-code-review
Copy link

Review Summary by Qodo

Add notification sending system with scheduled retry mechanism

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add notification sending and retry mechanism with scheduled tasks
• Create new notification record tracking entity and service layer
• Integrate notification creation into doctor appointment workflow
• Update database configuration credentials for local development
Diagram
flowchart LR
  A["Doctor Appointment<br/>YishengyuyueController"] -->|"creates notifications"| B["Notification Entity<br/>JiuzhentongzhiEntity"]
  A -->|"creates send records"| C["Send Record Entity<br/>TongzhifasongEntity"]
  D["Scheduled Task<br/>NotificationScheduleTask"] -->|"retries failed"| E["Service Layer<br/>TongzhifasongService"]
  E -->|"updates status"| C
  F["REST API<br/>TongzhifasongController"] -->|"manages records"| C
Loading

Grey Divider

File Changes

1. server_code/src/main/java/com/cl/SpringbootSchemaApplication.java ✨ Enhancement +2/-0

Enable scheduling annotation for task execution

server_code/src/main/java/com/cl/SpringbootSchemaApplication.java


2. server_code/src/main/java/com/cl/config/NotificationScheduleTask.java ✨ Enhancement +18/-0

New scheduled task for notification retry logic

server_code/src/main/java/com/cl/config/NotificationScheduleTask.java


3. server_code/src/main/java/com/cl/controller/TongzhifasongController.java ✨ Enhancement +134/-0

New REST controller for notification send records

server_code/src/main/java/com/cl/controller/TongzhifasongController.java


View more (11)
4. server_code/src/main/java/com/cl/controller/YishengyuyueController.java ✨ Enhancement +38/-0

Integrate notification creation into appointment workflow

server_code/src/main/java/com/cl/controller/YishengyuyueController.java


5. server_code/src/main/java/com/cl/dao/TongzhifasongDao.java ✨ Enhancement +23/-0

New data access interface for notification records

server_code/src/main/java/com/cl/dao/TongzhifasongDao.java


6. server_code/src/main/java/com/cl/entity/TongzhifasongEntity.java ✨ Enhancement +144/-0

New entity for tracking notification send records

server_code/src/main/java/com/cl/entity/TongzhifasongEntity.java


7. server_code/src/main/java/com/cl/entity/view/TongzhifasongView.java ✨ Enhancement +32/-0

View entity for notification record display

server_code/src/main/java/com/cl/entity/view/TongzhifasongView.java


8. server_code/src/main/java/com/cl/service/TongzhifasongService.java ✨ Enhancement +26/-0

Service interface with retry notification method

server_code/src/main/java/com/cl/service/TongzhifasongService.java


9. server_code/src/main/java/com/cl/service/impl/TongzhifasongServiceImpl.java ✨ Enhancement +89/-0

Service implementation with retry logic and status updates

server_code/src/main/java/com/cl/service/impl/TongzhifasongServiceImpl.java


10. server_code/sql/tongzhifasong_table.sql ⚙️ Configuration changes +21/-0

Database table schema for notification records

server_code/sql/tongzhifasong_table.sql


11. server_code/src/main/resources/application.yml ⚙️ Configuration changes +2/-2

Update database credentials and connection parameters

server_code/src/main/resources/application.yml


12. server_code/src/main/resources/mapper/TongzhifasongDao.xml ✨ Enhancement +32/-0

MyBatis mapper for notification record queries

server_code/src/main/resources/mapper/TongzhifasongDao.xml


13. server_code/target/classes/application.yml ⚙️ Configuration changes +2/-2

Compiled configuration with updated credentials

server_code/target/classes/application.yml


14. server_code/target/classes/mapper/TongzhifasongDao.xml ⚙️ Configuration changes +32/-0

Compiled MyBatis mapper configuration

server_code/target/classes/mapper/TongzhifasongDao.xml


Grey Divider

Qodo Logo

@qodo-code-review
Copy link

qodo-code-review bot commented Mar 6, 2026

Code Review by Qodo

🐞 Bugs (5) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Build产物被提交 🐞 Bug ⛯ Reliability
Description
server_code/target/classes 下的编译产物与资源文件被提交到仓库,会导致资源重复/过期、仓库膨胀,并把运行期配置(含数据库口令)一并固化进 git
历史。应从版本控制中移除并通过 .gitignore 排除。
Code

server_code/target/classes/application.yml[R10-16]

spring:
    datasource:
        driverClassName: com.mysql.cj.jdbc.Driver
-        url: jdbc:mysql://127.0.0.1:3306/cl515882190?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&useSSL=false
+        url: jdbc:mysql://127.0.0.1:3306/cl515882190?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true&useSSL=false
        username: root
-        password: 202911
+        password: 123456
Evidence
target/classes 中存在与源码资源相同的 application.yml 与 mapper
XML,表明构建输出被纳入版本控制;这些文件包含运行配置且会随构建变化,提交后容易产生不一致与泄露风险。

server_code/target/classes/application.yml[1-16]
server_code/target/classes/mapper/TongzhifasongDao.xml[1-28]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`server_code/target/` 下的构建产物被提交到了仓库(含复制后的 `application.yml`、mapper XML、静态资源等)。这会导致资源重复/过期、仓库膨胀,并把运行期配置与口令固化进 git 历史。

## Issue Context
构建产物应由构建流水线生成,不应纳入版本控制;否则容易出现“源码已改但运行仍读取旧 target 资源”的混乱情况。

## Fix Focus Areas
- server_code/target/classes/application.yml[1-53]
- server_code/target/classes/mapper/TongzhifasongDao.xml[1-32]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. 硬编码数据库口令 🐞 Bug ⛨ Security
Description
application.yml 中提交了明文数据库口令(并同步出现在 target/classes 中),属于敏感信息泄露与环境耦合问题。应改为环境变量/外部配置并从仓库与历史中清理。
Code

server_code/src/main/resources/application.yml[R10-16]

spring:
    datasource:
        driverClassName: com.mysql.cj.jdbc.Driver
-        url: jdbc:mysql://127.0.0.1:3306/cl515882190?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&useSSL=false
+        url: jdbc:mysql://127.0.0.1:3306/cl515882190?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true&useSSL=false
        username: root
-        password: 202911
+        password: 123456
Evidence
源码资源与构建输出资源中均包含明文口令,且该文件会随代码分发,任何拿到仓库的人都可获取连接信息。

server_code/src/main/resources/application.yml[10-16]
server_code/target/classes/application.yml[10-16]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`application.yml` 中存在明文数据库口令,并被复制到 `target/classes` 后也提交进仓库,构成凭据泄露。

## Issue Context
Spring Boot 支持通过环境变量或 profile 覆盖配置。口令不应进入代码仓库和构建产物的版本控制。

## Fix Focus Areas
- server_code/src/main/resources/application.yml[10-16]
- server_code/target/classes/application.yml[10-16]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. 重试逻辑为占位实现 🐞 Bug ✓ Correctness
Description
重试发送的 sendNotification() 只是 Thread.sleep(100) 后返回
true,导致“发送失败”的记录在重试时会被无条件标记为“发送成功”,并且每条记录阻塞调度线程,带来错误状态与性能问题。
Code

server_code/src/main/java/com/cl/service/impl/TongzhifasongServiceImpl.java[R52-86]

+	public void retryFailedNotifications() {
+		EntityWrapper<TongzhifasongEntity> wrapper = new EntityWrapper<>();
+		wrapper.eq("fasongzhuangtai", "发送失败");
+		wrapper.lt("chongshicishu", 5);
+		
+		List<TongzhifasongEntity> failedList = this.selectList(wrapper);
+		
+		for (TongzhifasongEntity record : failedList) {
+			try {
+				boolean success = sendNotification(record);
+				if (success) {
+					record.setFasongzhuangtai("发送成功");
+					record.setShibaiyuanyin(null);
+				} else {
+					record.setChongshicishu(record.getChongshicishu() + 1);
+					record.setChongshishijian(new Date());
+				}
+				this.updateById(record);
+			} catch (Exception e) {
+				record.setChongshicishu(record.getChongshicishu() + 1);
+				record.setChongshishijian(new Date());
+				record.setShibaiyuanyin(e.getMessage());
+				this.updateById(record);
+			}
+		}
+	}
+	
+	private boolean sendNotification(TongzhifasongEntity record) {
+		try {
+			Thread.sleep(100);
+			return true;
+		} catch (Exception e) {
+			return false;
+		}
+	}
Evidence
retryFailedNotifications 选择 fasongzhuangtai=发送失败 的记录后,调用 sendNotification;而 sendNotification 永远返回
true(除非 sleep 抛异常),从而把失败记录改成成功且没有真实发送实现,同时循环 sleep 会导致处理时间与失败条数线性增长。

server_code/src/main/java/com/cl/service/impl/TongzhifasongServiceImpl.java[52-76]
server_code/src/main/java/com/cl/service/impl/TongzhifasongServiceImpl.java[79-86]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
当前 `sendNotification()` 为占位实现:sleep 后直接返回 true,导致重试会把失败记录错误标记为成功,并且每条记录阻塞调度线程。

## Issue Context
`retryFailedNotifications()` 会查询 `fasongzhuangtai=&quot;发送失败&quot;` 且 `chongshicishu &lt; 5` 的记录进行重试。若发送逻辑不真实或总是返回成功,将直接破坏发送状态的可信度。

## Fix Focus Areas
- server_code/src/main/java/com/cl/service/impl/TongzhifasongServiceImpl.java[52-86]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (2)
4. 预约写入缺少事务且状态不一致 🐞 Bug ⛯ Reliability
Description
医生预约保存后再创建就诊通知与发送记录,但 save/add 未加事务,任一 insert
失败会导致预约/通知/发送记录部分成功的脏数据;同时发送记录创建时直接写“发送成功”,与重试逻辑(只处理“发送失败”)不一致,导致重试机制对这些记录永远无效。
Code

server_code/src/main/java/com/cl/controller/YishengyuyueController.java[R157-163]

    public R save(@RequestBody YishengyuyueEntity yishengyuyue, HttpServletRequest request){
    	//ValidatorUtils.validateEntity(yishengyuyue);
        yishengyuyueService.insert(yishengyuyue);
+        createNotifications(yishengyuyue);
        return R.ok();
    }
    
Evidence
save/add 在插入预约后调用 createNotifications 进行两次 insert(jiuzhentongzhi 与 tongzhifasong),但方法本身没有
@Transactional;且 tongzhifasong 记录在创建时就被标记为“发送成功”,而重试逻辑只扫描“发送失败”。

server_code/src/main/java/com/cl/controller/YishengyuyueController.java[155-173]
server_code/src/main/java/com/cl/controller/YishengyuyueController.java[176-201]
server_code/src/main/java/com/cl/service/impl/TongzhifasongServiceImpl.java[53-56]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
预约创建后写入通知与发送记录没有事务,且发送记录初始状态被设置为“发送成功”,与后续重试逻辑筛选“发送失败”相冲突。

## Issue Context
`save/add` 先 `yishengyuyueService.insert` 再执行 `createNotifications()` 的多次 insert。任何一步失败都会产生部分写入。

## Fix Focus Areas
- server_code/src/main/java/com/cl/controller/YishengyuyueController.java[155-202]
- server_code/src/main/java/com/cl/service/impl/TongzhifasongServiceImpl.java[52-56]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. 发送记录缺少数据隔离 🐞 Bug ⛨ Security
Description
TongzhifasongController 的 /page 读取 session 的 tableName 但未按角色/用户过滤数据,导致任意登录用户都可查询全部发送记录(含手机号等)。同时提供
/retry 触发重试但未做角色限制,存在越权触发后台任务风险。
Code

server_code/src/main/java/com/cl/controller/TongzhifasongController.java[R44-52]

+    @RequestMapping("/page")
+    public R page(@RequestParam Map<String, Object> params,TongzhifasongEntity tongzhifasong,
+                                                                            HttpServletRequest request){
+                    String tableName = request.getSession().getAttribute("tableName").toString();
+                                                                                                                        EntityWrapper<TongzhifasongEntity> ew = new EntityWrapper<TongzhifasongEntity>();
+        
+        PageUtils page = tongzhifasongService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, tongzhifasong), params), params));
+        return R.ok().put("data", page);
+    }
Evidence
同项目的 JiuzhentongzhiController 在 /page 会基于 tableName 将查询条件限制在当前用户;但 TongzhifasongController
未设置任何等值过滤。TongzhifasongEntity 含 shouji(手机) 字段,属于敏感信息。/retry 端点直接调用重试服务且未校验角色。

server_code/src/main/java/com/cl/controller/TongzhifasongController.java[44-52]
server_code/src/main/java/com/cl/controller/JiuzhentongzhiController.java[62-72]
server_code/src/main/java/com/cl/entity/TongzhifasongEntity.java[44-57]
server_code/src/main/java/com/cl/controller/TongzhifasongController.java[126-131]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Tongzhifasong 的查询与重试触发接口缺少按用户/角色的数据隔离与权限限制,可能导致 PII 泄露与越权触发重试任务。

## Issue Context
同项目中部分资源(如 `JiuzhentongzhiController.page`)会基于 session 的 `tableName/username` 进行过滤,但 `TongzhifasongController.page` 未做任何过滤。

## Fix Focus Areas
- server_code/src/main/java/com/cl/controller/TongzhifasongController.java[44-52]
- server_code/src/main/java/com/cl/controller/TongzhifasongController.java[126-131]
- server_code/src/main/java/com/cl/controller/JiuzhentongzhiController.java[62-72]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Comment on lines 10 to 16
spring:
datasource:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/cl515882190?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&useSSL=false
url: jdbc:mysql://127.0.0.1:3306/cl515882190?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true&useSSL=false
username: root
password: 202911
password: 123456

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Build产物被提交 🐞 Bug ⛯ Reliability

server_code/target/classes 下的编译产物与资源文件被提交到仓库,会导致资源重复/过期、仓库膨胀,并把运行期配置(含数据库口令)一并固化进 git
历史。应从版本控制中移除并通过 .gitignore 排除。
Agent Prompt
## Issue description
`server_code/target/` 下的构建产物被提交到了仓库(含复制后的 `application.yml`、mapper XML、静态资源等)。这会导致资源重复/过期、仓库膨胀,并把运行期配置与口令固化进 git 历史。

## Issue Context
构建产物应由构建流水线生成,不应纳入版本控制;否则容易出现“源码已改但运行仍读取旧 target 资源”的混乱情况。

## Fix Focus Areas
- server_code/target/classes/application.yml[1-53]
- server_code/target/classes/mapper/TongzhifasongDao.xml[1-32]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines 10 to 16
spring:
datasource:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/cl515882190?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&useSSL=false
url: jdbc:mysql://127.0.0.1:3306/cl515882190?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true&useSSL=false
username: root
password: 202911
password: 123456

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. 硬编码数据库口令 🐞 Bug ⛨ Security

application.yml 中提交了明文数据库口令(并同步出现在 target/classes 中),属于敏感信息泄露与环境耦合问题。应改为环境变量/外部配置并从仓库与历史中清理。
Agent Prompt
## Issue description
`application.yml` 中存在明文数据库口令,并被复制到 `target/classes` 后也提交进仓库,构成凭据泄露。

## Issue Context
Spring Boot 支持通过环境变量或 profile 覆盖配置。口令不应进入代码仓库和构建产物的版本控制。

## Fix Focus Areas
- server_code/src/main/resources/application.yml[10-16]
- server_code/target/classes/application.yml[10-16]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +52 to +86
public void retryFailedNotifications() {
EntityWrapper<TongzhifasongEntity> wrapper = new EntityWrapper<>();
wrapper.eq("fasongzhuangtai", "发送失败");
wrapper.lt("chongshicishu", 5);

List<TongzhifasongEntity> failedList = this.selectList(wrapper);

for (TongzhifasongEntity record : failedList) {
try {
boolean success = sendNotification(record);
if (success) {
record.setFasongzhuangtai("发送成功");
record.setShibaiyuanyin(null);
} else {
record.setChongshicishu(record.getChongshicishu() + 1);
record.setChongshishijian(new Date());
}
this.updateById(record);
} catch (Exception e) {
record.setChongshicishu(record.getChongshicishu() + 1);
record.setChongshishijian(new Date());
record.setShibaiyuanyin(e.getMessage());
this.updateById(record);
}
}
}

private boolean sendNotification(TongzhifasongEntity record) {
try {
Thread.sleep(100);
return true;
} catch (Exception e) {
return false;
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

3. 重试逻辑为占位实现 🐞 Bug ✓ Correctness

重试发送的 sendNotification() 只是 Thread.sleep(100) 后返回
true,导致“发送失败”的记录在重试时会被无条件标记为“发送成功”,并且每条记录阻塞调度线程,带来错误状态与性能问题。
Agent Prompt
## Issue description
当前 `sendNotification()` 为占位实现:sleep 后直接返回 true,导致重试会把失败记录错误标记为成功,并且每条记录阻塞调度线程。

## Issue Context
`retryFailedNotifications()` 会查询 `fasongzhuangtai="发送失败"` 且 `chongshicishu < 5` 的记录进行重试。若发送逻辑不真实或总是返回成功,将直接破坏发送状态的可信度。

## Fix Focus Areas
- server_code/src/main/java/com/cl/service/impl/TongzhifasongServiceImpl.java[52-86]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines 157 to 163
public R save(@RequestBody YishengyuyueEntity yishengyuyue, HttpServletRequest request){
//ValidatorUtils.validateEntity(yishengyuyue);
yishengyuyueService.insert(yishengyuyue);
createNotifications(yishengyuyue);
return R.ok();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

4. 预约写入缺少事务且状态不一致 🐞 Bug ⛯ Reliability

医生预约保存后再创建就诊通知与发送记录,但 save/add 未加事务,任一 insert
失败会导致预约/通知/发送记录部分成功的脏数据;同时发送记录创建时直接写“发送成功”,与重试逻辑(只处理“发送失败”)不一致,导致重试机制对这些记录永远无效。
Agent Prompt
## Issue description
预约创建后写入通知与发送记录没有事务,且发送记录初始状态被设置为“发送成功”,与后续重试逻辑筛选“发送失败”相冲突。

## Issue Context
`save/add` 先 `yishengyuyueService.insert` 再执行 `createNotifications()` 的多次 insert。任何一步失败都会产生部分写入。

## Fix Focus Areas
- server_code/src/main/java/com/cl/controller/YishengyuyueController.java[155-202]
- server_code/src/main/java/com/cl/service/impl/TongzhifasongServiceImpl.java[52-56]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +44 to +52
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,TongzhifasongEntity tongzhifasong,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
EntityWrapper<TongzhifasongEntity> ew = new EntityWrapper<TongzhifasongEntity>();

PageUtils page = tongzhifasongService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, tongzhifasong), params), params));
return R.ok().put("data", page);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

5. 发送记录缺少数据隔离 🐞 Bug ⛨ Security

TongzhifasongController 的 /page 读取 session 的 tableName 但未按角色/用户过滤数据,导致任意登录用户都可查询全部发送记录(含手机号等)。同时提供
/retry 触发重试但未做角色限制,存在越权触发后台任务风险。
Agent Prompt
## Issue description
Tongzhifasong 的查询与重试触发接口缺少按用户/角色的数据隔离与权限限制,可能导致 PII 泄露与越权触发重试任务。

## Issue Context
同项目中部分资源(如 `JiuzhentongzhiController.page`)会基于 session 的 `tableName/username` 进行过滤,但 `TongzhifasongController.page` 未做任何过滤。

## Fix Focus Areas
- server_code/src/main/java/com/cl/controller/TongzhifasongController.java[44-52]
- server_code/src/main/java/com/cl/controller/TongzhifasongController.java[126-131]
- server_code/src/main/java/com/cl/controller/JiuzhentongzhiController.java[62-72]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant