/**
* @Title: DeptController.java
* @Package org.action
* @Description: TODO该方法的主要作用:
* @author A18ccms A18ccms_gmail_com
* @date 2017-12-27 上午10:54:42
* @version V1.0
*/
package org.action;
import java.util.List;
import org.entity.Dept;
import org.service.IDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
/**
*
* 项目名称:test_ssh_16qn3
* 类名称:DeptController
* 类描述:
* 创建人:Mu Xiongxiong
* 创建时间:2017-12-27 上午10:54:42
* 修改人:Mu Xiongxiong
* 修改时间:2017-12-27 上午10:54:42
* 修改备注:
* @version
*
*/
@Controller
public class DeptController {
/**
* 自动注入Service层
*/
@Autowired
private IDeptService deptService;
@RequestMapping(value="showDept")
public ModelAndView showDept(){
ModelAndView modelAndViewContainer = new ModelAndView();
List<Dept> deptList = deptService.queryAll();
modelAndViewContainer.addObject("deptList",deptList);
modelAndViewContainer.setViewName("showDept");
return modelAndViewContainer;
}
@RequestMapping(value="saveDept")
public ModelAndView saveDept(Dept dept){
dept.setId(((Long)System.currentTimeMillis()).intValue());
deptService.saveEntity(dept);
return new ModelAndView("redirect:/showDept.do");
}
/**
*
* @Description: 该方法的主要作用:根据编号查询部门信息
* @Title: getDeptById
* @param @param id
* @param @return 设定文件
* @return 返回类型:ModelAndView
* @throws
*/
@RequestMapping(value="getDeptById")
public ModelAndView getDeptById(int id){
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("dept",deptService.queryById(id));
modelAndView.setViewName("updateDept");
return modelAndView;
}
/**
*
* @Description: 该方法的主要作用:修改部门信息
* @Title: updateEntity
* @param @param dept
* @param @return 设定文件
* @return 返回类型:ModelAndView
* @throws
*/
@RequestMapping(value="updateEntity")
public ModelAndView updateEntity(Dept dept){
deptService.updateEntity(dept);
return new ModelAndView("redirect:/showDept.do");
}
/**
*
* @Description: 该方法的主要作用:删除部门
* @Title: delEntity
* @param @param id
* @param @return 设定文件
* @return 返回类型:ModelAndView
* @throws
*/
@RequestMapping(value="delDept")
public ModelAndView delDept(int id) {
Dept dept = deptService.queryById(id);
deptService.delEntity(dept);
return new ModelAndView("redirect:/showDept.do");
}
}