Преглед изворни кода

Merge branch 'dev-lsy' into 'master'

添加Worker Location同步方法



See merge request !29

Li Shuying пре 7 година
родитељ
комит
eb5948117d

+ 3 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/dao/ContestDao.java

@@ -51,4 +51,7 @@ public interface ContestDao extends CrudRepository<Contest, Long> {
             "ORDER BY COUNT(distinct w.id) DESC")
     List<Object[]> CountByActive();
 
+    @Query(value = "SELECT uni_loc FROM university WHERE uni_name = :university", nativeQuery = true)
+    String findAreaByUniversity(@Param("university") String university);
+
 }

+ 2 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/service/ContestService.java

@@ -19,4 +19,6 @@ public interface ContestService {
     ContestStatistics getContestStatistics(Long contestId);
 
     String sycnStudentInfo();
+
+    String sycnStudentArea();
 }

+ 18 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/service/impl/ContestServiceImpl.java

@@ -176,4 +176,22 @@ public class ContestServiceImpl implements ContestService {
         return "ok";
     }
 
+    public String sycnStudentArea() {
+        List<Worker> workers = workerDao.getContestWorkerList();
+        System.out.println(workers.size());
+
+        for (int i = 0; i < workers.size(); i ++) {
+            Worker worker = workers.get(i);
+            if (worker.getLocation() == null && worker.getInformation() != null) {
+                String area = contestDao.findAreaByUniversity(worker.getInformation());
+                if (area != null) {
+                    worker.setLocation(area);
+                    workerDao.save(worker);
+                }
+            }
+        }
+
+        return "ok";
+    }
+
 }

+ 6 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/ctrl/ContestController.java

@@ -47,4 +47,10 @@ public class ContestController {
         System.out.println("同步学生信息");
         return contestLogic.sycnStudentInfo();
     }
+
+    @RequestMapping(value = UrlConstants.API_COMMON + "contest/sycnArea", method = RequestMethod.GET)
+    public String sycnStudentArea() {
+        System.out.println("同步学生信息");
+        return contestLogic.sycnStudentArea();
+    }
 }

+ 2 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/logic/ContestLogic.java

@@ -20,4 +20,6 @@ public interface ContestLogic {
     JSONObject getContestStatistics(Long contestId);
 
     String sycnStudentInfo();
+
+    String sycnStudentArea();
 }

+ 5 - 0
mooctest-site-server/src/main/java/cn/iselab/mooctest/site/web/logic/impl/ContestLogicImpl.java

@@ -85,4 +85,9 @@ public class ContestLogicImpl implements ContestLogic {
     public String sycnStudentInfo() {
         return contestService.sycnStudentInfo();
     }
+
+    @Override
+    public String sycnStudentArea() {
+        return contestService.sycnStudentArea();
+    }
 }