|
@@ -9,6 +9,7 @@ import org.apache.commons.fileupload.disk.DiskFileItem;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
@@ -61,8 +62,8 @@ public class FaceOuterServiceProvider extends ControllerSupport implements FaceO
|
|
|
@ApiOperation(value = "保存学生照片")
|
|
|
@PostMapping("addByUrl")
|
|
|
@Override
|
|
|
- public void addPhotoByUrl(@RequestParam Long rootOrgId, @RequestParam String photoUrl,
|
|
|
- @RequestParam String operator) {
|
|
|
+ public void addPhotoByUrl(@RequestParam Long rootOrgId, @RequestParam String identityNumber,
|
|
|
+ @RequestParam String photoUrl, @RequestParam String operator) {
|
|
|
|
|
|
if (photoUrl.startsWith("http")) {
|
|
|
byte[] bs = HttpClientUtil.get(photoUrl);
|
|
@@ -84,7 +85,7 @@ public class FaceOuterServiceProvider extends ControllerSupport implements FaceO
|
|
|
throw new StatusException("EX-100003", "文件读写失败");
|
|
|
}
|
|
|
|
|
|
- faceService.processFace(rootOrgId, fileName, temp, operator);
|
|
|
+ faceService.processFace(rootOrgId, identityNumber, fileSuffix, temp, operator);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -96,11 +97,22 @@ public class FaceOuterServiceProvider extends ControllerSupport implements FaceO
|
|
|
User accessUser = getAccessUser();
|
|
|
Long rootOrgId = accessUser.getRootOrgId();
|
|
|
|
|
|
- log.debug("fileName =" + file.getOriginalFilename());
|
|
|
DiskFileItem item = (DiskFileItem) file.getFileItem();
|
|
|
File storeLocation = item.getStoreLocation();
|
|
|
String fileName = file.getOriginalFilename();
|
|
|
- faceService.processFace(rootOrgId, fileName, storeLocation, accessUser.getDisplayName());
|
|
|
+
|
|
|
+ if (StringUtils.containsWhitespace(fileName)) {
|
|
|
+ throw new StatusException("EX-600100", "文件名不能含有空白字符");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!fileName.matches("[^\\.\\s]+\\.[^\\.\\s]+")) {
|
|
|
+ throw new StatusException("EX-600101", "文件名不合法");
|
|
|
+ }
|
|
|
+ String identityNumber = fileName.substring(0, fileName.lastIndexOf("."));
|
|
|
+ String fileSuffix = fileName.substring(fileName.lastIndexOf("."));
|
|
|
+
|
|
|
+ faceService.processFace(rootOrgId, identityNumber, fileSuffix, storeLocation,
|
|
|
+ accessUser.getDisplayName());
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "导入学生照片")
|
|
@@ -142,19 +154,32 @@ public class FaceOuterServiceProvider extends ControllerSupport implements FaceO
|
|
|
|
|
|
for (File f : files) {
|
|
|
Map<String, String> map = Maps.newHashMap();
|
|
|
+ String fileName = f.getName();
|
|
|
+ map.put("file", fileName);
|
|
|
|
|
|
if (f.length() > MAX_SIZE * 1024) {
|
|
|
- map.put("file", f.getName());
|
|
|
map.put("statusCode", "EX-620005");
|
|
|
map.put("statusDesc", "文件大小超过500KB");
|
|
|
ret.add(map);
|
|
|
continue;
|
|
|
}
|
|
|
try {
|
|
|
- map.put("file", f.getName());
|
|
|
- faceService.processFace(rootOrgId, f.getName(), f, accessUser.getDisplayName());
|
|
|
+ if (StringUtils.containsWhitespace(fileName)) {
|
|
|
+ throw new StatusException("EX-600100", "文件名不能含有空白字符");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!fileName.matches("[^\\.\\s]+\\.[^\\.\\s]+")) {
|
|
|
+ throw new StatusException("EX-600101", "文件名不合法");
|
|
|
+ }
|
|
|
+ String identityNumber = fileName.substring(0, fileName.lastIndexOf("."));
|
|
|
+ String fileSuffix = fileName.substring(fileName.lastIndexOf("."));
|
|
|
+
|
|
|
+ faceService.processFace(rootOrgId, identityNumber, fileSuffix, storeLocation,
|
|
|
+ accessUser.getDisplayName());
|
|
|
+
|
|
|
map.put("statusCode", "200");
|
|
|
map.put("statusDesc", "成功");
|
|
|
+
|
|
|
} catch (StatusException e) {
|
|
|
map.put("statusCode", e.getCode());
|
|
|
map.put("statusDesc", e.getDesc());
|