package com.cyksj.service.chatgpt;

import cn.hutool.json.JSONObject;
import com.cyksj.model.dto.ChatgptUserVerifyDto;
import com.cyksj.model.entity.ChatgptSession;
import com.cyksj.model.entity.ChatgptUser;
import com.cyksj.model.views.ChatGptUserView;
import com.cyksj.model.views.ChatgptCarInfoView;
import com.ejlchina.searcher.SearchResult;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author chan
 * @date 2024/3/19 11:01
 */
public interface ChatGptAccountService {

    String getLoginUrl(Long userId, Long relationId);

    String getCarLoginUrl(String domain, Long userId, Long relationId, String carId);

    String getCarLoginUrlWithToken(String domain, String userToken, String carId);

    ChatgptUser findByUserTokenAndExpireTimeAfter(String userToken, LocalDateTime now);

    /**
     * 获取对话次数
     *
     * @param userToken 用户token
     * @param limitTime 限制时间
     * @return
     */
    Long getConversationCount(String userToken, Long limitTime);

    ChatgptSession checkSession(String carId);

    Boolean checkCarAccount(long userId, Long relationId);

    Boolean checkCarAccountWithToken(String userToken);

    ChatgptUser getCarChatGptUser(long userId, Long relationId);

    ChatgptUser getCarChatGptUserWithToken(String userToken);

    SearchResult<ChatgptCarInfoView> getCarInfoPage(String userToken, Integer limit);

    List<ChatgptCarInfoView> getCarInfoList(String userToken, Integer limit, Boolean isPlus);

    ChatGptUserView getUserInfo(long userId, Long relationId);

    ChatGptUserView getUserInfoWithToken(String userToken);
    /**
     * 获取GPT session
     */
    String getGptSession(String account, String password);

    void clearGptNum(Long relationId) throws Exception;

    void gptSwitchModel(long userId, Long relationId);

    /**
     * 风控检测
     * @param userToken
     * @param referer
     * @param userAgent
     * @return
     */
    String isRestrictions(String userToken, String referer, String userAgent);

    /**
     * 获取验证状态
     * @param userToken
     * @param restrictionId
     * @return
     */
    Boolean gptRestrictionStatus(String userToken, String restrictionId);

    /**
     * 验证
     * @param chatgptUserVerifyDto
     * @return
     */
    Boolean verifyRestriction(ChatgptUserVerifyDto chatgptUserVerifyDto);

    /**
     * gpt3日体验卡
     */
    String trialGpt(String clientIP, String trialToken, String userAgent);

    JSONObject getGptUseInfo(String userToken);

	String getMirrorToken(long userId, Long relationId);
}
