|
@@ -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);
|
|
|
+ }
|
|
|
}
|