|
@@ -1,21 +1,31 @@
|
|
package com.qmth.cqb.paper.web;
|
|
package com.qmth.cqb.paper.web;
|
|
|
|
|
|
import cn.com.qmth.examcloud.common.uac.annotation.Uac;
|
|
import cn.com.qmth.examcloud.common.uac.annotation.Uac;
|
|
|
|
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
import cn.com.qmth.examcloud.common.uac.enums.RoleMeta;
|
|
import cn.com.qmth.examcloud.common.uac.enums.RoleMeta;
|
|
import cn.com.qmth.examcloud.common.uac.enums.UacPolicy;
|
|
import cn.com.qmth.examcloud.common.uac.enums.UacPolicy;
|
|
-
|
|
|
|
-import com.qmth.cqb.paper.service.ExportPaperService;
|
|
|
|
-
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.BeansException;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
|
+import org.springframework.context.ApplicationContextAware;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
|
|
+import com.qmth.cqb.paper.dao.ExportServiceManageRepo;
|
|
|
|
+import com.qmth.cqb.paper.model.ExportServiceManage;
|
|
|
|
+import com.qmth.cqb.paper.service.export.DzkdExportPaperService;
|
|
|
|
+import com.qmth.cqb.paper.service.export.ExportPaperAbstractService;
|
|
|
|
+import com.qmth.cqb.paper.service.export.ExportPaperService;
|
|
|
|
+
|
|
|
|
+import java.lang.reflect.Method;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -26,9 +36,13 @@ import javax.servlet.http.HttpServletResponse;
|
|
public class ExportPaperController {
|
|
public class ExportPaperController {
|
|
|
|
|
|
protected static final Logger log = LoggerFactory.getLogger(ExportPaperController.class);
|
|
protected static final Logger log = LoggerFactory.getLogger(ExportPaperController.class);
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ ExportServiceManageRepo exportServiceManageRepo;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
- ExportPaperService exportPaperService;
|
|
|
|
|
|
+ ExportPaperAbstractService exportPaperService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 导出试卷
|
|
* 导出试卷
|
|
@@ -38,10 +52,17 @@ public class ExportPaperController {
|
|
@ApiOperation(value="导出试卷",notes="导出试卷")
|
|
@ApiOperation(value="导出试卷",notes="导出试卷")
|
|
@Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
@Uac(roles={RoleMeta.QUESTION_ADMIN,RoleMeta.SUPER_ADMIN},policy=UacPolicy.IN)
|
|
@GetMapping(value = "/paper/export/{id}")
|
|
@GetMapping(value = "/paper/export/{id}")
|
|
- public void getPaperById(@PathVariable String id, HttpServletResponse response){
|
|
|
|
|
|
+ public void getPaperById(@PathVariable String id, HttpServletResponse response,HttpServletRequest request){
|
|
log.info("导出开始");
|
|
log.info("导出开始");
|
|
try {
|
|
try {
|
|
- exportPaperService.downloadPaper(id,response);
|
|
|
|
|
|
+ //AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
|
+ ExportServiceManage esm = exportServiceManageRepo.findByOrgName("电子科技大学");
|
|
|
|
+ Method mds[] = ExportPaperAbstractService.class.getDeclaredMethods();
|
|
|
|
+ for(Method met:mds){
|
|
|
|
+ if(met.getName().equals(esm.getExportServiceName())){
|
|
|
|
+ met.invoke(exportPaperService, id,response);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
log.error("导出异常:"+e.getMessage());
|
|
log.error("导出异常:"+e.getMessage());
|
|
@@ -49,4 +70,6 @@ public class ExportPaperController {
|
|
log.info("导出结束");
|
|
log.info("导出结束");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|