873b8e55da
✨ 新功能: - 创建了完整的Service层架构,包含所有业务实体的Service接口和实现类 - 新增8个标准化的Controller类,支持完整的CRUD操作 - 实现了统一的Request/Response模式和分页查询功能 - 创建了认证服务(AuthService)和令牌服务(TokenService) - 添加了Redis配置和认证拦截器 🏗️ 架构优化: - 移除Controller层所有try-catch块,使用全局异常处理机制 - 创建了专门的异常类(AuthException, TokenException, CaptchaException) - 统一了API返回格式,完善了Result类的方法 - 实现了标准的分页查询和参数校验 📦 新增文件: - 8个Controller类: Achievement, Comment, CommunityPost, Conversation, CozeApiCall, EmotionAnalysis, Reward, UserStats - 12个Service接口和对应的实现类 - 标准化的DTO类(Request/Response) - 异常处理类和拦截器 - 测试用例 🔧 重构优化: - 重写了AuthController,移除所有业务逻辑到Service层 - 优化了MessageController,使用标准的Request/Response格式 - 更新了全局异常处理器,支持多种异常类型 - 完善了WebConfig配置,添加认证拦截器 📊 代码统计: - 新增文件: 60+个 - 新增代码行数: 8000+行 - 重构代码行数: 1000+行 - 移除过时接口: 4个
129 lines
3.0 KiB
Java
129 lines
3.0 KiB
Java
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<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);
|
|
|
|
/**
|
|
* 更新用户统计值
|
|
*/
|
|
boolean updateStatsValue(String userId, String statsType, Double value);
|
|
|
|
/**
|
|
* 增加用户统计值
|
|
*/
|
|
boolean incrementStatsValue(String userId, String statsType, Double increment);
|
|
|
|
/**
|
|
* 批量更新用户统计
|
|
*/
|
|
boolean batchUpdateStats(String userId, List<UserStats> statsList);
|
|
|
|
/**
|
|
* 重新计算用户统计
|
|
*/
|
|
boolean recalculateUserStats(String userId);
|
|
|
|
/**
|
|
* 重新计算所有用户统计
|
|
*/
|
|
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);
|
|
|
|
/**
|
|
* 删除过期的统计数据
|
|
*/
|
|
boolean deleteExpiredStats(Integer days);
|
|
}
|