WANG 6 yıl önce
ebeveyn
işleme
031c1079ff

+ 14 - 11
examcloud-exchange-outer-api-provider/src/main/java/cn/com/qmth/examcloud/exchange/outer/api/provider/cug/CugOuterServiceProvider.java

@@ -77,6 +77,12 @@ public class CugOuterServiceProvider extends ControllerSupport implements CugOut
 		Long rootOrgId = req.getRootOrgId();
 		String identityNumber = req.getIdentityNumber();
 
+		String courseGroupName = req.getCourseGroupName();
+		String examName = req.getExamName();
+		String specialtyName = req.getSpecialtyName();
+
+		List<Course> courseList = courseGroupService.getCourseList(rootOrgId, courseGroupName);
+
 		SaveStudentReq request = new SaveStudentReq();
 		request.setIdentityNumber(identityNumber);
 		request.setName(req.getName());
@@ -93,18 +99,21 @@ public class CugOuterServiceProvider extends ControllerSupport implements CugOut
 
 		String photoUrl = req.getPhotoUrl();
 		if (StringUtils.isNotBlank(photoUrl)) {
-			byte[] bs = HttpClientUtil.get(photoUrl);
+			byte[] bs;
+			try {
+				bs = HttpClientUtil.get(photoUrl);
+			} catch (Exception e) {
+				throw new StatusException("EX-100002", "photoUrl is wrong");
+			}
 
 			int lastIndexOf = photoUrl.lastIndexOf(".");
 			if (0 > lastIndexOf) {
-				throw new StatusException("EX-100002",
-						"photoPath is not end with photo file suffix.");
+				throw new StatusException("EX-100002", "photoPath is not end with photo file suffix.");
 			}
 			String fileSuffix = photoUrl.substring(lastIndexOf);
 
 			String fileName = identityNumber + fileSuffix;
-			File temp = new File(
-					tempDir + File.separator + "student_photo" + File.separator + fileName);
+			File temp = new File(tempDir + File.separator + "student_photo" + File.separator + fileName);
 
 			try {
 				FileUtils.writeByteArrayToFile(temp, bs);
@@ -115,12 +124,6 @@ public class CugOuterServiceProvider extends ControllerSupport implements CugOut
 			faceService.processFace(rootOrgId, fileName, temp, req.getOperator());
 		}
 
-		String courseGroupName = req.getCourseGroupName();
-		String examName = req.getExamName();
-		String specialtyName = req.getSpecialtyName();
-
-		List<Course> courseList = courseGroupService.getCourseList(rootOrgId, courseGroupName);
-
 		GetExamReq getExamReq = new GetExamReq();
 		getExamReq.setName(examName);
 		getExamReq.setRootOrgId(rootOrgId);