Version: 0.1.2.dev.260207
feat: ⚠️ 批量导入课程接口支持冲突预检测与冲突提示 - 批量导入课程接口支持预先检测冲突 - 返回并展示具体发生冲突的课程信息 📚💥 - 补全此前规划的冲突提示功能(把大饼补上了 🍞) refactor: 🧱 使用工作单元模式管理 dao 层事务 - 引入工作单元模式(Unit of Work)统一管理 dao 层 - 新建全局事务,使跨 repo 的 gorm 事务管理更加方便 🔁 fix: 🐛 修复将任务块添加进日程接口的多个问题 - 修复核心逻辑 bug(费了老大劲 😵💫) - 补充并覆盖该接口的多种异常与错误场景测试 🧪
This commit is contained in:
@@ -56,11 +56,14 @@ func (sa *CourseHandler) AddUserCourses(c *gin.Context) {
|
||||
// 创建一个带 1 秒超时的上下文
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 1*time.Second)
|
||||
defer cancel() // 记得释放资源
|
||||
err = sa.service.AddUserCourses(ctx, req, userIDInterface)
|
||||
conflicts, err := sa.service.AddUserCourses(ctx, req, userIDInterface)
|
||||
if err != nil {
|
||||
switch {
|
||||
case errors.Is(err, respond.WrongParamType), errors.Is(err, respond.WrongCourseInfo):
|
||||
case errors.Is(err, respond.WrongParamType), errors.Is(err, respond.WrongCourseInfo),
|
||||
errors.Is(err, respond.InsertCourseTwice):
|
||||
c.JSON(http.StatusBadRequest, err)
|
||||
case errors.Is(err, respond.ScheduleConflict):
|
||||
c.JSON(http.StatusConflict, respond.RespWithData(respond.ScheduleConflict, conflicts))
|
||||
default:
|
||||
c.JSON(http.StatusInternalServerError, respond.InternalError(err))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user