39 lines
938 B
Go
39 lines
938 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 UpadtePasswordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
var req types.UpdatePasswordReq
|
|
if err := httpx.Parse(r, &req); err != nil {
|
|
httpx.ErrorCtx(r.Context(), w, err)
|
|
return
|
|
}
|
|
|
|
l := member.NewUpadtePasswordLogic(r.Context(), svcCtx)
|
|
resp, err := l.UpadtePassword(&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)
|
|
}
|
|
}
|
|
}
|