-
Notifications
You must be signed in to change notification settings - Fork 1
/
getInfoHandler.go
36 lines (31 loc) · 939 Bytes
/
getInfoHandler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package user
import (
"douyin-tiktok/common/middleware"
"douyin-tiktok/common/utils"
"net/http"
"douyin-tiktok/service/user/cmd/api/internal/logic/user"
"douyin-tiktok/service/user/cmd/api/internal/svc"
"douyin-tiktok/service/user/cmd/api/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
func GetInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.UserIdReq
if err := httpx.ParseForm(r, &req); err != nil {
httpx.OkJson(w, utils.GenErrorResp("参数错误!😥"))
return
}
loggedUser, err := middleware.JwtAuthenticate(r, req.Token)
if err != nil {
httpx.OkJson(w, utils.GenErrorResp(err.Error()))
return
}
l := user.NewGetInfoLogic(r.Context(), svcCtx)
resp, err := l.GetInfo(&req, loggedUser)
if err != nil {
httpx.OkJson(w, utils.GenErrorResp(err.Error()))
} else {
httpx.OkJson(w, resp)
}
}
}