基于springboot人事管理系统

这篇具有很好参考价值的文章主要介绍了基于springboot人事管理系统。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

末尾获取源码
开发语言:Java
Java开发工具:JDK1.8
后端框架:SpringBoot
前端:Vue
数据库:MySQL5.7和Navicat管理工具结合
开发软件:IDEA / Eclipse
是否Maven项目:是


前言

基于springboot人事管理系统有管理员与员工两大角色:

管理员:首页、个人中心、员工管理、部门管理、员工考勤管理、请假申请管理、加班申请管理、员工工资管理、招聘计划管理、员工培训管理、部门培训管理、员工详情管理。

员工:首页、个人中心、考勤、申请请假、加班申请、工资、查看招聘计划、参加员工培训、参加部门培训、查看员工信息等功能模块。

管理员功能模块

 管理员和员工的登录页面。基于springboot人事管理系统

 管理员登录到系统有首页、个人中心、员工管理、部门管理、员工考勤管理、请假申请管理、加班申请管理、员工工资管理、招聘计划管理、员工培训管理、部门培训管理、员工详情管理。基于springboot人事管理系统

 员工管理页面。基于springboot人事管理系统

 部门管理页面。基于springboot人事管理系统

 员工考勤管理页面。基于springboot人事管理系统

 员工申请请假管理页面。基于springboot人事管理系统

 员工申请加班页面。基于springboot人事管理系统

 招聘计划管理页面。基于springboot人事管理系统

 部门培训管理页面。基于springboot人事管理系统

员工功能

 员工登录到系统有首页、个人中心、考勤、申请请假、加班申请、工资、查看招聘计划、参加员工培训、参加部门培训、查看员工信息等功能模块。基于springboot人事管理系统

 员工申请请假页面。基于springboot人事管理系统文章来源地址https://www.toymoban.com/news/detail-453381.html


登录模块核心代码


package com.controller;


import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;

/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;

	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		return R.ok().put("token", token);
	}
	
	/**
	 * 注册
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setPassword("123456");
        userService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UserEntity user){
        EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
    	PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/list")
    public R list( UserEntity user){
       	EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", userService.selectListView(ew));
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
        userService.updateById(user);//全部更新
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        userService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

文件上传核心代码

package com.controller;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;

/**
 * 上传文件映射表
 */
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
	@Autowired
    private ConfigService configService;
	/**
	 * 上传文件
	 */
	@RequestMapping("/upload")
	public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
		if (file.isEmpty()) {
			throw new EIException("上传文件不能为空");
		}
		String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
		File path = new File(ResourceUtils.getURL("classpath:static").getPath());
		if(!path.exists()) {
		    path = new File("");
		}
		File upload = new File(path.getAbsolutePath(),"/upload/");
		if(!upload.exists()) {
		    upload.mkdirs();
		}
		String fileName = new Date().getTime()+"."+fileExt;
		File dest = new File(upload.getAbsolutePath()+"/"+fileName);
		file.transferTo(dest);
		FileUtils.copyFile(dest, new File("C:\\Users\\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\\static\\upload"+"/"+fileName));
		if(StringUtils.isNotBlank(type) && type.equals("1")) {
			ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
			if(configEntity==null) {
				configEntity = new ConfigEntity();
				configEntity.setName("faceFile");
				configEntity.setValue(fileName);
			} else {
				configEntity.setValue(fileName);
			}
			configService.insertOrUpdate(configEntity);
		}
		return R.ok().put("file", fileName);
	}
	
	/**
	 * 下载文件
	 */
	@IgnoreAuth
	@RequestMapping("/download")
	public ResponseEntity<byte[]> download(@RequestParam String fileName) {
		try {
			File path = new File(ResourceUtils.getURL("classpath:static").getPath());
			if(!path.exists()) {
			    path = new File("");
			}
			File upload = new File(path.getAbsolutePath(),"/upload/");
			if(!upload.exists()) {
			    upload.mkdirs();
			}
			File file = new File(upload.getAbsolutePath()+"/"+fileName);
			if(file.exists()){
				/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
					getResponse().sendError(403);
				}*/
				HttpHeaders headers = new HttpHeaders();
			    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);    
			    headers.setContentDispositionFormData("attachment", fileName);    
			    return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
	}
	
}

 封装代码

package com.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 */
public class R extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public R() {
		put("code", 0);
	}
	
	public static R error() {
		return error(500, "未知异常,请联系管理员");
	}
	
	public static R error(String msg) {
		return error(500, msg);
	}
	
	public static R error(int code, String msg) {
		R r = new R();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}

	public static R ok(String msg) {
		R r = new R();
		r.put("msg", msg);
		return r;
	}
	
	public static R ok(Map<String, Object> map) {
		R r = new R();
		r.putAll(map);
		return r;
	}
	
	public static R ok() {
		return new R();
	}

	public R put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}

