package com.emotion.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.emotion.common.BasePageRequest; import com.emotion.entity.UserStats; import java.time.LocalDateTime; import java.util.List; /** * 用户统计服务接口 * * @author emotion-museum * @date 2025-07-23 */ public interface UserStatsService extends IService { /** * 分页查询用户统计 */ IPage getPage(BasePageRequest request); /** * 根据用户ID查询统计信息 */ UserStats getByUserId(String userId); /** * 根据统计类型查询统计信息 */ List getByStatsType(String statsType); /** * 根据用户ID和统计类型查询统计信息 */ UserStats getByUserIdAndStatsType(String userId, String statsType); /** * 根据时间范围查询统计信息 */ List getByTimeRange(LocalDateTime startTime, LocalDateTime endTime); /** * 根据数值范围查询统计信息 */ List getByValueRange(Double minValue, Double maxValue); /** * 统计指定类型的记录数量 */ Long countByStatsType(String statsType); /** * 查询平均统计值 */ Double getAvgValueByStatsType(String statsType); /** * 查询最大统计值 */ Double getMaxValueByStatsType(String statsType); /** * 查询最小统计值 */ Double getMinValueByStatsType(String statsType); /** * 查询用户的所有统计类型 */ List getAllStatsByUserId(String userId); /** * 查询排名前N的用户统计 */ List getTopUsersByStatsType(String statsType, Integer limit); /** * 查询用户在指定统计类型中的排名 */ Long getUserRankByStatsType(String userId, String statsType); /** * 更新用户统计值 */ boolean updateStatsValue(String userId, String statsType, Double value); /** * 增加用户统计值 */ boolean incrementStatsValue(String userId, String statsType, Double increment); /** * 批量更新用户统计 */ boolean batchUpdateStats(String userId, List statsList); /** * 重新计算用户统计 */ boolean recalculateUserStats(String userId); /** * 重新计算所有用户统计 */ boolean recalculateAllUserStats(); /** * 根据周期查询统计信息 */ List getByPeriod(String period); /** * 根据用户ID和周期查询统计信息 */ List getByUserIdAndPeriod(String userId, String period); /** * 创建或更新用户统计 */ UserStats createOrUpdateUserStats(String userId, String statsType, Double value, String period); /** * 删除过期的统计数据 */ boolean deleteExpiredStats(Integer days); }