组织架构部分修改

master
shijie 4 years ago
parent 7e07a46b10
commit 96712cfb23
  1. 11
      src/main/java/com/yipin/liuwanr/controller/StaffGradeController.java
  2. 12
      src/main/java/com/yipin/liuwanr/mapper/StaffGradeMapper.java
  3. 24
      src/main/java/com/yipin/liuwanr/service/StaffGradeService.java
  4. 18
      src/test/java/com/yipin/liuwanr/service/StaffGradServiceTest.java

@ -1,6 +1,7 @@
package com.yipin.liuwanr.controller; package com.yipin.liuwanr.controller;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
@ -103,11 +104,19 @@ public class StaffGradeController {
Response deleteStaffGrade(@RequestBody StaffGrade staffGrade) { Response deleteStaffGrade(@RequestBody StaffGrade staffGrade) {
Response resp = new Response(); Response resp = new Response();
Integer staffGradeId = staffGrade.getStaffGradeId(); Integer staffGradeId = staffGrade.getStaffGradeId();
HashMap<String, Object> ret = new HashMap<>();
if (staffGradeId==null) { if (staffGradeId==null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("Parameter Invalid"); resp.setErrmessage("Parameter Invalid");
} else { } else {
HashMap<String, Object> ret = staffGradeService.deleteStaffGrade(staffGradeId); List<Integer> 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"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {
resp.setStatus(status); resp.setStatus(status);

@ -21,8 +21,15 @@ public interface StaffGradeMapper {
"</script> "}) "</script> "})
List<StaffGrade> queryStaffGrade(Integer staffProfessionalArchitectureId); List<StaffGrade> 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" +
"(<foreach collection='userIds' item='userId' separator=','>" +
"#{userId}" +
"</foreach>)")
void deleteStaffGrade(List<Integer> userIds);
@Update("UPDATE staff_grade SET isdel = 1 where staffGradeId = #{staffGradeId}") @Update("UPDATE staff_grade SET isdel = 1 where staffGradeId = #{staffGradeId}")
void deleteStaffGrade(Integer staffGradeId); void deleteStaffGradePs(Integer staffGradeId);
@Select({"<script>", @Select({"<script>",
"SELECT staffGradeId,staffGradeName,staffProfessionalArchitectureId from staff_grade where isdel = 0 and staffGradeId = #{staffGradeId}", "SELECT staffGradeId,staffGradeName,staffProfessionalArchitectureId from staff_grade where isdel = 0 and staffGradeId = #{staffGradeId}",
@ -31,4 +38,7 @@ public interface StaffGradeMapper {
@Update("UPDATE staff_grade SET staffGradeName = #{staffGradeName},staffProfessionalArchitectureId = #{staffProfessionalArchitectureId} where staffGradeId = #{staffGradeId}") @Update("UPDATE staff_grade SET staffGradeName = #{staffGradeName},staffProfessionalArchitectureId = #{staffProfessionalArchitectureId} where staffGradeId = #{staffGradeId}")
void updateStaffGrade(StaffGrade staffGrade); void updateStaffGrade(StaffGrade staffGrade);
@Select("select userId from staff where staffGradeId =#{staffGradeId} and isdel = 0")
List<Integer> queryUserIdsByGradeId(Integer staffGradeId);
} }

@ -1,6 +1,7 @@
package com.yipin.liuwanr.service; package com.yipin.liuwanr.service;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -47,10 +48,24 @@ public class StaffGradeService {
return resp; return resp;
} }
public HashMap<String, Object> deleteStaffGrade(Integer staffGradeId){ public HashMap<String, Object> deleteStaffGrade(List<Integer> userIds){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
staffGradeMapper.deleteStaffGrade(staffGradeId); staffGradeMapper.deleteStaffGrade(userIds);
resp.put("retcode", 200);
} catch (RuntimeException e) {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "Inquiry Failed");
return resp;
}
return resp;
}
public HashMap<String, Object> deleteStaffGradePs(Integer staffGradeId){
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
staffGradeMapper.deleteStaffGradePs(staffGradeId);
resp.put("retcode", 200); resp.put("retcode", 200);
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
@ -88,5 +103,8 @@ public class StaffGradeService {
} }
return resp; return resp;
} }
public List<Integer> queryUserIdsByGradeId(Integer staffGradeId) {
return staffGradeMapper.queryUserIdsByGradeId(staffGradeId);
}
} }

@ -52,15 +52,15 @@ public class StaffGradServiceTest {
/** /**
* 删除员工年级 * 删除员工年级
*/ */
@Test // @Test
@Transactional // @Transactional
public void deleteStaffGradeTest(){ // public void deleteStaffGradeTest(){
Integer staffGradeId = 1; // Integer staffGradeId = 1;
HashMap<String, Object> staffGrade = staffGradeService.deleteStaffGrade(staffGradeId); // HashMap<String, Object> staffGrade = staffGradeService.deleteStaffGrade(staffGradeId);
for (String s : staffGrade.keySet()) { // for (String s : staffGrade.keySet()) {
System.out.println("key:" + s + "," + "value:" + staffGrade.get(s)); // System.out.println("key:" + s + "," + "value:" + staffGrade.get(s));
} // }
} // }
/** /**
* 查询员工年级详情 * 查询员工年级详情

Loading…
Cancel
Save