|
@@ -1,16 +1,16 @@
|
|
|
package cn.com.qmth.examcloud.exchange.outer.service.impl;
|
|
|
|
|
|
-import main.java.com.UpYun;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.security.MessageDigest;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
+
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.exchange.outer.service.UpyunService;
|
|
|
-
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.security.MessageDigest;
|
|
|
-import java.security.NoSuchAlgorithmException;
|
|
|
+import main.java.com.UpYun;
|
|
|
|
|
|
/**
|
|
|
* Created by yuanpan on 2017/5/11.
|
|
@@ -87,31 +87,36 @@ public class UpyunServiceImpl implements UpyunService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean saveStudentPhoto(Long studentId, Long rootOrgId, String fileSuffix, File file) {
|
|
|
- String filePath = null;
|
|
|
+ public String saveStudentPhoto(String identityNumber, Long rootOrgId, String fileSuffix,
|
|
|
+ File file) {
|
|
|
+ String filePath = path + "/" + rootOrgId + "/" + identityNumber + "/"
|
|
|
+ + System.currentTimeMillis();
|
|
|
if (fileSuffix.startsWith(".")) {
|
|
|
- filePath = path + "/" + rootOrgId + "/" + studentId + fileSuffix;
|
|
|
+ filePath += fileSuffix;
|
|
|
} else {
|
|
|
- filePath = path + "/" + rootOrgId + "/" + studentId + "." + fileSuffix;
|
|
|
+ filePath += "." + fileSuffix;
|
|
|
}
|
|
|
try {
|
|
|
- return getUpyun().writeFile(filePath, file, true);
|
|
|
+ getUpyun().writeFile(filePath, file, true);
|
|
|
+ return filePath;
|
|
|
} catch (Exception e) {
|
|
|
throw new StatusException("EX-100001", "调用又拍云API写文件失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean saveStudentPhoto(Long studentId, Long rootOrgId, String fileSuffix,
|
|
|
+ public String saveStudentPhoto(String identityNumber, Long rootOrgId, String fileSuffix,
|
|
|
byte[] bytes) {
|
|
|
- String filePath = null;
|
|
|
+ String filePath = path + "/" + rootOrgId + "/" + identityNumber + "/"
|
|
|
+ + System.currentTimeMillis();
|
|
|
if (fileSuffix.startsWith(".")) {
|
|
|
- filePath = path + "/" + rootOrgId + "/" + studentId + fileSuffix;
|
|
|
+ filePath += fileSuffix;
|
|
|
} else {
|
|
|
- filePath = path + "/" + rootOrgId + "/" + studentId + "." + fileSuffix;
|
|
|
+ filePath += "." + fileSuffix;
|
|
|
}
|
|
|
try {
|
|
|
- return getUpyun().writeFile(filePath, bytes, true);
|
|
|
+ getUpyun().writeFile(filePath, bytes, true);
|
|
|
+ return filePath;
|
|
|
} catch (Exception e) {
|
|
|
throw new StatusException("EX-100001", "调用又拍云API写文件失败");
|
|
|
}
|