wangwei 6 rokov pred
rodič
commit
807464e335

+ 0 - 76
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamOrgTimeController.java

@@ -1,76 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.api.controller;
-
-import java.util.List;
-
-import org.springframework.beans.factory.annotation.Autowired;
-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.transaction.annotation.Transactional;
-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.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgTimeRepo;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgTime;
-import cn.com.qmth.examcloud.core.examwork.service.impl.ExamOrgTimeService;
-import io.swagger.annotations.ApiOperation;
-
-/**
- * 考试服务API Created by songyue on 17/1/13.
- */
-@Transactional
-@RestController
-@RequestMapping("${$rmp.ctr.examwork}/examOrgTime")
-public class ExamOrgTimeController {
-
-	@Autowired
-	ExamOrgTimeRepo examOrgTimeRepo;
-
-	@Autowired
-	ExamOrgTimeService examOrgTimeService;
-
-	@ApiOperation(value = "查询学习中心考试时间", notes = "分页")
-	@GetMapping("{curPage}/{pageSize}")
-	public ResponseEntity findByExamId(@ModelAttribute ExamOrgTime examOrgTime,
-			@PathVariable Integer curPage, @PathVariable Integer pageSize) {
-		PageRequest pageRequest = new PageRequest(curPage, pageSize);
-		Page<ExamOrgTime> orgTimePage = examOrgTimeService.getAllOrgTime(examOrgTime, pageRequest);
-		return new ResponseEntity(orgTimePage, HttpStatus.OK);
-	}
-
-	@ApiOperation(value = "查询学习中心考试时间", notes = "不分页")
-	@GetMapping("{examId}")
-	public ResponseEntity findByExamId(@PathVariable Long examId) {
-		List<ExamOrgTime> orgTimePage = examOrgTimeRepo.findByExamId(examId);
-		return new ResponseEntity(orgTimePage, HttpStatus.OK);
-	}
-
-	@ApiOperation(value = "按ID查询学习中心考试时间", notes = "ID查询")
-	@GetMapping("{id}")
-	public ResponseEntity findById(@PathVariable Long id) {
-		return new ResponseEntity(examOrgTimeRepo.findOne(id), HttpStatus.OK);
-	}
-
-	@ApiOperation(value = "新增学习中心考试时间", notes = "新增")
-	@PostMapping()
-	public ExamOrgTime add(@RequestBody ExamOrgTime examOrgTime) {
-		ExamOrgTime saved = examOrgTimeRepo.save(examOrgTime);
-
-		return saved;
-	}
-
-	@ApiOperation(value = "更新学习中心考试时间", notes = "更新")
-	@PutMapping()
-	public ExamOrgTime update(@RequestBody ExamOrgTime examOrgTime) {
-
-		ExamOrgTime saved = examOrgTimeRepo.save(examOrgTime);
-		return saved;
-	}
-}

+ 8 - 0
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamOrgRepo.java

@@ -4,7 +4,10 @@ import java.util.List;
 
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.query.QueryByExampleExecutor;
+import org.springframework.transaction.annotation.Transactional;
 
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgEntity;
 
