更新一次

This commit is contained in:
eson
2023-06-01 18:35:09 +08:00
parent 08e6f00ff5
commit 2f01aa24c4
14 changed files with 495 additions and 3 deletions

View File

@@ -12,6 +12,11 @@ import (
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodPost,
Path: "/user/login",
Handler: UserLoginHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/user/fonts",
@@ -24,4 +29,15 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
},
},
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodGet,
Path: "/user/basic-info",
Handler: UserBasicInfoHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
)
}

View File

@@ -0,0 +1,29 @@
package handler
import (
"net/http"
"fusenapi/home-user-auth/internal/logic"
"fusenapi/home-user-auth/internal/svc"
"fusenapi/home-user-auth/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
func UserBasicInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.Request
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := logic.NewUserBasicInfoLogic(r.Context(), svcCtx)
resp, err := l.UserBasicInfo(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

View File

@@ -0,0 +1,28 @@
package handler
import (
"net/http"
"fusenapi/home-user-auth/internal/logic"
"fusenapi/home-user-auth/internal/svc"
"fusenapi/home-user-auth/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
func UserLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.RequestUserLogin
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := logic.NewUserLoginLogic(r.Context(), svcCtx)
resp, err := l.UserLogin(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}