当前位置:   article > 正文

Java项目:人事管理系统(java+SpringBoot+Vue+ElementUI+Layui+Mysql)_java项目人力资源管理项目

java项目人力资源管理项目

 源码获取:俺的博客首页 "资源" 里下载!

项目介绍

基于SpringBoot Vue的人事管理

角色:管理员、员工

管理员:管理员登录系统后,可以对首页,个人中心,员工管理,部门管理,员工考勤管理,请假申请管理,加班申请管理,员工工资管理,招聘计划管理,员工培训管理,部门培训管理,员工详细管理

员工:员工登录进入人事管理系统可以对首页,个人中心,员工考勤管理,请假申请管理,加班申请管理,员工工资管理,招聘计划管理,员工培训管理,部门培训管理,员工详细管理等进行相应操作


环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 5.7/8.0版本均可;
5.是否Maven项目:是;


技术栈

后端:SpringBoot+Mybaits

前端:Vue+ElementUI+Layui+HTML+CSS+JS


使用说明

项目运行:
1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 运行项目,控制台提示运行成功后再去运行前端项目;
5. 管理员用户名密码:admin/admin
普通用户名密码:user/123456

 

类描述信息 员工Controller处理类: 

  1. /**
  2. * 类描述信息 员工Controller处理类
  3. */
  4. @Controller
  5. @RequestMapping("/employee")
  6. public class EmployeeController {
  7. //注入mapper
  8. @Autowired
  9. private IEmployeeService employeeService;
  10. @RequestMapping("/empView")
  11. public String employeeView() {
  12. return "employee/employee";
  13. }
  14. @RequestMapping("/empAddView")
  15. public String employeeAddView() {
  16. return "employee/employeeAdd";
  17. }
  18. //解析json
  19. private Employee jsonData(String data) {
  20. //解析前台传递的json数据
  21. JSONObject json = JSON.parseObject(data);
  22. if (json != null) {
  23. //{"name":"测试用户1","sex":"男","phone":"18349857548","email":"126@sin.com",
  24. //"positionId":"2","eduschool":"专科","idcard":"382859958958946","deptId":"1","address":"广州"}
  25. String name = json.getString("name");
  26. String sex = json.getString("sex");
  27. String phone = json.getString("phone");
  28. String email = json.getString("email");
  29. String positionId = json.getString("positionId");
  30. String eduschool = json.getString("eduschool");
  31. String idcard = json.getString("idcard");
  32. String deptId = json.getString("deptId");
  33. String address = json.getString("address");
  34. Position p = new Position();
  35. p.setId(Long.parseLong(positionId));
  36. Department d = new Department();
  37. d.setId(Long.parseLong(deptId));
  38. Employee e = new Employee(name, sex, phone, email, p, eduschool,
  39. idcard, d, address);
  40. return e;
  41. }
  42. return null;
  43. }
  44. //保存数据
  45. @RequestMapping(value = "/empSave", method = RequestMethod.POST)
  46. @ResponseBody
  47. public String employeeSave(@RequestBody JSONObject ob) {
  48. String data = ob.toJSONString();
  49. Employee employee = jsonData(data);
  50. if (employee != null) {
  51. int insert = employeeService.insert(employee);
  52. if (insert != 0) {
  53. return "success";
  54. }
  55. }
  56. return "error";
  57. }
  58. //更新
  59. @RequestMapping("/empUpdate")
  60. @ResponseBody
  61. public String update(@RequestBody JSONObject ob) {
  62. System.out.println("ob.toJSONString() = " + ob.toJSONString());
  63. String data = ob.toJSONString();
  64. Employee employee = jsonData(data);
  65. if (employee != null) {
  66. int index = employeeService.updateByPrimaryKey(employee);
  67. if (index != 0) {
  68. return "success";
  69. }
  70. }
  71. return "error";
  72. }
  73. //删除
  74. @RequestMapping("/empDelete")
  75. @ResponseBody
  76. public String delete(@RequestParam("id") Long id) {
  77. if (id != null) {
  78. int index = employeeService.deleteByPrimaryKey(id);
  79. if (index == 0 || index == -1) {
  80. return "error";
  81. }
  82. }
  83. return "success";
  84. }
  85. @RequestMapping(value = "/empList", method = RequestMethod.GET)
  86. public @ResponseBody
  87. Map<String, Object> empList(@RequestParam("page") int page, @RequestParam("limit") int limit) {
  88. //查询所有的数据
  89. List<Employee> countEmp = employeeService.selectAll();
  90. //加入分页
  91. if (page < 0) {
  92. page = 1;
  93. }
  94. PageHelper.startPage(page, limit);
  95. List<Employee> employeeList = employeeService.selectAll();
  96. Map<String, Object> map = new HashMap<>();
  97. map.put("code", 0);
  98. map.put("msg", "");
  99. //结果总数
  100. map.put("count", countEmp.size());
  101. //结果对象数据
  102. map.put("data", employeeList);
  103. System.out.println("map = " + map);
  104. return map;
  105. }
  106. }

 部门管理控制层:

  1. /**
  2. * 类描述信息 部门controller类
  3. */
  4. @Controller
  5. @RequestMapping("/department")
  6. public class DepartmentController {
  7. //注入业务
  8. @Autowired
  9. private IDepartmentService departmentService;
  10. @RequestMapping("/deptView")
  11. public String employeeView() {
  12. return "department/department";
  13. }
  14. //跳转添加页面
  15. @RequestMapping("/deptAddView")
  16. public String departmentAddView() {
  17. return "department/departmentAdd";
  18. }
  19. //查询部门所有数据
  20. @RequestMapping("/deptOption")
  21. @ResponseBody
  22. public List<Department> jsonDeptOption(String keyword) {
  23. List<Department> list = departmentService.selectAll(keyword);
  24. return list;
  25. }
  26. //部门添加
  27. @RequestMapping(value = "/deptAdd", method = RequestMethod.POST)
  28. @ResponseBody
  29. public String departmentAdd(@RequestBody Department dept) {
  30. int insert = departmentService.insert(dept);
  31. if (insert < 0) {
  32. return "error";
  33. }
  34. return "success";
  35. }
  36. //部门删除
  37. @RequestMapping(value = "/deptDelete", method = RequestMethod.GET)
  38. @ResponseBody
  39. public String delete(@RequestParam("id") Long id) {
  40. if (id != null) {
  41. int index;
  42. index = departmentService.deleteByPrimaryKey(id);
  43. if (index == 0 || index == -1) {
  44. return "error";
  45. }
  46. }
  47. return "success";
  48. }
  49. @RequestMapping(value = "/deptList", method = RequestMethod.GET)
  50. public @ResponseBody
  51. Map<String, Object> deptList(@RequestParam int page, @RequestParam int limit,
  52. String keyword) {
  53. System.out.println("keyword = " + keyword);
  54. //查询结果总数
  55. List<Department> countDept = departmentService.selectAll(keyword);
  56. //分页
  57. if (page < 0) {
  58. page = 1;
  59. }
  60. PageHelper.startPage(page, limit);
  61. List<Department> listDept = departmentService.selectAll(keyword);
  62. //封装json数据
  63. Map<String, Object> resultMap = new HashMap<String, Object>() {
  64. {
  65. put("code", 0);
  66. put("msg", "");
  67. put("count", countDept.size());
  68. put("data", listDept);
  69. }
  70. };
  71. return resultMap;
  72. }
  73. }

