Browse Source

班级组织:年级和班级新增时的防重复添加

zhaoy 6 years ago
parent
commit
14ae2ff131

+ 1 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/GradeServiceImpl.java

@@ -174,7 +174,7 @@ public class GradeServiceImpl implements GradeService{
             throw new BizException(BizExceptionCode.USELESS_DATA);
         }
         sysClazz.setClazz_status(1);
-        if(sysGradeMapper.countClazz(sysClazz.getClazz_name())>0){
+        if(sysClazzMapper.countClazz(sysClazz.getClazz_name(),sysClazz.getSchool_id())>0){
             throw new BizException(BizExceptionCode.REPEAT_CLASS_NAME);
         }
         sysClazzMapper.insertSelective(sysClazz);

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

@@ -32,4 +32,6 @@ public interface SysClazzMapper {
     void updateTeacher(SysTeacherClazz item);
 
     List<SysClazz> selectByClazz(@Param("condition") String condition, @Param("school_id") Long schoolId);
+
+    int countClazz(@Param("clazz_name") String clazz_name, @Param("school_id") Long school_id);
 }

+ 0 - 1
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SysGradeMapper.java

@@ -32,5 +32,4 @@ public interface SysGradeMapper {
 
     int count(@Param("grade_name") String grade_name, @Param("school_id") Long school_id);
 
-    int countClazz(@Param("clazz_name") String clazz_name);
 }

+ 13 - 0
applications/school/school-server/src/main/resources/mapper/SysClazzMapper.xml

@@ -232,4 +232,17 @@
       </if>
     </where>
   </select>
+
+  <select id="countClazz" resultType="int">
+    select count(*) from sys_clazz
+    <where>
+      <if test="clazz_name != null">
+        clazz_name = #{clazz_name}
+      </if>
+      <if test="school_id != null">
+        and school_id=#{school_id}
+      </if>
+    </where>
+  </select>
+
 </mapper>

+ 0 - 9
applications/school/school-server/src/main/resources/mapper/SysGradeMapper.xml

@@ -141,13 +141,4 @@
     </where>
   </select>
 
-  <select id="countClazz" resultType="int">
-    select count(*) from sys_grade
-    <where>
-      <if test="clazz_name != null">
-        clazz_name = #{clazz_name}
-      </if>
-    </where>
-  </select>
-
 </mapper>