backend/app/zeus/api/lark/internal/user/user.go

49 lines
955 B
Go
Raw Normal View History

2022-01-12 01:44:10 +08:00
package user
import (
2022-01-13 14:28:50 +08:00
"git.icechen.cn/monorepo/backend/pkg/api"
2022-01-12 01:44:10 +08:00
"git.icechen.cn/monorepo/backend/pkg/proto/zeus/lark"
"git.icechen.cn/monorepo/backend/pkg/rpc"
"github.com/gofiber/fiber/v2"
)
2022-01-14 00:40:35 +08:00
// LoginHandle 管理员登录
2022-01-12 01:44:10 +08:00
func LoginHandle(c *fiber.Ctx) error {
var p = struct {
2022-01-14 00:40:35 +08:00
Code string `json:"code" validate:"required"`
2022-01-12 01:44:10 +08:00
}{}
2022-01-13 14:28:50 +08:00
err := api.Bind(c, &p)
2022-01-12 01:44:10 +08:00
if err != nil {
return err
}
response, err := lark.NewUserClient(rpc.GetServiceConn("lark")).Login(c.Context(), &lark.LoginRequest{
Code: p.Code,
})
if err != nil {
return err
}
2022-01-14 00:40:35 +08:00
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
}
2022-01-12 01:44:10 +08:00
return c.JSON(response)
}