From 4d4eb9145efb294c3e66b0337574610e05424aa8 Mon Sep 17 00:00:00 2001 From: icechen Date: Fri, 14 Jan 2022 00:40:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A3=9E=E4=B9=A6=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/zeus/api/lark/internal/user/user.go | 27 ++++++++++++++++++++----- app/zeus/api/lark/main.go | 2 ++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/app/zeus/api/lark/internal/user/user.go b/app/zeus/api/lark/internal/user/user.go index 943784b..f74ba83 100644 --- a/app/zeus/api/lark/internal/user/user.go +++ b/app/zeus/api/lark/internal/user/user.go @@ -5,14 +5,12 @@ import ( "git.icechen.cn/monorepo/backend/pkg/proto/zeus/lark" "git.icechen.cn/monorepo/backend/pkg/rpc" "github.com/gofiber/fiber/v2" - ctxLogger "github.com/luizsuper/ctxLoggers" - "go.uber.org/zap" ) +// LoginHandle 管理员登录 func LoginHandle(c *fiber.Ctx) error { var p = struct { - Code string `json:"code" validate:"required"` - Email string `json:"email" label:"邮箱" validate:"email"` + Code string `json:"code" validate:"required"` }{} err := api.Bind(c, &p) if err != nil { @@ -26,6 +24,25 @@ func LoginHandle(c *fiber.Ctx) error { return err } - ctxLogger.FInfo(c, "response", zap.Any("resp", response)) + return c.JSON(response) +} + +// UserInfoHandle 管理员信息 +func UserInfoHandle(c *fiber.Ctx) error { + var p = struct { + Token string `json:"token"` + }{} + err := api.Bind(c, &p) + if err != nil { + return err + } + + response, err := lark.NewUserClient(rpc.GetServiceConn("lark")).Info(c.Context(), &lark.InfoRequest{ + Token: p.Token, + }) + if err != nil { + return err + } + return c.JSON(response) } diff --git a/app/zeus/api/lark/main.go b/app/zeus/api/lark/main.go index c6216de..7173b9a 100755 --- a/app/zeus/api/lark/main.go +++ b/app/zeus/api/lark/main.go @@ -13,9 +13,11 @@ func main() { ErrorHandler: api.FiberMiddleWareErrHandler, }) router.Use(api.FibberMiddleWareRespHandler) + router.Use(api.FibberUserCtxWithTraceHandler) userRouter := router.Group("/user") userRouter.Post("/login", user.LoginHandle) + userRouter.Post("/info", user.UserInfoHandle) err := router.Listen(":8080") if err != nil {