current position:Home>Implementation of enterprise personnel management system by separating the front and back ends of springboot + Vue

Implementation of enterprise personnel management system by separating the front and back ends of springboot + Vue

2022-04-29 05:20:41qq_ four hundred and sixty-nine million six hundred and three t

Author URI : Programming compass

Author's brief introduction :Java Quality creators in the field 、CSDN Blogger 、 Nuggets guest author 、 Years of architect design experience 、 Tencent classroom resident lecturer

primary coverage :Java project 、 Graduation project 、 The resume template 、 Learning materials 、 Interview question bank 、 Technical assistance

Get the source code at the end of the article  

One , Project brief introduction

The system is a front and rear end separated project , Direct start Springboot After application class , Start the front-end engineering access again . The main implementation   The personnel management function of the enterprise , It mainly includes employee management 、 Salary management 、 Position management 、 Rights management 、 Network disk file sharing management and other modules .

System highlights : Use REDIS Data caching , Optimize query performance ; Use distributed file system for file storage service ; be based on Springboot+vue Realize the separation of front and back end development

Two , Introduction to the environment

Language environment :Java:  jdk1.8

database :Mysql: mysql5.7

application server :Tomcat:  tomcat8.5.31

development tool :IDEA or eclipse

Development technology :Element UI 、Vue、Axios、SpringBoot、MyBatis、MySQL、Redis、FastDFS( or OSS)、Tomcat8.5.31

3、 ... and , System display

  The following shows the basic functions of the system :

The user login :

System main interface :

Employee management :

Advanced search

Employee reward and punishment management

Add rewards and punishments

Payroll ledger ( Salary standard ) management

Employee salary management

System management — Department of management

System management -- Position management

System management — Title Management

file management : Store files in a distributed file service Fastdfs Or alicloud OSS On , It can be configured in the system

The above is the basic function of the system , The technology used in this system is relatively advanced , The function is relatively complete , Beautiful interface , Suitable for graduation project .

Four , Core code display

package com.me.controller;

import com.me.pojo.Department;
import com.me.pojo.RespBean;
import com.me.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class DepartmentController {
    @Autowired
    DepartmentService departmentService;


    @GetMapping("/dep/deps")
    public RespBean getAllDepartments() {
        List<Department> list = departmentService.getAllDepartments();
//        for (Department department : list) {
//            System.out.println(department);
//        }
        return RespBean.ok("AllDepartments", list);
    }

    @PostMapping("/dep/add")
    public RespBean addDep(@RequestBody Department dep) {
        System.out.println(dep);
        departmentService.addDep(dep);
        if (dep.getResult() == 1) {
            return RespBean.ok(" Add success ", dep);
        }
        return RespBean.error(" Add failure ");
    }

    @DeleteMapping("/dep/{id}")
    public RespBean deleteDepById(@PathVariable Integer id) {
        Department dep = new Department();
        dep.setId(id);
        departmentService.deleteDepById(dep);
        if (dep.getResult() == -2) {
            return RespBean.error(" There are sub departments under this department , Delete failed ");
        } else if (dep.getResult() == -1) {
            return RespBean.error(" There are employees in this department , Delete failed ");
        } else if (dep.getResult() == 1) {
            return RespBean.ok(" Delete successful ");
        }
        return RespBean.error(" Delete failed ");
    }
}
package com.me.controller;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.me.pojo.*;
import com.me.service.DepartmentService;
import com.me.service.EmployeeService;
import com.me.service.JobLevelService;
import com.me.service.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
public class EmpController {
    @Autowired
    EmployeeService employeeService;

    @Autowired
    PositionService positionService;

    @GetMapping("/emp/query")
    public RespPageBean getEmployeeByPage(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size, Employee employee,  Date[] beginDateScope) {
//        System.out.println(employee);
        return employeeService.getEmployeeByPage(page, size, employee, beginDateScope);
    }


    @PostMapping("/emp/add")
    public RespBean addEmp(@RequestBody Employee employee) {
//        System.out.println(employee);
        if (employeeService.addEmp(employee) == 1) {
            return RespBean.ok(" Add success !");
        }
        return RespBean.error(" Add failure !");
    }

    @PutMapping("/emp/update")
    public RespBean updateEmp(@RequestBody Employee employee) {
//        System.out.println(employee);
        if (employeeService.updateEmp(employee) == 1) {
            return RespBean.ok(" The update is successful !");
        }
        return RespBean.error(" Update failed !");
    }

    @DeleteMapping("/emp/delete/{id}")
    public RespBean deleteEmpByEid(@PathVariable Integer id) {
        if (employeeService.deleteEmpByEid(id) == 1) {
            return RespBean.ok(" Delete successful !");
        }
        return RespBean.error(" Delete failed !");
    }

    @GetMapping("/emp/getAllPositions")
    public RespBean getAllPositions() {

        return RespBean.ok("positions-",positionService.getAllPositions()) ;
    }

    @GetMapping("/emp/nations")
    public RespBean getAllNations() {
        return RespBean.ok("nations-",employeeService.getAllNations());
    }


    @GetMapping("/emp/politicsstatus")
    public RespBean getAllPoliticsstatus() {
        return RespBean.ok("politicsss-",employeeService.getAllPoliticsstatus()) ;
    }


    @Autowired
    private JobLevelService jobLevelService;

