package com.cmvr.web.controller.test;

import com.cmvr.common.core.controller.BaseController;
import com.cmvr.common.core.domain.AjaxResult;
import com.cmvr.test.model.vo.FlowiseActionRequestVO;
import com.cmvr.test.model.vo.FlowiseChatRequestVO;
import com.cmvr.test.model.vo.FlowiseStartRequestVO;
import com.cmvr.test.service.FlowiseActionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
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.RestController;

@Api(tags = "测试--flowise服务")
@RestController
@RequestMapping("/flowise")
@RequiredArgsConstructor
public class TeFlowiseController extends BaseController {

    private final FlowiseActionService flowiseActionService;

    @ApiOperation("调用flowise")
    @PostMapping("/start")
    public AjaxResult start(@RequestBody FlowiseStartRequestVO request) {
        return AjaxResult.ok(flowiseActionService.start(request));
    }

    @ApiOperation("根据chatId查询执行结果")
    @GetMapping("/{chatId}")
    public AjaxResult query(@PathVariable String chatId) {
        return AjaxResult.ok(flowiseActionService.query(chatId));
    }

    @ApiOperation("终止flowise")
    @GetMapping("/abort")
    public AjaxResult abort() {
        return AjaxResult.ok(flowiseActionService.abort());
    }

    @ApiOperation("执行指令")
    @PostMapping("/command")
    public AjaxResult command(@RequestBody FlowiseActionRequestVO request) {
        return AjaxResult.ok(flowiseActionService.command(request));
    }

    @ApiOperation("闲聊")
    @PostMapping("/chat")
    public AjaxResult chat(@RequestBody FlowiseChatRequestVO request) {
        return AjaxResult.ok(flowiseActionService.chat(request));
    }

    @ApiOperation("动作（眨眼+动嘴+头部微动）")
    @GetMapping("/action/start")
    public AjaxResult actionStart() {
        return AjaxResult.ok(flowiseActionService.actionStart());
    }

    @ApiOperation("动作停止")
    @GetMapping("/action/stop")
    public AjaxResult actionStop() {
        return AjaxResult.ok(flowiseActionService.actionStop());
    }
}