新建一个DepartmentController控制类,用于部门信息的查询。
package com.gwolf.crud.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import com.gwolf.crud.bean.Department;
import com.gwolf.crud.bean.Msg;
import com.gwolf.crud.service.DepartmentService;
@Controller
public class DepartmentController {
@Autowired
private DepartmentService departmentService;
@ResponseBody
@RequestMapping("/depts")
public Msg getDepts() {
List list = this.departmentService.getDepts();
return Msg.success().add("depts", list);
}
}