瀏覽代碼

管理员功能Complete

bfzgs 2 年之前
父節點
當前提交
be7ef7c979

+ 0 - 49
final-timetable/src/main/java/org/brynhild/graduation/timetable/controller/AdminController.java

@@ -106,54 +106,5 @@ public class AdminController {
         return tableService.deleteTimeTable(info, token);
     }
 
-    @PostMapping("/statistic/class")
-    public Result queryClassStatistic(@RequestBody @Validated AdminQueryClassStatistic info,BindingResult result,
-                                    @RequestHeader(AccountConstant.ACCOUNT_HEADER)String token){
-        if (result.hasErrors()) {
-            return verifier.convertToErrors(result);
-        }
-        return tableService.queryClassStatistic(info,token);
-    }
-
-    @PostMapping("/statistic/student")
-    public Result queryStudentStatistic(@RequestBody @Validated AdminQueryStudentStatistic info,BindingResult result,
-                                      @RequestHeader(AccountConstant.ACCOUNT_HEADER)String token){
-        if (result.hasErrors()) {
-            return verifier.convertToErrors(result);
-        }
-        return tableService.queryStudentStatistic(info,token);
-    }
 
-    @GetMapping("/statistic/class")
-    public Result queryClassStatisticPublic(){
-        AdminQueryClassStatistic info=new AdminQueryClassStatistic();
-        info.setId(2L);
-        return tableService.generateClassStatistic(info,"");
-    }
-
-    @GetMapping("/statistic/student")
-    public Result queryStudentStatisticPublic(){
-        AdminQueryStudentStatistic info=new AdminQueryStudentStatistic();
-        info.setId(3L);
-        return tableService.generateStudentStatistic(info,"");
-    }
-
-
-    @PostMapping("/statistic/class/generate")
-    public Result generateClassStatistic(@RequestBody @Validated AdminQueryClassStatistic info,BindingResult result,
-                                      @RequestHeader(AccountConstant.ACCOUNT_HEADER)String token){
-        if (result.hasErrors()) {
-            return verifier.convertToErrors(result);
-        }
-        return tableService.generateClassStatistic(info,token);
-    }
-
-    @PostMapping("/statistic/student/generate")
-    public Result generateStudentStatistic(@RequestBody @Validated AdminQueryStudentStatistic info,BindingResult result,
-                                        @RequestHeader(AccountConstant.ACCOUNT_HEADER)String token){
-        if (result.hasErrors()) {
-            return verifier.convertToErrors(result);
-        }
-        return tableService.generateStudentStatistic(info,token);
-    }
 }

+ 63 - 3
final-timetable/src/main/java/org/brynhild/graduation/timetable/controller/CommonController.java

@@ -1,10 +1,16 @@
 package org.brynhild.graduation.timetable.controller;
 
+import lombok.RequiredArgsConstructor;
+import org.brynhild.graduation.common.constant.AccountConstant;
 import org.brynhild.graduation.common.transfer.dto.Result;
+import org.brynhild.graduation.common.utils.RequestBodyVerifier;
+import org.brynhild.graduation.timetable.service.ITimeTableService;
 import org.brynhild.graduation.transfer.timetable.bo.TimeTableConfig;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.brynhild.graduation.transfer.timetable.vo.AdminQueryClassStatistic;
+import org.brynhild.graduation.transfer.timetable.vo.AdminQueryStudentStatistic;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
 
 import java.time.LocalDate;
 import java.time.temporal.ChronoUnit;
@@ -13,7 +19,10 @@ import java.util.List;
 
 @RestController
 @RequestMapping("/public")
