package com.sonic.frog.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sonic.frog.domain.entity.AiUserHeartbeatRelation;
import com.sonic.frog.domain.input.HeartbeatRelationListInput;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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

/**
 * 用户与AI的心动关系数据库访问层
 */
@Mapper
public interface AiUserHeartbeatRelationDao extends BaseMapper<AiUserHeartbeatRelation> {
    /**
     * 获取最近90天当前用户与AI的心动值排名
     *
     * @param userId
     * @param aiId
     * @return
     */
    Integer getUserHeartbeatRank(@Param("userId") Long userId, @Param("aiId") Long aiId);

    /**
     * 获取最近90天与该AI达到初识关系的人数
     *
     * @param aiId
     * @return
     */
    Integer getUserHeartbeatCount(@Param("aiId") Long aiId);

    /**
     * 心动关系列表
     *
     * @param page
     * @param input
     * @return
     */
    IPage<AiUserHeartbeatRelation> heartbeatRelationListPage(Page<AiUserHeartbeatRelation> page, @Param("input") HeartbeatRelationListInput input);

    /**
     * 24小时未聊天的关系列表
     *
     * @param calcTime
     * @return
     */
    List<AiUserHeartbeatRelation> hours24NoChatRelationList(LocalDateTime calcTime);
}