基于SSM的人力资源管理系统

news2024/10/6 18:24:01

末尾获取源码
开发语言:Java
Java开发工具:JDK1.8
后端框架:SSM
前端:采用JSP技术开发
数据库:MySQL5.7和Navicat管理工具结合
服务器:Tomcat8.5
开发软件:IDEA / Eclipse
是否Maven项目:是


目录

一、项目简介

二、系统功能分析

三、系统项目截图

四、核心代码

4.1登录相关

4.2文件上传

4.3封装


一、项目简介

随着企业员工人数的不断增多,企业在人力资源管理方面负担越来越重,因此,为提高企业人力资源管理效率,特开发了本人力资源管理系统。

本文重点阐述了人力资源管理系统的开发过程,以实际运用为开发背景,基于SSM架构,运用了JSP技术和MYSQL作为系统数据库进行开发,充分保证系统的安全性和稳定性。本系统界面良好,操作简单方便,通过系统概述、系统分析、系统设计、数据库设计、系统测试这几个部分,详细的说明了系统的开发过程,最后并对整个开发过程进行了总结,实现了人力资源管理的重要功能。

本系统的使用使管理人员从繁重的工作中解脱出来,实现无纸化办公,能够有效的提高企业人力资源管理效率。


二、系统功能分析

本人力资源管理系统主要包括临时员工功能模块、正式员工功能模块、总管理员功能模块和管理员功能模块4大部分,下面将对这四大功能模块分别进行功能分析。

(1)管理员:管理员登录后主要功能模块包括个人中心、临时员工管理、正式员工管理、职位调度申请管理、报销申请管理、部门信息管理、职位信息管理、工作进度管理、管理员管理以及系统管理。管理员用户用例图如图3-1所示。

(2)总管理员:总管理员注册登录后主要功能模块包括个人中心、临时员工管理、正式员工管理、职位调度申请管理、报销申请管理、部门信息管理、职位信息管理、工作进度管理、总管理员管理、数据库管理、管理员管理以及系统管理,总管理员用例图如图3-2所示。

(3)临时员工:临时员工注册登录后主要功能模块包括个人中心、工作进度管理,临时员工用例图如图3-3所示。

(4)正式员工:正式员工注册登录后主要功能模块包括个人中心、职位调动申请管理、报修申请管理以及工作进度管理,正式员工员用例图如图3-4所示



三、系统项目截图

没有账号的临时员工、正式员工以及总管理员均可进入对于注册界面进行注册操作

用户要想进入本系统必须进行登录操作

 

管理员、总管理员均可增删改查工作进度信息,临时员工以及正式员工可查看工作进度信息,添加工作进度管理界面如图5-3所示,工作进度管理界面展示如图5-4所示,查看工作进度界面展示如图5-5所示。

 

 

 

管理员和总管理员均可增删改查临时员工信息,临时员工管理界面如图5-6所示。

 

管理员和总管理员均可添加、修改和删除正式员工信息,正式员工管理界面如图5-7所示。

 

正式员工登录后可进行职位调动申请操作,管理员和总管理员可查看,并可对其进行审核管理,职位调动申请界面展示如图5-8所示,职位调动申请管理界面如图5-7所示。

 

 


四、核心代码

4.1登录相关


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

4.2文件上传

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

4.3封装

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/720695.html

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

相关文章

剑指offer12.矩阵中的路径

太难了&#xff0c;想了一会儿没有头绪就直接看了题解。 class Solution {public boolean exist(char[][] board, String word) {int clowns board.length;int rows board[0].length;boolean[][] visited new boolean[clowns][rows];for(int i 0;i<clowns;i){for(int j0…

【QT】——QWidget窗口类

1.QWidget基本概念 QWidget 类是所有窗口类的父类 (控件类是也属于窗口类),QWidget 类的父类的 QObject, 也就意味着所有的窗口类对象只要指定了父对象, 都可以实现内存资源的自动回收.可以内嵌到其他窗口的内部&#xff0c;没有边框,需要指定父类窗口可以作为独立的窗口显示&…

DBeaver(一款非常好用的数据库管理工具)大批量数据导入导出非常友好

DBeaver(一款非常好用的数据库管理工具)大批量数据导入导出非常友好 背景说明&#xff1a; 最近因工作需要进行大批量的数据导入导出&#xff0c;很多工具都很难完成千万级以上的单表数据导入导出工作。后来找到了DBeaver这款工具&#xff0c;可以将千万级数据进行分批写入或导…

安装部署mysql

1.二进制方式安装 (1)下载压缩包 (2)创建用户和组 (3)解压 &#xff08;4&#xff09;创建软链接 (5)初始化 &#xff08;6&#xff09; 2.使用yum方式安装 (1)用yum install wget unzip bash-completion tree vim lrzsz net-tools -y命令安装常用软件 (2)用yum install mysql…

【数据仓库】FineBI数据可视化使用体验

FineBI介绍 FineBI是新一代自助式BI工具,企业客户多,服务范围广.凭借finebi简单流畅的操作,强劲的大数据性能和自助式的分析体验。 1&#xff0c;对个人用户来说&#xff0c;免费的无限期试用&#xff0c;解锁所有功能&#xff0c;除了限制两个并发访问&#xff0c;个人用户可以…

vue门户系统实现顶部菜单下拉效果

门户系统实现顶部菜单下拉效果 组件封装 直接上代码&#xff0c;已经封装成组件&#xff0c;只要传输正确的数据格式即可使用。 <template> <div class"head-v3" id"index"><div class"navigation-up"><div class"…

Java SSM 重制版(二)SpringMvc

