Browse Source

结构复用

weiwenhai 8 years ago
parent
commit
459c72d0d5

+ 165 - 161
cqb-paper/src/main/java/com/qmth/cqb/paper/model/ExportStructure.java

@@ -1,161 +1,165 @@
-package com.qmth.cqb.paper.model;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
-
-import org.springframework.data.annotation.Id;
-
-import com.qmth.cqb.paper.dto.ExportPaperInfoModel;
-import com.qmth.cqb.utils.enums.ExportType;
-
-import cn.com.qmth.examcloud.common.dto.em.enums.ExamType;
-
-/**
- * @author  	chenken
- * @date    	2017年7月12日 下午3:45:08
- * @company 	QMTH
- * @description 导出结构设置
- */
-public class ExportStructure implements Serializable{
-
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = -2710169914864126547L;
-	
-	@Id	
-	private String id;
-	/**
-	 * 考试类型
-	 */
-	private ExamType examType;
-	/**
-	 * 考试ID
-	 */
-	private String examId;
-	/**
-	 * 考试名称
-	 */
-	private String examName;
-	/**
-	 * 导出 类型
-	 */
-	private ExportType exportType;
-	
-	private List<QuestionTypeNum> questionTypeNums;
-	/**
-	 * 是否可用
-	 */
-	private Short useable;
-	
-	private String createUser;
-
-    private Date createTime;
-    
-    private String updateUser;
-
-    private Date updateTime;
-
-    public ExportStructure(){}
-    
-    public ExportStructure(String examId,ExamType examType){
-    	this.examId = examId;
-    	this.examType = examType;
-    }
-    
-    public ExportStructure(ExportPaperInfoModel exportModel){
-    	this.examId = exportModel.getExamId();
-    	this.examType = exportModel.getExamType();
-    }
-    
-	public String getId() {
-		return id;
-	}
-
-	public void setId(String id) {
-		this.id = id;
-	}
-
-	public ExamType getExamType() {
-		return examType;
-	}
-
-	public void setExamType(ExamType examType) {
-		this.examType = examType;
-	}
-
-	public String getExamName() {
-		return examName;
-	}
-
-	public void setExamName(String examName) {
-		this.examName = examName;
-	}
-
-	public ExportType getExportType() {
-		return exportType;
-	}
-
-	public void setExportType(ExportType exportType) {
-		this.exportType = exportType;
-	}
-
-	public Short getUseable() {
-		return useable;
-	}
-
-	public void setUseable(Short useable) {
-		this.useable = useable;
-	}
-
-	public String getCreateUser() {
-		return createUser;
-	}
-
-	public void setCreateUser(String createUser) {
-		this.createUser = createUser;
-	}
-
-	public Date getCreateTime() {
-		return createTime;
-	}
-
-	public void setCreateTime(Date createTime) {
-		this.createTime = createTime;
-	}
-
-	public String getUpdateUser() {
-		return updateUser;
-	}
-
-	public void setUpdateUser(String updateUser) {
-		this.updateUser = updateUser;
-	}
-
-	public Date getUpdateTime() {
-		return updateTime;
-	}
-
-	public void setUpdateTime(Date updateTime) {
-		this.updateTime = updateTime;
-	}
-
-	public String getExamId() {
-		return examId;
-	}
-
-	public void setExamId(String examId) {
-		this.examId = examId;
-	}
-	
-	public List<QuestionTypeNum> getQuestionTypeNums() {
-		return questionTypeNums;
-	}
-
-	public void setQuestionTypeNums(List<QuestionTypeNum> questionTypeNums) {
-		this.questionTypeNums = questionTypeNums;
-	}
-	
-}
-
+package com.qmth.cqb.paper.model;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+import org.springframework.data.annotation.Id;
+
+import com.qmth.cqb.paper.dto.ExportPaperInfoModel;
+import com.qmth.cqb.utils.enums.ExportType;
+
+import cn.com.qmth.examcloud.common.dto.em.enums.ExamType;
+
+/**
+ * @author  	chenken
+ * @date    	2017年7月12日 下午3:45:08
+ * @company 	QMTH
+ * @description 导出结构设置
+ */
+public class ExportStructure implements Serializable{
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -2710169914864126547L;
+	
+	@Id	
+	private String id;
+	/**
+	 * 考试类型
+	 */
+	private ExamType examType;
+	/**
+	 * 考试ID
+	 */
+	private String examId;
+	/**
+	 * 考试名称
+	 */
+	private String examName;
+	/**
+	 * 导出 类型
+	 */
+	private ExportType exportType;
+	
+	private List<QuestionTypeNum> questionTypeNums;
+	/**
+	 * 是否可用
+	 */
+	private Short useable;
+	
+	private String createUser;
+
+    private Date createTime;
+    
+    private String updateUser;
+
+    private Date updateTime;
+
+    public ExportStructure(){}
+    
+    public ExportStructure(ExamType examType){
+    	this.examType = examType;
+    }
+    
+    public ExportStructure(String examId,ExamType examType){
+    	this.examId = examId;
+    	this.examType = examType;
+    }
+    
+    public ExportStructure(ExportPaperInfoModel exportModel){
+    	this.examId = exportModel.getExamId();
+    	this.examType = exportModel.getExamType();
+    }
+    
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public ExamType getExamType() {
+		return examType;
+	}
+
+	public void setExamType(ExamType examType) {
+		this.examType = examType;
+	}
+
+	public String getExamName() {
+		return examName;
+	}
+
+	public void setExamName(String examName) {
+		this.examName = examName;
+	}
+
+	public ExportType getExportType() {
+		return exportType;
+	}
+
+	public void setExportType(ExportType exportType) {
+		this.exportType = exportType;
+	}
+
+	public Short getUseable() {
+		return useable;
+	}
+
+	public void setUseable(Short useable) {
+		this.useable = useable;
+	}
+
+	public String getCreateUser() {
+		return createUser;
+	}
+
+	public void setCreateUser(String createUser) {
+		this.createUser = createUser;
+	}
+
+	public Date getCreateTime() {
+		return createTime;
+	}
+
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+	public String getUpdateUser() {
+		return updateUser;
+	}
+
+	public void setUpdateUser(String updateUser) {
+		this.updateUser = updateUser;
+	}
+
+	public Date getUpdateTime() {
+		return updateTime;
+	}
+
+	public void setUpdateTime(Date updateTime) {
+		this.updateTime = updateTime;
+	}
+
+	public String getExamId() {
+		return examId;
+	}
+
+	public void setExamId(String examId) {
+		this.examId = examId;
+	}
+	
+	public List<QuestionTypeNum> getQuestionTypeNums() {
+		return questionTypeNums;
+	}
+
+	public void setQuestionTypeNums(List<QuestionTypeNum> questionTypeNums) {
+		this.questionTypeNums = questionTypeNums;
+	}
+	
+}
+

