43 lines
769 B
Go
43 lines
769 B
Go
package services
|
|
|
|
import (
|
|
"ai_scheduler/internal/biz"
|
|
"ai_scheduler/internal/entitys"
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
type TaskService struct {
|
|
taskBiz *biz.TaskBiz
|
|
chatBiz *biz.ChatHistoryBiz
|
|
}
|
|
|
|
func NewTaskService(sessionBiz *biz.SessionBiz, taskBiz *biz.TaskBiz) *TaskService {
|
|
return &TaskService{
|
|
taskBiz: taskBiz,
|
|
}
|
|
}
|
|
|
|
// Tasks 任务列表
|
|
func (s *TaskService) Tasks(c *fiber.Ctx) error {
|
|
req := &entitys.TaskRequest{}
|
|
if err := c.BodyParser(req); err != nil {
|
|
return err
|
|
}
|
|
|
|
auth := ""
|
|
if auths := c.GetReqHeaders()["Authorization"]; len(auths) > 0 {
|
|
auth = auths[0]
|
|
}
|
|
if auth == "" {
|
|
return fiber.ErrUnauthorized
|
|
}
|
|
|
|
result, err := s.taskBiz.TaskList(c.Context(), req, auth)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return c.JSON(result)
|
|
}
|