package com.guo.learningprogresstracker.controller; import com.guo.learningprogresstracker.dto.AiTaskResponse; import com.guo.learningprogresstracker.dto.request.AiTaskSubmitRequest; import com.guo.learningprogresstracker.entity.CommonResult; import com.guo.learningprogresstracker.exception.ErrorParameterException; import com.guo.learningprogresstracker.exception.NotFindEntitiesException; import com.guo.learningprogresstracker.service.AiTaskService; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; /** * AI 异步任务控制层(AI-02)。 * *
提交与查询分离:提交接口秒级返回任务标识,前端随后轮询查询接口拿结果。 * 这样刷新或离开页面都不会丢结果,AI 已消耗的 token 也不会白费。
*/ @RequestMapping("/ai/tasks") @RestController @Validated @RequiredArgsConstructor public class AiTaskController { private final AiTaskService aiTaskService; /** * 提交 AI 任务。 *同一目标已有进行中任务时直接返回该任务(AI-04:对外是任务状态,而不是可能为空的实体)。
*/ @PostMapping public CommonResult