GetUserInfoByUserID get user info, if user no login response http code is 200, but user info is null @Summary GetUserInfoByUserID @Description get user info, if user no login response http code is 200, but user info is null @Tags User @Accept json @Produce json @Security ApiKeyAuth @Success 200 {obj
(ctx *gin.Context)
| 81 | // @Success 200 {object} handler.RespBody{data=schema.GetCurrentLoginUserInfoResp} |
| 82 | // @Router /answer/api/v1/user/info [get] |
| 83 | func (uc *UserController) GetUserInfoByUserID(ctx *gin.Context) { |
| 84 | token := middleware.ExtractToken(ctx) |
| 85 | if len(token) == 0 { |
| 86 | handler.HandleResponse(ctx, nil, nil) |
| 87 | return |
| 88 | } |
| 89 | |
| 90 | // if user is no login return null in data |
| 91 | userInfo, _ := uc.authService.GetUserCacheInfo(ctx, token) |
| 92 | if userInfo == nil { |
| 93 | handler.HandleResponse(ctx, nil, nil) |
| 94 | return |
| 95 | } |
| 96 | |
| 97 | resp, err := uc.userService.GetUserInfoByUserID(ctx, token, userInfo.UserID) |
| 98 | uc.setVisitCookies(ctx, userInfo.VisitToken, false) |
| 99 | handler.HandleResponse(ctx, err, resp) |
| 100 | } |
| 101 | |
| 102 | // GetOtherUserInfoByUsername godoc |
| 103 | // @Summary GetOtherUserInfoByUsername |
nothing calls this directly
no test coverage detected