+@RequiredArgsConstructor
 public class CommonController {
+    private final RequestBodyVerifier verifier;
+    private final ITimeTableService tableService;
 
     @GetMapping("/config")
     public Result getCurrentConfig() {
@@ -26,4 +35,55 @@ public class CommonController {
         config.setTimes(strings);
         return new Result(true, "查询成功", config);
     }
+
+    @PostMapping("/statistic/class")
+    public Result queryClassStatistic(@RequestBody @Validated AdminQueryClassStatistic info, BindingResult result,
+                                      @RequestHeader(AccountConstant.ACCOUNT_HEADER)String token){
+        if (result.hasErrors()) {
+            return verifier.convertToErrors(result);
+        }
+        return tableService.queryClassStatistic(info,token);
+    }
+
+    @PostMapping("/statistic/student")
+    public Result queryStudentStatistic(@RequestBody @Validated AdminQueryStudentStatistic info, BindingResult result,
+                                        @RequestHeader(AccountConstant.ACCOUNT_HEADER)String token){
+        if (result.hasErrors()) {
+            return verifier.convertToErrors(result);
+        }
+        return tableService.queryStudentStatistic(info,token);
+    }
+
+    @GetMapping("/statistic/class")
+    public Result queryClassStatisticPublic(){
+        AdminQueryClassStatistic info=new AdminQueryClassStatistic();
+        info.setId(2L);
+        return tableService.queryClassStatistic(info,"");
+    }
+
+    @GetMapping("/statistic/student")
+    public Result queryStudentStatisticPublic(){
+        AdminQueryStudentStatistic info=new AdminQueryStudentStatistic();
+        info.setId(3L);
+        return tableService.queryStudentStatistic(info,"");
+    }
+
+
+    @PostMapping("/statistic/class/generate")
+    public Result generateClassStatistic(@RequestBody @Validated AdminQueryClassStatistic info,BindingResult result,
+                                         @RequestHeader(AccountConstant.ACCOUNT_HEADER)String token){
+        if (result.hasErrors()) {
+            return verifier.convertToErrors(result);
+        }
+        return tableService.generateClassStatistic(info,token);
+    }
+
+    @PostMapping("/statistic/student/generate")
+    public Result generateStudentStatistic(@RequestBody @Validated AdminQueryStudentStatistic info,BindingResult result,
+                                           @RequestHeader(AccountConstant.ACCOUNT_HEADER)String token){
+        if (result.hasErrors()) {
+            return verifier.convertToErrors(result);
+        }
+        return tableService.generateStudentStatistic(info,token);
+    }
 }

+ 2 - 2
final-timetable/src/main/java/org/brynhild/graduation/timetable/service/impl/TimeTableServiceImpl.groovy

@@ -142,7 +142,7 @@ class TimeTableServiceImpl implements ITimeTableService {
     @Override
     Result queryClassStatistic(AdminQueryClassStatistic info, String token) {
         def result=getClassStatistic(info)
-        return new Result(true,"查询成功",info)
+        return new Result(true,"查询成功",result)
     }
 
     private List<ClassStatisticInfo> getClassStatistic(AdminQueryClassStatistic info){
@@ -204,7 +204,7 @@ class TimeTableServiceImpl implements ITimeTableService {
     private List<StudentStatisticInfo> getStudentStatistic(AdminQueryStudentStatistic info){
         def optional = userRepository.findById(info.id)
         if(optional.isEmpty()){
-            return new Result(false,"该学生不存在")
+            return new ArrayList<StudentStatisticInfo>()
         }
         def user = optional.get()
         def timeTableByClass = tableRepository.findTimeTableByClazz("${user.departmentId}")

+ 2 - 2
final-transfer/src/main/java/org/brynhild/graduation/Main.java

@@ -5,7 +5,7 @@ import org.brynhild.graduation.common.parser.DataClassGenerator;
 public class Main {
     public static void main(String[] args) {
         DataClassGenerator.generate("dataClassDir",
-                "org.brynhild.graduation.transfer.timetable.bo",
-                "org.brynhild.graduation.common.transfer.bo.timetable");
+                "org.brynhild.graduation.transfer.timetable.vo",
+                "org.brynhild.graduation.common.transfer.vo.timetable");
     }
 }