状态修改
This commit is contained in:
@@ -25,9 +25,18 @@ public interface SchStudentRepository extends JpaRepository<SchStudent, Integer>
|
||||
|
||||
Optional<SchStudent> findByIdAndSchId(Integer Id, Integer schId);
|
||||
|
||||
@Query("SELECT s FROM SchStudent s WHERE s.schId = :schId AND s.classId = :classId AND s.abnormalStatus = 1 AND s.transferStatus=1 AND s.status = 1")
|
||||
@Query("SELECT s FROM SchStudent s WHERE s.schId = :schId AND s.classId = :classId AND s.abnormalStatus = 0 AND s.transferStatus= 0 AND s.status = 0")
|
||||
List<SchStudent> findBySchIdAndClassId(@Param("schId") Integer schId, @Param("classId") Integer classId);
|
||||
|
||||
/**
|
||||
* 根据学校、班级和转入状态查询学生实体
|
||||
* 适用场景:同步回收时定位某班当前“转入/转出”的学生,用于把用户中心已移除的学生标记为转出
|
||||
*/
|
||||
@Query("SELECT s FROM SchStudent s WHERE s.schId = :schId AND s.classId = :classId AND s.transferStatus = :transferStatus")
|
||||
List<SchStudent> findBySchIdAndClassIdAndTransferStatus(@Param("schId") Integer schId,
|
||||
@Param("classId") Integer classId,
|
||||
@Param("transferStatus") Integer transferStatus);
|
||||
|
||||
List<SchStudent> findAllByIdInAndSchId(List<Integer> ids, Integer schId);
|
||||
|
||||
|
||||
@@ -45,7 +54,7 @@ public interface SchStudentRepository extends JpaRepository<SchStudent, Integer>
|
||||
@Param("updateUserId") Integer updateUserId);
|
||||
|
||||
@Modifying
|
||||
@Query("UPDATE SchStudent s SET s.schId = :schId, s.classId = :newClassId,s.groupId = :newClassId, s.updateDate = :updateDate, s.updateUserId = :updateUserId , s.transferStatus =1 WHERE s.id IN :ids")
|
||||
@Query("UPDATE SchStudent s SET s.schId = :schId, s.classId = :newClassId,s.groupId = :newClassId, s.updateDate = :updateDate, s.updateUserId = :updateUserId , s.transferStatus = 0 WHERE s.id IN :ids")
|
||||
int batchUpdateSchIdAndClassId(@Param("ids") List<Integer> ids,
|
||||
@Param("schId") Integer schId, // 目标学校ID
|
||||
@Param("newClassId") Integer newClassId,
|
||||
@@ -104,11 +113,11 @@ public interface SchStudentRepository extends JpaRepository<SchStudent, Integer>
|
||||
|
||||
/**
|
||||
* 获取所有转出学生的学校ID(去重)
|
||||
* 转出条件:transfer_status = 0
|
||||
* 转出条件:transfer_status = 1
|
||||
* 关联:s.class_id = c.group_class_id
|
||||
*/
|
||||
@Query(value = "SELECT DISTINCT c.sch_id FROM sch_student s " +
|
||||
"INNER JOIN sch_class c ON s.class_id = c.group_class_id " +
|
||||
"WHERE s.transfer_status = 0 AND s.sch_id = c.sch_id AND s.status=1 ", nativeQuery = true)
|
||||
"WHERE s.transfer_status = 0 AND s.sch_id = c.sch_id AND s.status= 0 ", nativeQuery = true)
|
||||
List<Integer> findDistinctSchIdsByTransferOut();
|
||||
}
|
||||
|
||||
@@ -35,10 +35,16 @@ public interface SchTeacherGroupRepository extends JpaRepository<SchTeacherGroup
|
||||
|
||||
/**
|
||||
* 根据 teaId 列表、学校 ID 和转入状态查询组关联
|
||||
* 适用场景:只查询转入状态的记录(transferStatus = 1)
|
||||
* 适用场景:只查询转入状态的记录(transferStatus = 0)
|
||||
*/
|
||||
List<SchTeacherGroup> findByTeaIdInAndSchIdAndTransferStatus(List<Integer> teaIds, Integer schId, Integer transferStatus);
|
||||
|
||||
/**
|
||||
* 根据学校 ID 和转入状态查询教师分组实体
|
||||
* 适用场景:同步回收时定位某校当前“转入/转出”的教师分组,用于把用户中心已移除的教师标记为转出
|
||||
*/
|
||||
List<SchTeacherGroup> findBySchIdAndTransferStatus(Integer schId, Integer transferStatus);
|
||||
|
||||
/**
|
||||
* 根据学校 ID 查询该学校所有教师的 teaId(去重)
|
||||
* 适用场景:获取该校所有教师列表
|
||||
|
||||
@@ -26,13 +26,13 @@ public interface SchTeacherRepository extends JpaRepository<SchTeacher, Integer>
|
||||
@Query(value = "SELECT DISTINCT t.* FROM sch_teacher t " +
|
||||
"INNER JOIN sch_teacher_group g ON t.tea_id = g.tea_id " +
|
||||
"WHERE g.sch_id = :schId " +
|
||||
"AND g.transfer_status = 1 " + // 只查转入状态的教师
|
||||
"AND g.transfer_status = 0 " + // 只查转入状态的教师
|
||||
"AND (:groupId IS NULL OR g.group_id = :groupId) " +
|
||||
"AND (:keyword IS NULL OR t.name LIKE CONCAT('%', :keyword, '%') OR t.account LIKE CONCAT('%', :keyword, '%')) " ,
|
||||
countQuery = "SELECT COUNT(DISTINCT t.id) FROM sch_teacher t " +
|
||||
"INNER JOIN sch_teacher_group g ON t.tea_id = g.tea_id " +
|
||||
"WHERE g.sch_id = :schId " +
|
||||
"AND g.transfer_status = 1 " +
|
||||
"AND g.transfer_status = 0 " +
|
||||
"AND (:groupId IS NULL OR g.group_id = :groupId) " +
|
||||
"AND (:keyword IS NULL OR t.name LIKE CONCAT('%', :keyword, '%') OR t.account LIKE CONCAT('%', :keyword, '%'))",
|
||||
nativeQuery = true)
|
||||
@@ -45,8 +45,8 @@ public interface SchTeacherRepository extends JpaRepository<SchTeacher, Integer>
|
||||
@Query(value = "SELECT DISTINCT g.tea_id AS teaId, g.sch_id AS schId, t.name AS teaName, t.id_card AS idCard " +
|
||||
"FROM sch_teacher_group g " +
|
||||
"INNER JOIN sch_teacher t ON t.tea_id = g.tea_id " +
|
||||
"WHERE g.transfer_status = 0 " +
|
||||
"AND t.status = 1 " +
|
||||
"WHERE g.transfer_status = 1 " +
|
||||
"AND t.status = 0 " +
|
||||
"AND (:schId IS NULL OR g.sch_id = :schId) " +
|
||||
"AND (:groupId IS NULL OR g.group_id = :groupId) " +
|
||||
"AND (:keyword IS NULL OR t.name LIKE CONCAT('%', :keyword, '%') OR t.account LIKE CONCAT('%', :keyword, '%')) " +
|
||||
@@ -54,8 +54,8 @@ public interface SchTeacherRepository extends JpaRepository<SchTeacher, Integer>
|
||||
countQuery = "SELECT COUNT(DISTINCT CONCAT(g.tea_id, '_', g.sch_id)) " +
|
||||
"FROM sch_teacher_group g " +
|
||||
"INNER JOIN sch_teacher t ON t.tea_id = g.tea_id " +
|
||||
"WHERE g.transfer_status = 0 " +
|
||||
"AND t.status = 1 " +
|
||||
"WHERE g.transfer_status = 1 " +
|
||||
"AND t.status = 0 " +
|
||||
"AND (:schId IS NULL OR g.sch_id = :schId) " +
|
||||
"AND (:groupId IS NULL OR g.group_id = :groupId) " +
|
||||
"AND (:keyword IS NULL OR t.name LIKE CONCAT('%', :keyword, '%') OR t.account LIKE CONCAT('%', :keyword, '%'))",
|
||||
|
||||
Reference in New Issue
Block a user