+ 57 - 49
cqb-paper/src/main/java/com/qmth/cqb/paper/service/ExportStructureService.java

@@ -1,49 +1,57 @@
-package com.qmth.cqb.paper.service;
-
-import java.util.Map;
-
-import org.springframework.data.domain.Page;
-
-import cn.com.qmth.examcloud.common.dto.em.enums.ExamType;
-import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
-
-import com.qmth.cqb.paper.model.ExportStructure;
-
-/**
- * @author  	chenken
- * @date    	2017年7月12日 下午4:26:36
- * @company 	QMTH
- * @description ExportStructureService.java
- */
-public interface ExportStructureService {
-	
-	/**
-	 * 保存导出结构
-	 * @param exportStructure
-	 */
-	public void saveExportStructure(ExportStructure exportStructure,AccessUser user);
-	/**
-	 * 查询导出结构
-	 * @param exportStructure
-	 * @return
-	 */
-	public ExportStructure findByExportStructure(ExportStructure exportStructure);
-	/**
-	 * 分页查询
-	 * @param exportStructure
-	 * @param curPage
-	 * @param pageSize
-	 * @return
-	 */
-	public Page<ExportStructure> findPageByExportStructure(ExportStructure exportStructure,int curPage,int pageSize);
-	/**
-	 * 根据考试类型和考试ID查询结构
-	 * 如果结构存在、判断结构设置是否完整
-	 * 是否完整是指 客观题题数是否都设置过了
-	 * @param examId
-	 * @param examType
-	 * @return
-	 */
-	public Map<String,Object> findStructureByExamIdAndExamType(String examId,ExamType examType);
-}
-
+package com.qmth.cqb.paper.service;
+
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.data.domain.Page;
+
+import cn.com.qmth.examcloud.common.dto.em.enums.ExamType;
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
+
+import com.qmth.cqb.paper.model.ExportStructure;
+
+/**
+ * @author  	chenken
+ * @date    	2017年7月12日 下午4:26:36
+ * @company 	QMTH
+ * @description ExportStructureService.java
+ */
+public interface ExportStructureService {
+	
+	/**
+	 * 保存导出结构
+	 * @param exportStructure
+	 */
+	public void saveExportStructure(ExportStructure exportStructure,AccessUser user);
+	/**
+	 * 查询导出结构
+	 * @param exportStructure
+	 * @return
+	 */
+	public ExportStructure findByExportStructure(ExportStructure exportStructure);
+	/**
+	 * 分页查询
+	 * @param exportStructure
+	 * @param curPage
+	 * @param pageSize
+	 * @return
+	 */
+	public Page<ExportStructure> findPageByExportStructure(ExportStructure exportStructure,int curPage,int pageSize);
+	/**
+	 * 根据考试类型和考试ID查询结构
+	 * 如果结构存在、判断结构设置是否完整
+	 * 是否完整是指 客观题题数是否都设置过了
+	 * @param examId
+	 * @param examType
+	 * @return
+	 */
+	public Map<String,Object> findStructureByExamIdAndExamType(String examId,ExamType examType);
+	
+	/**
+	 * 根据考试类型查询考试id
+	 * @param examType
+	 * @return
+	 */
+	public List<String> findExportStructureByExamType(String examType);
+}
+

