feat: 飞书获取用户信息
continuous-integration/drone/push Build is passing Details

master
icechen 2022-01-14 00:40:35 +08:00
parent 0c37f4363b
commit 4d4eb9145e
2 changed files with 24 additions and 5 deletions

View File

@ -5,14 +5,12 @@ import (
"git.icechen.cn/monorepo/backend/pkg/proto/zeus/lark" "git.icechen.cn/monorepo/backend/pkg/proto/zeus/lark"
"git.icechen.cn/monorepo/backend/pkg/rpc" "git.icechen.cn/monorepo/backend/pkg/rpc"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
ctxLogger "github.com/luizsuper/ctxLoggers"
"go.uber.org/zap"
) )
// LoginHandle 管理员登录
func LoginHandle(c *fiber.Ctx) error { func LoginHandle(c *fiber.Ctx) error {
var p = struct { var p = struct {
Code string `json:"code" validate:"required"` Code string `json:"code" validate:"required"`
Email string `json:"email" label:"邮箱" validate:"email"`
}{} }{}
err := api.Bind(c, &p) err := api.Bind(c, &p)
if err != nil { if err != nil {
@ -26,6 +24,25 @@ func LoginHandle(c *fiber.Ctx) error {
return err 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) return c.JSON(response)
} }

View File

@ -13,9 +13,11 @@ func main() {
ErrorHandler: api.FiberMiddleWareErrHandler, ErrorHandler: api.FiberMiddleWareErrHandler,
}) })
router.Use(api.FibberMiddleWareRespHandler) router.Use(api.FibberMiddleWareRespHandler)
router.Use(api.FibberUserCtxWithTraceHandler)
userRouter := router.Group("/user") userRouter := router.Group("/user")
userRouter.Post("/login", user.LoginHandle) userRouter.Post("/login", user.LoginHandle)
userRouter.Post("/info", user.UserInfoHandle)
err := router.Listen(":8080") err := router.Listen(":8080")
if err != nil { if err != nil {