源码获取:博客首页 "资源" 里下载!
企业人事管理系统,可以实现简单的企业内部的管理.
主要有管理员、人事专员、员工三种角色。
管理员功能:登录、分发工资、管理其他角色账号
员工功能:注册、登录、打卡、查看工资、请假
人事专员:登录、查看员工信息列表、查看(编辑)考勤情况、请假审批
1.运行环境:最好是javajdk1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat7.x,8.x,9.x版本均可
4.硬件环境:windows7/8/101G内存以上;或者MacOS;
5.数据库:MySql5.7版本;
6.是否Maven项目:是;
1.后端:Spring+SpringMVC+Mybatis
2.前端:JSP+CSS+JavaScript
1.使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2.使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行mavenclean;maveninstall命令,然后运行;
3.将项目中resources/applicationContext.xml配置文件中的数据库配置改为自己的配置;
4.运行成功后,在浏览器中输入地址:http://localhost:8080/userLogin/login
@Controller
public class UserController {
@Autowired
@Qualifier("RainService")
private RainService rainservice;
// 如果在目录下输入为空,则跳转到指定链接
@RequestMapping(value="/user/")
public ModelAndView index2(ModelAndView mv){
mv.setViewName("/user/list");
return mv;
}
// 退出功能
@RequestMapping(value="/user/logout")
public ModelAndView logout(ModelAndView mv, HttpSession session){
session.setAttribute(Constants.USER_SESSION, null);
session.setAttribute("tip", null);
mv.setViewName("redirect:/index");
return mv;
}
@RequestMapping(value="/login")
public ModelAndView login(@RequestParam("loginname") String loginname,
@RequestParam("password") String password,@RequestParam("tip") String tip,
HttpSession session,
ModelAndView mv){
// 调用业务逻辑组件判断用户是否可以登录
boolean flag = false;
if("1".equals(tip)) {
User user = rainservice.login(loginname, password);
if(user!=null){
// 将用户保存到HttpSession当中
System.out.println("HttpSession");
session.setAttribute(Constants.USER_SESSION, user);
session.setAttribute("tip", "1");
// 客户端跳转到main页面
mv.setViewName("redirect:/index");
}else{
// 设置登录失败提示信息
System.out.println("设置登录失败提示信息");
mv.addObject("message", "登录名或密码错误!请重新输入");
// 服务器内部跳转到登录页面
mv.setViewName("forward:/loginForm");
}
}else {
Employee user = rainservice.login2(loginname, password);
if(user!=null){
// 将用户保存到HttpSession当中
System.out.println("HttpSession");
session.setAttribute(Constants.USER_SESSION, user);
session.setAttribute("tip", "2");
// 客户端跳转到main页面
mv.setViewName("redirect:/indexcustomer/");
}else{
// 设置登录失败提示信息
System.out.println("设置登录失败提示信息");
mv.addObject("message", "登录名或密码错误!请重新输入");
// 服务器内部跳转到登录页面
mv.setViewName("forward:/loginForm");
}
}
return mv;
}
// 如果在目录下输入任何不存在的参数,则跳转到list
@RequestMapping(value="/user/{formName}")
public String index2(@PathVariable String formName){
String blank = "/user/list";
return blank;
}
@RequestMapping(value="/user/list",method=RequestMethod.GET)
public String index(Model model,String content){
List job_list = rainservice.get_UserList();
if (content!=null){
job_list = rainservice.get_UserLikeList(content);
}
model.addAttribute("list",job_list);
return "user/list";
}
@RequestMapping(value="/user/add",method=RequestMethod.GET)
public String add(Model model,Integer id){
if(id!=null){
User job = rainservice.get_UserInfo(id);
model.addAttribute("job",job);
}
return "/user/add";
}
@RequestMapping(value="/user/add",method=RequestMethod.POST)
public ModelAndView add(ModelAndView mv,@ModelAttribute User notice ,Integer id){
System.out.println(id);
if(id!=null){
rainservice.update_UserInfo(notice);
}else{
rainservice.insert_UserInfo(notice);
}
mv.setViewName("redirect:/user/list");
return mv;
}
@RequestMapping(value="/user/delete",method=RequestMethod.GET)
public void delete(Integer id){
System.out.println(id);
if(id!=null){
rainservice.delete_UserInfo(id);
}
}
// 管理员自己修改密码时跳转的页面
@RequestMapping(value="/user/myupdate",method=RequestMethod.GET)
public String update(Model model,HttpSession session){
User user = (User) session.getAttribute(Constants.USER_SESSION);
model.addAttribute("job",user);
return "/user/myupdate";
}
@RequestMapping(value="/user/myupdate",method=RequestMethod.POST)
public ModelAndView update(ModelAndView mv,Model model,HttpSession session,User notice){
User user = (User) session.getAttribute(Constants.USER_SESSION);
// 如果是自己修改自己的密码,则更新session
user.setLoginname(notice.getLoginname());
user.setPassword(notice.getPassword());
user.setUsername(notice.getUsername());
rainservice.update_UserInfo(user);
session.setAttribute(Constants.USER_SESSION, user);
mv.setViewName("redirect:/user/myupdate");
return mv;
}
}
@Controller
public class JobController {
@Autowired
@Qualifier("RainService")
private RainService rainservice;
// 如果在目录下输入为空,则跳转到指定链接
@RequestMapping(value="/job/")
public ModelAndView index2(ModelAndView mv){
mv.setViewName("job/list");
return mv;
}
// 如果在目录下输入任何不存在的参数,则跳转到list
@RequestMapping(value="/job/{formName}")
public String index2(@PathVariable String formName){
String blank = "/job/list";
return blank;
}
@RequestMapping(value="/job/list",method=RequestMethod.GET)
public String index(Model model,String content){
List job_list = rainservice.findAllJob();
if (content!=null){
job_list = rainservice.findAllJob(content);
}
model.addAttribute("list",job_list);
return "job/list";
}
@RequestMapping(value="/job/add",method=RequestMethod.GET)
public String add(Model model,Integer id){
if(id!=null){
Job job = rainservice.get_JobInfo(id);
model.addAttribute("job",job);
}
return "/job/add";
}
@RequestMapping(value="/job/add",method=RequestMethod.POST)
public ModelAndView add(ModelAndView mv,@ModelAttribute Job job ,Integer id){
System.out.println(id);
if(id!=null){
rainservice.update_JobInfo(job);
}else{
rainservice.insert_JobInfo(job);
}
mv.setViewName("redirect:/job/list");
return mv;
}
@RequestMapping(value="/job/delete",method=RequestMethod.GET)
public void delete(Integer id){
System.out.println(id);
if(id!=null){
rainservice.delete_JobInfo(id);
}
}
}
@Controller
public class EmployeeController {
@Autowired
@Qualifier("RainService")
private RainService rainservice;
// 如果在目录下输入为空,则跳转到指定链接
@RequestMapping(value="/employee/")
public ModelAndView index2(ModelAndView mv){
mv.setViewName("employee/list");
return mv;
}
// 如果在目录下输入任何不存在的参数,则跳转到list
@RequestMapping(value="/employee/{formName}")
public String index2(@PathVariable String formName){
String blank = "/employee/list";
return blank;
}
@RequestMapping(value="/employee/list",method=RequestMethod.GET)
public String index(Model model,String content){
List job_list = rainservice.get_EmployeeList();
if (content!=null){
job_list = rainservice.get_EmployeeLikeList(content);
}
model.addAttribute("list",job_list);
return "employee/list";
}
@RequestMapping(value="/employee/add",method=RequestMethod.GET)
public String add(Model model,Integer id){
if(id!=null){
Employee employee = rainservice.get_EmployeeInfo(id);
model.addAttribute("job",employee);
}
List dept_list = rainservice.findAllDept();
List job_list = rainservice.findAllJob();
model.addAttribute("job_list", job_list);
model.addAttribute("dept_list",dept_list);
return "/employee/add";
}
@RequestMapping(value="/employee/add",method=RequestMethod.POST)
public ModelAndView add(ModelAndView mv,@ModelAttribute Employee job ,Integer id){
// System.out.println(id);
if(id!=null){
rainservice.update_EmployeeInfo(job);
}else{
rainservice.insert_EmployeeInfo(job);
}
mv.setViewName("redirect:/employee/list");
return mv;
}
@RequestMapping(value="/employee/delete",method=RequestMethod.GET)
public void delete(Integer id){
// System.out.println(id);
if(id!=null){
rainservice.delete_EmployeeInfo(id);
}
}
}
源码获取:博客首页 "资源" 里下载!