فهرست منبع

添加卷库题库,重构题库

gaoxing 8 سال پیش
والد
کامیت
5d148dabea
58فایلهای تغییر یافته به همراه2843 افزوده شده و 197 حذف شده
  1. 3 1
      cqb-base/src/main/java/com/qmth/cqb/base/dao/CourseRepo.java
  2. 1 0
      cqb-base/src/main/java/com/qmth/cqb/base/dao/QuesTypeRepo.java
  3. 2 0
      cqb-base/src/main/java/com/qmth/cqb/base/dao/RoleRepo.java
  4. 64 0
      cqb-base/src/main/java/com/qmth/cqb/base/service/CourseService.java
  5. 66 0
      cqb-base/src/main/java/com/qmth/cqb/base/service/QuesTypeService.java
  6. 87 1
      cqb-base/src/main/java/com/qmth/cqb/base/web/CourseController.java
  7. 85 1
      cqb-base/src/main/java/com/qmth/cqb/base/web/QuesTypeController.java
  8. 1 1
      cqb-base/src/main/java/com/qmth/cqb/base/web/RoleController.java
  9. 1 1
      cqb-base/src/main/java/com/qmth/cqb/base/web/UserController.java
  10. 12 0
      cqb-comm-utils/pom.xml
  11. 3 0
      cqb-gen-paper/src/main/java/com/qmth/cqb/genpaper/service/GenPaperService.java
  12. 10 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/dao/ExamPaperRepo.java
  13. 11 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/dao/ExtractConfigRepo.java
  14. 9 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/dao/PaperDetailRepo.java
  15. 12 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/dao/PaperDetailStructureRepo.java
  16. 11 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/dao/PaperDetailUnitRepo.java
  17. 10 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/dao/PaperRepo.java
  18. 12 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/dao/PaperStructureRepo.java
  19. 67 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/model/ExamPaper.java
  20. 58 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/model/ExtractConfig.java
  21. 147 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/model/Paper.java
  22. 96 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/model/PaperDetail.java
  23. 100 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/model/PaperDetailStructure.java
  24. 97 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/model/PaperDetailUnit.java
  25. 67 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/model/PaperStructure.java
  26. 59 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/ExtractService.java
  27. 77 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/ImportPaperService.java
  28. 76 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/PaperDetailService.java
  29. 63 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/PaperDetailStructureService.java
  30. 77 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/PaperDetailUnitService.java
  31. 138 13
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/PaperService.java
  32. 50 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/PaperStructureService.java
  33. 47 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/web/ExtractController.java
  34. 96 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/web/ImportPaperController.java
  35. 121 16
      cqb-paper/src/main/java/com/qmth/cqb/paper/web/PaperController.java
  36. 92 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/web/PaperDetailController.java
  37. 81 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/web/PaperDetailStructureController.java
  38. 90 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/web/PaperDetailUnitController.java
  39. 92 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/web/PaperStructureController.java
  40. 9 0
      cqb-question/src/main/java/com/qmth/cqb/question/dao/QuesOptionRepo.java
  41. 2 2
      cqb-question/src/main/java/com/qmth/cqb/question/dao/QuestionTypeRepo.java
  42. 51 38
      cqb-question/src/main/java/com/qmth/cqb/question/model/ImportPaper.java
  43. 60 0
      cqb-question/src/main/java/com/qmth/cqb/question/model/ImportPaperSearchCondition.java
  44. 0 62
      cqb-question/src/main/java/com/qmth/cqb/question/model/QuesStructType.java
  45. 5 5
      cqb-question/src/main/java/com/qmth/cqb/question/model/Question.java
  46. 60 0
      cqb-question/src/main/java/com/qmth/cqb/question/model/QuestionSearchCondition.java
  47. 76 0
      cqb-question/src/main/java/com/qmth/cqb/question/model/QuestionType.java
  48. 18 8
      cqb-question/src/main/java/com/qmth/cqb/question/service/ImportPaperService.java
  49. 15 13
      cqb-question/src/main/java/com/qmth/cqb/question/service/QuesService.java
  50. 9 9
      cqb-question/src/main/java/com/qmth/cqb/question/service/QuesStructTypeService.java
  51. 104 10
      cqb-question/src/main/java/com/qmth/cqb/question/web/ImportPaperController.java
  52. 110 4
      cqb-question/src/main/java/com/qmth/cqb/question/web/QuesController.java
  53. 0 10
      cqb-question/src/main/java/com/qmth/cqb/question/web/QuesStructTypeController.java
  54. 83 0
      cqb-question/src/main/java/com/qmth/cqb/question/web/QuestionTypeController.java
  55. 1 0
      cqb-starter/.gitignore
  56. 12 0
      cqb-starter/pom.xml
  57. 34 0
      cqb-starter/src/main/java/com/qmth/cqb/Swagger2.java
  58. 3 2
      cqb-starter/src/main/resources/application.properties

+ 3 - 1
cqb-base/src/main/java/com/qmth/cqb/base/dao/CourseRepo.java

@@ -1,6 +1,7 @@
 package com.qmth.cqb.base.dao;
 
 import com.qmth.cqb.base.model.Course;
+
 import org.springframework.data.mongodb.repository.MongoRepository;
 import org.springframework.data.repository.query.QueryByExampleExecutor;
 
@@ -8,4 +9,5 @@ import org.springframework.data.repository.query.QueryByExampleExecutor;
  * Created by songyue on 16/12/26.
  */
 public interface CourseRepo extends MongoRepository<Course, String>,QueryByExampleExecutor<Course> {
-}
+    Course findByCourseName(String loginName);
+}

+ 1 - 0
cqb-base/src/main/java/com/qmth/cqb/base/dao/QuesTypeRepo.java

@@ -8,4 +8,5 @@ import org.springframework.data.repository.query.QueryByExampleExecutor;
  * Created by songyue on 16/12/26.
  */
 public interface QuesTypeRepo extends MongoRepository<QuesType,String>,QueryByExampleExecutor<QuesType> {
+	QuesType findByTypeName(String typeName);
 }

+ 2 - 0
cqb-base/src/main/java/com/qmth/cqb/base/dao/RoleRepo.java

@@ -10,3 +10,5 @@ import org.springframework.data.repository.query.QueryByExampleExecutor;
 public interface RoleRepo extends MongoRepository<Role,String>,QueryByExampleExecutor<Role> {
     Role findById(String id);
 }
+ 
+

+ 64 - 0
cqb-base/src/main/java/com/qmth/cqb/base/service/CourseService.java

@@ -1,11 +1,75 @@
 package com.qmth.cqb.base.service;
 
+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.data.mongodb.core.MongoTemplate;
+import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
 
+import com.qmth.cqb.base.dao.CourseRepo;
+import com.qmth.cqb.base.model.Course;
+import com.qmth.cqb.utils.modal.NormalResponse;
+import com.qmth.cqb.utils.modal.PagingAndSortingResponse;
+
 /**
  * Created by songyue on 16/12/28.
  */
 @Service
 public class CourseService {
+	
+	@Autowired
+	CourseRepo courseRepo;
+	
+    @Autowired
+    MongoTemplate mongoTemplate;
+    
+    /**
+     * 查询所有课程
+     * @param searchCondition
+     * @param curPage
+     * @param pageSize
+     * @return
+     */
+    public PagingAndSortingResponse<Course> findAll(Course searchCondition, int curPage, int pageSize){
+        Page<Course> courseList = courseRepo.findAll(Example.of(searchCondition),new PageRequest(curPage-1,pageSize));
+        return new PagingAndSortingResponse<Course>(courseList.getNumber(),courseList.getSize(),
+        		courseList.getTotalPages(),courseList.getTotalElements(),courseList.getContent());
+    }
+
+    
+    /**
+     * 保存课程
+     * @param course
+     * @return
+     */
+    public NormalResponse saveCourse(Course course){
+    	Course tempCourse = courseRepo.save(course);
+        if(tempCourse != null){
+            return new NormalResponse(HttpStatus.OK.toString(),"success");
+        }else{
+            return new NormalResponse(HttpStatus.INTERNAL_SERVER_ERROR.toString(),"保存失败");
+        }
+    }
+    
+    /**
+     * 删除课程
+     * @param courseId
+     * @return
+     */
+    public NormalResponse deleteCourse(String courseId){
+    	courseRepo.delete(courseId);
+        return new NormalResponse(HttpStatus.OK.toString(),"success");
+    }
 
+    
+    /**
+     * 根据课程名称查找课程
+     * @param typeId
+     * @return
+     */
+    public Course findById(String courseName){
+        return courseRepo.findByCourseName(courseName);
+    }
 }

+ 66 - 0
cqb-base/src/main/java/com/qmth/cqb/base/service/QuesTypeService.java

@@ -1,10 +1,76 @@
 package com.qmth.cqb.base.service;
 
+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.data.mongodb.core.MongoTemplate;
+import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
 
+import com.qmth.cqb.base.dao.QuesTypeRepo;
+import com.qmth.cqb.base.model.QuesType;
+import com.qmth.cqb.utils.modal.NormalResponse;
+import com.qmth.cqb.utils.modal.PagingAndSortingResponse;
+
 /**
  * Created by songyue on 16/12/28.
  */
 @Service
 public class QuesTypeService {
+	
+	@Autowired
+	QuesTypeRepo quesTypeRepo;
+	
+    @Autowired
+    MongoTemplate mongoTemplate;
+    
+    /**
+     * 查询所题型
+     * @param searchCondition
+     * @param curPage
+     * @param pageSize
+     * @return
+     */
+    public PagingAndSortingResponse<QuesType> findAll(QuesType searchCondition, int curPage, int pageSize){
+        Page<QuesType> quesTypeList = quesTypeRepo.findAll(Example.of(searchCondition),new PageRequest(curPage-1,pageSize));
+        return new PagingAndSortingResponse<QuesType>(quesTypeList.getNumber(),quesTypeList.getSize(),
+        		quesTypeList.getTotalPages(),quesTypeList.getTotalElements(),quesTypeList.getContent());
+    }
+
+    
+    /**
+     * 保存题型
+     * @param quesType
+     * @return
+     */
+    public QuesType saveQuesType(QuesType quesType){
+    	QuesType tempPaper = quesTypeRepo.save(quesType);
+    	return tempPaper;
+//        if(tempPaper != null){
+//            return new NormalResponse(HttpStatus.OK.toString(),"success");
+//        }else{
+//            return new NormalResponse(HttpStatus.INTERNAL_SERVER_ERROR.toString(),"保存失败");
+//        }
+    }
+    
+    /**
+     * 删除题型
+     * @param quesTypeId
+     * @return
+     */
+    public NormalResponse deleteQuesType(String quesTypeId){
+    	quesTypeRepo.delete(quesTypeId);
+        return new NormalResponse(HttpStatus.OK.toString(),"success");
+    }
+    
+    /**
+     * 根据课程名称查找题型
+     * @param typeId
+     * @return
+     */
+    public QuesType findByName(String typeName){
+        return quesTypeRepo.findByTypeName(typeName);
+    }
+
 }

+ 87 - 1
cqb-base/src/main/java/com/qmth/cqb/base/web/CourseController.java

@@ -1,10 +1,96 @@
 package com.qmth.cqb.base.web;
 
+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.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.google.gson.Gson;
+import com.qmth.cqb.base.dao.CourseRepo;
+import com.qmth.cqb.base.model.Course;
+import com.qmth.cqb.base.model.Role;
+import com.qmth.cqb.base.service.CourseService;
+import com.qmth.cqb.utils.modal.NormalResponse;
+import com.qmth.cqb.utils.modal.PagingAndSortingResponse;
 
 /**
  * Created by songyue on 16/12/26.
  */