+ 102 - 88
cqb-paper/src/main/java/com/qmth/cqb/paper/service/impl/ExportStructureServiceImpl.java

@@ -1,88 +1,102 @@
-package com.qmth.cqb.paper.service.impl;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Example;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.stereotype.Service;
-
-import cn.com.qmth.examcloud.common.dto.em.enums.ExamType;
-import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
-
-import com.qmth.cqb.paper.dao.ExportStructureRepo;
-import com.qmth.cqb.paper.model.ExportStructure;
-import com.qmth.cqb.paper.model.QuestionTypeNum;
-import com.qmth.cqb.paper.service.ExportStructureService;
-import com.qmth.cqb.utils.enums.ExportType;
-
-/**
- * @author  	chenken
- * @date    	2017年7月12日 下午4:26:49
- * @company 	QMTH
- * @description 导出试卷结构设置
- */
-@Service("exportStructureService")
-public class ExportStructureServiceImpl implements ExportStructureService {
-
-	@Autowired
-	private ExportStructureRepo exportStructureRepo;
-	
-	@Override
-	public void saveExportStructure(ExportStructure exportStructure,AccessUser user) {
-		if(StringUtils.isBlank(exportStructure.getId())){
-			exportStructure.setCreateUser(user.getName());
-			exportStructure.setCreateTime(new Date());
-		}else{
-			exportStructure.setUpdateUser(user.getName());
-			exportStructure.setUpdateTime(new Date());
-		}
-		exportStructureRepo.save(exportStructure);
-	}
-
-	@Override
-	public ExportStructure findByExportStructure(ExportStructure exportStructure) {
-		List<ExportStructure> exportStructures = exportStructureRepo.findAll(Example.of(exportStructure));
-		if(exportStructures.size()>0){
-			return exportStructures.get(0);
-		}
-		return null;
-	}
-
-	@Override
-	public Page<ExportStructure> findPageByExportStructure(ExportStructure exportStructure, int curPage, int pageSize) {
-		Page<ExportStructure> list = exportStructureRepo.findAll(Example.of(exportStructure), new PageRequest(curPage - 1, pageSize));
-		return list;
-	}
-
-	@Override
-	public Map<String, Object> findStructureByExamIdAndExamType(String examId,ExamType examType) {
-		Map<String, Object> returnMap = new HashMap<String, Object>();
-		ExportStructure exportStructure = findByExportStructure(new ExportStructure(examId,examType));
-		if(exportStructure==null){
-			returnMap.put("returnMsg", "no_structure");
-			return returnMap;
-		}
-		if(exportStructure.getExportType()==ExportType.NORMAL){
-			List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-			for(QuestionTypeNum questionTypeNum:questionTypeNums){
-				if(questionTypeNum.getQuantity()==null){
-					//结构设置不完整
-					returnMap.put("returnMsg", "structure_imperfect");
-					return returnMap;
-				}
-			}
-		}
-		returnMap.put("exportStructure",exportStructure);
-		return returnMap;
-	}
-	
-	
-	
-}
-
+package com.qmth.cqb.paper.service.impl;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.stereotype.Service;
+
+import cn.com.qmth.examcloud.common.dto.em.enums.ExamType;
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
+
+import com.qmth.cqb.paper.dao.ExportStructureRepo;
+import com.qmth.cqb.paper.model.ExportStructure;
+import com.qmth.cqb.paper.model.QuestionTypeNum;
+import com.qmth.cqb.paper.service.ExportStructureService;
+import com.qmth.cqb.utils.enums.ExportType;
+
+/**
+ * @author  	chenken
+ * @date    	2017年7月12日 下午4:26:49
+ * @company 	QMTH
+ * @description 导出试卷结构设置
+ */
+@Service("exportStructureService")
+public class ExportStructureServiceImpl implements ExportStructureService {
+
+	@Autowired
+	private ExportStructureRepo exportStructureRepo;
+	
+	@Override
+	public void saveExportStructure(ExportStructure exportStructure,AccessUser user) {
+		if(StringUtils.isBlank(exportStructure.getId())){
+			exportStructure.setCreateUser(user.getName());
+			exportStructure.setCreateTime(new Date());
+		}else{
+			exportStructure.setUpdateUser(user.getName());
+			exportStructure.setUpdateTime(new Date());
+		}
+		exportStructureRepo.save(exportStructure);
+	}
+
+	@Override
+	public ExportStructure findByExportStructure(ExportStructure exportStructure) {
+		List<ExportStructure> exportStructures = exportStructureRepo.findAll(Example.of(exportStructure));
+		if(exportStructures.size()>0){
+			return exportStructures.get(0);
+		}
+		return null;
+	}
+
+	@Override
+	public Page<ExportStructure> findPageByExportStructure(ExportStructure exportStructure, int curPage, int pageSize) {
+		Page<ExportStructure> list = exportStructureRepo.findAll(Example.of(exportStructure), new PageRequest(curPage - 1, pageSize));
+		return list;
+	}
+
+	@Override
+	public Map<String, Object> findStructureByExamIdAndExamType(String examId,ExamType examType) {
+		Map<String, Object> returnMap = new HashMap<String, Object>();
+		ExportStructure exportStructure = findByExportStructure(new ExportStructure(examId,examType));
+		if(exportStructure==null){
+			returnMap.put("returnMsg", "no_structure");
+			return returnMap;
+		}
+		if(exportStructure.getExportType()==ExportType.NORMAL){
+			List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+			for(QuestionTypeNum questionTypeNum:questionTypeNums){
+				if(questionTypeNum.getQuantity()==null){
+					//结构设置不完整
+					returnMap.put("returnMsg", "structure_imperfect");
+					return returnMap;
+				}
+			}
+		}
+		returnMap.put("exportStructure",exportStructure);
+		return returnMap;
+	}
+
+	@Override
+	public List<String> findExportStructureByExamType(String examType) {
+		List<ExportStructure> exportStructures = exportStructureRepo.findAll(Example.of(new ExportStructure(ExamType.strToEnum(examType))));
+		if(exportStructures.size()>0){
+			List<String> list = new ArrayList<String>();
+			for(int i=0;i<exportStructures.size();i++){
+				list.add(exportStructures.get(i).getExamId());
+			}
+			return list;
+		}
+		return null;
+	}
+	
+	
+	
+}
+

