首页>代码>spring+spring mvc+mybatis开发java医院HR人事管理系统(加强版本+ shiro)>/HR/src/main/java/edu/hebeu/controller/DepartmentController.java
package edu.hebeu.controller;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;


import edu.hebeu.security.PermissionSign;
import edu.hebeu.security.RoleSign;

import edu.hebeu.entity.Department;
import edu.hebeu.service.DepartmentService;

@Controller
@RequestMapping("/department")
public class DepartmentController {

	@Autowired
	private DepartmentService departmentService;
	
	@RequestMapping("/listPage.do")
	@RequiresRoles(value = RoleSign.ADMIN)
	@RequiresPermissions(value = PermissionSign.DEPART_QUERY)
	public String selectListByPgae(Model model, int pageNo){
		Page<Department> page = departmentService.selectListByPage(pageNo);
		model.addAttribute("page",page);
		return "admin/department_list";
	}
	
	@RequestMapping("/toAdd.do")
	@RequiresRoles(value = RoleSign.ADMIN)
	@RequiresPermissions(value = PermissionSign.DEPART_ADD_SHOW)
	public String toAdd(Model model){
		List<Department> dList = departmentService.selectList(new EntityWrapper<Department>()
				.orderBy("department_number", false));
		model.addAttribute("departmentNumber", dList.get(0).getDepartmentNumber()+1);
		return "admin/department_add";
	}
	
	@RequestMapping("/add.do")
	@RequiresRoles(value = RoleSign.ADMIN)
	@RequiresPermissions(value = PermissionSign.DEPART_ADD_SUBMIT)
	public String add(Department department){
		departmentService.insert(department);
		return "forward:/department/listPage.do?pageNo=1";
	}
	
	@RequestMapping("/{id}/toUpdate.do")
	@RequiresRoles(value = RoleSign.ADMIN)
	@RequiresPermissions(value = PermissionSign.DEPART_UPDATE_SHOW)
	public String toUpdate(@PathVariable Integer id, Model model){
		Department department = departmentService.selectById(id);
		model.addAttribute("department", department);
		return "admin/department_update";
	}
	
	@RequestMapping("/{id}/update.do")
	@RequiresRoles(value = RoleSign.ADMIN)
	@RequiresPermissions(value = PermissionSign.DEPART_UPDATE_SUBMIT)
	public String updateById(@PathVariable Integer id, Department department){
		department.setId(id);
		departmentService.updateById(department);
		return "forward:/department/listPage.do?pageNo=1";
	}
	
	@RequestMapping("/{id}/delete.do")
	@RequiresRoles(value = RoleSign.ADMIN)
    @RequiresPermissions(value = PermissionSign.DEPART_DEL)
	public String deleteById(@PathVariable Integer id){
		departmentService.deleteById(id);
		return "forward:/department/listPage.do?pageNo=1";
	}
	
}
最近下载更多
TY0165  LV20 6月25日
嘲讽脸  LV5 5月15日
minjing123  LV8 1月4日
小安同学  LV7 2023年12月7日
微信网友_6372890284232704  LV4 2023年8月30日
dowell_liu  LV1 2023年8月2日
哇塞塞哈哈哈  LV8 2023年5月4日
bibibi234  LV1 2023年4月4日
a562571298  LV8 2023年3月23日
duoer12  LV5 2022年12月30日
最近浏览更多
千里草1046 5小时前
暂无贡献等级
杨秀益  LV1 11月7日
krispeng  LV13 8月29日
897258976  LV8 8月29日
quartz  LV8 7月1日
3334004690  LV10 6月28日
TY0165  LV20 6月25日
2578193624  LV2 6月16日
Nov1111  LV1 5月28日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友