package mingzuozhibi.action;

import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import static mingzuozhibi.utils.DiscUtils.needUpdateAsins;

@RestController
public class AdminController extends BaseController {

    @Transactional
    @GetMapping(value = "/api/admin/fetchCount")
    public String fetchCount() {
        return objectResult(needUpdateAsins(dao.session()).size());
    }

    @Deprecated
    @Transactional
    @GetMapping(value = "/api/discs/activeCount")
    public String deprecatedFetchCount() {
        return fetchCount();
    }

}

@@ -23,16 +23,81 @@
 ction;%0A%0A
+import org.springframework.security.access.prepost.PreAuthorize;%0A
 import o
@@ -408,16 +408,32 @@
 ller %7B%0A%0A
+    @Deprecated%0A
     @Tra
@@ -435,32 +435,70 @@
  @Transactional%0A
+    @PreAuthorize(%22hasRole('BASIC')%22)%0A
     @GetMapping(
@@ -515,19 +515,20 @@
 api/
-admin/fetch
+discs/active
 Coun
@@ -549,17 +549,27 @@
  String 
-f
+deprecatedF
 etchCoun
@@ -593,102 +593,85 @@
 urn 
-objectResult(needUpdateAsins(dao.session()).size());%0A    %7D%0A%0A    @Deprecated%0A    @Transactional
+fetchCount();%0A    %7D%0A%0A    @Transactional%0A    @PreAuthorize(%22hasRole('BASIC')%22)
 %0A   
@@ -693,36 +693,35 @@
 lue = %22/api/
-discs/active
+admin/fetch
 Count%22)%0A    
@@ -738,32 +738,139 @@
 ing 
-deprecatedFetchCount() %7B
+fetchCount() %7B%0A        int fetchCount = needUpdateAsins(dao.session()).size();%0A        debugRequest(%22%5BfetchCount:%7B%7D%5D%22, fetchCount);
 %0A   
@@ -873,32 +873,45 @@
 %0A        return 
+objectResult(
 fetchCount();%0A  
@@ -896,29 +896,28 @@
 esult(fetchCount
-(
 );%0A    %7D%0A%0A%7D%0A

Update fetchCount