shaoyongjun 73c5062c45 to:sync
2024-02-21 12:04:40 +08:00

33 lines
681 B
Go

package apps
import (
"ai-gateway/common/constant"
"ai-gateway/common/dto"
"ai-gateway/common/utils"
"ai-gateway/infrastructure/repository"
"ai-gateway/service"
"context"
"github.com/labstack/echo/v4"
"net/http"
)
func InitUserGroup(g *echo.Group) {
g.POST("ai/login", func(c echo.Context) error {
req := new(dto.ThirdLoginReq)
if err := c.Bind(req); err != nil {
return c.JSON(500, err)
}
req.BizId = constant.BizIdAI.Val()
ctx := context.WithValue(context.Background(), constant.DBKey, repository.Db)
token, err := service.Login.Login(ctx, *req)
if err != nil {
return c.JSON(500, err)
}
return c.JSON(http.StatusOK, utils.Ok(token))
})
}