+ 79 - 61
cqb-paper/src/main/java/com/qmth/cqb/paper/web/ExportStructureController.java

@@ -1,61 +1,79 @@
-package com.qmth.cqb.paper.web;
-
-import javax.servlet.http.HttpServletRequest;
-
-import io.swagger.annotations.ApiOperation;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
-
-import com.qmth.cqb.paper.model.ExportStructure;
-import com.qmth.cqb.paper.service.ExportStructureService;
-
-/**
- * @author  	chenken
- * @date    	2017年7月12日 下午4:28:55
- * @company 	QMTH
- * @description ExportStructureController.java
- */
-@Controller
-@RequestMapping("${api_cqb}/")
-public class ExportStructureController {
-	
-	@Autowired
-	private ExportStructureService exportStructureService;
-	
-	@ApiOperation(value = "保存导出结构", notes = "保存导出结构")
-    @PostMapping(value = "/saveExportStructure")
-	public ResponseEntity saveExportStructure(HttpServletRequest request,@RequestBody ExportStructure exportStructure){
-		try{
-			AccessUser user = (AccessUser) request.getAttribute("accessUser");
-			exportStructureService.saveExportStructure(exportStructure,user);
-			return new ResponseEntity(HttpStatus.OK);
-		}catch(Exception e){
-			return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
-		}
-	}
-	
-	@ApiOperation(value = "分页查询导出结构", notes = "分页查询导出结构")
-    @PostMapping(value = "/findPageByExportStructure/{curPage}/{pageSize}")
-	public ResponseEntity findPageByExportStructure(@PathVariable int curPage,
-													@PathVariable int pageSize,
-													@RequestBody ExportStructure exportStructure){
-		try{
-			Page<ExportStructure> pageExportStructure = exportStructureService.findPageByExportStructure(exportStructure, curPage, pageSize);
-			return new ResponseEntity(pageExportStructure,HttpStatus.OK);
-		}catch(Exception e){
-			return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
-		}
-	}
-	
-}
-
+package com.qmth.cqb.paper.web;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import io.swagger.annotations.ApiOperation;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import cn.com.qmth.examcloud.common.dto.em.enums.ExamType;
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
+
+import com.qmth.cqb.paper.model.ExportStructure;
+import com.qmth.cqb.paper.service.ExportStructureService;
+
+/**
+ * @author  	chenken
+ * @date    	2017年7月12日 下午4:28:55
+ * @company 	QMTH
+ * @description ExportStructureController.java
+ */
+@Controller
+@RequestMapping("${api_cqb}/")
+public class ExportStructureController {
+	
+	@Autowired
+	private ExportStructureService exportStructureService;
+	
+	@ApiOperation(value = "保存导出结构", notes = "保存导出结构")
+    @PostMapping(value = "/saveExportStructure")
+	public ResponseEntity saveExportStructure(HttpServletRequest request,@RequestBody ExportStructure exportStructure){
+		try{
+			AccessUser user = (AccessUser) request.getAttribute("accessUser");
+			exportStructureService.saveExportStructure(exportStructure,user);
+			return new ResponseEntity(HttpStatus.OK);
+		}catch(Exception e){
+			return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
+		}
+	}
+	
+	@ApiOperation(value = "分页查询导出结构", notes = "分页查询导出结构")
+    @PostMapping(value = "/findPageByExportStructure/{curPage}/{pageSize}")
+	public ResponseEntity findPageByExportStructure(@PathVariable int curPage,
+													@PathVariable int pageSize,
+													@RequestBody ExportStructure exportStructure){
+		try{
+			Page<ExportStructure> pageExportStructure = exportStructureService.findPageByExportStructure(exportStructure, curPage, pageSize);
+			return new ResponseEntity(pageExportStructure,HttpStatus.OK);
+		}catch(Exception e){
+			return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
+		}
+	}
+	
+	@ApiOperation(value="根据考试类型和考试名称查询导出结构",notes="根据考试类型和考试名称查询导出结构")
+	@GetMapping(value="/findExportStructureByExamTypeAndExamId/{examType}/{examId}")
+	public ResponseEntity findExportStructureByExamTypeAndExamId(@PathVariable String examType,
+																 @PathVariable String examId){
+		ExportStructure exportStructure = exportStructureService.findByExportStructure(new ExportStructure(examId,ExamType.strToEnum(examType)));
+		return new ResponseEntity(exportStructure,HttpStatus.OK);
+	}
+	
+	@ApiOperation(value="根据考试类型查询考试id",notes="根据考试类型查询考试id")
+	@GetMapping(value="/findExportStructureByExamType/{examType}")
+	public ResponseEntity findExportStructureByExamType(@PathVariable String examType){
+		List<String> list = exportStructureService.findExportStructureByExamType(examType);
+		return new ResponseEntity(list,HttpStatus.OK);
+	}
+}
+