package com.supervision.controller;


import com.supervision.dto.robot.RobotTalkDTO;
import com.supervision.dto.robot.SuspectInfo;
import com.supervision.service.RobotTalkService;
import com.supervision.vo.robot.ArchivesReqVo;
import com.supervision.vo.robot.CommonDialogVo;
import com.supervision.vo.talk.RobotTalkReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@Slf4j
@Api(tags = "机器人对话服务")
@RestController
@RequestMapping("/robot")
@RequiredArgsConstructor
public class RobotTalkController {

    private final RobotTalkService robotTalkService;


    @ApiOperation("机器人对话服务(文字)")
    @PostMapping("/textTalkRobot")
    public RobotTalkDTO textTalk2Robot(@RequestBody RobotTalkReq robotTalkReq) {
        robotTalkReq.populateSuspectInfo();
        return robotTalkService.textTalk2Robot(robotTalkReq);
    }

    @ApiOperation("机器人对话服务(语音)")
    @PostMapping("/videoTalkRobot")
    public RobotTalkDTO videoTalk2Robot(@RequestParam("file") MultipartFile multipartFile,
                                        @ModelAttribute RobotTalkReq robotTalkReq) {
        robotTalkReq.populateSuspectInfo();
        return robotTalkService.videoTalk2Robot(multipartFile, robotTalkReq);
    }


    @ApiOperation("获取对话内容列表")
    @GetMapping("/talkList")
    public List<CommonDialogVo> talkList(String sessionId) {
        return robotTalkService.talkList(sessionId);
    }

    @ApiOperation("获取音频")
    @GetMapping("/getAudio")
    public void getAudio(HttpServletResponse response,
                         @RequestParam("audioId")String audioId) throws IOException {
        robotTalkService.getAudio(response,audioId);
    }


    @ApiOperation("下载对话过程中的文件")
    @GetMapping("/downLoadFile")
    public void downLoadFile(HttpServletResponse response,
                             String fileType,
                             String fileId) throws IOException {
        robotTalkService.downLoadFile(response,fileType,fileId);
    }


    @ApiOperation("查询嫌疑人信息")
    @GetMapping("/querySuspectInfo")
    public List<SuspectInfo> querySuspectInfo(String sessionId, String name) {
       return robotTalkService.querySuspectInfo(sessionId,name);
    }
}
