tlias管理系统--部门管理--查询所有部门

This commit is contained in:
2025-11-08 17:02:22 +08:00
parent b3ef0895af
commit 89dde5eae2
4 changed files with 64 additions and 0 deletions

View File

@@ -1,7 +1,39 @@
package com.inmind.controller;
import com.inmind.pojo.Dept;
import com.inmind.pojo.Result;
import com.inmind.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@Slf4j
public class DeptController {
@Autowired
private DeptService deptService;
//logback日志框架
// private static Logger log = LoggerFactory.getLogger(DeptController.class);
/**
* 查询所有部门接口
* @return
*/
// @RequestMapping(value = "/depts",method = RequestMethod.GET)
@GetMapping("/depts")
public Result getDeptList(){
log.info("查询所有部门数据");
//调用业务层的查询部门的功能
List<Dept> deptList = deptService.getDeptList();
return Result.success(deptList);
}
}

View File

@@ -1,7 +1,13 @@
package com.inmind.mapper;
import com.inmind.pojo.Dept;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
public interface DeptMapper {
@Select("select * from dept")
List<Dept> getDeptList();
}

View File

@@ -1,4 +1,12 @@
package com.inmind.service;
import com.inmind.pojo.Dept;
import java.util.List;
public interface DeptService {
/*
查询所有部门的信息
*/
List<Dept> getDeptList();
}

View File

@@ -1,9 +1,27 @@
package com.inmind.service.impl;
import com.inmind.mapper.DeptMapper;
import com.inmind.pojo.Dept;
import com.inmind.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class DeptServiceImpl implements DeptService {
@Autowired//从spring容器中获取DeptMapper类的实现类对象进行自动注入(DI)
private DeptMapper deptMapper;
/**
* 查询所有部门信息
* @return
*/
@Override
public List<Dept> getDeptList() {
//调用mybatis的mapper中的获取所有部门信息即可
List<Dept> deptList = deptMapper.getDeptList();
return deptList;
}
}