generated from pkg/go-template
feat: 飞书获取用户信息
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
0c37f4363b
commit
4d4eb9145e
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue