基于springboot人事管理系统

news2024/9/21 4:40:35

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


前言

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

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

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

管理员功能模块

 管理员和员工的登录页面。

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

 员工管理页面。

 部门管理页面。

 员工考勤管理页面。

 员工申请请假管理页面。

 员工申请加班页面。

 招聘计划管理页面。

 部门培训管理页面。

员工功能

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

 员工申请请假页面。


登录模块核心代码


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;
	}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/547843.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

vscode录音及语音实时转写插件开发并在工作区生成本地mp3文件 踩坑日记!

前言 最近接到一个需求&#xff0c;实现录音功能并生成mp3文件到本地工作区&#xff0c;一开始考虑到的是在vscode主体代码里面开发&#xff0c;但这可不是一个小的工作量。时间紧&#xff0c;任务重&#xff01;市面上实现录音功能的案例其实很多&#xff0c;一些功能代码是可…

【敬伟ps教程】修复工具

文章目录 模糊工具锐化工具涂抹工具减淡、加深工具海绵工具仿制图章工具图案图章工具修复画笔工具污点修复画笔工具修补工具内容感知移动工具红眼工具 模糊工具 模糊工具的主要功能就是把图像变的模糊。虽然是把图像变模糊&#xff0c;但是模糊工具应用也是很广泛的。使用模糊工…

小黑子—Java从入门到入土过程:第十一章 - 网络编程、反射及动态代理

Java零基础入门11.0 网络编程1. 初识网络编程2. 网络编程三要素3.IP三要素3.1 IPV4的细节3.1.1特殊的IP地址3.1.2 常用的CMD命令 3.2 InetAddress 的使用3.3 端口号3.4 协议3.4.1 UDP协议3.4.1 - I UDP 发送数据3.4.1 - II UDP 接收数据3.4.1 - III UDP 练习&#xff08;聊天室…

C++实现日期类(超详细)

个人主页&#xff1a;平行线也会相交&#x1f4aa; 欢迎 点赞&#x1f44d; 收藏✨ 留言✉ 加关注&#x1f493;本文由 平行线也会相交 原创 收录于专栏【C之路】&#x1f48c; 本专栏旨在记录C的学习路线&#xff0c;望对大家有所帮助&#x1f647;‍ 希望我们一起努力、成长&…

六级备考28天|CET-6|听力第二讲|长对话满分技巧|听写技巧|2022年6月考题|14:30~16:00

目录 1. 听力策略 2. 第一二讲笔记 3. 听力原文复现 (5)第五小题 (6)第六小题 (7)第七小题 (8)第八小题 扩展业务 expand business 4. 重点词汇 1. 听力策略 2. 第一二讲笔记 3. 听力原文复现 (5)第五小题 our guest is Molly Sundas, a university stud…

【ZYNQ】ZYNQ7000 定时器及私有定时器驱动示例

简介 每个 Cortex-A9 处理器都有自己独立的 32 位私有定时器和 32 位看门狗定时器。这两个处理器共享一个 64 位的全局定时器。这些计时器的频率为 CPU 频率&#xff08;CPU_3x2x&#xff09;的 1/2。 在系统级别上&#xff0c;有一个 24 位看门狗定时器和两个 16 位三重定时…

据不可靠消息,ST的新一代机皇正式命名为STM32V8系列,搭载Cortex-M85内核

根据以往的传统单片机命名方式&#xff1a; C0, L0, G0, F0 > Cortex-M0内核 F1, L1 > Corterx-M3内核 F2, F3 > Corterx-M3/M4 F4&#xff0c;G4&#xff0c;L4, L4 > Cortex-M4内核 L5&#xff0c;U5, H5 > Cor…

数据结构—排序算法(插入排序及选择排序)

目录 1、排序的概念 2、常见的排序算法 3、直接插入排序&#xff08;插入排序&#xff09; 3.1 直接插入排序基本思想 3.2 直接插入排序实现 4、 希尔排序( 缩小增量排序 )&#xff08;插入排序&#xff09; 4.1 基本思想 4.2 希尔排序实现 4.3 希尔排序的特性总结 5、…

【Draw.io】让Draw.io导出的SVG格式图片包含自定义属性信息

前景提要 Draw.io重度用户一枚 这个Draw.io是一个极其好用的跨平台流程图绘制软件。 它保存的文件格式可以输出成SVG格式. 这个是基本功能了&#xff0c;没啥好说的 导出之后得到画的图片的SVG代码 SVG代码&#xff0c;也没啥好说的&#xff0c;一种矢量图片格式。 但是&…

改造Springboot+vue项目

