diff --git a/src/main/java/com/yipin/liuwanr/controller/StaffGradeController.java b/src/main/java/com/yipin/liuwanr/controller/StaffGradeController.java index 744ac20..9f685ff 100644 --- a/src/main/java/com/yipin/liuwanr/controller/StaffGradeController.java +++ b/src/main/java/com/yipin/liuwanr/controller/StaffGradeController.java @@ -105,13 +105,14 @@ public class StaffGradeController { Response resp = new Response(); Integer staffGradeId = staffGrade.getStaffGradeId(); HashMap ret = new HashMap<>(); + HashMap ret2 = new HashMap<>(); if (staffGradeId==null) { resp.setStatus(300); resp.setErrmessage("Parameter Invalid"); } else { List userIds = staffGradeService.queryUserIdsByGradeId(staffGradeId); if(userIds.size()>0){ - ret = staffGradeService.deleteStaffGrade(userIds); + ret2 = staffGradeService.deleteStaffGrade(userIds); ret = staffGradeService.deleteStaffGradePs(staffGradeId); }else{//如果组织架构下面没有员工,则只删除组织架构 ret = staffGradeService.deleteStaffGradePs(staffGradeId); diff --git a/src/main/java/com/yipin/liuwanr/mapper/StaffGradeMapper.java b/src/main/java/com/yipin/liuwanr/mapper/StaffGradeMapper.java index df85618..8cfc09e 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/StaffGradeMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/StaffGradeMapper.java @@ -2,10 +2,8 @@ package com.yipin.liuwanr.mapper; import java.util.List; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Options; -import org.apache.ibatis.annotations.Select; -import org.apache.ibatis.annotations.Update; +import com.yipin.liuwanr.entity.Student; +import org.apache.ibatis.annotations.*; import com.yipin.liuwanr.entity.Staff; import com.yipin.liuwanr.entity.StaffGrade; @@ -20,13 +18,15 @@ public interface StaffGradeMapper { "SELECT staffGradeId,staffGradeName,staffProfessionalArchitectureId from staff_grade where isdel = 0 and staffProfessionalArchitectureId = #{staffProfessionalArchitectureId}", " "}) List queryStaffGrade(Integer staffProfessionalArchitectureId); - -// @Update("UPDATE staff_grade SET isdel = 1 where staffGradeId = #{staffGradeId}") - @Update("UPDATE staff s,hr_user_info u SET s.isdel = 1,u.isdel = 1 WHERE s.userId = u.userId AND s.userId IN" + - "(" + - "#{userId}" + - ")") - void deleteStaffGrade(List userIds); + + @Update({""}) + void deleteStaffGrade(@Param("userIds") List userIds); + @Update("UPDATE staff_grade SET isdel = 1 where staffGradeId = #{staffGradeId}") void deleteStaffGradePs(Integer staffGradeId); @@ -41,4 +41,10 @@ public interface StaffGradeMapper { @Select("select userId from staff where staffGradeId =#{staffGradeId} and isdel = 0") List queryUserIdsByGradeId(Integer staffGradeId); + + @Update("UPDATE staff_grade SET isdel = 1 where staffProfessionalArchitectureId = #{staffProfessionalArchitectureId}") + void delStaffGradeByArchId(Integer staffProfessionalArchitectureId); + + @Update("UPDATE staff_grade SET isdel = 1 where staffProfessionalArchitectureId = #{staffProfessionalArchitectureId}") + void deleteStaffArch(Integer staffProfessionalArchitectureId); } \ No newline at end of file diff --git a/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java b/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java index c282345..dc58cb2 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java @@ -123,4 +123,7 @@ public interface StaffMapper { @Select("select schoolId,staffId FROM staff WHERE userId = #{userId} AND isdel = 0 GROUP BY schoolId ORDER BY staffId limit 1") Integer querySchoolId(Integer userId); + @Select("select userId from staff where staffProfessionalArchitectureId =#{staffProfessionalArchitectureId} and isdel = 0") + List queryUserIdsByArchId(Integer staffProfessionalArchitectureId); + } \ No newline at end of file diff --git a/src/main/java/com/yipin/liuwanr/service/StaffProfessionalArchitectureService.java b/src/main/java/com/yipin/liuwanr/service/StaffProfessionalArchitectureService.java index 03a3914..893954a 100644 --- a/src/main/java/com/yipin/liuwanr/service/StaffProfessionalArchitectureService.java +++ b/src/main/java/com/yipin/liuwanr/service/StaffProfessionalArchitectureService.java @@ -1,7 +1,10 @@ package com.yipin.liuwanr.service; import java.util.HashMap; +import java.util.List; +import com.yipin.liuwanr.mapper.StaffGradeMapper; +import com.yipin.liuwanr.mapper.StaffMapper; import org.jboss.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -17,6 +20,11 @@ public class StaffProfessionalArchitectureService { @Autowired private StaffProfessionalArchitectureMapper staffProfessionalArchitectureMapper; + @Autowired + private StaffGradeMapper staffGradeMapper; + @Autowired + private StaffMapper staffMapper; + public HashMap addStaffProfessionalArchitecture(StaffProfessionalArchitecture staffProfessionalArchitecture){ HashMap resp = new HashMap(); try { @@ -78,7 +86,19 @@ public class StaffProfessionalArchitectureService { public HashMap deleteStaffProfessionalArchitecture(Integer staffProfessionalArchitectureId){ HashMap resp = new HashMap(); try { + //删除员工专业一级组织架构 staffProfessionalArchitectureMapper.deleteStaffProfessionalArchitecture(staffProfessionalArchitectureId); + //根据一级架构id删除staff_grade表中二级组织架构(假删) + staffGradeMapper.delStaffGradeByArchId(staffProfessionalArchitectureId); + //根据staffProfessionalArchitectureId查询staff表中的userId,然后调用批量删除员工信息接口 + List userIds =staffMapper.queryUserIdsByArchId(staffProfessionalArchitectureId); + if(userIds.size()>0){//说明年级架构下面存在用户 + staffGradeMapper.deleteStaffGrade(userIds); + staffGradeMapper.deleteStaffArch(staffProfessionalArchitectureId); + }else{//如果组织架构下面没有员工,则只删除组织架构 + staffGradeMapper.deleteStaffArch(staffProfessionalArchitectureId); + } + resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage());