Browse Source

课程表,作业发布 删除限制

zhaoy 7 years ago
parent
commit
c3b74815ca

+ 5 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/CurriculumServiceImpl.java

@@ -145,6 +145,7 @@ public class CurriculumServiceImpl implements CurriculumService {
             main.setCreateTime(new Date());
             main.setSchoolId(BaseContextHolder.getSchoolId());
             main.setCreatorName(BaseContextHolder.getUserName());
+            main.setStatus("0");
             //保存主表
             curriculumMapper.insertSelective(main);
             Long mId = main.getId();
@@ -156,6 +157,7 @@ public class CurriculumServiceImpl implements CurriculumService {
                     curriculumDetailDTO.setSchoolId(schoolId);
                     curriculumDetailDTO.setClazzId(Long.parseLong(main.getClazzId()));
                     curriculumDetailDTO.setStatus(Integer.parseInt(main.getStatus()));
+                    curriculumDetailDTO.setStatus(0);
                 });
                 curriculumMapper.insertDetailSelective(items);
                 messageLogService.save(new DocBaseDTO(mId, CODE, NAME));
@@ -190,6 +192,9 @@ public class CurriculumServiceImpl implements CurriculumService {
     @Override
     @Transactional
     public void delete(Long id) {
+        if(curriculumMapper.courseStatus(id)>0){
+            throw new BizException(BizExceptionCode.COURSE_RELEASE_STATUS);
+        }
         curriculumMapper.deleteDetailByMainId(id);
         curriculumMapper.delete(id);
         messageLogService.delete(new DocBaseDTO(id, CODE, NAME));

+ 3 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/business/service/impl/HomeWorkServiceImpl.java

@@ -23,7 +23,6 @@ import org.springframework.util.ObjectUtils;
 import org.springframework.util.StringUtils;
 
 import java.util.List;
-import java.util.StringJoiner;
 
 /**
  * @author: guq
@@ -81,6 +80,9 @@ public class HomeWorkServiceImpl implements HomeWorkService{
         if (StringUtils.isEmpty(id) || "0".equals(id)) {
             return;
         }
+        if(homeWorkMapper.taskStatus("1",id)>0){
+            throw new BizException(BizExceptionCode.TASK_RELEASE_STATUS);
+        }
         homeWorkMapper.deleteByPrimaryKey(id);
     }
 

+ 2 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/exception/BizExceptionCode.java

@@ -28,6 +28,8 @@ public enum BizExceptionCode implements BaseExceptionCode {
     REPEAT_CLASS_NAME(600002, "班级名称重复"),
     REPEAT_STUDENT_NUMBER(600003, "学生学号不可重复"),
     EFFECTIVE_CLASS_DATA(600004, "无法删除有学生的班级"),
+    TASK_RELEASE_STATUS(600005, "作业已发布无法更改,您可取消发布"),
+    COURSE_RELEASE_STATUS(600006, "课程表已生效,无法删除"),
     NOT_EXISTS_SUBJECT(60005, "科目<u>%s</u>不存在");
 
 

+ 2 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/CurriculumMapper.java

@@ -82,4 +82,6 @@ public interface CurriculumMapper {
      * @param curriculumDetailDTOList
      */
     void updateDetailSelective(List<CurriculumDetailDTO> curriculumDetailDTOList);
+
+    int courseStatus(Long id);
 }

+ 6 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/HomeWorkMapper.java

@@ -3,7 +3,6 @@ package com.usoftchina.smartschool.school.mapper;
 import com.usoftchina.smartschool.school.po.HomeWork;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
-import org.springframework.web.bind.annotation.GetMapping;
 
 import java.util.List;
 
@@ -27,4 +26,10 @@ public interface HomeWorkMapper {
     List<HomeWork> selectByConditon(@Param("con") String condition, @Param("school_id") Long schoolId);
 
     int updateByPublish(Long task_id);
+
+    /**
+     * 查询作业发布状态
+     * @return
+     */
+    int taskStatus(@Param("task_status") String task_status,@Param("task_id") Long task_id);
 }

+ 4 - 0
applications/school/school-server/src/main/resources/mapper/CurriculumMapper.xml

@@ -258,4 +258,8 @@
     </foreach>
   </update>
 
+  <select id="courseStatus" parameterType="long" resultType="int">
+    select count(1) from clazz_curriculum where mcur_status=1 and cur_id=#{id}
+  </select>
+
 </mapper>

+ 12 - 0
applications/school/school-server/src/main/resources/mapper/HomeWorkMapper.xml

@@ -246,4 +246,16 @@
       publish_date = now()
     where task_id = #{task_id,jdbcType=BIGINT}
   </update>
+
+    <select id="taskStatus" resultType="int">
+        select count(1) from task_notify
+        <where>
+            <if test="task_status != null">
+                task_status=#{task_status}
+            </if>
+            <if test="task_id != null">
+                and task_id=#{task_id}
+            </if>
+        </where>
+    </select>
 </mapper>