tlias管理系统-删除部门功能实现

This commit is contained in:
2025-10-09 13:48:27 +08:00
parent c36bceb628
commit affa6356b8
4 changed files with 26 additions and 1 deletions

View File

@@ -32,4 +32,14 @@ public class DeptController {
List<Dept> deptList = deptService.list();
return Result.success(deptList);
}
/*
删除部门
*/
@DeleteMapping("/depts/{id}")
public Result delete(@PathVariable Integer id){
log.info("删除部门:{}",id);
deptService.delete(id);
return Result.success();
}
}

View File

@@ -1,6 +1,7 @@
package com.inmind.mapper;
import com.inmind.pojo.Dept;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
@@ -8,6 +9,11 @@ import java.util.List;
@Mapper
public interface DeptMapper {
//查询部门
@Select("select * from dept")
List<Dept> list();
//根据id删除部门
@Delete("delete from dept where id = #{id}")
void delete(Integer id);
}

View File

@@ -7,4 +7,7 @@ import java.util.List;
public interface DeptService {
//查询部门列表数据
List<Dept> list();
//根据id删除部门
void delete(Integer id);
}

View File

@@ -14,10 +14,16 @@ public class DeptServiceImpl implements DeptService {
@Autowired
private DeptMapper deptMapper;
@Override
//查询部门列表 @Override
public List<Dept> list() {
//调用deptMapper获取部门列表数据
List<Dept> deptList = deptMapper.list();
return deptList;
}
//根据id删除部门
@Override
public void delete(Integer id) {
deptMapper.delete(id);
}
}