소스 검색

ip限制,审核人,答题纸上传

qinchao 4 년 전
부모
커밋
1bd28f2fa2

+ 54 - 1
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/OrgController.java

@@ -757,7 +757,6 @@ public class OrgController extends ControllerSupport {
 
         List<String> keys = RegExpUtil.findAll(String.valueOf(value), "[^\\,]+");
         Map<String, String> properties = getProperties(orgEntity.getId(), keys);
-
         return properties;
     }
 
@@ -1363,6 +1362,60 @@ public class OrgController extends ControllerSupport {
         return url;
     }
 
+    @ApiOperation(value = "导入离线考试答题纸", notes = "导入离线考试答题纸")
+    @PostMapping("importAnswers/{orgId}")
+    @Transactional
+    public String importAnswers(@PathVariable Long orgId, @RequestParam CommonsMultipartFile file) throws IOException {
+
+        OrgEntity orgEntity = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
+        if (null == orgEntity) {
+            throw new StatusException("140002", "orgEntity is null");
+        }
+
+        validateRootOrgIsolation(orgEntity.getRootId());
+
+        DiskFileItem fileItem = (DiskFileItem) file.getFileItem();
+        File storeLocation = fileItem.getStoreLocation();
+        String name = file.getOriginalFilename();
+
+        if ( 2048*1024 < storeLocation.length()) {
+            throw new StatusException("140082", "文件过大");
+        }
+
+        String fileSuffix = null;
+        if (name.endsWith(".zip")) {
+            fileSuffix = ".zip";
+        } else {
+            throw new StatusException("101001", "文件格式错误");
+        }
+
+        //通用存储
+        FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
+        env.setFileSuffix(fileSuffix);
+        env.setRootOrgId(orgEntity.getRootId().toString());
+        YunPathInfo pi = FileStorageUtil.saveFile("orgAnswers", env, storeLocation, null);
+        String url = pi.getUrl();
+
+        User accessUser = getAccessUser();
+        ReportsUtil.report(new AdminOperateReport(accessUser.getRootOrgId(), accessUser.getUserId(), "考生端配置-上传学校答题纸模板", null));
+        return url;
+    }
+
+    @ApiOperation(value = "下载离线考试答题纸", notes = "下载离线考试答题纸")
+    @GetMapping("getAnswersUrl/{orgId}")
+    @Transactional
+    public String getAnswersUrl(@PathVariable Long orgId) {
+        OrgEntity orgEntity = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
+        if (null == orgEntity) {
+            throw new StatusException("140002", "orgEntity is null");
+        }
+        OrgPropertyEntity fileEntity = orgPropertyRepo.findByOrgIdAndKeyId(orgId, 26L);
+        if (null == fileEntity || StringUtils.isBlank(fileEntity.getValue())) {
+            return "";
+        }
+        return fileEntity.getValue();
+    }
+
     @ApiOperation(value = "下载导入模板", notes = "下载导入模板")
     @GetMapping("importTemplate")
     public void getDownloadTemplate(HttpServletResponse response) {

+ 7 - 0
examcloud-core-basic-starter/src/main/resources/aliyun.xml

@@ -15,6 +15,13 @@
         <maxSize>1M</maxSize>
         <path>/org_logo/${rootOrgId}/${timeMillis}${fileSuffix}</path>
     </site>
+    <site>
+        <id>orgAnswers</id>
+        <name>机构答题纸</name>
+        <aliyunId>1</aliyunId>
+        <maxSize>2M</maxSize>
+        <path>/org_answers/${rootOrgId}/${timeMillis}${fileSuffix}</path>
+    </site>
 
     <site>
         <id>orgPropertiesByOrgId</id>

+ 6 - 0
examcloud-core-basic-starter/src/main/resources/org-properties.xml

@@ -156,4 +156,10 @@
 		<desc>机构是否自定义菜单</desc>
 		<valueType>BOOLEAN</valueType>
 	</enum>
+	<enum>
+		<id>26</id>
+		<name>ANSWERS_TEMPLATE</name>
+		<desc>机构答题纸模板</desc>
+		<valueType>STRING</valueType>
+	</enum>
 </enums>

+ 1 - 0
examcloud-core-basic-starter/src/main/resources/security.properties

@@ -8,5 +8,6 @@
 [s][${$rmp.ctr.basic}/student][online_signal/{studentId}][GET]=true
 [s][${$rmp.ctr.basic}/org][propertyNoSession/{key}][GET]=true
 [s][${$rmp.ctr.basic}/org][property/{orgId}/{key}][GET]=true
+[s][${$rmp.ctr.basic}/org][getAnswersUrl/{orgId}][GET]=true
 [s][${$rmp.ctr.basic}/systemProperty][{key}][GET]=true
 [s][${$rmp.ctr.basic}/rolePrivilege][getStudentClientMenu][GET]=true