This commit is contained in:
2025-09-09 11:13:36 +08:00
parent cf50a9f1fa
commit fcd35c78e5
60 changed files with 2753 additions and 2196 deletions
@@ -1,11 +1,14 @@
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.common.PageResult;
import com.emotion.dto.request.UserStatsCreateRequest;
import com.emotion.dto.request.UserStatsIncrementRequest;
import com.emotion.dto.request.UserStatsPageRequest;
import com.emotion.dto.request.UserStatsUpdateValueRequest;
import com.emotion.dto.response.UserStatsResponse;
import com.emotion.entity.UserStats;
import java.time.LocalDateTime;
import java.util.List;
/**
@@ -17,84 +20,19 @@ import java.util.List;
public interface UserStatsService extends IService<UserStats> {
/**
* 分页查询用户统计
* 分页查询用户统计响应
*/
IPage<UserStats> getPage(BasePageRequest request);
/**
* 根据用户ID查询统计信息
*/
UserStats getByUserId(String userId);
/**
* 根据统计类型查询统计信息
*/
List<UserStats> getByStatsType(String statsType);
/**
* 根据用户ID和统计类型查询统计信息
*/
UserStats getByUserIdAndStatsType(String userId, String statsType);
/**
* 根据时间范围查询统计信息
*/
List<UserStats> getByTimeRange(LocalDateTime startTime, LocalDateTime endTime);
/**
* 根据数值范围查询统计信息
*/
List<UserStats> getByValueRange(Double minValue, Double maxValue);
/**
* 统计指定类型的记录数量
*/
Long countByStatsType(String statsType);
/**
* 查询平均统计值
*/
Double getAvgValueByStatsType(String statsType);
/**
* 查询最大统计值
*/
Double getMaxValueByStatsType(String statsType);
/**
* 查询最小统计值
*/
Double getMinValueByStatsType(String statsType);
/**
* 查询用户的所有统计类型
*/
List<UserStats> getAllStatsByUserId(String userId);
/**
* 查询排名前N的用户统计
*/
List<UserStats> getTopUsersByStatsType(String statsType, Integer limit);
/**
* 查询用户在指定统计类型中的排名
*/
Long getUserRankByStatsType(String userId, String statsType);
PageResult<UserStatsResponse> getPageWithResponse(UserStatsPageRequest request);
/**
* 更新用户统计值
*/
boolean updateStatsValue(String userId, String statsType, Double value);
boolean updateStatsValue(UserStatsUpdateValueRequest request);
/**
* 增加用户统计值
*/
boolean incrementStatsValue(String userId, String statsType, Double increment);
/**
* 批量更新用户统计
*/
boolean batchUpdateStats(String userId, List<UserStats> statsList);
boolean incrementStatsValue(UserStatsIncrementRequest request);
/**
* 重新计算用户统计
@@ -107,22 +45,12 @@ public interface UserStatsService extends IService<UserStats> {
boolean recalculateAllUserStats();
/**
* 根据周期查询统计信息
* 创建或更新用户统计响应
*/
List<UserStats> getByPeriod(String period);
/**
* 根据用户ID和周期查询统计信息
*/
List<UserStats> getByUserIdAndPeriod(String userId, String period);
/**
* 创建或更新用户统计
*/
UserStats createOrUpdateUserStats(String userId, String statsType, Double value, String period);
UserStatsResponse createOrUpdateUserStatsWithResponse(UserStatsCreateRequest request);
/**
* 删除过期的统计数据
*/
boolean deleteExpiredStats(Integer days);
}
}