package com.sonic.frog.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sonic.frog.domain.bo.AiGiftRankBo;
import com.sonic.frog.domain.bo.AiHeartbeatRankBo;
import com.sonic.frog.domain.bo.ChatRankBo;
import com.sonic.frog.domain.entity.AiUserStat;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;

/**
 * AI用户统计数据访问接口
 */
@Mapper
public interface AiUserStatDao extends BaseMapper<AiUserStat> {
    /**
     * 更新点赞数
     *
     * @param aiId
     * @param num
     */
    void updateLikedNum(@Param("aiId") Long aiId, @Param("num") Integer num);

    /**
     * 更新点赞数
     *
     * @param aiId
     * @param num
     */
    void updateDislikedNum(@Param("aiId") Long aiId, @Param("num") Integer num);

    /**
     * 添加聊天数
     *
     * @param aiId
     * @param num
     */
    void increaseChatNum(@Param("aiId") Long aiId, @Param("num") Integer num);

    /**
     * 更新会话数
     *
     * @param aiId
     */
    void increaseConversationNum(@Param("aiId") Long aiId);

    /**
     * 添加金币数
     *
     * @param aiId
     * @param coinNum
     */
    void increaseCoinNum(@Param("aiId") Long aiId, @Param("coinNum") Long coinNum);

    /**
     * 添加礼物金币数
     *
     * @param aiId
     * @param coinNum
     */
    void increaseGiftCoinNum(@Param("aiId") Long aiId, @Param("coinNum") Long coinNum);

    /**
     * 添加解锁图片金币数
     *
     * @param aiId
     * @param coinNum
     */
    void increaseUnlockImgCoinNum(@Param("aiId") Long aiId, @Param("coinNum") Long coinNum);

    /**
     * 查询出喜欢数最多的AI
     *
     * @param exAiIds
     * @param ps
     * @return
     */
    List<Long> queryLikedAiList(@Param("exAiIds") List<Long> exAiIds, @Param("exAlbumIdList") List<Long> exAlbumIdList, @Param("ps") int ps);

    /**
     * 更新数据
     *
     * @param aiId
     * @param heartbeatVal
     * @return
     */
    @Update("update ai_user_stat set heartbeat_val_total = if(heartbeat_val_total + #{heartbeatVal} > 0, heartbeat_val_total + #{heartbeatVal}, 0) where ai_id = #{aiId}")
    Integer incrementHeartbeatVal(@Param("aiId") Long aiId, @Param("heartbeatVal") BigDecimal heartbeatVal);


    /**
     * 查询热聊榜单
     *
     * @return
     */
    List<ChatRankBo> queryChatRank(@Param("ps") Integer ps);

    /**
     * 查询热聊榜单
     *
     * @return
     */
    List<AiHeartbeatRankBo> queryAiHeartbeatRank(@Param("ps") Integer ps);

    /**
     * 查询礼物榜单
     *
     * @param ps
     * @return
     */
    List<AiGiftRankBo> queryAiGiftRank(@Param("ps") Integer ps);
}