Explorar o código

添加订单查看账号权限

wangqifan %!s(int64=3) %!d(string=hai) anos
pai
achega
75c900326c

+ 1 - 0
src/main/java/com/izouma/nineth/enums/AuthorityName.java

@@ -7,6 +7,7 @@ public enum AuthorityName {
     ROLE_ADMIN("高级管理员"),
     ROLE_OPERATOR("普通管理员"),
     ROLE_NEWS("新闻管理员"),
+    ROLE_ORDERINFO("订单查看"),
     ROLE_COMPANY("企业用户")
     ;
     private final String description;

+ 7 - 7
src/main/java/com/izouma/nineth/web/StatisticController.java

@@ -28,49 +28,49 @@ public class StatisticController {
 
     @GetMapping("/total")
     @Cacheable("total")
-    @PreAuthorize("hasAnyRole('ADMIN','COMPANY')")
+    @PreAuthorize("hasAnyRole('ADMIN','COMPANY','ORDERINFO')")
     public Map<String, Object> total() {
         return statisticService.total(SecurityUtils.getAuthenticatedUser().getId());
     }
 
     @GetMapping("/userTrend")
     @Cacheable("userTrend")
-    @PreAuthorize("hasRole('ADMIN')")
+    @PreAuthorize("hasAnyRole('ADMIN','ORDERINFO')")
     public Map<String, Long> userTrend(int day) {
         return statisticService.userTrend(day);
     }
 
     @GetMapping("/userTrendV2")
     @Cacheable(value = "userTrendV2", key = "#yearMonth")
-    @PreAuthorize("hasRole('ADMIN')")
+    @PreAuthorize("hasAnyRole('ADMIN','ORDERINFO')")
     public Long userTrendV2(String yearMonth) {
         return statisticService.userTrendV2(yearMonth);
     }
 
     @GetMapping("/orderNumTrend")
     @Cacheable("orderNumTrend")
-    @PreAuthorize("hasAnyRole('ADMIN','COMPANY')")
+    @PreAuthorize("hasAnyRole('ADMIN','COMPANY','ORDERINFO')")
     public Map<String, Map<String, Long>> orderNumTrend(int day) {
         return statisticService.orderNumTrend(day, SecurityUtils.getAuthenticatedUser().getId());
     }
 
     @GetMapping("/orderPriceTrend")
     @Cacheable("orderPriceTrend")
-    @PreAuthorize("hasAnyRole('ADMIN','COMPANY')")
+    @PreAuthorize("hasAnyRole('ADMIN','COMPANY','ORDERINFO')")
     public Map<String, Map<String, BigDecimal>> orderPriceTrend(int day) {
         return statisticService.orderPriceTrend(day, SecurityUtils.getAuthenticatedUser().getId());
     }
 
     @GetMapping("/orderPriceTrendV2")
     @Cacheable(value = "orderPriceTrendV2", key = "#yearMonth")
-    @PreAuthorize("hasAnyRole('ADMIN','COMPANY')")
+    @PreAuthorize("hasAnyRole('ADMIN','COMPANY','ORDERINFO')")
     public Map<String, BigDecimal> orderPriceTrendV2(String yearMonth) {
         return statisticService.orderPriceTrendV2(yearMonth, SecurityUtils.getAuthenticatedUser().getId());
     }
 
     @GetMapping("/top")
     @CachePut(value = "top", key = "#month")
-    @PreAuthorize("hasRole('ADMIN')")
+    @PreAuthorize("hasAnyRole('ADMIN','ORDERINFO')")
     public String top(int year, int month) {
         LocalDateTime start = LocalDateTime.of(year, month, 1, 0, 0, 0);
         LocalDateTime end = start.plusMonths(1).minusSeconds(1);