——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Node.js≥14
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
❗没学过node.js的不要搞前后端分离项目
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot人事管理系统(java+springboot+mybaits+vue+elementui+mysql)
项目介绍
springboot人事系统
环境需要
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
使用说明
项目运行:
使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令;
将项目中application.yml配置文件中的数据库配置改为自己的配置;
运行项目,在浏览器中输入地址:
前台地址:http://localhost:8080/springbootrpj39/front/index.html
后台地址
http://localhost:8080/springbootrpj39/admin/dist/index.html
管理员 abo 密码 abo
用户:用户1 密码: 123456
注意项目文件路径中不能含有中文、空格、特殊字符等,否则图片会上传不成功。
——————————CodeStart——————————
员工信息Controller处理类:
/**
- 类描述信息 员工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
//加入分页
if (page < 0) {
page = 1;
PageHelper.startPage(page, limit);
List
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
List
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
//分页
if (page < 0) {
page = 1;
PageHelper.startPage(page, limit);
List
//封装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
//封装json数据
Map<String, Object> resultMap = new HashMap<String, Object>();
//分页
if (page < 0) {
page = 1;
PageHelper.startPage(page, limit);
List
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”;
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=251125130706201qf
https://javayms.pages.dev?id=251125130706201qf