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.*;
import com.sonic.frog.limit.RequestLimit;
import com.sonic.frog.service.AiUserSearchService;
import com.sonic.sdk.api.annotation.IgnoreAuth;
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-AI用户查询
 *
 * @author code
 */
@RestController
@Slf4j
public class AiUserSearchWeb {

    @Autowired
    private AiUserSearchService aiUserSearchService;

    @IgnoreAuth
    @ApiOperation(value = "获取AI基础信息", tags = {"Web-AI用户查询"})
    @PostMapping("/web/ai-user-search/base-info")
    public Result<AiUserBaseOutput> getAiUserBaseInfo(@Validated @RequestBody AiUserBaseInfoInput input, @ApiParam(hidden = true) Session session) {
        return Result.success(aiUserSearchService.getAiUserBaseInfo(session.getUserId(), input.getAiId()));
    }

    @ApiOperation(value = "获取用户自己的AI列表", tags = {"Web-AI用户查询"})
    @PostMapping("/web/ai-user-search/base-list")
    public Result<List<AiUserBaseListOutput>> baseAiList(@ApiParam(hidden = true) Session session) {
        return Result.success(aiUserSearchService.getBaseUserAiList(session.getUserId()));
    }

    @RequestLimit(count = 20, message = "operate too frequently，please try again 1min later")
    @ApiOperation(value = "目标用户的AI列表", tags = {"Web-AI用户查询"})
    @PostMapping("/web/ai-user-search/target-list")
    public Result<List<AiUserTargetListOutput>> targetAiList(@RequestBody @Validated UserIdInput input) {
        return Result.success(aiUserSearchService.getTargetUserAiList(input.getUserId()));
    }

    @IgnoreAuth
    @ApiOperation(value = "获取AI用户H5信息", tags = {"Web-AI用户查询"})
    @PostMapping("/web/ai-user-search/h5-info")
    public Result<AiUserH5Output> getAiUserH5Info(@Validated @RequestBody AiUserH5InfoInput input, @ApiParam(hidden = true) Session session) {
        return Result.success(aiUserSearchService.getAiUserH5Info(input.getAiId()));
    }

    @IgnoreAuth
    @ApiOperation(value = "获取AI用户seo基础信息", tags = {"Web-AI用户查询"})
    @PostMapping("/web//so/base-nfo")
    public Result<AiUserSeoBaseInfoOutput> getAiUserSeoBaseInfo(@Validated @RequestBody AiUserSeoBaseInfoInput input, @ApiParam(hidden = true) Session session) {
        return Result.success(aiUserSearchService.getAiUserSeoBaseInfo(input.getAiId()));
    }

    @IgnoreAuth
    @ApiOperation(value = "获取im聊天AI基础信息", tags = {"Web-AI用户查询"})
    @PostMapping("/web/ai-user-search/im-base-info")
    public Result<AiUserImBaseInfoOutput> getAiUserImBaseInfo(@Validated @RequestBody AiUserImBaseInfoInput input, @ApiParam(hidden = true) Session session) {
        return Result.success(aiUserSearchService.getAiUserImBaseInfo(input.getAiId(), session.getUserId()));
    }



}