SpringMVC基础 进入之前&#xff1a;《Spring核心内容》《JavaWeb》《JDK9-17新特性篇》 在前面学习完Spring框架技术之后&#xff0c;差不多会出现两批人&#xff1a;一批是听得云里雾里&#xff0c;依然不明白这个东西是干嘛的&#xff1b;还有一批就是差不多理解了核心思想…

大的zip文件使用7-zip软件分卷压缩和还原

使用7-zip软件进行分卷压缩和还原 1、7-zip软件的安装 官网&#xff1a;https://www.7-zip.org。 2、将比较大的zip文件拆分 设置压缩格式zip,分卷最大150M 拆分后 3、还原 还原后&#xff0c;又重新生成了原zip文件

qt各控件总结

qt控件又称组件或者部件&#xff0c;指用户看到的所有可视化界面以及界面中的各个元素&#xff0c;比如按钮&#xff0c;文本框&#xff0c;输入框等。1.QMainWindow类生成的窗口自带菜单栏&#xff0c;工具栏和状态栏&#xff0c;中央区域还可添加多个控件&#xff0c;常用来作…

Python_关于python2的encode(编码)和decode(解码)的使用

目录 python执行过程的编解码 encode&decode 中文乱码解决方法 常见问题 格式化带有中文的字符串报错 带有中文的字符串反转后乱码 在使用Python2时&#xff0c;我们习惯于在文件开头声明编码 # coding: utf-8 不然在文件中出现中文&#xff0c;运行时就会报错 Syn…

查看和指定GPU服务器显卡训练模型

查看和指定GPU服务器显卡 1.查看显卡2.间隔查看GPU使用情况3.查看当前显卡信息4. 使用os指定使用的显卡 1.查看显卡 nvidia-smiGPU&#xff1a;GPU 编号&#xff1b;与实际编号不一定一致 Name&#xff1a;GPU 型号&#xff1b; Persistence-M&#xff1a;持续模式的状态。持续…

【TEVC 2023】用于进化计算的知识学习 + 进化计算(Evolutionary computation (EC) )其中的一些概念

Knowledge Learning for Evolutionary Computation 进化计算&#xff08;Evolutionary computation (EC) &#xff09;是一种从自然进化和群体智能行为&#xff08;swarm intelligence behaviors&#xff09;中汲取灵感的元启发式算法。 目前&#xff0c;EC以其解决优化问题的…

《Redis 核心技术与实战》课程学习笔记(二)

数据结构&#xff1a;快速的 Redis 有哪些慢操作 数据库这么多&#xff0c;为啥 Redis 能有这么突出的表现呢&#xff1f; 一方面&#xff0c;因为它是内存数据库&#xff0c;所有操作都在内存上完成&#xff0c;内存的访问速度本身就很快。另一方面&#xff0c;因为&#xff…

SQL入门教程(非常详细)从零基础入门到精通,看完这一篇就够了

导读&#xff1a; SQL语言有40多年的历史&#xff0c;从它被应用至今几乎无处不在。我们消费的每一笔支付记录&#xff0c;收集的每一条用户信息&#xff0c;发出去的每一条消息&#xff0c;都会使用数据库或与其相关的产品来存储&#xff0c;而操纵数据库的语言正是 SQL &…

vue页面中一个小列表中多选框的选中状态的两种设置方法

第一种方法:所有类型都是固定的、后台提供了选中状态的接口(页面进入时默认展示所有类型和类型的选中状态 思路: 1、列出所有类型同时与后台规定好每种类型的id与对应的名称 2、在mounted中执行获取后台给定的选中状态(包含1个或多个的id数组) 3、将得到的结构绑定到el-ch…

单元测试基础

一、什么是单元测试&#xff1a; 单元测试是指&#xff0c;对软件中的最小可测试单元在与程序其他部分相隔离的情况下进行检查和验证的工作&#xff0c;这里的最小可测试单元通常是指函数或者类&#xff1b;单元测试属于最严格的软件测试手段&#xff0c;是最接近代码底层实现…

剑指 Offer 14- II: 剪绳子 II

这道题不能使用动态规划来解决&#xff0c;因为会越界。用贪心算法找规律可以得到答案&#xff08;3越多越好&#xff0c;小于等于4取本身的值&#xff09; 这道题错的原因在于res在存储过程中会越界&#xff0c;最轻微的上溢是 INT_MAX 1 &#xff1a;结果是 INT_MIN。 最严重…

C++学习笔记-第10单元 模板初步

第10单元 模板初步 文章目录 第10单元 模板初步单元导读10.1 模板与泛型编程10.1.1 元编程与泛型编程10.1.2 初识模板 10.2 函数模板10.2.1 函数模板10.2.2 函数模版实例化 10.3 排序示例与泛型化10.3.1 例子&#xff1a;选择排序10.3.2 将一个函数泛型化 10.4 类模板10.4.1 类…

基于matlab使用深度学习从分割图生成图像(附源码)

一、前言 此示例演示如何使用 pix2pixHD 条件生成对抗网络 &#xff08;CGAN&#xff09; 从语义分割映射生成场景的合成图像。 Pix2pixHD [1] 由两个同时训练的网络组成&#xff0c;以最大限度地提高两者的性能。 生成器是一种编码器-解码器风格的神经网络&#xff0c;可从语…

设置云服务器和配置docker

一、设置云服务器 刚租完服务器&#xff0c;直接利用公网ip登录此时进入到的是root目录下 ssh root公网ip 但是root的权限太大&#xff0c;一般做项目不会在root路径下直接操作&#xff0c;会创建一个子用户&#xff0c;一台服务器可以创建多个子用户&#xff0c;就像一个大…