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

49 lines
955 B
Go

package user
import (
"git.icechen.cn/monorepo/backend/pkg/api"
"git.icechen.cn/monorepo/backend/pkg/proto/zeus/lark"
"git.icechen.cn/monorepo/backend/pkg/rpc"
"github.com/gofiber/fiber/v2"
)
// LoginHandle 管理员登录
func LoginHandle(c *fiber.Ctx) error {
var p = struct {
Code string `json:"code" validate:"required"`
}{}
err := api.Bind(c, &p)
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
}
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)
}