赞
踩
源码获取:俺的博客首页 "资源" 里下载!
项目介绍
基于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处理类
- */
- @Controller
- @RequestMapping("/employee")
- public class EmployeeController {
-
- //注入mapper
- @Autowired
- private IEmployeeService employeeService;
-
- @RequestMapping("/empView")
- public String employeeView() {
-
- return "employee/employee";
- }
-
- @RequestMapping("/empAddView")
- public String employeeAddView() {
-
- return "employee/employeeAdd";
- }
-
- //解析json
- private Employee jsonData(String data) {
- //解析前台传递的json数据
- JSONObject json = JSON.parseObject(data);
- if (json != null) {
- //{"name":"测试用户1","sex":"男","phone":"18349857548","email":"126@sin.com",
- //"positionId":"2","eduschool":"专科","idcard":"382859958958946","deptId":"1","address":"广州"}
- String name = json.getString("name");
- String sex = json.getString("sex");
- String phone = json.getString("phone");
- String email = json.getString("email");
- String positionId = json.getString("positionId");
- String eduschool = json.getString("eduschool");
- String idcard = json.getString("idcard");
- String deptId = json.getString("deptId");
- String address = json.getString("address");
- Position p = new Position();
- p.setId(Long.parseLong(positionId));
- Department d = new Department();
- d.setId(Long.parseLong(deptId));
- Employee e = new Employee(name, sex, phone, email, p, eduschool,
- idcard, d, address);
- return e;
- }
- return null;
- }
-
- //保存数据
- @RequestMapping(value = "/empSave", method = RequestMethod.POST)
- @ResponseBody
- public String employeeSave(@RequestBody JSONObject ob) {
- String data = ob.toJSONString();
- Employee employee = jsonData(data);
- if (employee != null) {
- int insert = employeeService.insert(employee);
- if (insert != 0) {
- return "success";
- }
- }
- return "error";
- }
-
- //更新
- @RequestMapping("/empUpdate")
- @ResponseBody
- public String update(@RequestBody JSONObject ob) {
- System.out.println("ob.toJSONString() = " + ob.toJSONString());
- String data = ob.toJSONString();
- Employee employee = jsonData(data);
- if (employee != null) {
- int index = employeeService.updateByPrimaryKey(employee);
- if (index != 0) {
- return "success";
- }
- }
- return "error";
- }
-
- //删除
- @RequestMapping("/empDelete")
- @ResponseBody
- public String delete(@RequestParam("id") Long id) {
- if (id != null) {
- int index = employeeService.deleteByPrimaryKey(id);
- if (index == 0 || index == -1) {
- return "error";
- }
- }
- return "success";
- }
-
- @RequestMapping(value = "/empList", method = RequestMethod.GET)
- public @ResponseBody
- Map<String, Object> empList(@RequestParam("page") int page, @RequestParam("limit") int limit) {
- //查询所有的数据
- List<Employee> countEmp = employeeService.selectAll();
- //加入分页
- if (page < 0) {
- page = 1;
- }
- PageHelper.startPage(page, limit);
- List<Employee> employeeList = employeeService.selectAll();
- Map<String, Object> map = new HashMap<>();
- map.put("code", 0);
- map.put("msg", "");
- //结果总数
- map.put("count", countEmp.size());
- //结果对象数据
- map.put("data", employeeList);
- System.out.println("map = " + map);
- return map;
- }
- }

- /**
- * 类描述信息 部门controller类
- */
- @Controller
- @RequestMapping("/department")
- public class DepartmentController {
-
- //注入业务
- @Autowired
- private IDepartmentService departmentService;
-
- @RequestMapping("/deptView")
- public String employeeView() {
-
- return "department/department";
- }
-
- //跳转添加页面
- @RequestMapping("/deptAddView")
- public String departmentAddView() {
-
- return "department/departmentAdd";
- }
-
- //查询部门所有数据
- @RequestMapping("/deptOption")
- @ResponseBody
- public List<Department> jsonDeptOption(String keyword) {
- List<Department> list = departmentService.selectAll(keyword);
- return list;
- }
-
- //部门添加
- @RequestMapping(value = "/deptAdd", method = RequestMethod.POST)
- @ResponseBody
- public String departmentAdd(@RequestBody Department dept) {
- int insert = departmentService.insert(dept);
- if (insert < 0) {
- return "error";
- }
- return "success";
- }
-
- //部门删除
- @RequestMapping(value = "/deptDelete", method = RequestMethod.GET)
- @ResponseBody
- public String delete(@RequestParam("id") Long id) {
- if (id != null) {
- int index;
- index = departmentService.deleteByPrimaryKey(id);
- if (index == 0 || index == -1) {
- return "error";
- }
- }
- return "success";
- }
-
- @RequestMapping(value = "/deptList", method = RequestMethod.GET)
- public @ResponseBody
- Map<String, Object> deptList(@RequestParam int page, @RequestParam int limit,
- String keyword) {
- System.out.println("keyword = " + keyword);
- //查询结果总数
- List<Department> countDept = departmentService.selectAll(keyword);
- //分页
- if (page < 0) {
- page = 1;
- }
- PageHelper.startPage(page, limit);
- List<Department> listDept = departmentService.selectAll(keyword);
- //封装json数据
- Map<String, Object> resultMap = new HashMap<String, Object>() {
- {
- put("code", 0);
- put("msg", "");
- put("count", countDept.size());
- put("data", listDept);
- }
- };
- return resultMap;
- }
- }

- @Controller
- @RequestMapping("/admin")
- public class UserController {
-
- @Autowired
- private IUserService userService;
-
- //加载列表界面
- @RequestMapping("/userView")
- public String showUser() {
- return "user/user";
- }
-
-
- //跳转add页面
- @RequestMapping("/addView")
- public String userAddView() {
-
- return "user/userAdd";
- }
-
- @RequestMapping(value = "/userAdd", method = RequestMethod.POST)
- @ResponseBody
- public String userAdd(@RequestBody User user) {
- int insert = userService.insert(user);
- if (insert < 0) {
- return "error";
- }
- return "success";
- }
-
- //page=1&limit=10
- @RequestMapping(value = "/userList", method = RequestMethod.GET)
- public @ResponseBody
- Map<String, Object> showUserList(@RequestParam("page") int page, @RequestParam("limit") int limit,
- String keyword1, String keyword2) {
- System.out.println("keyword1 = " + keyword1);
- System.out.println("keyword2 = " + keyword2);
- //查询结果集对象
- List<User> countData = userService.selectAll(keyword1, keyword2);
- //封装json数据
- Map<String, Object> resultMap = new HashMap<String, Object>();
- //分页
- if (page < 0) {
- page = 1;
- PageHelper.startPage(page, limit);
- }
- List<User> users = userService.selectAll(keyword1, keyword2);
- resultMap.put("code", 0);
- resultMap.put("msg", "");
- //结果总数
- resultMap.put("count", countData.size());
- //结果对象数据
- resultMap.put("data", users);
- return resultMap;
- }
-
- @RequestMapping("/delete")
- @ResponseBody
- public String delete(@RequestParam("id") Long id) {
- System.out.println("id = " + id);
- int index = userService.deleteByPrimaryKey(id);
- if (index > 0) {
- return "success";
- }
- //删除失败返回error
- return "error";
- }
-
- @RequestMapping("/update")
- @ResponseBody
- public String update(@RequestBody User user) {
- if (user != null) {
- int index = userService.updateByPrimaryKey(user);
- if (index > 0) {
- return "success";
- }
- }
- return "error";
- }
-
- }

源码获取:俺的博客首页 "资源" 里下载!
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。