feat(player): 新增 GET /players/me 查询当前用户打手资料
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
// goctl 1.10.1
|
||||
|
||||
package player
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"juwan-backend/app/player/api/internal/logic/player"
|
||||
"juwan-backend/app/player/api/internal/svc"
|
||||
"juwan-backend/app/player/api/internal/types"
|
||||
)
|
||||
|
||||
// 获取当前用户的打手资料
|
||||
func GetMyPlayerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.EmptyResp
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := player.NewGetMyPlayerLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetMyPlayer(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
Path: "/players/me",
|
||||
Handler: player.InitPlayerHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 获取当前用户的打手资料
|
||||
Method: http.MethodGet,
|
||||
Path: "/players/me",
|
||||
Handler: player.GetMyPlayerHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 更新接单状态
|
||||
Method: http.MethodPut,
|
||||
|
||||
Reference in New Issue
Block a user