准备 搜索一个项目&#xff0c;并成功运行 毕设时&#xff0c;我们可以从网上搜索一个项目&#xff08;包括前端的页面、后台的处理、数据库等有一下简单的模板样式&#xff09;并能成功的将项目在自己的电脑上跑起来。毕设项目可以用搜索的模板&#xff08;不用从头开始写&a…

【数据结构】_2.包装类与泛型

目录 1. 包装类 1.1 基本数据类型和对应的包装类 1.2 &#xff08;自动&#xff09;装箱和&#xff08;自动&#xff09;拆箱 1.2.1 装箱与拆箱 1.2.2 自动装箱与自动拆箱 1.3 valueOf()方法 2. 泛型类 2.1 泛型类与Object类 2.2 泛型类语法 2.3 泛型类示例 2.4 裸类…

怎么把照片缩小到200k?图片指定大小压缩怎么弄?

平时在给账号设置头像时&#xff0c;都会遇到图片过大无法上传的情况&#xff0c;这时候我们可以通过图片压缩指定大小工具来将图片压缩到200kb以下&#xff0c;这样就可以顺利设置头像了&#xff0c;下面一起来看一下图片指定大小压缩&#xff08;https://www.yasuotu.com/ima…

机器学习笔记 - windows基于TensorRT的UNet推理部署

一、TensorRT简介 NVIDIA TensorRT是一个用于高性能深度学习推理的平台。TensorRT适用于使用CUDA平台的所有NVIDIA GPU。所以如果需要基于TensorRT部署,至少需要一个NVIDIA显卡,算力5.0以上,比Maxwell更新的架构,可以参考下表。 CUDA GPUs - Compute Capability | NVIDIA …

电动车头盔检测数据集

现在正慢慢整理自己有关电动车头盔检测的项目内容&#xff0c;会逐渐将这些资源进行发布&#xff0c;供大家参考和使用【部分资源有偿提供&#xff0c;毕竟花费了很多心血】。 这篇文章主要是发布相关数据集的。网上关于工厂环境下的头盔数据集有很多&#xff0c;而且多种多样…

PFCdocumentation_Coupling PFC and FLAC3D

目录 Coupling PFC and FLAC3D 1D Structural Element Coupling Scheme Wall-Zone Coupling Scheme 2D 3D Ball-Zone Coupling Scheme Commands FISH Functions Coupling PFC and FLAC3D 在 FLAC3D 图形用户界面中&#xff0c;可以通过“工具 ‣ 加载 PFC”菜单项加载 …

计算机组成与结构易错题

计算机组成与结构 海明校验码是在n个数据位之外增设k个校验位&#xff0c;从而形成一个kn位的新的码字&#xff0c;使新的码字的码距比较均匀地拉大。n与k的关系是&#xff08;A&#xff09;。 A、2k-1≥nk B、2n-1≤nk C、nk D、n-1≤k 知识&#xff1a; 确定要传输的信息&…

普通专科生,拿什么拯救自己的未来我想成为一名网络安全专业人员,需要做什么?

前 言 写这篇文章的初衷是很多朋友都想了解如何入门/转行网络安全&#xff0c;实现自己的“黑客梦”。文章的宗旨是&#xff1a; 1.指出一些自学的误区 2.提供客观可行的学习表 3.推荐我认为适合小白学习的资源.大佬绕道哈&#xff01; 我的经历&#xff1a; 我19年毕业&…

【C语言】入门必看之循环练习(含二分查找动图)

&#x1f6a9;纸上得来终觉浅&#xff0c; 绝知此事要躬行。 &#x1f31f;主页&#xff1a;June-Frost &#x1f680;专栏&#xff1a;C语言 ⚡注&#xff1a;此篇文章的 代码风格部分 将根据《高质量 C/C 编程指南》 —— 林锐 进行说明。该部分将用紫色表示 该篇将对循环语…

AI落地:10分钟变身Excel高手

本文首发公众号突围一只鹰。 使用Excel的时候经常有几个难点&#xff1a; 有些功能不知道如何操作不知道该用哪个公式不知道公式的参数如何设置复杂数据处理不知道如何写公式多表链接的时候不知道如何写公式其他数据源导入Excel只会手动录入 有了ChatGPT之后&#xff0c;很多…

求爷爷告奶奶,阿里大佬才甩出这份Spark+Hadoop+中台实战pdf

Spark大数据分析实战 1、Spark简介 初识Spark Sp ark生态系统BDAS Sp ark架构与运行逻辑 弹性分布式数据集 2、Spark开发与环境配置 Spark应用开发环境2置 使用Intelli i开发Spark 远程调试Spark程序 Spark编译 配置Spark源码阅读环境 3、BDAS简介 SQL on Spark S…