lideyin 5 жил өмнө
parent
commit
b239e8cda0

+ 15 - 0
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/IllegallyTypeController.java

@@ -6,7 +6,9 @@ import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.commons.helpers.poi.ExcelWriter;
 import cn.com.qmth.examcloud.commons.util.PathUtil;
 import cn.com.qmth.examcloud.core.oe.admin.api.bean.IllegallyTypeDomain;
+import cn.com.qmth.examcloud.core.oe.admin.dao.ExamAuditRepo;
 import cn.com.qmth.examcloud.core.oe.admin.dao.IllegallyTypeRepo;
+import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamAuditEntity;
 import cn.com.qmth.examcloud.core.oe.admin.dao.entity.IllegallyTypeEntity;
 import cn.com.qmth.examcloud.core.oe.admin.service.IllegallyTypeService;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.IllegallyTypeInfo;
@@ -22,6 +24,7 @@ import org.apache.commons.fileupload.disk.DiskFileItem;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Sort;
@@ -59,6 +62,9 @@ public class IllegallyTypeController extends ControllerSupport {
     @Autowired
     IllegallyTypeRepo illegallyTypeRepo;
 
+    @Autowired
+    ExamAuditRepo examAuditRepo;
+
     private static final String[] EXCEL_HEADER = new String[]{"违纪类型名称", "违纪类型代码", "排序号"};
 
     /**
@@ -266,6 +272,15 @@ public class IllegallyTypeController extends ControllerSupport {
             if (null == one) {
                 continue;
             }
+
+            //判断审核表中是否存在当前类型的违纪类型
+            ExamAuditEntity examAudit =
+                    examAuditRepo.findFirstByDisciplineTypeAndCreationTimeGreaterThan(one.getCode(), one.getCreationTime());
+            boolean isIllegallyTypeInUse = (null != examAudit);
+            if (isIllegallyTypeInUse) {
+                throw new StatusException("100001","违纪类型已使用不允许删除");
+            }
+
             validateRootOrgIsolation(one.getRootOrgId());
             illegallyTypeRepo.delete(one);
 

+ 6 - 2
examcloud-core-oe-admin-dao/src/main/java/cn/com/qmth/examcloud/core/oe/admin/dao/ExamAuditRepo.java

@@ -6,6 +6,8 @@ import org.springframework.stereotype.Repository;
 
 import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamAuditEntity;
 
+import java.util.Date;
+
 /**
  * @author chenken
  * @date 2018/8/15 10:05
@@ -14,7 +16,9 @@ import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamAuditEntity;
  */
 @Repository
 public interface ExamAuditRepo extends JpaRepository<ExamAuditEntity, Long>, JpaSpecificationExecutor<ExamAuditEntity> {
-	
+
 	public ExamAuditEntity findByExamRecordDataId(Long examRecordDataId);
-	
+
+	ExamAuditEntity findFirstByDisciplineTypeAndCreationTimeGreaterThan(String disciplineType, Date creationTime);
+
 }