2023-06-04 22:54:54 +08:00
|
|
|
package apps
|
|
|
|
|
|
|
|
import (
|
|
|
|
"ai-gateway/common/constant"
|
|
|
|
"ai-gateway/common/dto"
|
|
|
|
"ai-gateway/common/utils"
|
|
|
|
"ai-gateway/infrastructure/repository"
|
|
|
|
"ai-gateway/service"
|
2024-02-21 12:04:40 +08:00
|
|
|
"context"
|
2023-06-04 22:54:54 +08:00
|
|
|
"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()
|
2024-02-21 12:04:40 +08:00
|
|
|
ctx := context.WithValue(context.Background(), constant.DBKey, repository.Db)
|
2023-06-04 22:54:54 +08:00
|
|
|
|
|
|
|
token, err := service.Login.Login(ctx, *req)
|
|
|
|
if err != nil {
|
|
|
|
return c.JSON(500, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.JSON(http.StatusOK, utils.Ok(token))
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|