package com.cyksj.service.chatgpt;

import com.cyksj.model.entity.Account;
import com.cyksj.model.entity.ChatgptSession;
import com.cyksj.model.entity.ChatgptUser;
import com.cyksj.model.request.gpt.ConversationRequest;
import com.cyksj.model.response.ConversationLimitResponse;
import com.cyksj.model.views.ChatGptUserView;
import com.cyksj.model.views.ChatgptCarInfoView;

import java.time.LocalDateTime;
import java.util.Set;

/**
 * @author chan
 * @date 2024/3/19 11:01
 */
public interface ChatGptAccountService {
    String addAccount(Account account);

    void upAccount(Account account);

    String getLoginUrl(Long userId, Long relationId);

    String getCarLoginUrl(Long userId, Long relationId, String carId);
    String getCarLoginUrlWithToken(String userToken, String carId);

    ChatgptUser findByUserTokenAndExpireTimeAfter(String userToken, LocalDateTime now);

    /**
     * 对话限制
     *
     * @param userToken 用户token
     * @param model     对话模型
     * @return 是否限制
     */
    ConversationLimitResponse conversationLimit(String userToken, String model, String carId, ChatgptUser user, Boolean isCar);

    void saveConversationRecord(String userToken, ConversationRequest conversationRequest);

    /**
     * 获取对话次数
     *
     * @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);

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

    ChatGptUserView getUserInfo(long userId, Long relationId);

    ChatGptUserView getUserInfoWithToken(String userToken);

    void genTitleSync(String messageId, String carid, String userToken);

    /**
     * oai 触发车队限制
     */
    void carLimited(String carId, String userToken, Long expTime, Boolean isTeam);

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

}
