为 9 个模块添加 Context 超时控制
完成模块: - auth: 3 个 Repository 方法 + Service + Handler + Middleware - wallet: 已有 context 支持,修复依赖调用 - payment: 已有 context 支持,修复 wallet 调用 - adminaudit: 1 个方法 - notification: 2 个方法 - realname: 2 个方法 - systemconfig: 4 个方法 - adminauth: 7 个方法 - adminuser: 6 个方法 所有数据库调用已改为 r.db.WithContext(ctx),完整传递 context 链路。 待完成模块: order, listing, chat 等 12 个模块(约 157 个方法)
This commit is contained in:
@@ -35,7 +35,7 @@ func (h *Handler) Me(c *gin.Context) {
|
||||
response.Unauthorized(c, "缺少用户上下文")
|
||||
return
|
||||
}
|
||||
user, err := h.users.FindByID(userID.(uint64))
|
||||
user, err := h.users.FindByID(c.Request.Context(), userID.(uint64))
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
response.Unauthorized(c, "用户不存在")
|
||||
return
|
||||
@@ -79,7 +79,7 @@ func (h *Handler) UpdateMe(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
user, err := h.users.UpdateProfile(userID.(uint64), nickname, avatarURL)
|
||||
user, err := h.users.UpdateProfile(c.Request.Context(), userID.(uint64), nickname, avatarURL)
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
response.Unauthorized(c, "用户不存在")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user