Version: 0.2.0.dev.260210
feat: 🗑️ 新增删除单个课程与解除安排日程接口 - 逻辑复杂,初版接口写完后才发现需求需要传切片 - 针对需求修改,通过大 for 循环和事务处理来解决问题 🔄 refactor: 🔧 移除部分冗余的用户 ID 验证逻辑 - sv/schedule.go 中,进来的 ID 已通过 redis 黑名单与 JWT 保护验证 - 去除重复的数据库查验,优化了代码流程 🛠️ refactor: 🔄 重构 API 层业务错误判断逻辑 - 抛弃了原有的手动比对方式,封装进 `respond` 包,简化判断流程 - 未来不再手动遍历数据链路,提升了开发效率 🧹 undo: ⚠️ 修复任务块添加到日程的接口问题(待修复) - 接口允许直接修改已经安排的任务时间,且重复执行时未被禁止 - 此逻辑存在问题,计划在下个版本修复 🔧 undo: ⚠️ 重测接口的幂等性与其他特性 - 当前接口幂等性等特性尚未专门测试,后续计划重测所有接口 - 测试不充分,待进一步完善 🔄 undo: ⚠️ 修复刷新 token 接口错误处理问题 - 当前接口将 token 本身的错误以 500 错误返回,需修复此问题 🛠️
This commit is contained in:
@@ -2,7 +2,6 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -41,13 +40,8 @@ func (th *TaskHandler) AddTask(c *gin.Context) {
|
||||
defer cancel() // 记得释放资源
|
||||
resp, err := th.svc.AddTask(ctx, &req, userID)
|
||||
if err != nil {
|
||||
switch {
|
||||
case errors.Is(err, respond.InvalidPriority): //如果是无效刷新令牌或者无效claims或者无效签名方法
|
||||
c.JSON(http.StatusBadRequest, err)
|
||||
return
|
||||
default:
|
||||
c.JSON(http.StatusInternalServerError, respond.InternalError(err))
|
||||
}
|
||||
respond.DealWithError(c, err)
|
||||
return
|
||||
}
|
||||
//3. 返回响应
|
||||
c.JSON(http.StatusOK, respond.RespWithData(respond.Ok, resp))
|
||||
@@ -62,14 +56,8 @@ func (th *TaskHandler) GetUserTasks(c *gin.Context) {
|
||||
defer cancel() // 记得释放资源
|
||||
resp, err := th.svc.GetUserTasks(ctx, userID)
|
||||
if err != nil {
|
||||
switch {
|
||||
case errors.Is(err, respond.UserTasksEmpty): //如果任务列表为空
|
||||
c.JSON(http.StatusOK, respond.RespWithData(respond.UserTasksEmpty, []model.Task{})) //确实没错误,但是任务列表为空,返回自定义响应
|
||||
return
|
||||
default:
|
||||
c.JSON(http.StatusInternalServerError, respond.InternalError(err))
|
||||
return
|
||||
}
|
||||
respond.DealWithError(c, err)
|
||||
return
|
||||
}
|
||||
//3. 返回响应
|
||||
c.JSON(http.StatusOK, respond.RespWithData(respond.Ok, resp))
|
||||
|
||||
Reference in New Issue
Block a user