Java project: enterprise personnel system (java+SpringBoot+Vue+ElementUI+maven+mysql)

Source code acquisition: download from "resources" on the blog home page!

Project introduction

The functions of the personnel management system include six modules: personnel communication, employee information, personnel evaluation, rewards and punishments, training management, salary management, statistical analysis, and system management, corresponding to the basic process of personnel work: establishment of new employee entry file, transfer, resignation, query of employee information, salary management, etc System management can assign menu permission settings according to different roles, grant different roles to different users, and make overall deployment settings for personnel structure and company structure Online chat can realize the timely communication of information 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 view Compared with MVC mode and MVP, MVVM is a relatively new development architecture. It is a new development framework developed by combining MVP mode with WPF
Front end and back end separation means that the front end and the back end are separated from the former one in which the back end is responsible. Instead of sharing a Server, the front end exists as an independent Server The front and back ends interact through the interface using HTTP protocol. This project uses vu entity attribute outer for front-end routing processing Page Jump is not handled by the back end, but the data interaction between the front and back end The advantage of front and rear end separation is to reduce the coupling of front and rear ends When facing different hardware scenarios, you need to build different interfaces. After the front and back ends are separated, you only need to expand the front-end project without modifying the back-end services

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

Environmental needs

1. Running environment: java jdk 1.8 is preferred. We run it on this platform. Other versions are theoretically OK.
2.IDE environment: IDEA, eclipse and MyEclipse are OK. Recommend IDEA;
3.tomcat environment: Tomcat 7 x,8. x,9. X version is available
4. Hardware environment: Windows 7 / 8 / 10 with more than 1G memory; Or Mac OS;
5. Maven project: Yes; Check whether the source directory contains POM xml; If yes, it is a maven project; otherwise, it is a non Maven project

6. Database: MySQL version 5.7;

Technology stack

1. Back end: Spring Boot,Spring Security, MyBatis

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

instructions

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. Add ApplicationContext to the project Change the database configuration in the XML configuration file to your own configuration;
3. Use IDEA/Eclipse/MyEclipse to import the project. When importing Eclipse/MyEclipse, if it is a maven project, please select Maven; If it is a maven project, please execute Maven clean after successful import; Maven install command, configure tomcat, and then run;
4. Run the project and enter localhost: 8080 / indext HTML login
5. Administrator user name: admin Password: 123

 

 

 

 

 

 

 

User management control layer:

@Controller
public class UserController {
	@Autowired
	@Qualifier("RainService")
	private RainService rainservice;
	// If it is blank in the directory, you will jump to the specified link
		@RequestMapping(value="/user/")
		 public ModelAndView index2(ModelAndView mv){
			mv.setViewName("/user/list");
			return mv;
		}
//		Exit function
		@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){
			// Call the business logic component to determine whether the user can log in
			boolean flag = false;
			if("1".equals(tip)) {
				User user = rainservice.login(loginname, password);
				if(user!=null){
					// Save the user to HttpSession
					System.out.println("HttpSession");
					session.setAttribute(Constants.USER_SESSION, user);
					session.setAttribute("tip", "1");
					// The client jumps to the main page
					mv.setViewName("redirect:/index");
				}else{
					// Set login failure prompt
					System.out.println("Set login failure prompt");
					mv.addObject("message", "Login or password error!Please re-enter");
					// Jump to the login page inside the server
					mv.setViewName("forward:/loginForm");
				}
			}else {
				Employee user = rainservice.login2(loginname, password);
				if(user!=null){
					// Save the user to HttpSession
					System.out.println("HttpSession");
					session.setAttribute(Constants.USER_SESSION, user);
					session.setAttribute("tip", "2");
					// The client jumps to the main page
					mv.setViewName("redirect:/indexcustomer/");
				}else{
					// Set login failure prompt
					System.out.println("Set login failure prompt");
					mv.addObject("message", "Login or password error!Please re-enter");
					// Jump to the login page inside the server
					mv.setViewName("forward:/loginForm");
				}
				
			}
			return mv;
		}
		// If you enter any non-existent parameters in the directory, you will jump to 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);
			}
		}
//		Page to jump to when the administrator changes the password 
		@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);
//			If you change your password, update the 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;
		}
}

Department management control level:

@Controller
public class DeptController {
	@Autowired
	@Qualifier("RainService")
	private RainService rainservice;
	
	// If it is blank in the directory, you will jump to the specified link
	@RequestMapping(value="/dept/")
	 public ModelAndView index2(ModelAndView mv){
		mv.setViewName("dept/list");
		return mv;
	}
	// If you enter any non-existent parameters in the directory, you will jump to 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;
	// If it is blank in the directory, you will jump to the specified link
		@RequestMapping(value="/employee/")
		 public ModelAndView index2(ModelAndView mv){
			mv.setViewName("employee/list");
			return mv;
		}
		// If you enter any non-existent parameters in the directory, you will jump to 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);
			}
		}
}

Source code acquisition: download from "resources" on the blog home page!  

Tags: Java MySQL Maven Spring Boot Vue

Posted by clarencek on Sat, 23 Apr 2022 10:15:17 +0300