-@Controller
+
+@RestController
+@RequestMapping("${api_cqb}/")
 public class CourseController {
+    @Autowired
+    Gson gson;
+    
+    @Autowired
+    CourseRepo courseRepo;
+
+    @Autowired
+    CourseService courseService;
+
+
+    /**
+     * 获取全部课程
+     * @return
+     */
+    @GetMapping(value = "/course/all/{curPage}/{paseSize}")
+    public PagingAndSortingResponse<Course> getAllCourse(@ModelAttribute Course searchCondition, @PathVariable int curPage, @PathVariable int pageSize){
+        //return courseService.findAll(searchCondition,new PageRequest(curPage - 1,pageSize));
+        Page<Course> courseList = courseRepo.findAll(Example.of(searchCondition),new PageRequest(curPage-1,pageSize));
+        return new PagingAndSortingResponse<Course>(courseList.getNumber(),courseList.getSize(),
+        		courseList.getTotalPages(),courseList.getTotalElements(),courseList.getContent());
+    }
+
+    /**
+     * 更新课程
+     * @param user
+     * @return
+     */
+    @PutMapping(value = "/course")
+    public NormalResponse updateCourse(@ModelAttribute Course course){
+    	return courseService.saveCourse(course);
+    }
+
+    /**
+     * 新增课程
+     * @param course
+     * @return
+     */
+    @PostMapping(value = "/course")
+    public NormalResponse addCourse(@ModelAttribute Course course){
+    	return courseService.saveCourse(course);
+    }
+
+    /**
+     * 删除课程
+     * @param 课程ID coruse_id
+     * @return
+     */
+    @DeleteMapping(value = "/course/{coruse_id}")
+    public NormalResponse removeCourse(@PathVariable String coruse_id){
+    	return courseService.deleteCourse(coruse_id);
+    }
+    
+    /**
+     * 根据课程名称获取课程信息
+     * @param courseName
+     * @return
+     */
+    @GetMapping(value = "/course/{course_name}")
+    public Course getCourseByName(@PathVariable String course_name){
+        return courseService.findById(course_name);
+    }
+
 }

+ 85 - 1
cqb-base/src/main/java/com/qmth/cqb/base/web/QuesTypeController.java

@@ -1,10 +1,94 @@
 package com.qmth.cqb.base.web;
 
+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.http.HttpStatus;
 import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.google.gson.Gson;
+import com.qmth.cqb.base.dao.QuesTypeRepo;
+import com.qmth.cqb.base.model.QuesType;
+import com.qmth.cqb.base.service.QuesTypeService;
+import com.qmth.cqb.utils.modal.NormalResponse;
+import com.qmth.cqb.utils.modal.PagingAndSortingResponse;
 
 /**
  * Created by songyue on 16/12/26.
  */
-@Controller
+@RestController
+@RequestMapping("${api_cqb}/")
 public class QuesTypeController {
+	
+    @Autowired
+    QuesTypeRepo quesTypeRepo;
+
+    @Autowired
+    Gson gson;
+    
+
+    @Autowired
+    QuesTypeService quesTypeService;
+
+
+    /**
+     * 获取全部题型
+     * @return
+     */
+    @GetMapping(value = "/quesType/all/{curPage}/{paseSize}")
+    public PagingAndSortingResponse<QuesType> getAllQuesType(@ModelAttribute QuesType searchCondition, @PathVariable int curPage, @PathVariable int pageSize){
+    	 return quesTypeService.findAll(searchCondition,curPage, pageSize);
+    }
+
+    /**
+     * 更新题型
+     * @param user
+     * @return
+     */
+    @PutMapping(value = "/quesType")
+    public NormalResponse updateQuesType(@ModelAttribute QuesType quesType){
+    	quesTypeService.saveQuesType(quesType);
+        return new NormalResponse(HttpStatus.OK.toString(),"success");
+    }
+
+    /**
+     * 新增题型
+     * @param quesType
+     * @return
+     */
+    @PostMapping(value = "/quesType")
+    public NormalResponse addQuesType(@ModelAttribute QuesType quesType){
+	    quesTypeService.saveQuesType(quesType);
+	    return new NormalResponse(HttpStatus.OK.toString(),"success");
+    }
+
+    /**
+     * 删除题型
+     * @param 题型ID quesType_id
+     * @return
+     */
+    @DeleteMapping(value = "/quesType/{quesType_id}")
+    //ResponseEntity
+    public NormalResponse removeQuesType(@PathVariable String quesType_id){
+    	return quesTypeService.deleteQuesType(quesType_id);
+    }
+    
+    /**
+     * 根据题型名称获取题型信息
+     * @param quesTypeName
+     * @return
+     */
+    @GetMapping(value = "/quesType/{quesType_name}")
+    public QuesType getQuesTypeByName(@PathVariable String quesType_name){
+        return quesTypeService.findByName(quesType_name);
+    }
 }

+ 1 - 1
cqb-base/src/main/java/com/qmth/cqb/base/web/RoleController.java

@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.*;
  * Created by songyue on 16/12/26.
  */
 @RestController
