package com.sonic.frog.controller.web;

import com.sonic.common.auth.domains.Session;
import com.sonic.common.rpc.Result;
import com.sonic.frog.domain.input.*;
import com.sonic.frog.domain.output.ChatBubbleListOutput;
import com.sonic.frog.domain.output.ChatSetOutput;
import com.sonic.frog.service.ChatSetService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Web-聊天设置
 *
 * @author code
 */
@RestController
@Slf4j
public class ChatSetWeb {

    @Autowired
    private ChatSetService chatSetService;

    @ApiOperation(value = "获取我的聊天设置", tags = {"Web-聊天设置"})
    @PostMapping("/web/chat-set/get-my")
    public Result<ChatSetOutput> getMyChatSet(@Validated @RequestBody ChatSetInput input, @ApiParam(hidden = true) Session session) {
        return Result.success(chatSetService.getMyChatSet(session.getUserId(), input.getAiId()));
    }

    @ApiOperation(value = "设置我的聊天设定", tags = {"Web-聊天设置"})
    @PostMapping("/web/chat-set/set")
    public Result<Void> setMyChatSetting(@Validated @RequestBody SetMyChatSettingInput input, @ApiParam(hidden = true) Session session) {
        chatSetService.setMyChatSetting(session.getUserId(), input);
        return Result.success();
    }

    @ApiOperation(value = "设置对话模型", tags = {"Web-聊天设置"})
    @PostMapping("/web/chat-set/set-chat-model")
    public Result<Void> setChatModel(@Validated @RequestBody SetChatModelInput input, @ApiParam(hidden = true) Session session) {
        chatSetService.setChatModel(session.getUserId(), input);
        return Result.success();
    }

    @ApiOperation(value = "设置聊天气泡字典列表", tags = {"Web-聊天设置"})
    @PostMapping("/web/chat-set/get-chat-bubble-list")
    public Result<List<ChatBubbleListOutput>> getChatBubbleList(@Validated @RequestBody ChatBubbleListInput input, @ApiParam(hidden = true) Session session) {
        List<ChatBubbleListOutput> outputList = chatSetService.getChatBubbleList(session.getUserId(), input);
        return Result.success(outputList);
    }

    @ApiOperation(value = "设置聊天气泡", tags = {"Web-聊天设置"})
    @PostMapping("/web/chat-set/set-chat-bubble")
    public Result<Void> setChatBubble(@Validated @RequestBody SetChatBubbleInput input, @ApiParam(hidden = true) Session session) {
        chatSetService.setChatBubble(session.getUserId(), input);
        return Result.success();
    }

    @ApiOperation(value = "设备是否自动播放语音", tags = {"Web-聊天设置"})
    @PostMapping("/web/chat-set/auto-play-voice")
    public Result<Void> setIsAutoPlayVoice(@Validated @RequestBody SetIsAutoPlayVoiceInput input, @ApiParam(hidden = true) Session session) {
        chatSetService.setIsAutoPlayVoice(session.getUserId(), input);
        return Result.success();
    }


}