@@ -13,6 +16,11 @@ public interface ExamOrgRepo
 			JpaRepository<ExamOrgEntity, Long>,
 			QueryByExampleExecutor<ExamOrgEntity> {
 
+	@Transactional
+	@Modifying
+	@Query("delete from ExamOrgEntity where examId = ?1")
+	void deleteByExamId(Long examId);
+
 	List<ExamOrgEntity> findAllByExamId(Long examId, Pageable pageable);
 
 	List<ExamOrgEntity> findAllByExamIdAndOrgId(Long examId, Long orgId, Pageable pageable);

+ 0 - 30
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamOrgTimeRepo.java

@@ -1,30 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.dao;
-
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-import org.springframework.data.jpa.repository.Modifying;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.transaction.annotation.Transactional;
-
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgTime;
-
-import java.util.List;
-
-public interface ExamOrgTimeRepo
-		extends
-			JpaRepository<ExamOrgTime, Long>,
-			JpaSpecificationExecutor<ExamOrgTime> {
-
-	List<ExamOrgTime> findByExamId(Long examId);
-
-	Page<ExamOrgTime> findByExamId(Long examId, Pageable pageable);
-
-	ExamOrgTime findFirstByExamIdAndOrgId(Long examId, Long orgId);
-
-	@Transactional
-	@Modifying
-	@Query("delete from ExamOrgTime where examId = ?1")
-	void deleteByExamId(Long examId);
-}

+ 1 - 1
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/CourseGroupEntity.java

@@ -18,7 +18,7 @@ import cn.com.qmth.examcloud.commons.web.jpa.JpaEntity;
  *
  */
 @Entity
-@Table(name = "ecs_e_course_group")
+@Table(name = "EC_E_COURSE_GROUP")
 public class CourseGroupEntity extends JpaEntity {
 
 	private static final long serialVersionUID = -3335725218626631530L;

+ 48 - 5
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamOrgEntity.java

@@ -3,8 +3,9 @@ package cn.com.qmth.examcloud.core.examwork.dao.entity;
 import java.util.Date;
 
 import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
-import javax.persistence.IdClass;
+import javax.persistence.Index;
 import javax.persistence.Table;
 
 import org.springframework.format.annotation.DateTimeFormat;
@@ -12,23 +13,36 @@ import org.springframework.format.annotation.DateTimeFormat;
 import cn.com.qmth.examcloud.commons.web.jpa.JpaEntity;
 
 /**
- * 类注释
+ * 考试机构设置
  *
  * @author WANGWEI
  * @date 2018年5月16日
  * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
  */
 @Entity
-@Table(name = "ecs_e_exam_org")
-@IdClass(ExamOrgPK.class)
+@Table(name = "EC_E_EXAM_ORG", indexes = {
+		@Index(name = "IDX_E_E_ORG_001001", columnList = "examId,orgId", unique = true)})
 public class ExamOrgEntity extends JpaEntity {
 
 	private static final long serialVersionUID = -3335725218626631530L;
 
 	@Id
+	@GeneratedValue
+	private Long id;
+
+	/**
+	 * 考试ID
+	 */
 	private Long examId;
 
-	@Id
+	/**
+	 * 顶级机构ID
+	 */
+	private Long rootOrgId;
+
+	/**
+	 * 机构ID
+	 */
 	private Long orgId;
 
 	/**
@@ -43,6 +57,19 @@ public class ExamOrgEntity extends JpaEntity {
 	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 	private Date endTime;
 
+	/**
+	 * 是否允许上传附件(离线考试)
+	 */
+	private Boolean canUploadAttachment;
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
 	public Long getExamId() {
 		return examId;
 	}
@@ -51,6 +78,14 @@ public class ExamOrgEntity extends JpaEntity {
 		this.examId = examId;
 	}
 
+	public Long getRootOrgId() {
+		return rootOrgId;
+	}
+
+	public void setRootOrgId(Long rootOrgId) {
+		this.rootOrgId = rootOrgId;
+	}
+
 	public Long getOrgId() {
 		return orgId;
 	}
@@ -75,4 +110,12 @@ public class ExamOrgEntity extends JpaEntity {
 		this.endTime = endTime;
 	}
 
+	public Boolean getCanUploadAttachment() {
+		return canUploadAttachment;
+	}
+
+	public void setCanUploadAttachment(Boolean canUploadAttachment) {
+		this.canUploadAttachment = canUploadAttachment;
+	}
+
 }

+ 0 - 45
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamOrgPK.java

@@ -1,45 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.dao.entity;
-
-import java.io.Serializable;
-
-/**
- * 考试-学习中心 PK
- * 
- * @author WANG
- *
- */
-public class ExamOrgPK implements Serializable {
-
-	private static final long serialVersionUID = 3692854300698527252L;
-
-	private Long examId;
-
-	private Long orgId;
-
-	public ExamOrgPK() {
-		super();
-	}
-
-	public ExamOrgPK(Long examId, Long orgId) {
-		super();
-		this.examId = examId;
-		this.orgId = orgId;
-	}
-
-	public Long getExamId() {
-		return examId;
-	}
-
-	public void setExamId(Long examId) {
-		this.examId = examId;
-	}
-
-	public Long getOrgId() {
-		return orgId;
-	}
-
-	public void setOrgId(Long orgId) {
-		this.orgId = orgId;
-	}
-
-}

+ 0 - 130
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamOrgTime.java

@@ -1,130 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.dao.entity;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.validation.constraints.NotNull;
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * 学习中心设置考试时间,只针对离线考试
- * Created by songyue on 18/2/1.
- */
-@Entity
-@Table(name = "ecs_exam_org_time")
-public class ExamOrgTime implements Serializable{
-
-    private static final long serialVersionUID = -6957590800607876766L;
-
-    @Id
-    @GeneratedValue
-    private Long id;
-
-    @NotNull
-    private Long examId;
-
-    @NotNull
-    private Long orgId;
-
-    private String orgCode;
-
-    private String orgName;
-
-    /**
-     * 该学习中心考试开始时间
-     */
-    private Date beginTime;
-
-    /**
-     * 该学习中心考试结束时间
-     */
-    private Date endTime;
-
-    /**
-     * 是否可上传
-     */
-    private Boolean canUpload;
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public Long getExamId() {
-        return examId;
-    }
-
-    public void setExamId(Long examId) {
-        this.examId = examId;
-    }
-
-    public Long getOrgId() {
-        return orgId;
-    }
-
-    public void setOrgId(Long orgId) {
-        this.orgId = orgId;
-    }
-
-    public Date getBeginTime() {
-        return beginTime;
-    }
-
-    public void setBeginTime(Date beginTime) {
-        this.beginTime = beginTime;
-    }
-
-    public Date getEndTime() {
-        return endTime;
-    }
-
-    public void setEndTime(Date endTime) {
-        this.endTime = endTime;
-    }
-
-    public String getOrgName() {
-        return orgName;
-    }
-
-    public void setOrgName(String orgName) {
-        this.orgName = orgName;
-    }
-
-    public Boolean getCanUpload() {
-        return canUpload;
-    }
-
-    public void setCanUpload(Boolean canUpload) {
-        this.canUpload = canUpload;
-    }
-
-    public String getOrgCode() {
-        return orgCode;
-    }
-
-    public void setOrgCode(String orgCode) {
-        this.orgCode = orgCode;
-    }
-
-    public ExamOrgTime(Long examId,
-                       Long orgId,
-                       String orgCode,
-                       String orgName,
-                       Date beginTime,
-                       Date endTime) {
-        this.examId = examId;
-        this.orgId = orgId;
-        this.orgCode = orgCode;
-        this.orgName = orgName;
-        this.beginTime = beginTime;
-        this.endTime = endTime;
-    }
-
-    public ExamOrgTime() {
-    }
-}

+ 0 - 61
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamOrgTimeService.java

@@ -1,61 +0,0 @@
-package cn.com.qmth.examcloud.core.examwork.service.impl;
-
-import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgTimeRepo;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgTime;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.domain.Specification;
-import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
-
-import javax.persistence.criteria.Predicate;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by songyue on 18/3/1.
- */
-@Service
-public class ExamOrgTimeService {
-
-
-    @Autowired
-    private ExamOrgTimeRepo examOrgTimeRepo;
-
-    /**
-     * 获取所有学习中心考试时间(分页)
-     * @param examOrgTime
-     * @param pageable
-     * @return
-     * @return
-     */
-    public Page<ExamOrgTime> getAllOrgTime(ExamOrgTime examOrgTime, Pageable pageable){
-        Specification<ExamOrgTime> specification = getPageSpecification(examOrgTime);
-        Page<ExamOrgTime> examOrgTimes = examOrgTimeRepo.findAll(specification,pageable);
-        return examOrgTimes;
-    }
-
-    /**
-     * 生成查询条件
-     * @param examOrgTime
-     * @return
-     */
-    private Specification<ExamOrgTime> getPageSpecification(ExamOrgTime examOrgTime) {
-        Specification<ExamOrgTime> specification = (root, query, cb) -> {
-            List<Predicate> predicates = new ArrayList<>();
-            if(!StringUtils.isEmpty(examOrgTime.getExamId())){
-                predicates.add(cb.equal(root.get("examId"),examOrgTime.getExamId()));
-            }
-            if(!StringUtils.isEmpty(examOrgTime.getOrgCode())){
-                predicates.add(cb.like(root.get("orgCode"),"%"+examOrgTime.getOrgCode()+"%"));
-            }
-            if(!StringUtils.isEmpty(examOrgTime.getOrgName())){
-                predicates.add(cb.like(root.get("orgName"),"%"+examOrgTime.getOrgName()+"%"));
-            }
-            return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-        };
-        return specification;
-    }
-}

+ 3 - 3
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamServiceImpl.java

@@ -15,7 +15,7 @@ import com.google.common.collect.Maps;
 import cn.com.qmth.examcloud.commons.base.exception.StatusException;
 import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
 import cn.com.qmth.examcloud.core.examwork.base.enums.ExamProperty;
-import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgTimeRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamPropertyRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
@@ -39,7 +39,7 @@ public class ExamServiceImpl implements ExamService {
 	ExamStudentServiceImpl examStudentService;
 
 	@Autowired
-	ExamOrgTimeRepo examOrgTimeRepo;
+	ExamOrgRepo examOrgRepo;
 
 	@Autowired
 	OrgCloudService orgCloudService;
@@ -60,7 +60,7 @@ public class ExamServiceImpl implements ExamService {
 				throw new StatusException("", "[ " + exam.getName() + " ] 已经开考,不能删除");
 			}
 			// 删除学习中心考试时间
-			examOrgTimeRepo.deleteByExamId(exam.getId());
+			examOrgRepo.deleteByExamId(exam.getId());
 			examStudentService.deleteExamStudentsByExamId(exam.getId());
 			examRepo.delete(exam);
 		}

+ 2 - 2
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamStudentServiceImpl.java

@@ -22,7 +22,7 @@ import cn.com.qmth.examcloud.core.basic.api.request.SaveCourseReq;
 import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
 import cn.com.qmth.examcloud.core.basic.api.response.GetStudentResp;
 import cn.com.qmth.examcloud.core.basic.api.response.SaveCourseResp;
-import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgTimeRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
@@ -45,7 +45,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 	ExamRepo examRepo;
 
 	@Autowired
-	ExamOrgTimeRepo examOrgTimeRepo;
+	ExamOrgRepo examOrgRepo;
 
 	@Autowired
 	OrgCloudService orgCloudService;