13.5.4 职位管理
处理职位的JobController
代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| package org.fkit.hrm.controller;
import java.util.List; import org.fkit.hrm.domain.Job; import org.fkit.hrm.service.HrmService; import org.fkit.hrm.util.tag.PageModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView;
@Controller public class JobController {
@Autowired @Qualifier("hrmService") private HrmService hrmService;
@RequestMapping(value = "/job/selectJob") public String selectJob(Model model, Integer pageIndex, @ModelAttribute Job job) { System.out.println("selectJob -->> " + job); PageModel pageModel = new PageModel(); if (pageIndex != null) { pageModel.setPageIndex(pageIndex); } List<Job> jobs = hrmService.findJob(job, pageModel); model.addAttribute("jobs", jobs); model.addAttribute("pageModel", pageModel); return "job/job";
}
@RequestMapping(value = "/job/removeJob") public ModelAndView removeJob(String ids, ModelAndView mv) { String[] idArray = ids.split(","); for (String id : idArray) { hrmService.removeJobById(Integer.parseInt(id)); } mv.setViewName("redirect:/job/selectJob"); return mv; }
@RequestMapping(value = "/job/addJob") public ModelAndView addJob(String flag, @ModelAttribute Job job, ModelAndView mv) { if (flag.equals("1")) { mv.setViewName("job/showAddJob"); } else { hrmService.addJob(job); mv.setViewName("redirect:/job/selectJob"); } return mv; }
@RequestMapping(value = "/job/updateJob") public ModelAndView updateDpet(String flag, @ModelAttribute Job job, ModelAndView mv) { if (flag.equals("1")) { Job target = hrmService.findJobById(job.getId()); mv.addObject("job", target); mv.setViewName("job/showUpdateJob"); } else { hrmService.modifyJob(job); mv.setViewName("redirect:/job/selectJob"); } return mv; } }
|
单击左侧菜单职位管理下面的添加职位命令,跳转到添加职位界面。
输入需要添加的职位名称和详细描述,单击“添加”按钮,若添加成功则跳转到职位査询界面,显示所有职位信息。
- 输入职位名称,单击”搜索”按钮可以完成模糊查询功能。
- 选择每一行最后一列的”操作”按钮,可以进入修改页面,对选中的职位进行修改操作。
- 选择每一行第一列的复选框,单击”删除”按钮,则可以对选中的职位进行删除操作。