diff --git a/src/main/java/com/yipin/liuwanr/controller/StaffGradeController.java b/src/main/java/com/yipin/liuwanr/controller/StaffGradeController.java index 0e170fd..744ac20 100644 --- a/src/main/java/com/yipin/liuwanr/controller/StaffGradeController.java +++ b/src/main/java/com/yipin/liuwanr/controller/StaffGradeController.java @@ -1,6 +1,7 @@ package com.yipin.liuwanr.controller; import java.util.HashMap; +import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; @@ -103,11 +104,19 @@ public class StaffGradeController { Response deleteStaffGrade(@RequestBody StaffGrade staffGrade) { Response resp = new Response(); Integer staffGradeId = staffGrade.getStaffGradeId(); + HashMap ret = new HashMap<>(); if (staffGradeId==null) { resp.setStatus(300); resp.setErrmessage("Parameter Invalid"); } else { - HashMap ret = staffGradeService.deleteStaffGrade(staffGradeId); + List userIds = staffGradeService.queryUserIdsByGradeId(staffGradeId); + if(userIds.size()>0){ + ret = staffGradeService.deleteStaffGrade(userIds); + ret = staffGradeService.deleteStaffGradePs(staffGradeId); + }else{//如果组织架构下面没有员工,则只删除组织架构 + ret = staffGradeService.deleteStaffGradePs(staffGradeId); + } + int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); diff --git a/src/main/java/com/yipin/liuwanr/mapper/StaffGradeMapper.java b/src/main/java/com/yipin/liuwanr/mapper/StaffGradeMapper.java index aaeef71..df85618 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/StaffGradeMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/StaffGradeMapper.java @@ -21,8 +21,15 @@ public interface StaffGradeMapper { " "}) 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("UPDATE staff_grade SET isdel = 1 where staffGradeId = #{staffGradeId}") - void deleteStaffGrade(Integer staffGradeId); + void deleteStaffGradePs(Integer staffGradeId); @Select({"