用户管理控制层: 

  1. @Controller
  2. @RequestMapping("/admin")
  3. public class UserController {
  4. @Autowired
  5. private IUserService userService;
  6. //加载列表界面
  7. @RequestMapping("/userView")
  8. public String showUser() {
  9. return "user/user";
  10. }
  11. //跳转add页面
  12. @RequestMapping("/addView")
  13. public String userAddView() {
  14. return "user/userAdd";
  15. }
  16. @RequestMapping(value = "/userAdd", method = RequestMethod.POST)
  17. @ResponseBody
  18. public String userAdd(@RequestBody User user) {
  19. int insert = userService.insert(user);
  20. if (insert < 0) {
  21. return "error";
  22. }
  23. return "success";
  24. }
  25. //page=1&limit=10
  26. @RequestMapping(value = "/userList", method = RequestMethod.GET)
  27. public @ResponseBody
  28. Map<String, Object> showUserList(@RequestParam("page") int page, @RequestParam("limit") int limit,
  29. String keyword1, String keyword2) {
  30. System.out.println("keyword1 = " + keyword1);
  31. System.out.println("keyword2 = " + keyword2);
  32. //查询结果集对象
  33. List<User> countData = userService.selectAll(keyword1, keyword2);
  34. //封装json数据
  35. Map<String, Object> resultMap = new HashMap<String, Object>();
  36. //分页
  37. if (page < 0) {
  38. page = 1;
  39. PageHelper.startPage(page, limit);
  40. }
  41. List<User> users = userService.selectAll(keyword1, keyword2);
  42. resultMap.put("code", 0);
  43. resultMap.put("msg", "");
  44. //结果总数
  45. resultMap.put("count", countData.size());
  46. //结果对象数据
  47. resultMap.put("data", users);
  48. return resultMap;
  49. }
  50. @RequestMapping("/delete")
  51. @ResponseBody
  52. public String delete(@RequestParam("id") Long id) {
  53. System.out.println("id = " + id);
  54. int index = userService.deleteByPrimaryKey(id);
  55. if (index > 0) {
  56. return "success";
  57. }
  58. //删除失败返回error
  59. return "error";
  60. }
  61. @RequestMapping("/update")
  62. @ResponseBody
  63. public String update(@RequestBody User user) {
  64. if (user != null) {
  65. int index = userService.updateByPrimaryKey(user);
  66. if (index > 0) {
  67. return "success";
  68. }
  69. }
  70. return "error";
  71. }
  72. }

 

源码获取:俺的博客首页 "资源" 里下载!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/845629
推荐阅读
相关标签
  

闽ICP备14008679号