修复权限验证问题:普通用户无法访问后台管理页面
This commit is contained in:
@@ -15,6 +15,7 @@ import org.springframework.security.core.Authentication;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
|
||||
@@ -6,7 +6,8 @@ public enum OrderType {
|
||||
SUBSCRIPTION("订阅订单"),
|
||||
DIGITAL("数字商品"),
|
||||
PHYSICAL("实体商品"),
|
||||
PAYMENT("支付订单");
|
||||
PAYMENT("支付订单"),
|
||||
MEMBERSHIP("会员订单");
|
||||
|
||||
private final String displayName;
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ public class UserActivityStats {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "stat_date", nullable = false, unique = true)
|
||||
private LocalDate statDate;
|
||||
@Column(name = "activity_date", nullable = false, unique = true)
|
||||
private LocalDate activityDate;
|
||||
|
||||
@Column(name = "daily_active_users", nullable = false)
|
||||
private Integer dailyActiveUsers = 0;
|
||||
@@ -55,8 +55,8 @@ public class UserActivityStats {
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public LocalDate getStatDate() { return statDate; }
|
||||
public void setStatDate(LocalDate statDate) { this.statDate = statDate; }
|
||||
public LocalDate getActivityDate() { return activityDate; }
|
||||
public void setActivityDate(LocalDate activityDate) { this.activityDate = activityDate; }
|
||||
|
||||
public Integer getDailyActiveUsers() { return dailyActiveUsers; }
|
||||
public void setDailyActiveUsers(Integer dailyActiveUsers) { this.dailyActiveUsers = dailyActiveUsers; }
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
@@ -17,60 +16,61 @@ public interface UserActivityStatsRepository extends JpaRepository<UserActivityS
|
||||
/**
|
||||
* 根据日期查找日活用户数
|
||||
*/
|
||||
@Query("SELECT uas.dailyActiveUsers FROM UserActivityStats uas WHERE uas.statDate = :date")
|
||||
@Query("SELECT uas.dailyActiveUsers FROM UserActivityStats uas WHERE uas.activityDate = :date")
|
||||
Integer findDailyActiveUsersByDate(@Param("date") LocalDate date);
|
||||
|
||||
/**
|
||||
* 获取指定年份的月度日活用户数据
|
||||
*/
|
||||
@Query("SELECT MONTH(uas.statDate) as month, " +
|
||||
@Query("SELECT MONTH(uas.activityDate) as month, " +
|
||||
"AVG(uas.dailyActiveUsers) as avgDailyActive, " +
|
||||
"MAX(uas.dailyActiveUsers) as maxDailyActive, " +
|
||||
"MIN(uas.dailyActiveUsers) as minDailyActive " +
|
||||
"FROM UserActivityStats uas " +
|
||||
"WHERE YEAR(uas.statDate) = :year " +
|
||||
"GROUP BY MONTH(uas.statDate) " +
|
||||
"ORDER BY MONTH(uas.statDate)")
|
||||
"WHERE YEAR(uas.activityDate) = :year " +
|
||||
"GROUP BY MONTH(uas.activityDate) " +
|
||||
"ORDER BY MONTH(uas.activityDate)")
|
||||
List<java.util.Map<String, Object>> findMonthlyActiveUsers(@Param("year") int year);
|
||||
|
||||
/**
|
||||
* 获取指定年份的每日日活用户数据
|
||||
*/
|
||||
@Query("SELECT DAYOFYEAR(uas.statDate) as dayOfYear, " +
|
||||
"WEEK(uas.statDate) as weekOfYear, " +
|
||||
@Query("SELECT DAYOFYEAR(uas.activityDate) as dayOfYear, " +
|
||||
"WEEK(uas.activityDate) as weekOfYear, " +
|
||||
"uas.dailyActiveUsers as dailyActiveUsers, " +
|
||||
"uas.statDate as statDate " +
|
||||
"uas.activityDate as activityDate " +
|
||||
"FROM UserActivityStats uas " +
|
||||
"WHERE YEAR(uas.statDate) = :year " +
|
||||
"ORDER BY uas.statDate")
|
||||
"WHERE YEAR(uas.activityDate) = :year " +
|
||||
"ORDER BY uas.activityDate")
|
||||
List<java.util.Map<String, Object>> findDailyActiveUsersByYear(@Param("year") int year);
|
||||
|
||||
/**
|
||||
* 获取指定月份的平均日活用户数
|
||||
*/
|
||||
@Query("SELECT AVG(uas.dailyActiveUsers) FROM UserActivityStats uas " +
|
||||
"WHERE YEAR(uas.statDate) = :year AND MONTH(uas.statDate) = :month")
|
||||
"WHERE YEAR(uas.activityDate) = :year AND MONTH(uas.activityDate) = :month")
|
||||
Double findAverageDailyActiveUsersByMonth(@Param("year") int year, @Param("month") int month);
|
||||
|
||||
/**
|
||||
* 获取指定年份的平均日活用户数
|
||||
*/
|
||||
@Query("SELECT AVG(uas.dailyActiveUsers) FROM UserActivityStats uas " +
|
||||
"WHERE YEAR(uas.statDate) = :year")
|
||||
"WHERE YEAR(uas.activityDate) = :year")
|
||||
Double findAverageDailyActiveUsersByYear(@Param("year") int year);
|
||||
|
||||
/**
|
||||
* 获取最新的统计数据
|
||||
*/
|
||||
Optional<UserActivityStats> findTopByOrderByStatDateDesc();
|
||||
Optional<UserActivityStats> findTopByOrderByActivityDateDesc();
|
||||
|
||||
/**
|
||||
* 获取指定日期范围的统计数据
|
||||
*/
|
||||
List<UserActivityStats> findByStatDateBetween(LocalDate startDate, LocalDate endDate);
|
||||
List<UserActivityStats> findByActivityDateBetween(LocalDate startDate, LocalDate endDate);
|
||||
|
||||
/**
|
||||
* 获取指定年份的所有统计数据
|
||||
*/
|
||||
List<UserActivityStats> findByStatDateYear(int year);
|
||||
@Query("SELECT uas FROM UserActivityStats uas WHERE YEAR(uas.activityDate) = :year ORDER BY uas.activityDate")
|
||||
List<UserActivityStats> findByActivityDateYear(@Param("year") int year);
|
||||
}
|
||||
|
||||
@@ -28,3 +28,5 @@ public class PlainTextPasswordEncoder implements PasswordEncoder {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user