youtu_server/game_open_api/internal/handler/wechat/wechatCode2UserIdHandler.go
2025-01-20 18:20:25 +08:00

30 lines
735 B
Go

package wechat
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"youtu_server/game_open_api/internal/logic/wechat"
"youtu_server/game_open_api/internal/svc"
"youtu_server/game_open_api/internal/types"
)
func WechatCode2UserIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.WechatCode2TokenRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := wechat.NewWechatCode2UserIdLogic(r.Context(), svcCtx)
resp, err := l.WechatCode2UserId(&req)
if err != nil {
resp.Code = -1
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}