tlias管理系统--员工管理--删除员工实现功能
This commit is contained in:
@@ -6,12 +6,10 @@ import com.inmind.service.EmpService;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RequestMapping("/emps")
|
@RequestMapping("/emps")
|
||||||
@RestController
|
@RestController
|
||||||
@@ -36,4 +34,12 @@ public class EmpController {
|
|||||||
PageBean pageBean = empService.page(page,pageSize,name,gender,begin,end);
|
PageBean pageBean = empService.page(page,pageSize,name,gender,begin,end);
|
||||||
return Result.success(pageBean);
|
return Result.success(pageBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public Result delete(@PathVariable List<Integer> ids)
|
||||||
|
{
|
||||||
|
log.info("批量删除员工:{}",ids);
|
||||||
|
empService.delete(ids);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.inmind.mapper;
|
package com.inmind.mapper;
|
||||||
|
|
||||||
import com.inmind.pojo.Emp;
|
import com.inmind.pojo.Emp;
|
||||||
|
import org.apache.ibatis.annotations.Delete;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
@@ -32,4 +33,10 @@ public interface EmpMapper {
|
|||||||
|
|
||||||
// @Select("select * from emp")
|
// @Select("select * from emp")
|
||||||
public List<Emp> list(String name, Short gender, LocalDate begin, LocalDate end);
|
public List<Emp> list(String name, Short gender, LocalDate begin, LocalDate end);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id删除员工-批量删除
|
||||||
|
* @param ids
|
||||||
|
*/
|
||||||
|
void delete(List<Integer> ids);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.inmind.service;
|
|||||||
import com.inmind.pojo.PageBean;
|
import com.inmind.pojo.PageBean;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface EmpService {
|
public interface EmpService {
|
||||||
/**
|
/**
|
||||||
@@ -17,4 +18,10 @@ public interface EmpService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
PageBean page(Integer page, Integer pageSize, String name, Short gender, LocalDate begin, LocalDate end);
|
PageBean page(Integer page, Integer pageSize, String name, Short gender, LocalDate begin, LocalDate end);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id删除员工-批量删除
|
||||||
|
* @param ids
|
||||||
|
*/
|
||||||
|
void delete(List<Integer> ids);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,4 +67,13 @@ public class EmpServiceImpl implements EmpService {
|
|||||||
//封装分页查询结果
|
//封装分页查询结果
|
||||||
return new PageBean(p.getTotal(), p.getResult());
|
return new PageBean(p.getTotal(), p.getResult());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id删除员工-批量删除
|
||||||
|
* @param ids
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void delete(List<Integer> ids) {
|
||||||
|
empMapper.delete(ids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.inmind.mapper.EmpMapper">
|
<mapper namespace="com.inmind.mapper.EmpMapper">
|
||||||
|
|
||||||
|
|
||||||
<select id="list" resultType="com.inmind.pojo.Emp"><!--注意:resultType定义的是单条记录的java封装类型-->
|
<select id="list" resultType="com.inmind.pojo.Emp"><!--注意:resultType定义的是单条记录的java封装类型-->
|
||||||
select * from emp
|
select * from emp
|
||||||
<where>
|
<where>
|
||||||
@@ -20,4 +21,10 @@
|
|||||||
order by update_time desc
|
order by update_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<delete id="delete">
|
||||||
|
delete from emp where id in
|
||||||
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user