Selaa lähdekoodia

题库下载逻辑配置

xiatian 5 vuotta sitten
vanhempi
commit
17febe8406

+ 1 - 1
examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/core/questions/api/controller/ExportPaperController.java

@@ -59,7 +59,7 @@ public class ExportPaperController extends ControllerSupport {
         ExportServiceManage esm = exportServiceManageRepo.findByOrgName(orgName);
 
         if (esm == null) {
-            throw new StatusException("500", String.format("学校【%s】尚未配置导出模板!", orgName));
+            throw new StatusException("500", String.format("学校【%s】尚未配置导出逻辑!", orgName));
         }
         User user = getAccessUser();
         exportPaperService.exportPaperFile(id, esm.getExportServiceName(), exportContentList, response, loginName,

+ 47 - 1
examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/core/questions/api/controller/ExportTemplateController.java

@@ -2,6 +2,7 @@ package cn.com.qmth.examcloud.core.questions.api.controller;
 
 import javax.validation.constraints.NotNull;
 
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -17,7 +18,10 @@ import org.springframework.web.multipart.MultipartFile;
 
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.core.questions.base.bean.ExportServiceManageBean;
 import cn.com.qmth.examcloud.core.questions.base.dto.ExportTemplateDto;
+import cn.com.qmth.examcloud.core.questions.dao.ExportServiceManageRepo;
+import cn.com.qmth.examcloud.core.questions.dao.entity.ExportServiceManage;
 import cn.com.qmth.examcloud.core.questions.service.ExportTemplateService;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import io.swagger.annotations.Api;
@@ -27,7 +31,8 @@ import io.swagger.annotations.ApiOperation;
 @RestController
 @RequestMapping("${api_cqb}/exportTemplate")
 public class ExportTemplateController extends ControllerSupport {
-
+    @Autowired
+    ExportServiceManageRepo exportServiceManageRepo;
     @Autowired
     private ExportTemplateService exportTemplateService;
 
@@ -94,4 +99,45 @@ public class ExportTemplateController extends ControllerSupport {
         }
         exportTemplateService.disenable(rootOrgId, id);
     }
+    
+    @ApiOperation(value = "查询配置")
+    @GetMapping("/config/{rootOrgId}")
+    public ExportServiceManageBean getConfig(@PathVariable Long rootOrgId) {
+        User accessUser = getAccessUser();
+        if (!isSuperAdmin()) {
+            if (!rootOrgId.equals(accessUser.getRootOrgId())) {
+                throw new StatusException("100005", "无效的请求");
+            }
+        }
+        ExportServiceManage esm = exportServiceManageRepo.findByOrgId(String.valueOf(rootOrgId));
+        ExportServiceManageBean bean=new ExportServiceManageBean();
+        if(esm!=null) {
+            bean.setOrgId(esm.getOrgId());
+            bean.setId(esm.getId());
+            bean.setExportServiceName(esm.getExportServiceName());
+        }
+        return bean;
+    }
+
+    @ApiOperation(value = "新增/修改配置")
+    @PutMapping("/config/{rootOrgId}")
+    public void modifyConfig(@RequestParam @NotNull(message = "配置名称不能为空!") String serviceName,
+            @PathVariable Long rootOrgId) {
+        User accessUser = getAccessUser();
+        if (!isSuperAdmin()) {
+            if (!rootOrgId.equals(accessUser.getRootOrgId())) {
+                throw new StatusException("100006", "无效的请求");
+            }
+        }
+        if(StringUtils.isBlank(serviceName)) {
+            throw new StatusException("100007", "配置名称不能为空!");
+        }
+        ExportServiceManage esm = exportServiceManageRepo.findByOrgId(String.valueOf(rootOrgId));
+        if(esm==null) {
+            esm=new ExportServiceManage();
+            esm.setOrgId(String.valueOf(rootOrgId));
+        }
+        esm.setExportServiceName(serviceName.trim());
+        exportServiceManageRepo.save(esm);
+    }
 }

+ 35 - 0
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/bean/ExportServiceManageBean.java

@@ -0,0 +1,35 @@
+package cn.com.qmth.examcloud.core.questions.base.bean;
+
+public class ExportServiceManageBean {
+
+    private String id;
+
+    private String orgId;
+
+    private String exportServiceName;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getExportServiceName() {
+        return exportServiceName;
+    }
+
+    public void setExportServiceName(String exportServiceName) {
+        this.exportServiceName = exportServiceName;
+    }
+
+    public String getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(String orgId) {
+        this.orgId = orgId;
+    }
+
+}