package com.pavis.admin.controller.aigc;

import com.pavis.admin.aigc.core.agent.planner.PlanContext;
import com.pavis.admin.aigc.model.query.AgentPlanQuery;
import com.pavis.admin.aigc.model.req.AgentPlanReq;
import com.pavis.admin.aigc.model.resp.AgentPlanDetailResp;
import com.pavis.admin.aigc.model.resp.AgentPlanResp;
import com.pavis.admin.aigc.service.AgentPlanService;
import com.pavis.admin.common.controller.BaseController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.enums.Api;

/**
 * 智能体规划记录管理 API
 *
 * @author semi
 * @since 2025/05/28 16:59
 */
@Tag(name = "AIGC智能体计划管理 API")
@RestController
@CrudRequestMapping(value = "/aigc/agentPlan", api = {Api.PAGE, Api.GET, Api.CREATE, Api.UPDATE, Api.DELETE,
    Api.EXPORT})
public class AgentPlanController extends BaseController<AgentPlanService, AgentPlanResp, AgentPlanDetailResp, AgentPlanQuery, AgentPlanReq> {

    @Autowired
    private AgentPlanService agentPlanService;

    /**
     * 生成计划
     *
     * @param req 用户请求的规划JSON信息
     * @return 计划上下文信息
     */
    @Operation(summary = "生成计划", description = "生成计划")
    @PostMapping("/generate")
    public PlanContext generatePlan(@RequestBody AgentPlanReq req) {
        return agentPlanService.createPlan(req);
    }

    /**
     * 执行计划
     *
     * @param context 计划执行的上下文
     * @return 计划上下文信息
     */
    @Operation(summary = "执行计划", description = "执行计划")
    @PostMapping("/execute")
    public PlanContext executePlan(@RequestBody PlanContext context) {
        return agentPlanService.executePlan(context);
    }

}