app-cloudep-portal-api-gateway/internal/handler/member/info_handler.go

39 lines
906 B
Go

package member
import (
"net/http"
ers "code.30cm.net/digimon/library-go/errors"
"app-cloudep-portal-api-gateway/internal/logic/member"
"app-cloudep-portal-api-gateway/internal/svc"
"app-cloudep-portal-api-gateway/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
func InfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetMemberHeader
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := member.NewInfoLogic(r.Context(), svcCtx)
resp, err := l.Info(&req)
if err != nil {
e := ers.FromGRPCError(err)
httpx.WriteJsonCtx(r.Context(), w, e.HTTPStatus(), types.BaseResponse{
Status: types.Status{
Code: int64(e.FullCode()),
Message: e.Error(),
},
})
return
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}