    @GetMapping("/emp/joblevels")
    public RespBean getAllJobLevels() {
        return RespBean.ok("joblevels-",jobLevelService.getAllJobLevels());
    }


    @Autowired
    private DepartmentService departmentService;

    @GetMapping("/emp/deps")
    public RespBean getAllDepartments() {
        List<Department> list = departmentService.getAllDepartments();
//        for (Department department : list) {
//            System.out.println(department);
//        }
        return RespBean.ok("AllDepartments", list);
    }


}
package com.me.controller;

import com.me.pojo.Employee;
import com.me.pojo.Employeeec;
import com.me.pojo.RespBean;
import com.me.pojo.RespPageBean;
import com.me.service.EmployeeecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class EmployeeecController {

    @Autowired
    EmployeeecService employeeecService;

    @GetMapping("/ec/{keyword}")
    public RespBean selectByNameOrWorkId(@PathVariable String keyword){
        System.out.println(keyword);
        return RespBean.ok(" Get -",employeeecService.selectByNameOrWorkId(keyword));
    }


    @DeleteMapping("/ec/{id}")
    public RespBean deleteById(@PathVariable int id){
        System.out.println(id);
        if(employeeecService.deleteById(id)==1){
            return RespBean.ok(" Delete successful ");
        }
        return RespBean.error(" Failure ");
    }

    @PostMapping("/ec/add")
    public RespBean add(@RequestBody Employeeec employeeec){
        System.out.println(employeeec);

        if(employeeecService.insertEc(employeeec)==1){
            return RespBean.ok(" Add success ");
        }
        return RespBean.error(" Failure ");
    }

    @PutMapping("/ec/update")
    public RespBean put(@RequestBody Employeeec employeeec){
        System.out.println(employeeec);

        if(employeeecService.updateEc(employeeec)==1){
            return RespBean.ok(" Add success ");
        }
        return RespBean.error(" Failure ");
    }




}

package com.me.controller;

import com.me.pojo.RespBean;
import com.me.service.FileService;
import com.me.util.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

@RestController
public class FileController {

    @Autowired
    FileService fileService;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @PostMapping("/file/upload")
    public RespBean updateFile(MultipartFile file,int id) {
        System.out.println(id);
        System.out.println(MD5Util.getMultiFileMd5(file));
        if(fileService.uploadFile(file,id)){
            return RespBean.ok(" Upload successful ");
        }
        return RespBean.error(" The picture is too large or the format is wrong ");
    }

    @DeleteMapping("/file/{id}")
    public RespBean deleteById(@PathVariable int id){

//        System.out.println(id);
        if(fileService.deleteById(id)){
            return RespBean.ok(" Delete successful ");
        }
        return RespBean.error(" Delete failed ");
    }



    @GetMapping("/file/getAll/{id}")
    public RespBean getAll(@PathVariable String id){
        return RespBean.ok("files-",fileService.getAllHrFiles(id));
    }

    @GetMapping("/file/getLoginHrId")
    public RespBean getHrId(HttpServletRequest request){
        String token = request.getHeader("token");

        String s = stringRedisTemplate.opsForValue().get("id"+token);

        return RespBean.ok(" Get users id",s);
    }

}
package com.me.controller;

import com.me.pojo.Hr;
import com.me.pojo.RespBean;
import com.me.service.HrService;
import org.csource.fastdfs.StorageClient1;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
public class HrController {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Autowired
    private HrService hrService;


    @GetMapping("/hr/getLoginUser")
    public RespBean getLoginUser(HttpServletRequest request){
        String token = request.getHeader("token");
        String s = stringRedisTemplate.opsForValue().get(token);
//        System.out.println("getLoginUser"+s);

        Hr hr = hrService.loadUserByUsername(s);

        return RespBean.ok(" Get users ",hr);
    }


    @PutMapping("/hr/pass")
    public RespBean updateHrPasswd(@RequestBody Map<String, Object> info,HttpServletRequest request) {
        String oldpass = (String) info.get("oldpass");
        String pass = (String) info.get("pass");
        Integer hrid = (Integer) info.get("hrid");
        System.out.println(hrid+pass);
        if (hrService.updateHrPasswd(oldpass, pass, hrid)) {
            // After changing the password, you need to log in again 
            String token = request.getHeader("token");
            Boolean b = stringRedisTemplate.delete(token);

            return RespBean.ok(" The update is successful ! Please login again !");
        }
        return RespBean.error(" Update failed !");
    }


    @PutMapping("/hr/info")
    public RespBean updateHr(@RequestBody Hr hr) {
        if (hrService.updateHr(hr) == 1) {
            return RespBean.ok(" The update is successful !");
        }
        return RespBean.error(" Update failed !");
    }

    @PostMapping("/hr/userface")
    public RespBean updateHrUserface(MultipartFile file, Integer id) {
        System.out.println("face    "+id);

       if(hrService.updateHrUserface(file,id)){
           return RespBean.ok(" The update is successful !");
       }
       return RespBean.error(" The picture is too large or the format is wrong ");

    }




}

5、 ... and , Project summary

    Project adoption springboot+vue Realize the project development of front and rear end separation , The function is simple and generous , In addition, I used redis Cache database and oss Distributed file storage services , It is a highlight of the project .

copyright notice
author[qq_ four hundred and sixty-nine million six hundred and three t],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/116/202204261120091781.html

Random recommended