package com.red.circle.other.adapter.app.ai.qianfan;

import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.app.dto.clientobject.ai.qianfan.QianFanChatCO;
import com.red.circle.other.app.dto.cmd.ai.qianfan.QianFanChatCmd;
import com.red.circle.other.app.service.ai.qianfan.QianFanService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 千帆AI服务.
 *
 * @author pengliang on 2023/5/31
 * @eo.api-type http
 * @eo.groupName AI 服务
 * @eo.path /ai/qianfan
 */
@Validated
@RestController
@RequestMapping(value = "/ai/qianfan", produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class QianFanRestController extends BaseController {

    private final QianFanService qianFanService;

    @PostMapping("/chat")
    public QianFanChatCO chat(@RequestBody @Validated QianFanChatCmd cmd) {
        return qianFanService.chat(cmd);
    }

    @GetMapping("/list/{userId}")
    public List<QianFanChatCO> chatList(@PathVariable(value = "userId") Long userId) {
        return qianFanService.chatList(userId);
    }

    @PutMapping("/update/{id}/{status}")
    public void updateQianFanAiChat(@PathVariable(value = "id") Long id,
                                    @PathVariable(value = "status") Integer status) {
        qianFanService.updateQianFanAiChat(id, status);
    }
}