到了这里,关于基于springboot人事管理系统的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • springboot/java/php/node/python人事管理系统【计算机毕设】

    本系统 (程序+源码) 带文档lw万字以上    文末可领取本课题的JAVA源码参考   选题背景: 随着信息技术的不断发展和企业规模的扩大,人事管理在企业运营中变得越来越重要。传统的人事管理方式已经无法满足现代企业对高效、精确和可靠的人力资源管理需求。因此,开

    2024年02月05日
    浏览(22)
  • ssm/php/node/python基于大数据的高校人事管理系统

    本系统 (程序+源码) 带文档lw万字以上    文末可领取本课题的JAVA源码参考 选题背景: 随着信息技术的飞速发展,大数据已经成为了当今社会的一个热门话题。大数据技术的应用已经渗透到各个领域,为企业、政府和个人带来了巨大的便利和价值。在教育领域,大数据技

    2024年01月25日
    浏览(30)
  • python+java+nodejs基于vue的企业人事工资管理系统

    根据系统功能需求分析,对系统功能的进行设计和分解。功能分解的过程就是一个由抽象到具体的过程。 作为人事数据库系统,其主要实现的功能应包括以下几个模块: 1.登录模块 登录模块是由管理员、员工2种不同身份进行登录。 2.系统管理模块 用户管理:新用户的添加和

    2024年02月03日
    浏览(31)
  • 数据库系统课设--人事管理系统

    目录 前言 一,课程设计的目的 二,总体设计 1 系统需求分析 1.1 系统功能分析 1.2 系统功能模块设计(划分) 1.3 与其它系统的关系 1.4 数据流程图 2 数据库设计 2.1 数据库需求分析 2.2 数据库概念结构设计 2.3 数据库逻辑结构设计 2.4 数据库的建立 2.4.1 数据库的建立 2.4.2 初始

    2024年02月06日
    浏览(32)
  • 数据库课程设计-人事管理系统

    学期就要结束了,要完成一个数据库的课程设计项目,想想自己一个学期下来啥也没学到,现在突然要独立完成一个小项目,不能偷懒,记录一下吧。 代码已经放在文章末尾 ^ v ^ 完成软件下载与环境配置,成功运行老师写好的学生管理系统。  第一次实现用代码弹出具体的

    2024年02月05日
    浏览(26)
  • 企业员工人事管理系统(数据库课设)

    前言 一、数据库课设概述 二、需求分析 三、概念结构设计 四、逻辑结构设计 五、物理结构设计 六、数据库设计实施 七、团队成员负责模块 八、涉及到数据库与JAVA连接部分代码 九、完成界面设计主要涉及到JAVA的代码部分 十、企业人事资源管理系统功能的主要演示展示

    2024年02月03日
    浏览(32)
  • JSP企业人事管理系统(源代码+论文)

    随着计算机技术的飞速发展,计算机在企业管理中应用的普及,利用计算机实现企业人事管理势在必行。对于大中型企业来说,利用计算机支持企业高效率完成劳动人事管理的日常事务,是适应现代企业制度要求、推动企业劳动人事管理走向科学化、规范化的必要条件;计算

    2024年02月03日
    浏览(26)
  • nodejs+vue+elementui高校人事管理系统

    总体设计 根据高校人事管理系统的功能需求,进行系统设计。 用户功能:用户进入系统可以实现首页、个人中心、职称申报管理、工资信息管理、绩效信息管理、奖惩信息管理、招聘管理等进行操作; 院长功能:院长进入系统可以实现首页、个人中心、用户管理、职称申报

    2024年02月09日
    浏览(23)
  • JSP企业人事管理系统设计(源代码+论文)

    随着计算机技术的飞速发展,计算机在企业管理中应用的普及,利用计算机实现企业人事管理势在必行。对于大中型企业来说,利用计算机支持企业高效率完成劳动人事管理的日常事务,是适应现代企业制度要求、推动企业劳动人事管理走向科学化、规范化的必要条件;计算

    2024年02月03日
    浏览(29)
  • 数据库课程设计 某单位人事管理系统 含前台程序

    1.课程设计目的 ( 1 )培养学生运用所学课程《数据库原理及应用》的理论知识和技能,深入理解《数据库原理及应用》课程相关的理论知识,学会分析实际问题的能力。   ( 2 )培养学生掌握用《数据库原理及应用》的知识设计计算机应用课题的思想和方法。   ( 3 )培

    2024年02月08日
    浏览(22)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包