diff --git a/tlias-web-management/src/main/java/com/inmind/controller/EmpController.java b/tlias-web-management/src/main/java/com/inmind/controller/EmpController.java index 695c1f1..fe0c008 100644 --- a/tlias-web-management/src/main/java/com/inmind/controller/EmpController.java +++ b/tlias-web-management/src/main/java/com/inmind/controller/EmpController.java @@ -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 ids) + { + log.info("批量删除员工:{}",ids); + empService.delete(ids); + return Result.success(); + } } diff --git a/tlias-web-management/src/main/java/com/inmind/mapper/EmpMapper.java b/tlias-web-management/src/main/java/com/inmind/mapper/EmpMapper.java index c073855..116c25d 100644 --- a/tlias-web-management/src/main/java/com/inmind/mapper/EmpMapper.java +++ b/tlias-web-management/src/main/java/com/inmind/mapper/EmpMapper.java @@ -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 list(String name, Short gender, LocalDate begin, LocalDate end); + + /** + * 根据id删除员工-批量删除 + * @param ids + */ + void delete(List ids); } diff --git a/tlias-web-management/src/main/java/com/inmind/service/EmpService.java b/tlias-web-management/src/main/java/com/inmind/service/EmpService.java index d287125..e69d849 100644 --- a/tlias-web-management/src/main/java/com/inmind/service/EmpService.java +++ b/tlias-web-management/src/main/java/com/inmind/service/EmpService.java @@ -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 ids); } diff --git a/tlias-web-management/src/main/java/com/inmind/service/impl/EmpServiceImpl.java b/tlias-web-management/src/main/java/com/inmind/service/impl/EmpServiceImpl.java index d14359c..5af1dbb 100644 --- a/tlias-web-management/src/main/java/com/inmind/service/impl/EmpServiceImpl.java +++ b/tlias-web-management/src/main/java/com/inmind/service/impl/EmpServiceImpl.java @@ -67,4 +67,13 @@ public class EmpServiceImpl implements EmpService { //封装分页查询结果 return new PageBean(p.getTotal(), p.getResult()); } + + /** + * 根据id删除员工-批量删除 + * @param ids + */ + @Override + public void delete(List ids) { + empMapper.delete(ids); + } } diff --git a/tlias-web-management/src/main/resources/com/inmind/mapper/EmpMapper.xml b/tlias-web-management/src/main/resources/com/inmind/mapper/EmpMapper.xml index ab3aa0d..a75fc4d 100644 --- a/tlias-web-management/src/main/resources/com/inmind/mapper/EmpMapper.xml +++ b/tlias-web-management/src/main/resources/com/inmind/mapper/EmpMapper.xml @@ -4,6 +4,7 @@ "https://mybatis.org/dtd/mybatis-3-mapper.dtd"> + + + delete from emp where id in + + #{id} + + \ No newline at end of file