tlias管理系统--员工管理--删除员工实现功能

This commit is contained in:
2025-11-16 17:00:29 +08:00
parent 18a8f28e70
commit b85a795db4
5 changed files with 40 additions and 4 deletions

View File

@@ -6,12 +6,10 @@ import com.inmind.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;
import java.util.List;
@RequestMapping("/emps")
@RestController
@@ -36,4 +34,12 @@ public class EmpController {
PageBean pageBean = empService.page(page,pageSize,name,gender,begin,end);
return Result.success(pageBean);
}
@DeleteMapping("/{ids}")
public Result delete(@PathVariable List<Integer> ids)
{
log.info("批量删除员工:{}",ids);
empService.delete(ids);
return Result.success();
}
}

View File

@@ -1,6 +1,7 @@
package com.inmind.mapper;
import com.inmind.pojo.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
@@ -32,4 +33,10 @@ public interface EmpMapper {
// @Select("select * from emp")
public List<Emp> list(String name, Short gender, LocalDate begin, LocalDate end);
/**
* 根据id删除员工-批量删除
* @param ids
*/
void delete(List<Integer> ids);
}

View File

@@ -3,6 +3,7 @@ package com.inmind.service;
import com.inmind.pojo.PageBean;
import java.time.LocalDate;
import java.util.List;
public interface EmpService {
/**
@@ -17,4 +18,10 @@ public interface EmpService {
* @return
*/
PageBean page(Integer page, Integer pageSize, String name, Short gender, LocalDate begin, LocalDate end);
/**
* 根据id删除员工-批量删除
* @param ids
*/
void delete(List<Integer> ids);
}

View File

@@ -67,4 +67,13 @@ public class EmpServiceImpl implements EmpService {
//封装分页查询结果
return new PageBean(p.getTotal(), p.getResult());
}
/**
* 根据id删除员工-批量删除
* @param ids
*/
@Override
public void delete(List<Integer> ids) {
empMapper.delete(ids);
}
}

View File

@@ -4,6 +4,7 @@
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.inmind.mapper.EmpMapper">
<select id="list" resultType="com.inmind.pojo.Emp"><!--注意resultType定义的是单条记录的java封装类型-->
select * from emp
<where>
@@ -20,4 +21,10 @@
order by update_time desc
</select>
<delete id="delete">
delete from emp where id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>