|
@@ -1,5 +1,20 @@
|
|
|
package cn.com.qmth.examcloud.exchange.outer.api.provider;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.util.HttpClientUtil;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
|
|
@@ -19,25 +34,14 @@ import cn.com.qmth.examcloud.exchange.outer.api.response.OuterSaveStudentResp;
|
|
|
import cn.com.qmth.examcloud.exchange.outer.api.response.OuterUpdatePasswordResp;
|
|
|
import cn.com.qmth.examcloud.exchange.outer.api.response.OuterUpdateStudentStatusResp;
|
|
|
import cn.com.qmth.examcloud.exchange.outer.service.FaceService;
|
|
|
+import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
+import cn.com.qmth.examcloud.support.cache.bean.OrgPropertyCacheBean;
|
|
|
import cn.com.qmth.examcloud.support.util.IdUtil;
|
|
|
import cn.com.qmth.examcloud.web.config.SystemProperties;
|
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
-import com.google.common.collect.Lists;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
-import org.apache.commons.collections4.CollectionUtils;
|
|
|
-import org.apache.commons.io.FileUtils;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 类注释
|
|
@@ -64,8 +68,7 @@ public class StudentOuterServiceProvider extends ControllerSupport implements St
|
|
|
@ApiOperation(value = "保存学生信息")
|
|
|
@PostMapping("saveStudent")
|
|
|
@Override
|
|
|
- public OuterSaveStudentResp saveStudent(
|
|
|
- @RequestBody @ApiParam(required = true) OuterSaveStudentReq req) {
|
|
|
+ public OuterSaveStudentResp saveStudent(@RequestBody @ApiParam(required = true) OuterSaveStudentReq req) {
|
|
|
trim(req);
|
|
|
Long rootOrgId = req.getRootOrgId();
|
|
|
if (!getEnterpriseRootOrgId().equals(rootOrgId)) {
|
|
@@ -91,7 +94,9 @@ public class StudentOuterServiceProvider extends ControllerSupport implements St
|
|
|
// 保存学生
|
|
|
SaveStudentResp response = studentCloudService.saveStudent(request);
|
|
|
// 处理照片
|
|
|
- processPhotoUrl(rootOrgId, req.getIdentityNumber(), req.getPhotoUrl(), req.getOperator());
|
|
|
+ if (StringUtils.isBlank(response.getPhotoPath()) || overwritePhoto(rootOrgId)) {
|
|
|
+ processPhotoUrl(rootOrgId, req.getIdentityNumber(), req.getPhotoUrl(), req.getOperator());
|
|
|
+ }
|
|
|
|
|
|
OuterSaveStudentResp resp = new OuterSaveStudentResp();
|
|
|
resp.setOrgId(response.getOrgId());
|
|
@@ -101,6 +106,20 @@ public class StudentOuterServiceProvider extends ControllerSupport implements St
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
+ private boolean overwritePhoto(Long rootOrgId) {
|
|
|
+ OrgPropertyCacheBean orgProperty = CacheHelper.getOrgProperty(rootOrgId, "OVERWRITE_PHOTO");
|
|
|
+
|
|
|
+ if (orgProperty == null) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (orgProperty.getHasValue()) {
|
|
|
+ return "true".equals(orgProperty.getValue());
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 处理照片
|
|
|
*
|
|
@@ -110,8 +129,7 @@ public class StudentOuterServiceProvider extends ControllerSupport implements St
|
|
|
* @param operator
|
|
|
* @author WANGWEI
|
|
|
*/
|
|
|
- private void processPhotoUrl(Long rootOrgId, String identityNumber, String photoUrl,
|
|
|
- String operator) {
|
|
|
+ private void processPhotoUrl(Long rootOrgId, String identityNumber, String photoUrl, String operator) {
|
|
|
|
|
|
if (StringUtils.isNotBlank(photoUrl)) {
|
|
|
int lastIndexOf = photoUrl.lastIndexOf(".");
|
|
@@ -121,8 +139,8 @@ public class StudentOuterServiceProvider extends ControllerSupport implements St
|
|
|
|
|
|
String fileSuffix = photoUrl.substring(lastIndexOf);
|
|
|
String fileName = IdUtil.uuid() + fileSuffix;
|
|
|
- File temp = new File(systemConfig.getTempDataDir() + File.separator + "student_photo"
|
|
|
- + File.separator + fileName);
|
|
|
+ File temp = new File(
|
|
|
+ systemConfig.getTempDataDir() + File.separator + "student_photo" + File.separator + fileName);
|
|
|
|
|
|
try {
|
|
|
byte[] bs = HttpClientUtil.get(photoUrl);
|
|
@@ -193,7 +211,9 @@ public class StudentOuterServiceProvider extends ControllerSupport implements St
|
|
|
SaveStudentResp ssResp = studentCloudService.saveStudent(ssReq);
|
|
|
|
|
|
// 处理照片
|
|
|
- processPhotoUrl(req.getRootOrgId(), cur.getIdentityNumber(), cur.getPhotoUrl(), cur.getOperator());
|
|
|
+ if (StringUtils.isBlank(ssResp.getPhotoPath()) || overwritePhoto(cur.getRootOrgId())) {
|
|
|
+ processPhotoUrl(req.getRootOrgId(), cur.getIdentityNumber(), cur.getPhotoUrl(), cur.getOperator());
|
|
|
+ }
|
|
|
|
|
|
StudentStatus4BatchBean studentStatus4BatchBeanSuccess = new StudentStatus4BatchBean();
|
|
|
studentStatus4BatchBeanSuccess.setStudentId(ssResp.getStudentId());
|
|
@@ -218,8 +238,7 @@ public class StudentOuterServiceProvider extends ControllerSupport implements St
|
|
|
@ApiOperation(value = "更新学生密码")
|
|
|
@PostMapping("updatePassword")
|
|
|
@Override
|
|
|
- public OuterUpdatePasswordResp updatePassword(
|
|
|
- @RequestBody OuterUpdatePasswordReq req) {
|
|
|
+ public OuterUpdatePasswordResp updatePassword(@RequestBody OuterUpdatePasswordReq req) {
|
|
|
|
|
|
if (!getEnterpriseRootOrgId().equals(req.getRootOrgId())) {
|
|
|
throw new StatusException("1000001", "rootOrgId is wrong");
|
|
@@ -239,8 +258,7 @@ public class StudentOuterServiceProvider extends ControllerSupport implements St
|
|
|
@ApiOperation(value = "启用禁用学生")
|
|
|
@PostMapping("updateStudentStatus")
|
|
|
@Override
|
|
|
- public OuterUpdateStudentStatusResp updateStudentStatus(
|
|
|
- @RequestBody OuterUpdateStudentStatusReq req) {
|
|
|
+ public OuterUpdateStudentStatusResp updateStudentStatus(@RequestBody OuterUpdateStudentStatusReq req) {
|
|
|
|
|
|
if (!getEnterpriseRootOrgId().equals(req.getRootOrgId())) {
|
|
|
throw new StatusException("1000001", "rootOrgId is wrong");
|