修复任务更新主键校验与会话查询SQL参数化

This commit is contained in:
2026-04-12 13:06:11 +08:00
parent c696397d83
commit 43747f785c
2 changed files with 14 additions and 3 deletions
@@ -71,7 +71,17 @@ public class TasksServiceImpl extends ServiceImpl<TasksMapper, TaskEntity>
@Override
public void updateTask(String taskId, TaskRequest updatedTask) {
TaskEntity taskEntity = TaskConvert.MAPPER.taskRequestToTaskEntity(updatedTask);
this.updateById(taskEntity);
int id;
try {
id = Integer.parseInt(taskId);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("任务ID格式错误: " + taskId);
}
taskEntity.setId(id);
boolean updated = this.updateById(taskEntity);
if (!updated) {
throw new IllegalArgumentException("任务不存在或更新失败: " + taskId);
}
}
@@ -86,4 +96,3 @@ public class TasksServiceImpl extends ServiceImpl<TasksMapper, TaskEntity>