|
@@ -30,6 +30,8 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.apache.commons.lang.math.RandomUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -46,6 +48,8 @@ import java.util.concurrent.TimeUnit;
|
|
|
@RequestMapping("${app.api.oe.student}/examControl")
|
|
|
public class ExamControlController extends ControllerSupport {
|
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(ExamControlController.class);
|
|
|
+
|
|
|
private static final String SEPARATOR = "/";
|
|
|
|
|
|
private static final String UNDERLINE = "_";
|
|
@@ -205,8 +209,9 @@ public class ExamControlController extends ControllerSupport {
|
|
|
@ApiOperation(value = "获取文件上传签名(微信小程序调用)")
|
|
|
@PostMapping("/yunSignature")
|
|
|
public GetYunSignDomain getYunSignature(@ModelAttribute @Valid GetYunSignatureReq req) {
|
|
|
+ FileStorageType fileStorageType = FileStorageUtil.getFileStorageType();
|
|
|
|
|
|
- if (FileStorageType.UPYUN.equals(FileStorageUtil.getFileStorageType())) {
|
|
|
+ if (FileStorageType.UPYUN.equals(fileStorageType)) {
|
|
|
GetUpyunSignDomain result = new GetUpyunSignDomain();
|
|
|
Map<String, String> params = Maps.newHashMap();
|
|
|
UpyunSignatureInfo info = examControlService.getUpyunSignature(req);
|
|
@@ -219,17 +224,21 @@ public class ExamControlController extends ControllerSupport {
|
|
|
result.setSignIdentifier(signIdentifier);
|
|
|
return result;
|
|
|
}
|
|
|
- if (FileStorageType.ALIYUN.equals(FileStorageUtil.getFileStorageType())) {
|
|
|
+
|
|
|
+ if (FileStorageType.ALIYUN.equals(fileStorageType)) {
|
|
|
String fileSuffix = req.getFileSuffix();
|
|
|
if (StringUtils.isNullOrEmpty(fileSuffix)) {
|
|
|
throw new StatusException("5002", "文件后缀名不允许为空");
|
|
|
}
|
|
|
+ fileSuffix = !fileSuffix.contains(".") ? "." + fileSuffix : fileSuffix;
|
|
|
|
|
|
ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(req.getExamRecordDataId());
|
|
|
- fileSuffix = fileSuffix.indexOf(".") == -1 ? "." + fileSuffix : fileSuffix;
|
|
|
+ if (examRecordData == null) {
|
|
|
+ log.warn("ExamRecordDataCache not exist! examRecordDataId = {}", req.getExamRecordDataId());
|
|
|
+ throw new StatusException("5002", "请求参数值有误!");
|
|
|
+ }
|
|
|
|
|
|
StringBuffer filePath = new StringBuffer();
|
|
|
-
|
|
|
filePath.append(OE_ANSWER_FILE_PATH).append(SEPARATOR)
|
|
|
.append(examRecordData.getExamStudentId()).append(SEPARATOR).append(req.getExamRecordDataId())
|
|
|
.append(SEPARATOR).append(req.getOrder()).append(SEPARATOR)
|
|
@@ -240,12 +249,13 @@ public class ExamControlController extends ControllerSupport {
|
|
|
if (!StringUtils.isNullOrEmpty(req.getExt())) {
|
|
|
filePath.append(UNDERLINE).append(req.getExt());
|
|
|
}
|
|
|
- filePath.append(".").append(req.getFileSuffix());
|
|
|
+ filePath.append(fileSuffix);
|
|
|
|
|
|
GetAliyunSignDomain result = new GetAliyunSignDomain();
|
|
|
String signIdentifier = String.valueOf(System.currentTimeMillis());
|
|
|
FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
|
env.setRelativePath(filePath.toString());
|
|
|
+
|
|
|
YunHttpRequest aliYunHttpRequest = FileStorageUtil.getSignature(FileStorageType.ALIYUN, Constants.MINI_PROGRAM_ANWSER_SITEID, env, req.getFileMd5());
|
|
|
result.setAccessUrl(aliYunHttpRequest.getAccessUrl());
|
|
|
result.setFormUrl(aliYunHttpRequest.getFormUrl());
|
|
@@ -253,6 +263,7 @@ public class ExamControlController extends ControllerSupport {
|
|
|
result.setSignIdentifier(signIdentifier);
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
throw new StatusException("5002", "未配置正确云存储类型");
|
|
|
}
|
|
|
|