作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
企业人事管理系统
项目介绍
企业人事管理系统,可以实现简单的企业内部的管理.
主要有管理员、人事专员、员工三种角色。
> 管理员功能:登录、分发工资、管理其他角色账号
> 员工功能:注册、登录、打卡、查看工资、请假
> 人事专员:登录、查看员工信息列表、查看(编辑)考勤情况、请假审批
环境要求
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 5.7版本;
6.是否Maven项目:是;
技术栈
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+CSS+JavaScript
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中resources/applicationContext.xml配置文件中的数据库配置改为自己的配置;
4. 运行成功后,在浏览器中输入地址:http://localhost:8080/userLogin/index
运行截图
相关代码
用户登录
package com.controller;
import com.domain.UserLogin;
import com.service.UserLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import java.util.List;
@Controller
@RequestMapping("/userLogin")
@SessionAttributes(value = "ul")
public class UserLoginController {
@Autowired
private UserLoginService userLoginService;
/**
* 注册页面请求
* @return
*/
@RequestMapping("/registerForm")
public String registerForm() {
return "register";
}
/**
* 注册流程
* @return
*/
@RequestMapping("/register")
public String register(UserLogin ul){
if (userLoginService.userRegister(ul)) {
return "main";
} else {
return "addRenShi";
}
}
@RequestMapping("/register1")
public String register1(UserLogin ul){
if (userLoginService.userRegister(ul)) {
return "index";
} else {
return "register";
}
}
/**
* 登录验证请求
* @param userLogin
* @return
*/
@RequestMapping("/login")
public String login(HttpServletRequest request,UserLogin userLogin,ModelMap model) {
try {
if (userLoginService.loginCheck(userLogin)) {
model.put("ul",userLogin);
request.getSession().removeAttribute("message");
return "success";
} else {
request.getSession().setAttribute("message", "用户名或密码输入错误");
return "index";
}
}catch (Exception e){
request.getSession().setAttribute("message", "系统内部错误");
e.printStackTrace();
return "index";
}
}
/**
* 登录主页请求
* @return
*/
@RequestMapping("/index")
public String index() {
return "index";
}
@RequestMapping("/findAll")
public String findAll(Model model) {
//调用service的方法
List<UserLogin> list = userLoginService.findAll();
System.out.println(list);
model.addAttribute("list", list);
return "list";
}
}
UserSalaryController
package com.controller;
import com.domain.UserInfo;
import com.domain.UserLeave;
import com.domain.UserLogin;
import com.domain.UserSalary;
import com.service.UserInfoService;
import com.service.UserLeaveService;
import com.service.UserSalaryService;
import com.sun.org.apache.xpath.internal.operations.Mod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import sun.awt.ModalityListener;
import javax.servlet.http.HttpServletRequest;
import java.time.Month;
import java.util.Date;
import java.util.List;
@Controller
@RequestMapping("/userSalary")
public class UserSalaryController {
@Autowired
private UserSalaryService userSalaryService;
@Autowired
private UserInfoService userInfoService;
/**
*查看工资页面的请求
* @param model
* @return
*/
@RequestMapping("/UserSalary")
public String UserLeave(Model model)
{
//从Session中读取accountName并查询个人信息展示出accountName和realName
HttpServletRequest request=((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
String accountName=((UserLogin)request.getSession().getAttribute("ul")).getAccountName();
if (accountName == null) {
return "user_salary_error";
}else{
List<UserSalary> list=userSalaryService.allUserSalary(accountName);
model.addAttribute("list",list);
return "userSalary";
}
}
/**
* 发放工资页面请求
* @param model
* @return
*/
@RequestMapping("/addUserSalaryForm")
public String addUserSalaryForm(Model model)
{
List<UserInfo> list=userInfoService.SearchALLUserInfo();
model.addAttribute("list",list);
return "addUserSalary";
}
/**
* 添加工资信息
* @param
* @param model
* @return
*/
@RequestMapping("/addUserSalary")
public String addUserLeave(Model model,HttpServletRequest request) {
UserLogin userLogin = ((UserLogin) request.getSession().getAttribute("ul"));
String date=request.getParameter("MONTH");
int year=Integer.parseInt(date.substring(0,4));
int month=Integer.parseInt(date.substring(5,7));
UserSalary userSalary = new UserSalary();
userSalary.setAccountName(request.getParameter("accountName"));
userSalary.setRealName(request.getParameter("realName"));
userSalary.setSalaryDate(request.getParameter("salaryDate"));
userSalary.setSalary(Integer.parseInt(request.getParameter("salary")));
userSalary.setYEAR(year);
userSalary.setMONTH(month);
//用以查看该员工工资是否发放过了
UserSalary userSalary1=userSalaryService.SearchUserSalaryByYearAndMonth(userSalary);
//未完善信息或不是管理员不能进行发放工资
if (userLogin == null||userLogin.getUserType()!=0) {
return "add_user_salary_error";
} else{
//如果没有查到记录,就给予发放
if(userSalary1==null)
{
userSalaryService.addUserSalary(userSalary);
List<UserInfo> list=userInfoService.SearchALLUserInfo();
model.addAttribute("list",list);
return "add_user_salary_success";
}
else
{
return "add_user_salary_error";
}
}
}
}
UserLeaveController
package com.controller;
import com.domain.UserClock;
import com.domain.UserInfo;
import com.domain.UserLeave;
import com.domain.UserLogin;
import com.service.UserClockService;
import com.service.UserInfoService;
import com.service.UserLeaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Controller
@RequestMapping("/userLeave")
public class UserLeaveController {
@Autowired
private UserLeaveService userLeaveService;
@Autowired
private UserInfoService userInfoService;
/**
*请假页面的请求
* @param model
* @return
*/
@RequestMapping("/UserLeave")
public String UserLeave(Model model)
{
//从Session中读取accountName并查询个人信息展示出accountName和realName
HttpServletRequest request=((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
String accountName=((UserLogin)request.getSession().getAttribute("ul")).getAccountName();
UserInfo userInfo=userInfoService.SearchUserInfoByAname(accountName);
if (userInfo == null) {
return "user_info_error";
}else{
UserLeave userLeave=new UserLeave();
userLeave.setAccountName(userInfo.getAccountName());
userLeave.setRealName(userInfo.getRealName());
model.addAttribute("userLeave",userLeave);
return "userLeave";
}
}
/**
* 添加请假信息
* @param userLeave
* @return
*/
@RequestMapping("/addUserLeave")
public String addUserLeave(UserLeave userLeave,HttpServletRequest request) {
String time=request.getParameter("leaveDate");
userLeave.setLeaveDate(time);
if(userLeaveService.addUserLeave(userLeave))
{
return "userleave_success";
} else{
return "userLeave";
}
}
/**
* 审批页面的请求
* @return
*/
@RequestMapping("/findAll")
public String findAll(Model model)
{
List<UserLeave> list=userLeaveService.allUserLeave();
model.addAttribute("list",list);
return "leaveapproval";
}
/**
* 请假审批
* @return
*/
@RequestMapping("/leaveapproval")
public String leaveapproval(Model model,HttpServletRequest request)
{
int id = Integer.parseInt(request.getParameter("id"));
String result = request.getParameter("result");
userLeaveService.updateUserLeave(id,result);
List<UserLeave> list=userLeaveService.allUserLeave();
model.addAttribute("list",list);
return "leaveapproval";
}
@RequestMapping("/searchUserLeave")
public String searchUserLeave(Model model)
{
HttpServletRequest request=((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
String accountName=((UserLogin)request.getSession().getAttribute("ul")).getAccountName();
List<UserLeave> list=userLeaveService.searchUserLeave(accountName);
model.addAttribute("list",list);
return "searchUserLeave";
}
}
UserInfoController
package com.controller;
import com.domain.UserInfo;
import com.domain.UserLogin;
import com.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Controller
@RequestMapping("/userInfo")
public class UserInfoController {
@Autowired
private UserInfoService userInfoService;
/**
* 完善信息页面请求
* @return
*/
@RequestMapping("/addUserInfoForm")
public String index() {
return "addUserInfo";
}
/**
* 完善用户信息
* @param userInfo
* @return
*/
@RequestMapping("/addUserInfo")
public String findAll(UserInfo userInfo) {
HttpServletRequest request=((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
userInfo.setAccountName(((UserLogin)request.getSession().getAttribute("ul")).getAccountName());
if(userInfoService.addUserInfo(userInfo))
{
return "main";
} else{
return "addUserInfo";
}
}
/**
*通过用户名查询个人信息
* @param model
* @return
*/
@RequestMapping("/searchUserInfo")
public String SearchUserInfo(Model model) {
//获取session中的用户名
HttpServletRequest request=((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
String accountName=((UserLogin)request.getSession().getAttribute("ul")).getAccountName();
//根据用户名获取用户信息
UserInfo userInfo=userInfoService.SearchUserInfoByAname(accountName);
model.addAttribute("ui",userInfo);
return "updateUserInfo";
}
/**
*修改个人信息
* @return
*/
@RequestMapping("/updateUserInfo")
public String updateUserInfo(Model model,UserInfo userInfo) {
HttpServletRequest request=((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
String accountName=((UserLogin)request.getSession().getAttribute("ul")).getAccountName();
UserInfo ul=userInfoService.SearchUserInfoByAname(accountName);
model.addAttribute("ui",ul);
if(userInfoService.updateUserInfo(userInfo))
{
return "main";
}
else
{
return "updateUserInfo";
}
}
@RequestMapping("/allUserInfo")
public String allUserInfo(Model model)
{
List<UserInfo> list=userInfoService.SearchALLUserInfo();
model.addAttribute("list",list);
return "allUserInfo";
}
}
如果也想学习本系统,下面领取。关注并回复:032ssm
本文含有隐藏内容,请 开通VIP 后查看