package com.sonic.cow.controller.web;

import com.sonic.common.auth.domains.Session;
import com.sonic.common.rpc.Result;
import com.sonic.cow.domain.input.GenAiUserContentV1Input;
import com.sonic.cow.domain.input.GenAutoChatContentInput;
import com.sonic.cow.domain.input.GenSupContentInput;
import com.sonic.cow.domain.output.GenAiUserContentV1Output;
import com.sonic.cow.domain.output.GenSupContentOutput;
import com.sonic.cow.enums.SexEnums;
import com.sonic.cow.service.GenAiUserContentService;
import com.sonic.cow.service.GenSupContentService;
import com.sonic.cow.utils.DateUtils;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * WEB-AI一键生成
 */
@Slf4j
@RestController
public class AIUserContentWeb {

    @Autowired
    private GenAiUserContentService genAiUserContentService;
    @Autowired
    private GenSupContentService genSupContentService;

    @ApiOperation(value = "生成人物的通用方法-V1版本", tags = {"WEB-AI一键生成"})
    @RequestMapping(value = "/web/gen/user-content-v1", produces = {"application/json"}, method = RequestMethod.POST)
    public Result<GenAiUserContentV1Output> aiGenUserContentV1(@Validated @RequestBody GenAiUserContentV1Input input, @ApiParam(hidden = true) Session session) throws Exception {
        return Result.success(genAiUserContentService.genAiUserContentV1(session.getUserId(), input));
    }

    @ApiOperation(value = "生成辅助对话内容", tags = {"WEB-AI一键生成"})
    @RequestMapping(value = "/web/gen/sup-content", produces = {"application/json"}, method = RequestMethod.POST)
    public Result<GenSupContentOutput> aiGenSupContent(@Validated @RequestBody GenSupContentInput input, @ApiParam(hidden = true) Session session) {
        return Result.success(genSupContentService.genSupContent(session.getUserId(), input));
    }

    @ApiOperation(value = "用户超过3分钟停留没有发消息了生成自动聊天内容并发送IM消息", tags = {"WEB-AI一键生成"})
    @RequestMapping(value = "/web/g/at-ct", produces = {"application/json"}, method = RequestMethod.POST)
    public Result<Void> genAutoChatAndSendImMessage(@Validated @RequestBody GenAutoChatContentInput input, @ApiParam(hidden = true) Session session) {
        genSupContentService.genAutoChatAndSendImMessage(session.getUserId(), input.getAiId());
        return Result.success();
    }

}
