tlias管理系统--部门管理--查询所有部门
This commit is contained in:
@@ -1,7 +1,39 @@
|
|||||||
package com.inmind.controller;
|
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 org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@Slf4j
|
||||||
public class DeptController {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
package com.inmind.mapper;
|
package com.inmind.mapper;
|
||||||
|
|
||||||
|
import com.inmind.pojo.Dept;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface DeptMapper {
|
public interface DeptMapper {
|
||||||
|
@Select("select * from dept")
|
||||||
|
List<Dept> getDeptList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
package com.inmind.service;
|
package com.inmind.service;
|
||||||
|
|
||||||
|
import com.inmind.pojo.Dept;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface DeptService {
|
public interface DeptService {
|
||||||
|
/*
|
||||||
|
查询所有部门的信息
|
||||||
|
*/
|
||||||
|
List<Dept> getDeptList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,27 @@
|
|||||||
package com.inmind.service.impl;
|
package com.inmind.service.impl;
|
||||||
|
|
||||||
|
import com.inmind.mapper.DeptMapper;
|
||||||
|
import com.inmind.pojo.Dept;
|
||||||
import com.inmind.service.DeptService;
|
import com.inmind.service.DeptService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DeptServiceImpl implements DeptService {
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user