-@RequestMapping("/")
+@RequestMapping("${api_cqb}/")
 public class RoleController {
     @Autowired
     Gson gson;

+ 1 - 1
cqb-base/src/main/java/com/qmth/cqb/base/web/UserController.java

@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.*;
  * Created by songyue on 16/12/26.
  */
 @RestController
-@RequestMapping("/")
+@RequestMapping("${api_cqb}/")
 public class UserController {
     @Autowired
     Gson gson;

+ 12 - 0
cqb-comm-utils/pom.xml

@@ -33,6 +33,18 @@
             <artifactId>spring-boot-starter-data-mongodb</artifactId>
         </dependency>
 
+     <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>2.6.1</version>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>2.6.1</version>
+        </dependency>
+
+
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>

+ 3 - 0
cqb-gen-paper/src/main/java/com/qmth/cqb/genpaper/service/GenPaperService.java

@@ -11,4 +11,7 @@ import org.springframework.stereotype.Service;
 public class GenPaperService {
     @Autowired
     GenPaperRepo genPaperRepo;
+    
+    
+    
 }

+ 10 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/dao/ExamPaperRepo.java

@@ -0,0 +1,10 @@
+package com.qmth.cqb.paper.dao;
+
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import com.qmth.cqb.paper.model.ExamPaper;
+
+public interface ExamPaperRepo extends MongoRepository<ExamPaper, Long>,QueryByExampleExecutor<ExamPaper> {
+
+}

+ 11 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/dao/ExtractConfigRepo.java

@@ -0,0 +1,11 @@
+package com.qmth.cqb.paper.dao;
+
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import com.qmth.cqb.paper.model.ExamPaper;
+import com.qmth.cqb.paper.model.ExtractConfig;
+
+public interface ExtractConfigRepo extends MongoRepository<ExtractConfig, Long>,QueryByExampleExecutor<ExtractConfig> {
+
+}

+ 9 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/dao/PaperDetailRepo.java

@@ -0,0 +1,9 @@
+package com.qmth.cqb.paper.dao;
+
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+import com.qmth.cqb.paper.model.PaperDetail;
+
+public interface PaperDetailRepo extends MongoRepository<PaperDetail, String>,QueryByExampleExecutor<PaperDetail> {
+	//PaperDetail findByNumber(int number);
+}

+ 12 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/dao/PaperDetailStructureRepo.java

@@ -0,0 +1,12 @@
+package com.qmth.cqb.paper.dao;
+
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import com.qmth.cqb.paper.model.PaperDetailStructure;
+import com.qmth.cqb.paper.model.PaperDetailUnit;
+
+
+public interface PaperDetailStructureRepo extends MongoRepository<PaperDetailStructure, String>,QueryByExampleExecutor<PaperDetailStructure> {
+	//PaperDetailStructure findByNumber(int number);
+}

+ 11 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/dao/PaperDetailUnitRepo.java

@@ -0,0 +1,11 @@
+package com.qmth.cqb.paper.dao;
+
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import com.qmth.cqb.paper.model.PaperDetailUnit;
+
+
+public interface PaperDetailUnitRepo extends MongoRepository<PaperDetailUnit, String>,QueryByExampleExecutor<PaperDetailUnit> {
+	
+}

+ 10 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/dao/PaperRepo.java

@@ -0,0 +1,10 @@
+package com.qmth.cqb.paper.dao;
+
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import com.qmth.cqb.paper.model.Paper;
+
+public interface PaperRepo extends MongoRepository<Paper, String>,QueryByExampleExecutor<Paper> {
+	
+}

+ 12 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/dao/PaperStructureRepo.java

@@ -0,0 +1,12 @@
+package com.qmth.cqb.paper.dao;
+
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import com.qmth.cqb.paper.model.Paper;
+import com.qmth.cqb.paper.model.PaperDetailStructure;
+import com.qmth.cqb.paper.model.PaperStructure;
+
+public interface PaperStructureRepo extends MongoRepository<PaperStructure, String>,QueryByExampleExecutor<PaperStructure> {
+	
+}

+ 67 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/model/ExamPaper.java

@@ -0,0 +1,67 @@
+package com.qmth.cqb.paper.model;
+
+public class ExamPaper {
+	
+	private Long examId;
+	
+	private String courseCode;
+	
+	private String groupCode;
+	
+	private String paperId;
+	
+	private int extractCount;//抽取试卷次数
+	
+	private double weight;//抽取权重比例
+
+	public Long getExamId() {
+		return examId;
+	}
+
+	public void setExamId(Long examId) {
+		this.examId = examId;
+	}
+
+	public String getCourseCode() {
+		return courseCode;
+	}
+
+	public void setCourseCode(String courseCode) {
+		this.courseCode = courseCode;
+	}
+
+	public String getGroupCode() {
+		return groupCode;
+	}
+
+	public void setGroupCode(String groupCode) {
+		this.groupCode = groupCode;
+	}
+
+	public String getPaperId() {
+		return paperId;
+	}
+
+	public void setPaperId(String paperId) {
+		this.paperId = paperId;
+	}
+
+	public int getExtractCount() {
+		return extractCount;
+	}
+
+	public void setExtractCount(int extractCount) {
+		this.extractCount = extractCount;
+	}
+
+	public double getWeight() {
+		return weight;
+	}
+
+	public void setWeight(double weight) {
+		this.weight = weight;
+	}
+	
+	
+	
+}

+ 58 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/model/ExtractConfig.java

@@ -0,0 +1,58 @@
+package com.qmth.cqb.paper.model;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import com.qmth.cqb.utils.enumeration.ExtractPolicy;
+
+public class ExtractConfig implements Serializable{
+	
+
+	private static final long serialVersionUID = -5234564748332601375L;
+
+	private Long examId;
+	
+	private String courseCode;
+	
+	private ExtractPolicy policy;//抽卷规则
+	
+	 private Map params;//类型参数
+
+	public Long getExamId() {
+		return examId;
+	}
+
+	public void setExamId(Long examId) {
+		this.examId = examId;
+	}
+
+	public String getCourseCode() {
+		return courseCode;
+	}
+
+	public void setCourseCode(String courseCode) {
+		this.courseCode = courseCode;
+	}
+
+	public ExtractPolicy getPolicy() {
+		return policy;
+	}
+
+	public void setPolicy(ExtractPolicy policy) {
+		this.policy = policy;
+	}
+
+	public Map getParams() {
+		return params;
+	}
+
+	public void setParams(Map params) {
+		this.params = params;
+	}
+
+	public static long getSerialversionuid() {
+		return serialVersionUID;
+	}
+	
+
+}

+ 147 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/model/Paper.java

@@ -0,0 +1,147 @@
+package com.qmth.cqb.paper.model;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.index.Indexed;
+
+/**
+ * @author songyue
+ *
+ */
+public class Paper implements Serializable { 
+	
+	private static final long serialVersionUID = 5259364047220441490L;
+
+	@Id
+    private String id;
+
+    @Indexed(unique = true)
+    private String name;//试卷名称
+    
+    private String title;//试卷标题
+    
+    private double totalScore;//试卷总分
+    
+    private int paperDetailCount;//大题数量
+    
+    //private String corusecode;//课程代码
+    
+    //private String groupCode;//试卷类型
+    
+    private String creatorId;//创建人id
+     
+    private String createTime;//创建时间
+
+    private String word;//原始试卷word
+
+    private String html;//原始试卷html
+
+    private Map<String,String> params;//导入试卷属性
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getTitle() {
+		return title;
+	}
+
+	public void setTitle(String title) {
+		this.title = title;
+	}
+
+	public double getTotalScore() {
+		return totalScore;
+	}
+
+	public void setTotalScore(double totalScore) {
+		this.totalScore = totalScore;
+	}
+	
+
+	public int getPaperDetailCount() {
+		return paperDetailCount;
+	}
+
+	public void setPaperDetailCount(int paperDetailCount) {
+		this.paperDetailCount = paperDetailCount;
+	}
+
+	public String getCreatorId() {
+		return creatorId;
+	}
+
+	public void setCreatorId(String creatorId) {
+		this.creatorId = creatorId;
+	}
+
+	public String getCreateTime() {
+		return createTime;
+	}
+
+//	public String getCorusecode() {
+//		return corusecode;
+//	}
+//
+//	public void setCorusecode(String corusecode) {
+//		this.corusecode = corusecode;
+//	}
+//	
+//	public String getGroupCode() {
+//		return groupCode;
+//	}
+//
+//	public void setGroupCode(String groupCode) {
+//		this.groupCode = groupCode;
+//	}
+
+	public void setCreateTime(String createTime) {
+		this.createTime = createTime;
+	}
+
+	public String getWord() {
+		return word;
+	}
+
+	public void setWord(String word) {
+		this.word = word;
+	}
+
+	public String getHtml() {
+		return html;
+	}
+
+	public void setHtml(String html) {
+		this.html = html;
+	}
+
+	public Map<String, String> getParams() {
+		return params;
+	}
+
+	public void setParams(Map<String, String> params) {
+		this.params = params;
+	}
+
+	public static long getSerialversionuid() {
+		return serialVersionUID;
+	}
+    
+	public Paper() {
+    }
+    
+}

+ 96 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/model/PaperDetail.java

@@ -0,0 +1,96 @@
+package com.qmth.cqb.paper.model;
+
+import java.io.Serializable;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.DBRef;
+
+import com.qmth.cqb.question.model.QuestionType;
+
+public class PaperDetail implements Serializable {
+
+	private static final long serialVersionUID = 6674961232283369404L; 
+	
+	@Id
+	private String id;
+	
+	@DBRef
+	private Paper paper;//关联的试卷
+	
+	private int number;//大题序号
+	
+	private String name;//大题名称
+	
+	@DBRef
+	private QuestionType questionType;//大题类型
+	
+	private double score;//大题分数
+	
+	private int unitCount;//大题下的小题数量
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public Paper getPaper() {
+		return paper;
+	}
+
+	public void setPaper(Paper paper) {
+		this.paper = paper;
+	}
+
+	public int getNumber() {
+		return number;
+	}
+
+	public void setNumber(int number) {
+		this.number = number;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public QuestionType getQuesStructType() {
+		return questionType;
+	}
+
+	public void setQuesStructType(QuestionType questionType) {
+		this.questionType = questionType;
+	}
+
+	public double getScore() {
+		return score;
+	}
+
+	public void setScore(double score) {
+		this.score = score;
+	}
+
+	public int getUnitCount() {
+		return unitCount;
+	}
+
+	public void setUnitCount(int unitCount) {
+		this.unitCount = unitCount;
+	}
+
+	public static long getSerialversionuid() {
+		return serialVersionUID;
+	}
+	
+	public PaperDetail(){
+		
+	}
+	
+	
+}

+ 100 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/model/PaperDetailStructure.java

@@ -0,0 +1,100 @@
+package com.qmth.cqb.paper.model;
+
+import java.io.Serializable;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.DBRef;
+import com.qmth.cqb.utils.enumeration.QuesStructType;
+
+public class PaperDetailStructure implements Serializable{
+	
+	private static final long serialVersionUID = -1102384643351847702L;
+
+	@Id
+	private String id;
+	
+	@DBRef
+	private PaperStructure paperStructure;//关联的试卷
+	
+	private int number;//大题序号
+	
+	private String name;//大题名称
+	
+	private QuesStructType structType;//大题类型
+	
+	private double totalScore;//大题分数
+	
+	private int questionCount;//大题下的小题数量
+	
+	private double[] questionScores;//大题下面小题分数
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public int getNumber() {
+		return number;
+	}
+
+	public void setNumber(int number) {
+		this.number = number;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public PaperStructure getPaperStructure() {
+		return paperStructure;
+	}
+
+	public void setPaperStructure(PaperStructure paperStructure) {
+		this.paperStructure = paperStructure;
+	}
+
+	public QuesStructType getStructType() {
+		return structType;
+	}
+
+	public void setStructType(QuesStructType structType) {
+		this.structType = structType;
+	}
+
+	public double getTotalScore() {
+		return totalScore;
+	}
+
+	public void setTotalScore(double totalScore) {
+		this.totalScore = totalScore;
+	}
+
+	public int getQuestionCount() {
+		return questionCount;
+	}
+
+	public void setQuestionCount(int questionCount) {
+		this.questionCount = questionCount;
+	}
+
+	public double[] getQuestionScores() {
+		return questionScores;
+	}
+
+	public void setQuestionScores(double[] questionScores) {
+		this.questionScores = questionScores;
+	}
+
+	public static long getSerialversionuid() {
+		return serialVersionUID;
+	}
+	
+	
+}

+ 97 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/model/PaperDetailUnit.java

@@ -0,0 +1,97 @@
+package com.qmth.cqb.paper.model;
+
+import java.io.Serializable;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.DBRef;
+
+import com.qmth.cqb.question.model.Question;
+import com.qmth.cqb.question.model.QuestionType;
+
+public class PaperDetailUnit implements Serializable{
+
+	private static final long serialVersionUID = -8854150484922002075L;
+	
+	@Id
+	private String id;
+	
+	@DBRef
+	private Paper paper;//关联的试卷
+	
+	private int number;//小题序号
+	
+	private double score;//小题分数
+	
+	@DBRef
+	private PaperDetail paperDeation;//关联的大题
+	
+	@DBRef
+	private QuestionType questionType;//小题类型
+	
+	@DBRef
+	private Question question;//关联试题
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public Paper getPaper() {
+		return paper;
+	}
+
+	public void setPaper(Paper paper) {
+		this.paper = paper;
+	}
+
+	public int getNumber() {
+		return number;
+	}
+
+	public void setNumber(int number) {
+		this.number = number;
+	}
+
+	public double getScore() {
+		return score;
+	}
+
+	public void setScore(double score) {
+		this.score = score;
+	}
+
+	public PaperDetail getPaperDeation() {
+		return paperDeation;
+	}
+
+	public void setPaperDeation(PaperDetail paperDeation) {
+		this.paperDeation = paperDeation;
+	}
+
+	public QuestionType getQuesStructType() {
+		return questionType;
+	}
+
+	public void setQuesStructType(QuestionType questionType) {
+		this.questionType = questionType;
+	}
+
+	public Question getQuestion() {
+		return question;
+	}
+
+	public void setQuestion(Question question) {
+		this.question = question;
+	}
+
+	public static long getSerialversionuid() {
+		return serialVersionUID;
+	}
+	
+	
+	
+
+}

+ 67 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/model/PaperStructure.java

@@ -0,0 +1,67 @@
+package com.qmth.cqb.paper.model;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.index.Indexed;
+
+public class PaperStructure implements Serializable{
+
+	private static final long serialVersionUID = 6380530617488717881L;
+
+	@Id
+    private String id;
+
+    @Indexed(unique = true)
+    private String name;//试卷结构名称
+        
+    private double totalScore;//总分
+    
+    private int detailCount;//大题数量
+    
+    private Map paraMap;
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public double getTotalScore() {
+		return totalScore;
+	}
+
+	public void setTotalScore(double totalScore) {
+		this.totalScore = totalScore;
+	}
+
+	public int getDetailCount() {
+		return detailCount;
+	}
+
+	public void setDetailCount(int detailCount) {
+		this.detailCount = detailCount;
+	}
+
+	public Map getParaMap() {
+		return paraMap;
+	}
+
+	public void setParaMap(Map paraMap) {
+		this.paraMap = paraMap;
+	}
+    
+    
+    
+}

+ 59 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/service/ExtractService.java

@@ -0,0 +1,59 @@
+package com.qmth.cqb.paper.service;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.stereotype.Service;
+
+import com.qmth.cqb.paper.dao.ExamPaperRepo;
+import com.qmth.cqb.paper.dao.ExtractConfigRepo;
+import com.qmth.cqb.paper.dao.PaperRepo;
+import com.qmth.cqb.paper.model.ExamPaper;
+import com.qmth.cqb.paper.model.ExtractConfig;
+import com.qmth.cqb.paper.model.Paper;
+
+@Service
+public class ExtractService {
+	
+	@Autowired
+	ExamPaperRepo examPaperRepo;
+	
+	@Autowired
+	PaperRepo paperRepo;
+	
+	@Autowired 
+	ExtractConfigRepo extractConfigRepo;
+	
+//	public Paper extrcatExamPaper(long examId,String courseCode,String groupCode){
+//     	ExamPaper examPaper = new ExamPaper();
+//    	examPaper.setExamId(examId);
+//    	examPaper.setCourseCode(courseCode);
+//    	examPaper.setGroupCode(groupCode);
+//        ExamPaper examPaper2 = examPaperRepo.findOne(Example.of(examPaper));
+//        Paper paper = paperRepo.findOne(examPaper2.getPaperId());
+//		return paper;		
+//	}
+	/**
+	 * 随机抽一张试卷
+	 * @param papers
+	 * @return
+	 */
+	public Paper randomPaper(List<Paper> papers){
+	    Collections.shuffle(papers);
+		Paper paper = papers.get(0);
+		return paper;
+	}
+	
+	
+	public ExtractConfig findConfig(long examId,String courseCode){
+		ExtractConfig tempConfig = new ExtractConfig();
+		tempConfig.setExamId(examId);
+		tempConfig.setCourseCode(courseCode);
+		ExtractConfig config =  extractConfigRepo.findOne(Example.of(tempConfig));
+		return config;
+	}
+	
+}

+ 77 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/service/ImportPaperService.java

@@ -0,0 +1,77 @@
+package com.qmth.cqb.paper.service;
+
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.stereotype.Service;
+
+import com.qmth.cqb.paper.model.Paper;
+import com.qmth.cqb.question.model.ImportPaperSearchCondition;
+import com.qmth.cqb.utils.modal.PagingAndSortingResponse;
+
+@Service
+public class ImportPaperService {
+	
+
+    /**
+     * 一般返回类型统一为NormalResponse对象
+     * NormalResponse(String httpStatus, String Message)
+     * 分页集合返回类型为PagingAndSortingResponse
+     * PagingAndSortingResponse(int curPage, int pageSize, int totalPages, long totalElements, List dataList)
+     * 一般集合返回类型为List
+     */
+
+    @Autowired
+    com.qmth.cqb.paper.dao.PaperRepo paperRepo;
+
+
+    /**
+     * 查询所有已导入试卷
+     * @param searchCondition
+     * @param curPage
+     * @param pageSize
+     * @return
+     */
+    public PagingAndSortingResponse<Paper> findAll(ImportPaperSearchCondition searchCondition,int curPage,int pageSize){
+    	Paper importPaper = new Paper();
+    	BeanUtils.copyProperties(searchCondition,importPaper);
+    	ExampleMatcher matcher = ExampleMatcher.matching().withMatcher("paperName", startsWith());
+        Page<Paper> importPaperList = paperRepo.findAll(Example.of(importPaper,matcher),new PageRequest(curPage-1,pageSize));
+        return new PagingAndSortingResponse<Paper>(importPaperList.getNumber(),importPaperList.getSize(),
+                importPaperList.getTotalPages(),importPaperList.getTotalElements(),importPaperList.getContent());
+    }
+
+    /**
+     * 按ID查询导入试卷
+     * @param paperId
+     * @return
+     */
+    public Paper findById(String paperId){
+        return paperRepo.findOne(paperId);
+    }
+
+    /**
+     * 保存试卷
+     * @param importPaper
+     * @return
+     */
+    public Paper saveImportPaper(Paper importPaper){
+    	Paper tempPaper = paperRepo.save(importPaper);
+        return tempPaper;
+    }
+
+    /**
+     * 删除导入试卷
+     * @param paperId
+     * @return
+     */
+    public void deleteImportPaper(String paperId){
+    	paperRepo.delete(paperId);
+    }
+
+}

+ 76 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/service/PaperDetailService.java

@@ -0,0 +1,76 @@
+package com.qmth.cqb.paper.service;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.stereotype.Service;
+
+import com.qmth.cqb.paper.dao.PaperDetailRepo;
+import com.qmth.cqb.paper.model.Paper;
+import com.qmth.cqb.paper.model.PaperDetail;
+import com.qmth.cqb.paper.model.PaperDetailUnit;
+
+@Service
+public class PaperDetailService {
+	
+	
+	@Autowired
+	PaperDetailRepo paperDetailRepo;
+	
+	@Autowired
+	PaperDetailUnitService unitService;
+	
+	
+	/**
+	 * 根据Id获得对应所有小题
+	 * @param id
+	 * @return
+	 */
+	public List<PaperDetailUnit> getUnitsByPaperDetailId(String id){	
+		return unitService.getUnitsByPaperDetail(paperDetailRepo.findOne(id));
+	}
+	
+	
+	
+    /**
+     * 按ID查询大题
+     * @param id
+     * @return
+     */
+    public PaperDetail findById(String id){
+        return paperDetailRepo.findOne(id);
+    }
+
+    /**
+     * 保存大题
+     * @param PaperDetail
+     * @return
+     */
+    public PaperDetail savePaperDetail(PaperDetail pd){
+        PaperDetail paperDetail = paperDetailRepo.save(pd);
+        return paperDetail;
+    }
+
+    /**
+     * 删除大题
+     * @param id
+     * @return
+     */
+    public void deletePaperDetail(String id){
+    	paperDetailRepo.delete(id);
+    }
+    
+    /**
+     * 查询同一个试卷对象对应大题
+     * @param paperDetail
+     * @return
+     */
+    public List<PaperDetail> getPaperDetailsByPaper(Paper paper){
+    	PaperDetail pd = new PaperDetail();
+    	pd.setPaper(paper);  	
+    	List<PaperDetail> paperDetails = paperDetailRepo.findAll(Example.of(pd));
+    	return paperDetails;
+    }
+}
+

+ 63 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/service/PaperDetailStructureService.java

@@ -0,0 +1,63 @@
+package com.qmth.cqb.paper.service;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.stereotype.Service;
+import com.qmth.cqb.paper.dao.PaperDetailStructureRepo;
+import com.qmth.cqb.paper.model.PaperDetailStructure;
+import com.qmth.cqb.paper.model.PaperStructure;
+/**
+ * Created by songyue on 16/12/28.
+ */
+@Service
+public class PaperDetailStructureService {
+	
+	@Autowired
+	PaperDetailStructureRepo detailStructureRepo;
+	
+	
+
+    /**
+     * 按ID查询试卷结构明细
+     * @param detailId
+     * @return
+     */
+    public PaperDetailStructure findById(String detailId){
+        return detailStructureRepo.findOne(detailId);
+    }
+    
+    
+
+    /**
+     * 保存试卷结构明细
+     * @param PaperDetailStructure
+     * @return
+     */
+    public PaperDetailStructure savePaperStructureDetail(PaperDetailStructure pds){
+    	PaperDetailStructure temp = detailStructureRepo.save(pds);
+        return temp;
+    }
+
+    /**
+     * 删除试卷结构明细
+     * @param detailId
+     * @return
+     */
+    public void deletePaperDetailStructure(String detailId){
+    	detailStructureRepo.delete(detailId);
+    }
+
+    /**
+     * 查询同一个试卷对象对应试卷结构明细
+     * @param paperDetail
+     * @return
+     */
+    public List<PaperDetailStructure> getDetailsByPaperStructure(PaperStructure paperStructure){
+    	PaperDetailStructure pd = new PaperDetailStructure();
+    	pd.setPaperStructure(paperStructure);  	
+    	List<PaperDetailStructure> paperDetails = detailStructureRepo.findAll(Example.of(pd));
+    	return paperDetails;
+    }
+}

+ 77 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/service/PaperDetailUnitService.java

@@ -0,0 +1,77 @@
+package com.qmth.cqb.paper.service;
+
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.stereotype.Service;
+
+import com.qmth.cqb.paper.dao.PaperDetailUnitRepo;
+import com.qmth.cqb.paper.model.PaperDetail;
+import com.qmth.cqb.paper.model.PaperDetailUnit;
+import com.qmth.cqb.question.model.Question;
+import com.qmth.cqb.question.service.QuesService;
+
+@Service
+public class PaperDetailUnitService {
+	@Autowired
+	PaperDetailUnitRepo paperDetailUnitRepo;
+	
+	@Autowired
+	QuesService quesService;
+	
+	/**
+	 * 根据Id获得对应的试题对象
+	 * @param id
+	 * @return
+	 */
+	public Question getQuestionByPaperDetailUnitId(String id){
+		PaperDetailUnit pdu = paperDetailUnitRepo.findOne(id);
+		Question ques = quesService.findById(pdu.getId());
+		return ques;		
+	}
+	
+    /**
+     * 按ID查询小题
+     * @param id
+     * @return
+     */
+    public PaperDetailUnit findById(String id){
+        return paperDetailUnitRepo.findOne(id);
+    }
+
+    /**
+     * 保存小题
+     * @param PaperDetailUnit
+     * @return
+     */
+    public PaperDetailUnit savePaperDetailUnit(PaperDetailUnit pdu){
+        PaperDetailUnit tempPdu = paperDetailUnitRepo.save(pdu);
+        return tempPdu;
+    }
+
+    /**
+     * 删除小题
+     * @param id
+     * @return
+     */
+    public void deletePaperDetailUnit(String id){
+        paperDetailUnitRepo.delete(id);
+    }
+    
+    /**
+     * 根据大题查小题
+     * @param paperDetail
+     * @return
+     */
+    public List<PaperDetailUnit> getUnitsByPaperDetail(PaperDetail paperDetail){
+    	PaperDetailUnit pdu = new PaperDetailUnit();
+    	pdu.setPaperDeation(paperDetail);  	
+    	List<PaperDetailUnit> units = paperDetailUnitRepo.findAll(Example.of(pdu));
+    	return units;
+    }
+}
+	

+ 138 - 13
cqb-paper/src/main/java/com/qmth/cqb/paper/service/PaperService.java

@@ -1,27 +1,152 @@
 package com.qmth.cqb.paper.service;
 
-import com.qmth.cqb.genpaper.dao.GenPaperRepo;
-import com.qmth.cqb.genpaper.service.GenPaperService;
-import com.qmth.cqb.question.dao.ImportPaperRepo;
-import com.qmth.cqb.question.model.ImportPaper;
-import com.qmth.cqb.question.service.ImportPaperService;
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
 
+import com.qmth.cqb.paper.dao.ExamPaperRepo;
+import com.qmth.cqb.paper.dao.PaperRepo;
+import com.qmth.cqb.paper.model.ExamPaper;
+import com.qmth.cqb.paper.model.Paper;
+import com.qmth.cqb.paper.model.PaperDetail;
+
 /**
  * Created by songyue on 16/12/28.
  */
 @Service
 public class PaperService {
-    @Autowired
-    GenPaperService genPaperService;
+	
+	@Autowired
+	PaperRepo paperRepo;
+	
+	@Autowired
+	PaperDetailService paperDetailService;
+	
+	@Autowired
+	ExamPaperRepo examPaperRepo; 
+	
+	
+	
+	/**
+	 * 查询考试试卷
+	 * @param examId
+	 * @param courseCode
+	 * @param groupCode
+	 * @return
+	 */
+    public List<Paper> listExamPapers(long examId,String courseCode,String groupCode){
+    	List<Paper> papers = new ArrayList<Paper>();
+     	ExamPaper examPaper = new ExamPaper();
+    	examPaper.setExamId(examId);
+    	examPaper.setCourseCode(courseCode);
+    	examPaper.setGroupCode(groupCode);
+    	List<ExamPaper> examPapers = examPaperRepo.findAll(Example.of(examPaper));
+    	for(ExamPaper ePaper:examPapers){
+    		Paper paper = paperRepo.findOne(ePaper.getPaperId());
+    		papers.add(paper);
+    	}
+    	
+		return papers;
+    }
+    
+    
+    /**
+     * 设置考试试卷
+     * @param examId
+     * @param courseCode
+     * @param groupCode
+     * @param paperId
+     * @return
+     */
+    public boolean joinToExamPaper(long examId,String courseCode,String groupCode,String paperId){ 	
+    	boolean flag = false;
+		ExamPaper examPaper = new ExamPaper();
+		examPaper.setExamId(examId);
+		examPaper.setGroupCode(groupCode);
+		examPaper.setCourseCode(courseCode);
+		examPaper.setPaperId(paperId);
+		examPaperRepo.save(examPaper);
+		flag = true;
+    	return flag;   	
+    }
+    
+    public boolean releaseExamPaper(long examId,String courseCode,String groupCode,String paperId){ 	
+    	boolean flag = false;
+		ExamPaper examPaper = new ExamPaper();
+		examPaper.setExamId(examId);
+		examPaper.setGroupCode(groupCode);
+		examPaper.setCourseCode(courseCode);
+		examPaper.setPaperId(paperId);
+		examPaperRepo.delete(examPaper);
+		flag = true;
+    	return flag;   	
+    }
+    
+    
+    public Set<String> listGroupCodes(long examId,String courseCode){
+    	Set<String> groupSet = new HashSet<String>();
+    	ExamPaper examPaper = new ExamPaper();
+    	examPaper.setExamId(examId);
+		examPaper.setCourseCode(courseCode);
+		List<ExamPaper> examPapers = examPaperRepo.findAll(Example.of(examPaper));
+		for(ExamPaper expaper:examPapers){
+			groupSet.add(expaper.getGroupCode());
+		}
+		return groupSet;
+    }
+    
+    
+    public boolean deletGroupCode(long examId,String courseCode,String groupCode){
+    	boolean flag = false;
+    	ExamPaper examPaper = new ExamPaper();
+    	examPaper.setExamId(examId);
+		examPaper.setCourseCode(courseCode);
+		examPaper.setCourseCode(courseCode);
+		examPaperRepo.delete(examPaper);
+		flag = true;
+		return flag;
+    }
+    
+    
+    /**
+     * 根据试卷ID获取试卷下面的大题
+     * @param id
+     * @return
+     */
+    public List<PaperDetail> findPaperDetailsById(String id){
+        return paperDetailService.getPaperDetailsByPaper(paperRepo.findOne(id));
+    }
 
-    @Autowired
-    GenPaperRepo genPaperRepo;
+	
+	
+    /**
+     * 按ID查询试卷
+     * @param id
+     * @return
+     */
+    public Paper findById(String id){
+        return paperRepo.findOne(id);
+    }
 
-    @Autowired
-    ImportPaperRepo importPaperRepo;
+    /**
+     * 保存试卷
+     * @param Paper
+     * @return
+     */
+    public Paper savePaper(Paper pd){
+        Paper paper = paperRepo.save(pd);
+        return paper;
+    }
 
-    @Autowired
-    ImportPaperService importPaperService;
 }

+ 50 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/service/PaperStructureService.java

@@ -0,0 +1,50 @@
+package com.qmth.cqb.paper.service;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.qmth.cqb.paper.dao.PaperStructureRepo;
+import com.qmth.cqb.paper.model.PaperStructure;
+
+/**
+ * Created by songyue on 16/12/28.
+ */
+@Service
+public class PaperStructureService {
+	
+	@Autowired
+	PaperStructureRepo paperStructureRepo;
+	
+
+    /**
+     * 按ID查询导入试卷
+     * @param paperId
+     * @return
+     */
+    public PaperStructure findById(String paperId){
+        return paperStructureRepo.findOne(paperId);
+    }
+
+    /**
+     * 保存试卷
+     * @param importPaper
+     * @return
+     */
+    public PaperStructure savePaperStructure(PaperStructure ps){
+    	PaperStructure tempPaper = paperStructureRepo.save(ps);
+        return tempPaper;
+    }
+
+    /**
+     * 删除导入试卷
+     * @param paperId
+     * @return
+     */
+    public void deletePaperStructure(String paperId){
+    	paperStructureRepo.delete(paperId);
+    }
+	
+
+
+}

+ 47 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/web/ExtractController.java

@@ -0,0 +1,47 @@
+package com.qmth.cqb.paper.web;
+
+import com.qmth.cqb.paper.model.ExtractConfig;
+import com.qmth.cqb.paper.model.Paper;
+import com.qmth.cqb.paper.service.ExtractService;
+import com.qmth.cqb.paper.service.PaperService;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * Created by songyue on 16/12/28.
+ */
+@RestController
+@RequestMapping("${api_cqb}/")
+public class ExtractController {
+    @Autowired
+    ExtractService extractService;
+    
+    @Autowired
+    PaperService paperService;
+    
+    @GetMapping(value = "/extract/{exam_id}/{course_code}/{group_code}")
+    public Paper extract(@PathVariable String exam_id,@PathVariable String course_code,
+    		@PathVariable String group_code){
+    	Paper paper = null;
+    	ExtractConfig config = extractService.findConfig(Long.parseLong(exam_id), course_code);
+    	if("RANDOM_PAPER".equals(config.getPolicy().getKey())){
+    		List<Paper> papers = paperService.listExamPapers(config.getExamId(), config.getCourseCode(), group_code);
+    	    paper = extractService.randomPaper(papers);
+    	}     	
+		return paper;
+    }
+    
+//    @GetMapping(value = "/extract/{exam_id}/{course_code}")
+//    public ExtractConfig findConfig (@PathVariable String exam_id,@PathVariable String course_code){
+//    	ExtractConfig config = extractService.findConfig(Long.parseLong(exam_id), course_code);
+//		return config;
+//    }
+
+}

+ 96 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/web/ImportPaperController.java

@@ -0,0 +1,96 @@
+package com.qmth.cqb.paper.web;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.qmth.cqb.paper.model.Paper;
+import com.qmth.cqb.paper.service.ImportPaperService;
+import com.qmth.cqb.question.model.ImportPaperSearchCondition;
+import com.qmth.cqb.utils.modal.PagingAndSortingResponse;
+
+/**
+ * Created by songyue on 16/12/28.
+ */
+@RestController
+@RequestMapping("${api_cqb}/")
+public class ImportPaperController {
+	
+	@Autowired
+	ImportPaperService importPaperService;
+    /**
+     * 获取导入试卷
+     * @param importPaper_id
+     * @return
+     */
+    @GetMapping(value = "/importPaper/{importPaper_id}")
+    public Paper getPaperById(@PathVariable String importPaper_id){
+        return importPaperService.findById(importPaper_id);
+    }
+    
+    /**
+     * 获取导入试卷的所有试题
+     * @param importPaper_id
+     * @return
+     */
+//    @GetMapping(value = "/importPaper/question/{importPaper_id}")
+//    public List<Question> getQuesPaperById(@PathVariable String importPaper_id){
+//    	return importPaperService.findById(importPaper_id).getQuestionList();
+//    }
+
+
+    /**
+     * 获取全部导入试卷
+     * @return
+     */
+    @GetMapping(value = "/importPaper/all/{curPage}/{paseSize}")
+    public PagingAndSortingResponse<Paper> getAllPaper(@ModelAttribute ImportPaperSearchCondition searchCondition, @PathVariable int curPage, @PathVariable int pageSize){
+      PagingAndSortingResponse<Paper> psr = importPaperService.findAll(searchCondition, curPage, pageSize);
+      return psr;
+    }
+
+    /**
+     * 更新导入试卷信息
+     * @param 
+     * @return
+     */
+    @PutMapping(value = "/importPaper")
+    public ResponseEntity updatePaper(@ModelAttribute Paper paper){
+    	Paper paper2 = importPaperService.saveImportPaper(paper);
+    	ResponseEntity rse = new ResponseEntity(paper2,HttpStatus.OK);
+    	return rse;
+    	
+    }
+
+    /**
+     * 新增导入试卷
+     * @param paper
+     * @return
+     */
+    @PostMapping(value = "/importPaper")
+    public ResponseEntity addPaper(@ModelAttribute Paper paper){
+    	Paper paper2 = importPaperService.saveImportPaper(paper);
+    	ResponseEntity rse = new ResponseEntity(paper2,HttpStatus.OK);
+    	return rse;
+    }
+
+    /**
+     * 删除导入试卷
+     * @param paper_id
+     * @return
+     */
+    @DeleteMapping(value = "/importPaper/{importPaper_id}")
+    public ResponseEntity removePaper(@PathVariable String importPaper_id){
+    	importPaperService.deleteImportPaper(importPaper_id);
+    	ResponseEntity res = new ResponseEntity(importPaper_id,HttpStatus.OK);
+		return res;
+    }
+}

+ 121 - 16
cqb-paper/src/main/java/com/qmth/cqb/paper/web/PaperController.java

@@ -1,26 +1,131 @@
 package com.qmth.cqb.paper.web;
 
-import com.qmth.cqb.genpaper.dao.GenPaperRepo;
-import com.qmth.cqb.genpaper.service.GenPaperService;
-import com.qmth.cqb.question.dao.ImportPaperRepo;
-import com.qmth.cqb.question.service.ImportPaperService;
+import com.qmth.cqb.paper.model.Paper;
+import com.qmth.cqb.paper.service.PaperService;
+import io.swagger.annotations.ApiOperation;
+
+import java.util.List;
+import java.util.Set;
+
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 /**
  * Created by songyue on 16/12/28.
  */
-@Controller
+@RestController
+@RequestMapping("${api_cqb}/")
 public class PaperController {
     @Autowired
-    GenPaperService genPaperService;
-
-    @Autowired
-    GenPaperRepo genPaperRepo;
-
-    @Autowired
-    ImportPaperRepo importPaperRepo;
-
-    @Autowired
-    ImportPaperService importPaperService;
+    PaperService paperService;
+    
+    
+    /**
+     * 新增试卷
+     * @param paper
+     * @return
+     */
+    @PostMapping(value = "/paper")
+    public ResponseEntity CreatePaper(@ModelAttribute Paper paper){
+      Paper tempPaper  = paperService.savePaper(paper);
+      ResponseEntity rse = new ResponseEntity(tempPaper,HttpStatus.OK);
+      return rse;
+    }
+    
+    /**
+     * 根据Id获取试卷
+     * @param id
+     * @return
+     */
+    @ApiOperation(value="获取单张试卷",notes="获取单张试卷")
+    @GetMapping(value = "/paper/{paper_id}")
+    public Paper getPaperById(@PathVariable String paper_id){
+        return paperService.findById(paper_id);
+    }
+    
+    
+    /**
+     * 获取卷库考试试卷
+     * @param paper_id
+     * @return
+     */
+    @GetMapping(value = "/paper/list/{exam_id}/{course_code}/{group_code}")
+    public List<Paper> listPaperById(
+    		@PathVariable String exam_id,
+    		@PathVariable String course_code,
+    		@PathVariable String group_code){
+        return paperService.listExamPapers(Long.parseLong(exam_id), course_code, group_code);
+    }
+    
+    /**
+     * 新增考试试卷
+     * @param exam_id
+     * @param course_code
+     * @param group_code
+     * @param paper_id
+     * @return
+     */
+    @PostMapping(value = "/paper/join/{exam_id}/{course_code}/{group_code}/{paper_id}")
+    public ResponseEntity joinExamPaper(@PathVariable String exam_id,
+    		@PathVariable String course_code,
+    		@PathVariable String group_code,
+    		@PathVariable String paper_id){
+      boolean falg = paperService.joinToExamPaper(Long.parseLong(exam_id), course_code, group_code, paper_id);
+      ResponseEntity rse = new ResponseEntity(falg,HttpStatus.OK);
+      return rse;
+    }
+    
+    /**
+     * 删除考试试卷
+     * @param exam_id
+     * @param course_code
+     * @param group_code
+     * @param paper_id
+     * @return
+     */
+    @DeleteMapping(value = "/paper/release/{exam_id}/{course_code}/{group_code}/{paper_id}")
+    public ResponseEntity releaseExamPaper(@PathVariable String exam_id,
+    		@PathVariable String course_code,
+    		@PathVariable String group_code,
+    		@PathVariable String paper_id){
+      boolean falg = paperService.releaseExamPaper(Long.parseLong(exam_id), course_code, group_code, paper_id);
+      ResponseEntity rse = new ResponseEntity(falg,HttpStatus.OK);
+      return rse;
+    }
+    
+    /**
+     * 获取卷库考试试卷类型集合
+     * @param exam_id
+     * @param group_code
+     * @return
+     */
+    @GetMapping(value = "/paper/listCode/{exam_id}/{group_code}")
+    public Set<String> listGroup(@PathVariable String exam_id,@PathVariable String group_code){
+        return paperService.listGroupCodes(Long.parseLong(exam_id), group_code);
+    }
+    
+    
+    /**
+     * 删除试卷类型
+     * @param exam_id
+     * @param course_code
+     * @param group_code
+     * @return
+     */
+    @DeleteMapping(value = "/paper/deleteCode/{exam_id}/{course_code}/{group_code}")
+    public ResponseEntity deleteGropu(@PathVariable String exam_id,
+    		@PathVariable String course_code,
+    		@PathVariable String group_code){
+      boolean falg = paperService.deletGroupCode(Long.parseLong(exam_id), course_code, group_code);
+      ResponseEntity rse = new ResponseEntity(falg,HttpStatus.OK);
+      return rse;
+    }
 }

+ 92 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/web/PaperDetailController.java

@@ -0,0 +1,92 @@
+package com.qmth.cqb.paper.web;
+
+import com.qmth.cqb.paper.model.PaperDetail;
+import com.qmth.cqb.paper.model.PaperDetailUnit;
+import com.qmth.cqb.paper.service.PaperDetailService;
+
+import io.swagger.annotations.ApiOperation;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * Created by songyue on 16/12/28.
+ */
+@RestController
+@RequestMapping("${api_cqb}/")
+public class PaperDetailController {
+	@Autowired
+	PaperDetailService paperDetailService;
+	
+		
+		 /**
+		  * 获取单个大题获得对应的小题
+		  * @param paperDetail
+		  * @return
+		  */
+		 @GetMapping(value = "/paperDetail/units/{detail_id}")
+		 public List<PaperDetailUnit> getUnitsByPaperDetailId(String detail_id){
+			 return paperDetailService.getUnitsByPaperDetailId(detail_id);
+		 }
+		 
+	   /**
+	    * 获取大题
+	    * @param id
+	    * @return
+	    */
+	   @ApiOperation(value="获取单个大题",notes="获取单个大题")
+	   @GetMapping(value = "/paperDetail/{detail_id}")
+	   public PaperDetail getPaperDetailId(@PathVariable String detail_id){
+	       return paperDetailService.findById(detail_id);
+	   }
+	
+	
+	   /**
+	    * 更新大题信息
+	    * @param PaperDetail
+	    * @return
+	    */
+	   @PutMapping(value = "/paperDetail")
+	   public ResponseEntity updatePaperDetail(@ModelAttribute PaperDetail pd){
+	       PaperDetail paperDetail = paperDetailService.savePaperDetail(pd);
+	       ResponseEntity rse = new ResponseEntity(paperDetail,HttpStatus.OK);
+	       return rse;
+	   	
+	   }
+	
+	   /**
+	    * 新增大题
+	    * @param PaperDetail
+	    * @return
+	    */
+	   @PostMapping(value = "/paperDetail")
+	   public ResponseEntity addPaperDetail(@ModelAttribute PaperDetail pd){
+	     PaperDetail paperDetail = paperDetailService.savePaperDetail(pd);
+	     ResponseEntity rse2 = new ResponseEntity(paperDetail,HttpStatus.OK);
+	     return rse2;
+	   }
+	
+	   /**
+	    * 删除大题
+	    * @param id
+	    * @return
+	    */
+	   @DeleteMapping(value = "/paperDetail/{detail_id}")
+	   public ResponseEntity removePaperDetail(@PathVariable String detail_id){
+	   	paperDetailService.deletePaperDetail(detail_id);
+	   	ResponseEntity rse2 = new ResponseEntity(detail_id,HttpStatus.OK);
+	   	return rse2;
+	   }
+	
+}

+ 81 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/web/PaperDetailStructureController.java

@@ -0,0 +1,81 @@
+package com.qmth.cqb.paper.web;
+
+import com.qmth.cqb.paper.model.PaperDetailStructure;
+import com.qmth.cqb.paper.service.PaperDetailStructureService;
+
+import io.swagger.annotations.ApiOperation;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * Created by songyue on 16/12/28.
+ */
+@RestController
+@RequestMapping("${api_cqb}/")
+public class PaperDetailStructureController {
+	@Autowired
+	PaperDetailStructureService detailService;
+	
+	
+	
+	
+   /**
+    * 获取大题
+    * @param id
+    * @return
+    */
+   @ApiOperation(value="获取单个大题",notes="获取单个大题")
+   @GetMapping(value = "/PaperDetailStructure/{detail_id}")
+   public PaperDetailStructure getPaperDetailStructureById(@PathVariable String detail_id){
+       return detailService.findById(detail_id);
+   }
+
+
+   /**
+    * 更新大题信息
+    * @param PaperDetailStructure
+    * @return
+    */
+   @PutMapping(value = "/paperDetailStructure")
+   public ResponseEntity updatePaperDetailStructure(@ModelAttribute PaperDetailStructure pd){
+       PaperDetailStructure paperDetail = detailService.savePaperStructureDetail(pd);
+       ResponseEntity rse = new ResponseEntity(paperDetail,HttpStatus.OK);
+       return rse;
+   	
+   }
+
+   /**
+    * 新增大题
+    * @param PaperDetailStructure
+    * @return
+    */
+   @PostMapping(value = "/paperDetailStructure")
+   public ResponseEntity addPaperDetailStructure(@ModelAttribute PaperDetailStructure pd){
+     PaperDetailStructure paperDetail = detailService.savePaperStructureDetail(pd);
+     ResponseEntity rse2 = new ResponseEntity(paperDetail,HttpStatus.OK);
+     return rse2;
+   }
+
+   /**
+    * 删除大题
+    * @param id
+    * @return
+    */
+   @DeleteMapping(value = "/paperDetailStructure/{detail_id}")
+   public ResponseEntity removePaperDetailStructure(@PathVariable String detail_id){
+   	detailService.deletePaperDetailStructure(detail_id);
+   	ResponseEntity rse2 = new ResponseEntity(detail_id,HttpStatus.OK);
+   	return rse2;
+   }
+	
+}

+ 90 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/web/PaperDetailUnitController.java

@@ -0,0 +1,90 @@
+package com.qmth.cqb.paper.web;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.qmth.cqb.paper.model.PaperDetailUnit;
+import com.qmth.cqb.paper.service.PaperDetailUnitService;
+import com.qmth.cqb.question.model.Question;
+
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * Created by songyue on 16/12/28.
+ */
+@RestController
+@RequestMapping("${api_cqb}/")
+public class PaperDetailUnitController {
+		 @Autowired
+		 PaperDetailUnitService  unitService;
+		 
+		 /**
+		  * 获取单个小题对应的试题
+		  * @param unit_id
+		  * @return
+		  */
+		 @GetMapping(value = "/paperDetailUnit/question/{unit_id}")
+		 public Question getQuestionByUnitId(String unit_id){
+			 return unitService.getQuestionByPaperDetailUnitId(unit_id);
+		 }
+		 
+	    /**
+	     * 获取小题
+	     * @param id
+	     * @return
+	     */
+	    @ApiOperation(value="获取单个小题",notes="获取单个小题")
+	    @GetMapping(value = "/paperDetailUnit/{unit_id}")
+	    public PaperDetailUnit getPaperDetailUnitId(@PathVariable String unit_id){
+	        return unitService.findById(unit_id);
+	    }
+	
+	
+	    /**
+	     * 更新小题信息
+	     * @param PaperDetailUnit
+	     * @return
+	     */
+	    @PutMapping(value = "/paperDetailUnit")
+	    public ResponseEntity updatePaperDetailUnit(@ModelAttribute PaperDetailUnit pdu){
+	        PaperDetailUnit pdUnit = unitService.savePaperDetailUnit(pdu);
+	        ResponseEntity rse = new ResponseEntity(pdUnit,HttpStatus.OK);
+	        return rse;
+	    	
+	    }
+	
+	    /**
+	     * 新增小题
+	     * @param PaperDetailUnit
+	     * @return
+	     */
+	    @PostMapping(value = "/paperDetailUnit")
+	    public ResponseEntity addPaperDetailUnit(@ModelAttribute PaperDetailUnit pdu){
+	      PaperDetailUnit pdUnit = unitService.savePaperDetailUnit(pdu);
+	      ResponseEntity rse2 = new ResponseEntity(pdUnit,HttpStatus.OK);
+	      return rse2;
+	    }
+	
+	    /**
+	     * 删除小题
+	     * @param id
+	     * @return
+	     */
+	    @DeleteMapping(value = "/paperDetailUnit/{unit_id}")
+	    public ResponseEntity removePaperDetailUnit(@PathVariable String unit_id){
+	    	unitService.deletePaperDetailUnit(unit_id);
+	    	ResponseEntity rse2 = new ResponseEntity(unit_id,HttpStatus.OK);
+	    	return rse2;
+	    }
+
+}

+ 92 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/web/PaperStructureController.java

@@ -0,0 +1,92 @@
+package com.qmth.cqb.paper.web;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.qmth.cqb.paper.model.PaperDetailStructure;
+import com.qmth.cqb.paper.model.PaperStructure;
+import com.qmth.cqb.paper.service.PaperDetailStructureService;
+import com.qmth.cqb.paper.service.PaperStructureService;
+
+/**
+ * Created by songyue on 16/12/28.
+ */
+@RestController
+@RequestMapping("${api_cqb}/")
+public class PaperStructureController {
+	
+	@Autowired
+    PaperStructureService paperStructureService;
+	
+	@Autowired
+    PaperDetailStructureService detailService;
+	
+    /**
+     * 根据id获取试卷结构
+     * @param 
+     * @return
+     */
+    @GetMapping(value = "/paperStructure/{paper_id}")
+    public PaperStructure getPaperStructureById(@PathVariable String paper_id){
+        return paperStructureService.findById(paper_id);
+    }
+    
+    /**
+     * 获取试卷结构下面的详情信息
+     * @param paper_id
+     * @return
+     */
+    @GetMapping(value = "/paperStructure/detail/{paper_id}")
+    public List<PaperDetailStructure> getQuesPaperById(@PathVariable String paper_id){
+    	return detailService.getDetailsByPaperStructure(paperStructureService.findById(paper_id));
+    }
+
+
+    /**
+     * 更新导入试卷信息
+     * @param 
+     * @return
+     */
+    @PutMapping(value = "/paperStructure")
+    public ResponseEntity updatePaperStructure(@ModelAttribute PaperStructure ps){
+    	PaperStructure temp = paperStructureService.savePaperStructure(ps);
+    	ResponseEntity rse = new ResponseEntity(temp,HttpStatus.OK);
+    	return rse;
+    	
+    }
+
+    /**
+     * 新增导入试卷
+     * @param paper
+     * @return
+     */
+    @PostMapping(value = "/paperStructure")
+    public ResponseEntity addPaperStructure(@ModelAttribute PaperStructure ps){
+    	PaperStructure temp = paperStructureService.savePaperStructure(ps);
+    	ResponseEntity rse = new ResponseEntity(temp,HttpStatus.OK);
+    	return rse;
+    }
+
+    /**
+     * 删除导入试卷
+     * @param paper_id
+     * @return
+     */
+    @DeleteMapping(value = "/paperStructure/{paper_id}")
+    public ResponseEntity removePaperStructure(@PathVariable String paper_id){
+    	paperStructureService.deletePaperStructure(paper_id);
+    	ResponseEntity res = new ResponseEntity(paper_id,HttpStatus.OK);
+		return res;
+    }
+}

+ 9 - 0
cqb-question/src/main/java/com/qmth/cqb/question/dao/QuesOptionRepo.java

@@ -0,0 +1,9 @@
+package com.qmth.cqb.question.dao;
+
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import com.qmth.cqb.question.model.QuesOption;
+
+public interface QuesOptionRepo extends MongoRepository<QuesOption,String>,QueryByExampleExecutor<QuesOption>{
+}

+ 2 - 2
cqb-question/src/main/java/com/qmth/cqb/question/dao/QuesStructTypeRepo.java → cqb-question/src/main/java/com/qmth/cqb/question/dao/QuestionTypeRepo.java

@@ -1,11 +1,11 @@
 package com.qmth.cqb.question.dao;
 
-import com.qmth.cqb.question.model.QuesStructType;
+import com.qmth.cqb.question.model.QuestionType;
 import org.springframework.data.mongodb.repository.MongoRepository;
 import org.springframework.data.repository.query.QueryByExampleExecutor;
 
 /**
  * Created by songyue on 16/12/28.
  */
-public interface QuesStructTypeRepo extends MongoRepository<QuesStructType,String>,QueryByExampleExecutor<QuesStructType>{
+public interface QuestionTypeRepo extends MongoRepository<QuestionType,String>,QueryByExampleExecutor<QuestionType>{
 }

+ 51 - 38
cqb-question/src/main/java/com/qmth/cqb/question/model/ImportPaper.java

@@ -8,7 +8,7 @@ import java.util.List;
 import java.util.Map;
 
 /**
- * 导入试卷实体类
+ * 试卷实体类
  * Created by songyue on 16/12/28.
  */
 public class ImportPaper implements Serializable{
@@ -19,18 +19,22 @@ public class ImportPaper implements Serializable{
 
     @Indexed(unique = true)
     private String paperName;//试卷名称
+    
+    private String title;//试卷标题
+    
+    private double totalScore;//试卷总分
 
     private String createTime;//创建时间
 
     private String updateTime;//更新时间
 
-    private byte[] paperWord;//原始试卷word
+    private String word;//原始试卷word
 
-    private byte[] paperHtml;//原始试卷html
+    private String html;//原始试卷html
 
-    private List<Question> questionList;//试卷中的所有试题,按顺序排列
+    //private List<Question> questionList;//试卷中的所有试题,按顺序排列
 
-    private Map<String,String> quesParams;//导入试卷属性
+    private Map<String,String> params;//导入试卷属性
 
     public String getId() {
         return id;
@@ -47,8 +51,41 @@ public class ImportPaper implements Serializable{
     public void setPaperName(String paperName) {
         this.paperName = paperName;
     }
+    
+    public String getTitle() {
+		return title;
+	}
 
-    public String getCreateTime() {
+	public void setTitle(String title) {
+		this.title = title;
+	}
+
+    
+    public double getTotalScore() {
+		return totalScore;
+	}
+
+	public void setTotalScore(double totalScore) {
+		this.totalScore = totalScore;
+	}
+
+	public String getWord() {
+		return word;
+	}
+
+	public void setWord(String word) {
+		this.word = word;
+	}
+
+	public String getHtml() {
+		return html;
+	}
+
+	public void setHtml(String html) {
+		this.html = html;
+	}
+
+	public String getCreateTime() {
         return createTime;
     }
 
@@ -63,43 +100,19 @@ public class ImportPaper implements Serializable{
     public void setUpdateTime(String updateTime) {
         this.updateTime = updateTime;
     }
-
-    public byte[] getPaperWord() {
-        return paperWord;
-    }
-
-    public void setPaperWord(byte[] paperWord) {
-        this.paperWord = paperWord;
-    }
-
-    public byte[] getPaperHtml() {
-        return paperHtml;
-    }
-
-    public void setPaperHtml(byte[] paperHtml) {
-        this.paperHtml = paperHtml;
-    }
-
-    public List<Question> getQuestionList() {
-        return questionList;
-    }
-
-    public void setQuestionList(List<Question> questionList) {
-        this.questionList = questionList;
-    }
-
+    
     public static long getSerialVersionUID() {
         return serialVersionUID;
     }
 
-    public Map<String, String> getQuesParams() {
-        return quesParams;
-    }
+	public Map<String, String> getParams() {
+		return params;
+	}
 
-    public void setQuesParams(Map<String, String> quesParams) {
-        this.quesParams = quesParams;
-    }
+	public void setParams(Map<String, String> params) {
+		this.params = params;
+	}
 
-    public ImportPaper() {
+	public ImportPaper() {
     }
 }

+ 60 - 0
cqb-question/src/main/java/com/qmth/cqb/question/model/ImportPaperSearchCondition.java

@@ -0,0 +1,60 @@
+package com.qmth.cqb.question.model;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.index.Indexed;
+
+public class ImportPaperSearchCondition {
+	
+    private String id;
+    
+    private String paperName;//试卷名称
+
+    private String createTime;//创建时间
+
+    private String updateTime;//更新时间
+    
+    private String creatorId;//创建人id
+    
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getPaperName() {
+		return paperName;
+	}
+
+	public void setPaperName(String paperName) {
+		this.paperName = paperName;
+	}
+
+	public String getCreateTime() {
+		return createTime;
+	}
+
+	public void setCreateTime(String createTime) {
+		this.createTime = createTime;
+	}
+
+	public String getUpdateTime() {
+		return updateTime;
+	}
+
+	public void setUpdateTime(String updateTime) {
+		this.updateTime = updateTime;
+	}
+
+	public String getCreatorId() {
+		return creatorId;
+	}
+
+	public void setCreatorId(String creatorId) {
+		this.creatorId = creatorId;
+	}
+    
+    
+
+}

+ 0 - 62
cqb-question/src/main/java/com/qmth/cqb/question/model/QuesStructType.java

@@ -1,62 +0,0 @@
-package com.qmth.cqb.question.model;
-
-import org.springframework.data.annotation.Id;
-
-import java.io.Serializable;
-import java.util.Map;
-
-/**
- * 试题结构类型(单选、多选、判断等)
- * Created by songyue on 16/12/28.
- */
-public class QuesStructType implements Serializable{
-    private static final long serialVersionUID = -4183850561167604080L;
-
-    @Id
-    private String id;
-
-    private String typeName;//类型名称
-
-    private String typeTitle;//类型标题
-
-    private Map params;//类型参数
-
-    public static long getSerialVersionUID() {
-        return serialVersionUID;
-    }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public String getTypeName() {
-        return typeName;
-    }
-
-    public void setTypeName(String typeName) {
-        this.typeName = typeName;
-    }
-
-    public String getTypeTitle() {
-        return typeTitle;
-    }
-
-    public void setTypeTitle(String typeTitle) {
-        this.typeTitle = typeTitle;
-    }
-
-    public Map getParams() {
-        return params;
-    }
-
-    public void setParams(Map params) {
-        this.params = params;
-    }
-
-    public QuesStructType() {
-    }
-}

+ 5 - 5
cqb-question/src/main/java/com/qmth/cqb/question/model/Question.java

@@ -35,7 +35,7 @@ public class Question implements Serializable{
     private List<QuesResource> quesResource;//试题resource(试题资源库集合,适用于多媒体介质试题)
 
     @DBRef
-    private QuesStructType quesStructType;//试题结构类型
+    private QuestionType questionType;//试题结构类型
 
     private String createTime;//创建时间
 
@@ -153,11 +153,11 @@ public class Question implements Serializable{
         this.quesAnswerAnalysisWord = quesAnswerAnalysisWord;
     }
 
-    public QuesStructType getQuesStructType() {
-        return quesStructType;
+    public QuestionType getQuesStructType() {
+        return questionType;
     }
 
-    public void setQuesStructType(QuesStructType quesStructType) {
-        this.quesStructType = quesStructType;
+    public void setQuesStructType(QuestionType questionType) {
+        this.questionType = questionType;
     }
 }

+ 60 - 0
cqb-question/src/main/java/com/qmth/cqb/question/model/QuestionSearchCondition.java

@@ -0,0 +1,60 @@
+package com.qmth.cqb.question.model;
+
+import java.util.Map;
+
+public class QuestionSearchCondition {
+
+	private String id;
+
+	private String quesTypeName;// 试题类型名称
+
+	private String createTime;// 创建时间
+
+	private String updateTime;// 更新时间
+
+	private Map<String, String> quesParams;// 试题其他属性
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getQuesTypeName() {
+		return quesTypeName;
+	}
+
+	public void setQuesTypeName(String quesTypeName) {
+		this.quesTypeName = quesTypeName;
+	}
+
+	public String getCreateTime() {
+		return createTime;
+	}
+
+	public void setCreateTime(String createTime) {
+		this.createTime = createTime;
+	}
+
+	public String getUpdateTime() {
+		return updateTime;
+	}
+
+	public void setUpdateTime(String updateTime) {
+		this.updateTime = updateTime;
+	}
+
+	public Map<String, String> getQuesParams() {
+		return quesParams;
+	}
+
+	public void setQuesParams(Map<String, String> quesParams) {
+		this.quesParams = quesParams;
+	}
+	  
+	  
+
+
+}

+ 76 - 0
cqb-question/src/main/java/com/qmth/cqb/question/model/QuestionType.java

@@ -0,0 +1,76 @@
+package com.qmth.cqb.question.model;
+
+import org.springframework.data.annotation.Id;
+
+import com.qmth.cqb.utils.enumeration.QuesStructType;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * 试题结构类型(单选、多选、判断等)
+ * Created by songyue on 16/12/28.
+ */
+public class QuestionType implements Serializable{
+    private static final long serialVersionUID = -4183850561167604080L;
+
+    @Id
+    private long id;
+
+    private QuesStructType quesType;//类型名称
+
+    private String name;//类型标题
+
+    private Map params;//类型参数
+
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
+    }
+
+
+    public long getId() {
+		return id;
+	}
+
+
+	public void setId(long id) {
+		this.id = id;
+	}
+
+
+	public QuesStructType getQuesType() {
+		return quesType;
+	}
+
+
+	public void setQuesType(QuesStructType quesType) {
+		this.quesType = quesType;
+	}
+
+
+	public String getName() {
+		return name;
+	}
+
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+
+	public static long getSerialversionuid() {
+		return serialVersionUID;
+	}
+
+
+	public Map getParams() {
+        return params;
+    }
+
+    public void setParams(Map params) {
+        this.params = params;
+    }
+
+    public QuestionType() {
+    }
+}

+ 18 - 8
cqb-question/src/main/java/com/qmth/cqb/question/service/ImportPaperService.java

@@ -2,10 +2,16 @@ package com.qmth.cqb.question.service;
 
 import com.qmth.cqb.question.dao.ImportPaperRepo;
 import com.qmth.cqb.question.model.ImportPaper;
+import com.qmth.cqb.question.model.ImportPaperSearchCondition;
 import com.qmth.cqb.utils.modal.NormalResponse;
 import com.qmth.cqb.utils.modal.PagingAndSortingResponse;
+
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith;
+
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Example;
+import org.springframework.data.domain.ExampleMatcher;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.http.HttpStatus;
@@ -50,8 +56,11 @@ public class ImportPaperService {
      * @param pageSize
      * @return
      */
-    public PagingAndSortingResponse<ImportPaper> findAll(ImportPaper searchCondition,int curPage,int pageSize){
-        Page<ImportPaper> importPaperList = importPaperRepo.findAll(Example.of(searchCondition),new PageRequest(curPage-1,pageSize));
+    public PagingAndSortingResponse<ImportPaper> findAll(ImportPaperSearchCondition searchCondition,int curPage,int pageSize){
+    	ImportPaper importPaper = new ImportPaper();
+    	BeanUtils.copyProperties(searchCondition,importPaper);
+    	ExampleMatcher matcher = ExampleMatcher.matching().withMatcher("paperName", startsWith());
+        Page<ImportPaper> importPaperList = importPaperRepo.findAll(Example.of(importPaper,matcher),new PageRequest(curPage-1,pageSize));
         return new PagingAndSortingResponse<ImportPaper>(importPaperList.getNumber(),importPaperList.getSize(),
                 importPaperList.getTotalPages(),importPaperList.getTotalElements(),importPaperList.getContent());
     }
@@ -70,13 +79,14 @@ public class ImportPaperService {
      * @param importPaper
      * @return
      */
-    public NormalResponse saveImportPaper(ImportPaper importPaper){
+    public ImportPaper saveImportPaper(ImportPaper importPaper){
         ImportPaper tempPaper = importPaperRepo.save(importPaper);
-        if(tempPaper != null){
-            return new NormalResponse(HttpStatus.OK.toString(),"success");
-        }else{
-            return new NormalResponse(HttpStatus.INTERNAL_SERVER_ERROR.toString(),"保存失败");
-        }
+        return tempPaper;
+//        if(tempPaper != null){
+//            return new NormalResponse(HttpStatus.OK.toString(),"success");
+//        }else{
+//            return new NormalResponse(HttpStatus.INTERNAL_SERVER_ERROR.toString(),"保存失败");
+//        }
     }
 
     /**

+ 15 - 13
cqb-question/src/main/java/com/qmth/cqb/question/service/QuesService.java

@@ -1,9 +1,13 @@
 package com.qmth.cqb.question.service;
 
 import com.qmth.cqb.question.dao.QuesRepo;
+import com.qmth.cqb.question.model.QuestionType;
 import com.qmth.cqb.question.model.Question;
+import com.qmth.cqb.question.model.QuestionSearchCondition;
 import com.qmth.cqb.utils.modal.NormalResponse;
 import com.qmth.cqb.utils.modal.PagingAndSortingResponse;
+
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Example;
 import org.springframework.data.domain.Page;
@@ -35,8 +39,13 @@ public class QuesService {
      * @param pageSize
      * @return
      */
-    public PagingAndSortingResponse<Question> findAll(Question searchCondition, int curPage, int pageSize){
-        Page<Question> quesList = quesRepo.findAll(Example.of(searchCondition),new PageRequest(curPage-1,pageSize));
+    public PagingAndSortingResponse<Question> findAll(QuestionSearchCondition searchCondition, int curPage, int pageSize){
+    	Question que = new Question();
+    	QuestionType qst = new QuestionType();
+    	qst.setName(searchCondition.getQuesTypeName());
+    	que.setQuesStructType(qst);
+    	BeanUtils.copyProperties(searchCondition,que);
+        Page<Question> quesList = quesRepo.findAll(Example.of(que),new PageRequest(curPage-1,pageSize));
         return new PagingAndSortingResponse<Question>(quesList.getNumber(),quesList.getSize(),
                 quesList.getTotalPages(),quesList.getTotalElements(),quesList.getContent());
     }
@@ -55,13 +64,9 @@ public class QuesService {
      * @param question
      * @return
      */
-    public NormalResponse saveQuestion(Question question){
-        Question tempPaper = quesRepo.save(question);
-        if(tempPaper != null){
-            return new NormalResponse(HttpStatus.OK.toString(),"success");
-        }else{
-            return new NormalResponse(HttpStatus.INTERNAL_SERVER_ERROR.toString(),"保存失败");
-        }
+    public Question saveQuestion(Question question){
+        Question tempQues = quesRepo.save(question);
+        return tempQues;
     }
 
     /**
@@ -69,10 +74,7 @@ public class QuesService {
      * @param typeId
      * @return
      */
-    public NormalResponse deleteQuestion(String typeId){
+    public void deleteQuestion(String typeId){
         quesRepo.delete(typeId);
-        return new NormalResponse(HttpStatus.OK.toString(),"success");
     }
-
-
 }

+ 9 - 9
cqb-question/src/main/java/com/qmth/cqb/question/service/QuesStructTypeService.java

@@ -1,7 +1,7 @@
 package com.qmth.cqb.question.service;
 
-import com.qmth.cqb.question.dao.QuesStructTypeRepo;
-import com.qmth.cqb.question.model.QuesStructType;
+import com.qmth.cqb.question.dao.QuestionTypeRepo;
+import com.qmth.cqb.question.model.QuestionType;
 import com.qmth.cqb.utils.modal.NormalResponse;
 import com.qmth.cqb.utils.modal.PagingAndSortingResponse;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -27,7 +27,7 @@ public class QuesStructTypeService {
      */
 
     @Autowired
-    QuesStructTypeRepo quesStructTypeRepo;
+    QuestionTypeRepo quesStructTypeRepo;
 
 
     /**
@@ -37,9 +37,9 @@ public class QuesStructTypeService {
      * @param pageSize
      * @return
      */
-    public PagingAndSortingResponse<QuesStructType> findAll(QuesStructType searchCondition, int curPage, int pageSize){
-        Page<QuesStructType> quesStructTypeList = quesStructTypeRepo.findAll(Example.of(searchCondition),new PageRequest(curPage-1,pageSize));
-        return new PagingAndSortingResponse<QuesStructType>(quesStructTypeList.getNumber(),quesStructTypeList.getSize(),
+    public PagingAndSortingResponse<QuestionType> findAll(QuestionType searchCondition, int curPage, int pageSize){
+        Page<QuestionType> quesStructTypeList = quesStructTypeRepo.findAll(Example.of(searchCondition),new PageRequest(curPage-1,pageSize));
+        return new PagingAndSortingResponse<QuestionType>(quesStructTypeList.getNumber(),quesStructTypeList.getSize(),
                 quesStructTypeList.getTotalPages(),quesStructTypeList.getTotalElements(),quesStructTypeList.getContent());
     }
 
@@ -48,7 +48,7 @@ public class QuesStructTypeService {
      * @param typeId
      * @return
      */
-    public QuesStructType findById(String typeId){
+    public QuestionType findById(String typeId){
         return quesStructTypeRepo.findOne(typeId);
     }
 
@@ -57,8 +57,8 @@ public class QuesStructTypeService {
      * @param quesStructType
      * @return
      */
-    public NormalResponse saveQuesStructType(QuesStructType quesStructType){
-        QuesStructType tempPaper = quesStructTypeRepo.save(quesStructType);
+    public NormalResponse saveQuesStructType(QuestionType quesStructType){
+        QuestionType tempPaper = quesStructTypeRepo.save(quesStructType);
         if(tempPaper != null){
             return new NormalResponse(HttpStatus.OK.toString(),"success");
         }else{

+ 104 - 10
cqb-question/src/main/java/com/qmth/cqb/question/web/ImportPaperController.java

@@ -1,10 +1,104 @@
-package com.qmth.cqb.question.web;
-
-import org.springframework.stereotype.Controller;
-
-/**
- * Created by songyue on 16/12/29.
- */
-@Controller
-public class ImportPaperController {
-}
+//package com.qmth.cqb.question.web;
+//
+//import java.util.List;
+//
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.http.HttpStatus;
+//import org.springframework.http.ResponseEntity;
+//import org.springframework.stereotype.Controller;
+//import org.springframework.web.bind.annotation.DeleteMapping;
+//import org.springframework.web.bind.annotation.GetMapping;
+//import org.springframework.web.bind.annotation.ModelAttribute;
+//import org.springframework.web.bind.annotation.PathVariable;
+//import org.springframework.web.bind.annotation.PostMapping;
+//import org.springframework.web.bind.annotation.PutMapping;
+//import org.springframework.web.bind.annotation.RequestMapping;
+//import org.springframework.web.bind.annotation.RestController;
+//
+//import com.google.gson.Gson;
+//import com.qmth.cqb.question.model.ImportPaper;
+//import com.qmth.cqb.question.model.ImportPaperSearchCondition;
+//import com.qmth.cqb.question.model.Question;
+//import com.qmth.cqb.question.service.ImportPaperService;
+//import com.qmth.cqb.utils.modal.NormalResponse;
+//import com.qmth.cqb.utils.modal.PagingAndSortingResponse;
+//
+///**
+// * Created by songyue on 16/12/29.
+// */
+//@RestController
+//@RequestMapping("${api_cqb}/")
+//public class ImportPaperController {
+//    @Autowired
+//    ImportPaperService importPaperService;
+//      
+//    @Autowired
+//    Gson gson;
+//
+//
+//    /**
+//     * 获取导入试卷
+//     * @param importPaper_id
+//     * @return
+//     */
+//    @GetMapping(value = "/importPaper/{importPaper_id}")
+//    public ImportPaper getImportPaperById(@PathVariable String importPaper_id){
+//        return importPaperService.findById(importPaper_id);
+//    }
+//    
+//    /**
+//     * 获取导入试卷的所有试题
+//     * @param importPaper_id
+//     * @return
+//     */
+////    @GetMapping(value = "/importPaper/question/{importPaper_id}")
+////    public List<Question> getQuesImportPaperById(@PathVariable String importPaper_id){
+////    	return importPaperService.findById(importPaper_id).getQuestionList();
+////    }
+//
+//
+//    /**
+//     * 获取全部导入试卷
+//     * @return
+//     */
+//    @GetMapping(value = "/importPaper/all/{curPage}/{paseSize}")
+//    public PagingAndSortingResponse<ImportPaper> getAllImportPaper(@ModelAttribute ImportPaperSearchCondition searchCondition, @PathVariable int curPage, @PathVariable int pageSize){
+//      PagingAndSortingResponse<ImportPaper> psr = importPaperService.findAll(searchCondition, curPage, pageSize);
+//      return psr;
+//    }
+//
+//    /**
+//     * 更新导入试卷信息
+//     * @param 
+//     * @return
+//     */
+//    @PutMapping(value = "/importPaper")
+//    public ResponseEntity updateImportPaper(@ModelAttribute ImportPaper paper){
+//    	ImportPaper paper2 = importPaperService.saveImportPaper(paper);
+//    	ResponseEntity rse = new ResponseEntity(paper2,HttpStatus.OK);
+//    	return rse;
+//    	
+//    }
+//
+//    /**
+//     * 新增导入试卷
+//     * @param paper
+//     * @return
+//     */
+//    @PostMapping(value = "/importPaper")
+//    public ResponseEntity addImportPaper(@ModelAttribute ImportPaper paper){
+//    	ImportPaper paper2 = importPaperService.saveImportPaper(paper);
+//    	ResponseEntity rse = new ResponseEntity(paper2,HttpStatus.OK);
+//    	return rse;
+//    }
+//
+//    /**
+//     * 删除导入试卷
+//     * @param paper_id
+//     * @return
+//     */
+//    @DeleteMapping(value = "/importPaper/{importPaper_id}")
+//    public NormalResponse removeImportPaper(@PathVariable String importPaper_id){
+//    	return importPaperService.deleteImportPaper(importPaper_id);
+//    }
+//}

+ 110 - 4
cqb-question/src/main/java/com/qmth/cqb/question/web/QuesController.java

@@ -1,18 +1,124 @@
 package com.qmth.cqb.question.web;
 
-import com.qmth.cqb.question.dao.QuesRepo;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import com.qmth.cqb.question.model.QuesOption;
+import com.qmth.cqb.question.model.QuestionType;
+import com.qmth.cqb.question.model.Question;
+import com.qmth.cqb.question.model.QuestionSearchCondition;
 import com.qmth.cqb.question.service.QuesService;
+import com.qmth.cqb.utils.modal.NormalResponse;
+import com.qmth.cqb.utils.modal.PagingAndSortingResponse;
+
+import io.swagger.annotations.ApiOperation;
+
+import java.util.ArrayList;
+import java.util.List;
+
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 /**
  * Created by songyue on 16/12/28.
  */
-@Controller
+@RestController
+@RequestMapping("${api_cqb}/")
 public class QuesController {
     @Autowired
     QuesService quesService;
 
+      
     @Autowired
-    QuesRepo quesRepo;
+    Gson gson;
+
+
+    /**
+     * 获取试题
+     * @param ques_id
+     * @return
+     */
+    @ApiOperation(value="获取单个试题",notes="获取单个试题")
+    @GetMapping(value = "/ques/{ques_id}")
+    public Question getQuesById(@PathVariable String ques_id){
+        return quesService.findById(ques_id);
+    }
+
+    /**
+     * 获取全部试题
+     * @return
+     */
+    @GetMapping(value = "/ques/all/{curPage}/{pageSize}")
+    public PagingAndSortingResponse<Question> getAllQuestion(@ModelAttribute QuestionSearchCondition searchCondition, @PathVariable int curPage, @PathVariable int pageSize){
+      PagingAndSortingResponse<Question> psr = quesService.findAll(searchCondition, curPage, pageSize);
+      return psr;
+    }
+
+    /**
+     * 更新试题信息
+     * @param 
+     * @return
+     */
+    @PutMapping(value = "/question")
+    public ResponseEntity updateQuestion(@ModelAttribute Question ques){
+    	//return quesService.saveQuestion(ques);
+        Question qus = quesService.saveQuestion(ques);
+        ResponseEntity rse = new ResponseEntity(qus,HttpStatus.OK);
+        return rse;
+    	
+    }
+
+    /**
+     * 新增试题
+     * @param question
+     * @return
+     */
+    @PostMapping(value = "/question")
+    public ResponseEntity addQuestion(@ModelAttribute Question ques){
+//    	QuesOption opt1 =  new QuesOption();
+//    	opt1.setOptionNo("1");
+//    	opt1.setOptionBody("10");
+//    	QuesOption opt2 =  new QuesOption();
+//    	opt2.setOptionNo("2");
+//    	opt2.setOptionBody("15");
+//    	List<QuesOption> opts = new ArrayList<QuesOption>();
+//    	opts.add(opt1);
+//    	opts.add(opt2);
+//    	QuesStructType type = new QuesStructType();
+//    	type.setId("1");
+//    	type.setTypeName("单选");
+//    	type.setTypeTitle("单项选择题");
+//    	Question questemp = new Question();
+//    	questemp.setCreateTime("1");
+//    	questemp.setQuesAnswer("B");
+//    	questemp.setQuesBody("5乘以3等于几");
+//    	questemp.setQuesOptions(opts);
+//    	questemp.setQuesStructType(type);
+//    	
+//      String quesJson = gson.toJson(questemp);
+//      Question ques = gson.fromJson(quesJson,Question.class);
+      Question qus = quesService.saveQuestion(ques);
+      ResponseEntity rse2 = new ResponseEntity(qus,HttpStatus.OK);
+      return rse2;
+    }
+
+    /**
+     * 删除试题
+     * @param ques_id
+     * @return
+     */
+    @DeleteMapping(value = "/ques/{ques_id}")
+    public ResponseEntity removeQuestion(@PathVariable String ques_id){
+    	quesService.deleteQuestion(ques_id);
+    	ResponseEntity rse2 = new ResponseEntity(ques_id,HttpStatus.OK);
+    	return rse2;
+    }
 }

+ 0 - 10
cqb-question/src/main/java/com/qmth/cqb/question/web/QuesStructTypeController.java

@@ -1,10 +0,0 @@
-package com.qmth.cqb.question.web;
-
-import org.springframework.stereotype.Controller;
-
-/**
- * Created by songyue on 16/12/29.
- */
-@Controller
-public class QuesStructTypeController {
-}

+ 83 - 0
cqb-question/src/main/java/com/qmth/cqb/question/web/QuestionTypeController.java

@@ -0,0 +1,83 @@
+package com.qmth.cqb.question.web;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.google.gson.Gson;
+import com.qmth.cqb.question.model.QuestionType;
+import com.qmth.cqb.question.service.QuesStructTypeService;
+import com.qmth.cqb.utils.modal.NormalResponse;
+import com.qmth.cqb.utils.modal.PagingAndSortingResponse;
+
+/**
+ * Created by songyue on 16/12/29.
+ */
+@RestController
+@RequestMapping("${api_cqb}/")
+public class QuestionTypeController {
+    @Autowired
+    QuesStructTypeService quesStructTypeService;
+      
+    @Autowired
+    Gson gson;
+
+
+    /**
+     * 获取试题结构类型
+     * @param ques_id
+     * @return
+     */
+    @GetMapping(value = "/quesStructType/{quesStype_id}")
+    public QuestionType getQuesById(@PathVariable String quesStype_id){
+        return quesStructTypeService.findById(quesStype_id);
+    }
+
+    /**
+     * 获取全部试卷结构
+     * @return
+     */
+    @GetMapping(value = "/quesStructType/all/{curPage}/{paseSize}")
+    public PagingAndSortingResponse<QuestionType> getAllQuesStructType(@ModelAttribute QuestionType searchCondition, @PathVariable int curPage, @PathVariable int pageSize){
+      PagingAndSortingResponse<QuestionType> psr = quesStructTypeService.findAll(searchCondition, curPage, pageSize);
+      return psr;
+    }
+
+    /**
+     * 更新试卷结构信息
+     * @param 
+     * @return
+     */
+    @PutMapping(value = "/quesStructType")
+    public NormalResponse updateQuesStructType(@ModelAttribute QuestionType ques){
+    	return quesStructTypeService.saveQuesStructType(ques);
+    	
+    }
+
+    /**
+     * 新增试卷结构
+     * @param quesStype
+     * @return
+     */
+    @PostMapping(value = "/quesStructType")
+    public NormalResponse addQuesStructType(@ModelAttribute QuestionType quesStype){
+    	return quesStructTypeService.saveQuesStructType(quesStype);
+    }
+
+    /**
+     * 删除试卷结构
+     * @param quesStype_id
+     * @return
+     */
+    @DeleteMapping(value = "/quesStructType/{quesStype_id}")
+    public NormalResponse removeQuesStructType(@PathVariable String quesStype_id){
+    	return quesStructTypeService.deleteQuesStructType(quesStype_id);
+    }
+}

+ 1 - 0
cqb-starter/.gitignore

@@ -0,0 +1 @@
+/target/

+ 12 - 0
cqb-starter/pom.xml

@@ -71,6 +71,18 @@
             <artifactId>spring-boot-devtools</artifactId>
             <optional>true</optional>
         </dependency>
+        
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>2.6.1</version>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>2.6.1</version>
+        </dependency>
+        
 
     </dependencies>
     <build>

+ 34 - 0
cqb-starter/src/main/java/com/qmth/cqb/Swagger2.java

@@ -0,0 +1,34 @@
+package com.qmth.cqb;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableSwagger2
+public class Swagger2 {
+    @Bean
+    public Docket createRestApi() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(apiInfo())
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("com.qmth.cqb"))
+                .paths(PathSelectors.any())
+                .build();
+    }
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                .title("题库接口")
+                .description("基于swagger构建的Restful API")
+                .version("1.0")
+                .build();
+    }
+
+}

+ 3 - 2
cqb-starter/src/main/resources/application.properties

@@ -1,3 +1,4 @@
-spring.data.mongodb.uri=mongodb://localhost:27017/comm-ques-bank
+spring.data.mongodb.uri=mongodb://192.168.1.99:27017/comm-ques-bank
 spring.data.mongodb.grid-fs-database=comm-ques-bank
-server.port=8888
+server.port=8888
+api_cqb=/api/cqb