Java Project: Enterprise Personnel System (java+SpringBoot+Vue+ElementUI+maven+mysql)

Get the source code: Download it from "Resources" on the homepage of the blog!

Project Introduction

The functions of the personnel management system include six modules: personnel communication, employee information, personnel evaluation, reward and punishment, training management, salary management, statistical analysis, and system management, corresponding to the basic process of personnel work: establishment of new employee entry files, transfer, resignation, employee information Inquiry and salary management, etc. System management can assign menu authority settings according to different roles, grant different roles to different users, and conduct overall deployment settings for personnel structure and unit structure. Online chat can realize real-time communication between operators. .
The project is developed based on the front-end and back-end separation development mode of MVVM. MVVM is Model-View-View Model, which realizes the two-way binding of data views. Compared with MVC mode and MVP, MVVM is a relatively new development architecture. It is a new development framework developed and evolved from the combination of MVP mode and WPF application method. The
separation of front and back ends refers to the separation of front and back ends from the previous ones that were all in charge of the back end. Separated, no longer share a server, the front end exists as an independent server. The front and back ends use the HTTP protocol to interact through the interface. This project uses the vu entity attribute outer for front-end routing processing. The page jump is not processed by the back-end, the front-end and back-end are just Data interaction. The advantage of separating front-end and back-end is that it reduces the coupling between front-end and back-end. When facing different hardware scenarios, you need to build different interfaces. After the front-end and back-end are separated, you only need to expand the front-end project without modifying the back-end. Serve.

In terms of dynamic permission processing, the security framework Spring Security is used, and the access control model based on RBAC (Role-Based Access Control) role is mainly composed of authentication and authorization. Authentication is processed based on the Filter principle in Servlet, and authorization is handled by the system Administrator operation. The main idea of ​​RBAC is: permissions are related to roles, and users are assigned corresponding roles as their members, which greatly simplifies the management of permissions.

environmental needs

1. Operating environment: preferably java jdk 1.8, we are running on this platform. Other versions are also theoretically possible.
2. IDE environment: IDEA, Eclipse, Myeclipse can be used. IDEA is recommended;
3. Tomcat environment: Tomcat 7.x, 8.x, 9.x versions are available
4. Hardware environment: Windows 7/8/10 with more than 1G memory; or Mac OS;
5. Maven project: Yes; Check whether pom.xml is included in the source code directory; if so, it is a maven project, otherwise it is a non-maven project

6. Database: MySql version 5.7;

technology stack

1. Backend: Spring Boot, Spring Security, MyBatis

2. Front-end: Vue, ElementUI, axios, Web Socket

Instructions for use

1. Use Navicat or other tools to create a database with the corresponding name in mysql, and import the sql file of
the project; 2. Change the database configuration in the applicationContext.xml configuration file in the project to your own configuration;
3. Use IDEA/Eclipse /MyEclipse import project, when Eclipse/MyEclipse is imported, if it is a maven project, please select maven; if it is a maven project, after the import is successful, please execute the maven clean; maven install command, configure tomcat, and then run;
4. Run the project, enter localhost: 8080/indext.html Login
5. Administrator Username: admin Password: 123

 

 

 

 

 

 

 

 

 

User management control layer:

@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<User> 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;
		}
}

Departmental management control layer:

@Controller
public class DeptController {
	@Autowired
	@Qualifier("RainService")
	private RainService rainservice;
	
	// 如果在目录下输入为空,则跳转到指定链接
	@RequestMapping(value="/dept/")
	 public ModelAndView index2(ModelAndView mv){
		mv.setViewName("dept/list");
		return mv;
	}
	// 如果在目录下输入任何不存在的参数,则跳转到list
	@RequestMapping(value="/dept/{formName}")
	 public String index2(@PathVariable String formName){
//		return formName;
		String blank = "/dept/list";
		return blank;
	}
	
	@RequestMapping(value="/dept/list",method=RequestMethod.GET)
	 public String index(Model model,String content){
//		System.out.println("4234");
		List<Dept> dept_list = rainservice.findAllDept();
		if (content!=null){
			dept_list = rainservice.findAllDept(content);
		}
		
		model.addAttribute("list",dept_list);
//		for(Dept attribute : dept_list) {
//			  System.out.println(attribute.getName());
//			}
		return "dept/list";
	}
	@RequestMapping(value="/dept/add",method=RequestMethod.GET)
	 public String add(Model model,Integer id){
//		System.out.println(id);
		if(id!=null){
			Dept dept = rainservice.get_Info(id);
			model.addAttribute("dept",dept);
//			System.out.println(dept.getName());
		}
		return "/dept/add";
	}
	@RequestMapping(value="/dept/add",method=RequestMethod.POST)
	 public ModelAndView add(ModelAndView mv,@ModelAttribute Dept dept ,Integer id){
		System.out.println(id);
//		System.out.println(dept.getId());
		if(id!=null){
			rainservice.update_Info(dept);
			System.out.println(dept.getId());
		}else{
			rainservice.addDept(dept);
		}
//		System.out.println(dept.getName());
		mv.setViewName("redirect:/dept/list");
		return mv;
	}
	@RequestMapping(value="/dept/delete",method=RequestMethod.GET)
	 public void delete(Integer id){
		System.out.println(id);
		if(id!=null){
			rainservice.delete_Info(id);
		}
	}
}

Role management control layer:

@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<Employee> 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> dept_list = rainservice.findAllDept();
			List<Job> 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);
			}
		}
}

Get the source code: Download it from "Resources" on the homepage of the blog! 

おすすめ

転載: blog.csdn.net/yuyecsdn/article/details/124364018