修复任务更新主键校验与会话查询SQL参数化
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
from study_sessions ss
|
||||
left join tasks t on ss.task_num = t.task_num and ss.session_state != 'ENDED' and ss.deleted = 0
|
||||
where t.deleted = 0
|
||||
and t.task_num = ${task_num}
|
||||
and t.task_num = #{task_num}
|
||||
order by ss.last_modified_time desc, ss.created_time desc
|
||||
limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user