Browse Source

对外接口批量保存学生、考生信息列表,条数限制每次100条内

deason 1 năm trước cách đây
mục cha
commit
34471ce183

+ 11 - 6
examcloud-exchange-api-provider/src/main/java/cn/com/qmth/examcloud/exchange/outer/api/provider/ExamStudentOuterServiceProvider.java

@@ -27,6 +27,7 @@ import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.web.support.StatusResponse;
 import cn.com.qmth.examcloud.web.support.StatusResponse;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Lists;
 import io.swagger.annotations.*;
 import io.swagger.annotations.*;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -41,14 +42,11 @@ import java.util.List;
  *
  *
  * @author WANGWEI
  * @author WANGWEI
  * @date 2018年7月2日
  * @date 2018年7月2日
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
  */
  */
 @Api(tags = "考生相关接口")
 @Api(tags = "考生相关接口")
 @RestController
 @RestController
 @RequestMapping("${$rmp.cloud.exchange.outer}/examStudent")
 @RequestMapping("${$rmp.cloud.exchange.outer}/examStudent")
-public class ExamStudentOuterServiceProvider extends ControllerSupport
-        implements
-        ExamStudentOuterService {
+public class ExamStudentOuterServiceProvider extends ControllerSupport implements ExamStudentOuterService {
 
 
     private static final long serialVersionUID = -8252740695302763716L;
     private static final long serialVersionUID = -8252740695302763716L;
 
 
@@ -144,6 +142,15 @@ public class ExamStudentOuterServiceProvider extends ControllerSupport
             throw new StatusException("1000001", "rootOrgId is wrong");
             throw new StatusException("1000001", "rootOrgId is wrong");
         }
         }
 
 
+        List<ExamStudent4BatchBean> examStudentList = req.getExamStudentList();
+        if (CollectionUtils.isEmpty(examStudentList)) {
+            throw new StatusException("1000001", "考生信息列表为空!");
+        }
+
+        if (examStudentList.size() > 100) {
+            throw new StatusException("1000001", "考生信息列表,条数限制每次100条内!");
+        }
+
         Long examId = req.getExamId();
         Long examId = req.getExamId();
         String examCode = req.getExamCode();
         String examCode = req.getExamCode();
         String examName = req.getExamName();
         String examName = req.getExamName();
@@ -158,8 +165,6 @@ public class ExamStudentOuterServiceProvider extends ControllerSupport
         GetExamResp r = examCloudService.getExam(getExamReq);
         GetExamResp r = examCloudService.getExam(getExamReq);
         ExamBean examBean = r.getExamBean();
         ExamBean examBean = r.getExamBean();
 
 
-        List<ExamStudent4BatchBean> examStudentList = req.getExamStudentList();
-
         List<ExamStudentStatus4BatchBean> successList = Lists.newArrayList();
         List<ExamStudentStatus4BatchBean> successList = Lists.newArrayList();
         List<ExamStudentStatus4BatchBean> failureList = Lists.newArrayList();
         List<ExamStudentStatus4BatchBean> failureList = Lists.newArrayList();
 
 

+ 10 - 4
examcloud-exchange-api-provider/src/main/java/cn/com/qmth/examcloud/exchange/outer/api/provider/StudentOuterServiceProvider.java

@@ -24,6 +24,7 @@ import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.web.support.StatusResponse;
 import cn.com.qmth.examcloud.web.support.StatusResponse;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Lists;
 import io.swagger.annotations.*;
 import io.swagger.annotations.*;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -41,7 +42,6 @@ import java.util.List;
  *
  *
  * @author WANGWEI
  * @author WANGWEI
  * @date 2018年6月29日
  * @date 2018年6月29日
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
  */
  */
 @Api(tags = "学生相关接口")
 @Api(tags = "学生相关接口")
 @RestController
 @RestController
@@ -163,6 +163,13 @@ public class StudentOuterServiceProvider extends ControllerSupport implements St
         }
         }
 
 
         List<Student4BatchBean> studentList = req.getStudentList();
         List<Student4BatchBean> studentList = req.getStudentList();
+        if (CollectionUtils.isEmpty(studentList)) {
+            throw new StatusException("1000001", "学生信息列表为空!");
+        }
+
+        if (studentList.size() > 100) {
+            throw new StatusException("1000001", "学生信息列表,条数限制每次100条内!");
+        }
 
 
         List<StudentStatus4BatchBean> successList = Lists.newArrayList();
         List<StudentStatus4BatchBean> successList = Lists.newArrayList();
         List<StudentStatus4BatchBean> failureList = Lists.newArrayList();
         List<StudentStatus4BatchBean> failureList = Lists.newArrayList();
@@ -185,12 +192,11 @@ public class StudentOuterServiceProvider extends ControllerSupport implements St
             }
             }
 
 
             try {
             try {
-
                 // 保存学生
                 // 保存学生
                 SaveStudentResp ssResp = studentCloudService.saveStudent(ssReq);
                 SaveStudentResp ssResp = studentCloudService.saveStudent(ssReq);
+
                 // 处理照片
                 // 处理照片
-                processPhotoUrl(req.getRootOrgId(), cur.getIdentityNumber(), cur.getPhotoUrl(),
-                        cur.getOperator());
+                processPhotoUrl(req.getRootOrgId(), cur.getIdentityNumber(), cur.getPhotoUrl(), cur.getOperator());
 
 
                 StudentStatus4BatchBean studentStatus4BatchBeanSuccess = new StudentStatus4BatchBean();
                 StudentStatus4BatchBean studentStatus4BatchBeanSuccess = new StudentStatus4BatchBean();
                 studentStatus4BatchBeanSuccess.setStudentId(ssResp.getStudentId());
                 studentStatus4BatchBeanSuccess.setStudentId(ssResp.getStudentId());