基于springboot人事管理系统的设计与实现
目录
基于springboot人事管理系统的设计与实现
一、摘要
二、相关技术
三、系统设计
3.1 整体功能结构图
3.2 功能具体细节设计
四、数据库设计
五、核心代码
六、论文参考
七、源码获取:
一、摘要
传统信息的管理大部分依赖于管理人员的手工登记与管理,然而,随着近些年信息技术的迅猛发展,让许多比较老套的信息管理模式进行了更新迭代,问卷信息因为其管理内容繁杂,管理数量繁多导致手工进行处理不能满足广大用户的需求,因此就应运而生出相应的人事管理系统。
本人事管理系统分为管理员还有用户两个权限,管理员可以管理用户的基本信息内容,可以管理公告信息以及公告的租赁信息,能够与用户进行相互交流等操作,用户可以查看问卷信息,可以查看公告以及查看管理员回复信息等操作。
该人事管理系统采用的是WEB应用程序开发中最受欢迎的B/S三层结构模式,使用占用空间小但功能齐全的MySQL数据库进行数据的存储操作,系统开发技术使用到了JSP技术。该人事管理系统能够解决许多传统手工操作的难题,比如数据查询耽误时间长,数据管理步骤繁琐等问题。总的来说,人事管理系统性能稳定,功能较全,投入运行使用性价比很高。
关键词:人事管理系统;MySQL数据库;springBoot相关技术
二、相关技术
java、tomcat、mysql、spring、sprigBoot、mybatis、query、vue
三、系统设计
3.1 整体功能结构图:
管理员可以管理用户的基本信息,可以管理等功能。管理员功能结构图如下
3.2 功能具体细节设计:
(1)问卷列表
如图显示的就是问卷列表页面,此页面提供给管理员的功能有:查看问卷、新增问卷、修改问卷、删除问卷等。
(2)公告信息管理
管理员可以对公告信息进行管理,可以新增公告信息,修改公告信息,删除无效的公告信息。公告信息管理界面如图所示。
(3)公告类型管理
公告类型管理页面显示所有公告类型,在此页面既可以让管理员添加新的公告信息类型,也能对已有的公告类型信息执行编辑更新,失效的公告类型信息也能让管理员快速删除。下图就是公告类型管理页面。公告类型管理界面如图所示。
四、数据库设计
(1)下图是请假实体和其具备的属性。
(2)下图是考试记录表实体和其具备的属性。
(3)下图是答题详情表实体和其具备的属性。
(4)下图是员工实体和其具备的属性。
(5)下图是错题表实体和其具备的属性。
更多图略....
五、核心代码
package com.controller;import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;/*** 错题表* 后端接口* @author* @email
*/
@RestController
@Controller
@RequestMapping("/examrewrongquestion")
public class ExamrewrongquestionController {private static final Logger logger = LoggerFactory.getLogger(ExamrewrongquestionController.class);@Autowiredprivate ExamrewrongquestionService examrewrongquestionService;@Autowiredprivate TokenService tokenService;@Autowiredprivate DictionaryService dictionaryService;//级联表service@Autowiredprivate ExampaperService exampaperService;@Autowiredprivate ExamquestionService examquestionService;@Autowiredprivate YonghuService yonghuService;/*** 后端列表*/@RequestMapping("/page")public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));String role = String.valueOf(request.getSession().getAttribute("role"));if(false)return R.error(511,"永不会进入");else if("员工".equals(role))params.put("yonghuId",request.getSession().getAttribute("userId"));if(params.get("orderBy")==null || params.get("orderBy")==""){params.put("orderBy","id");}PageUtils page = examrewrongquestionService.queryPage(params);//字典表数据转换List<ExamrewrongquestionView> list =(List<ExamrewrongquestionView>)page.getList();for(ExamrewrongquestionView c:list){//修改对应字典表字段dictionaryService.dictionaryConvert(c, request);}return R.ok().put("data", page);}/*** 后端详情*/@RequestMapping("/info/{id}")public R info(@PathVariable("id") Long id, HttpServletRequest request){logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);ExamrewrongquestionEntity examrewrongquestion = examrewrongquestionService.selectById(id);if(examrewrongquestion !=null){//entity转viewExamrewrongquestionView view = new ExamrewrongquestionView();BeanUtils.copyProperties( examrewrongquestion , view );//把实体数据重构到view中//级联表ExampaperEntity exampaper = exampaperService.selectById(examrewrongquestion.getExampaperId());if(exampaper != null){BeanUtils.copyProperties( exampaper , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段view.setExampaperId(exampaper.getId());}//级联表ExamquestionEntity examquestion = examquestionService.selectById(examrewrongquestion.getExamquestionId());if(examquestion != null){BeanUtils.copyProperties( examquestion , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段view.setExamquestionId(examquestion.getId());}//级联表YonghuEntity yonghu = yonghuService.selectById(examrewrongquestion.getYonghuId());if(yonghu != null){BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段view.setYonghuId(yonghu.getId());}//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 后端保存*/@RequestMapping("/save")public R save(@RequestBody ExamrewrongquestionEntity examrewrongquestion, HttpServletRequest request){logger.debug("save方法:,,Controller:{},,examrewrongquestion:{}",this.getClass().getName(),examrewrongquestion.toString());String role = String.valueOf(request.getSession().getAttribute("role"));if(false)return R.error(511,"永远不会进入");else if("员工".equals(role))examrewrongquestion.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));Wrapper<ExamrewrongquestionEntity> queryWrapper = new EntityWrapper<ExamrewrongquestionEntity>().eq("yonghu_id", examrewrongquestion.getYonghuId()).eq("exampaper_id", examrewrongquestion.getExampaperId()).eq("examquestion_id", examrewrongquestion.getExamquestionId()).eq("examredetails_myanswer", examrewrongquestion.getExamredetailsMyanswer());logger.info("sql语句:"+queryWrapper.getSqlSegment());ExamrewrongquestionEntity examrewrongquestionEntity = examrewrongquestionService.selectOne(queryWrapper);if(examrewrongquestionEntity==null){examrewrongquestion.setInsertTime(new Date());examrewrongquestion.setCreateTime(new Date());examrewrongquestionService.insert(examrewrongquestion);return R.ok();}else {return R.error(511,"表中有相同数据");}}/*** 后端修改*/@RequestMapping("/update")public R update(@RequestBody ExamrewrongquestionEntity examrewrongquestion, HttpServletRequest request){logger.debug("update方法:,,Controller:{},,examrewrongquestion:{}",this.getClass().getName(),examrewrongquestion.toString());String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
// else if("员工".equals(role))
// examrewrongquestion.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));//根据字段查询是否有相同数据Wrapper<ExamrewrongquestionEntity> queryWrapper = new EntityWrapper<ExamrewrongquestionEntity>().notIn("id",examrewrongquestion.getId()).andNew().eq("yonghu_id", examrewrongquestion.getYonghuId()).eq("exampaper_id", examrewrongquestion.getExampaperId()).eq("examquestion_id", examrewrongquestion.getExamquestionId()).eq("examredetails_myanswer", examrewrongquestion.getExamredetailsMyanswer());logger.info("sql语句:"+queryWrapper.getSqlSegment());ExamrewrongquestionEntity examrewrongquestionEntity = examrewrongquestionService.selectOne(queryWrapper);if(examrewrongquestionEntity==null){examrewrongquestionService.updateById(examrewrongquestion);//根据id更新return R.ok();}else {return R.error(511,"表中有相同数据");}}/*** 删除*/@RequestMapping("/delete")public R delete(@RequestBody Integer[] ids){logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());examrewrongquestionService.deleteBatchIds(Arrays.asList(ids));return R.ok();}/*** 批量上传*/@RequestMapping("/batchInsert")public R save( String fileName, HttpServletRequest request){logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");try {List<ExamrewrongquestionEntity> examrewrongquestionList = new ArrayList<>();//上传的东西Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段Date date = new Date();int lastIndexOf = fileName.lastIndexOf(".");if(lastIndexOf == -1){return R.error(511,"该文件没有后缀");}else{String suffix = fileName.substring(lastIndexOf);if(!".xls".equals(suffix)){return R.error(511,"只支持后缀为xls的excel文件");}else{URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径File file = new File(resource.getFile());if(!file.exists()){return R.error(511,"找不到上传文件,请联系管理员");}else{List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件dataList.remove(0);//删除第一行,因为第一行是提示for(List<String> data:dataList){//循环ExamrewrongquestionEntity examrewrongquestionEntity = new ExamrewrongquestionEntity();
// examrewrongquestionEntity.setYonghuId(Integer.valueOf(data.get(0))); //员工id 要改的
// examrewrongquestionEntity.setExampaperId(Integer.valueOf(data.get(0))); //问卷(外键) 要改的
// examrewrongquestionEntity.setExamquestionId(Integer.valueOf(data.get(0))); //试题id(外键) 要改的
// examrewrongquestionEntity.setExamredetailsMyanswer(data.get(0)); //考生作答 要改的
// examrewrongquestionEntity.setInsertTime(date);//时间
// examrewrongquestionEntity.setCreateTime(date);//时间examrewrongquestionList.add(examrewrongquestionEntity);//把要查询是否重复的字段放入map中}//查询是否重复examrewrongquestionService.insertBatch(examrewrongquestionList);return R.ok();}}}}catch (Exception e){e.printStackTrace();return R.error(511,"批量插入数据异常,请联系管理员");}}/*** 前端列表*/@IgnoreAuth@RequestMapping("/list")public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));// 没有指定排序字段就默认id倒序if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){params.put("orderBy","id");}PageUtils page = examrewrongquestionService.queryPage(params);//字典表数据转换List<ExamrewrongquestionView> list =(List<ExamrewrongquestionView>)page.getList();for(ExamrewrongquestionView c:list)dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段return R.ok().put("data", page);}/*** 前端详情*/@RequestMapping("/detail/{id}")public R detail(@PathVariable("id") Long id, HttpServletRequest request){logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);ExamrewrongquestionEntity examrewrongquestion = examrewrongquestionService.selectById(id);if(examrewrongquestion !=null){//entity转viewExamrewrongquestionView view = new ExamrewrongquestionView();BeanUtils.copyProperties( examrewrongquestion , view );//把实体数据重构到view中//级联表ExampaperEntity exampaper = exampaperService.selectById(examrewrongquestion.getExampaperId());if(exampaper != null){BeanUtils.copyProperties( exampaper , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段view.setExampaperId(exampaper.getId());}//级联表ExamquestionEntity examquestion = examquestionService.selectById(examrewrongquestion.getExamquestionId());if(examquestion != null){BeanUtils.copyProperties( examquestion , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段view.setExamquestionId(examquestion.getId());}//级联表YonghuEntity yonghu = yonghuService.selectById(examrewrongquestion.getYonghuId());if(yonghu != null){BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段view.setYonghuId(yonghu.getId());}//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 前端保存*/@RequestMapping("/add")public R add(@RequestBody ExamrewrongquestionEntity examrewrongquestion, HttpServletRequest request){logger.debug("add方法:,,Controller:{},,examrewrongquestion:{}",this.getClass().getName(),examrewrongquestion.toString());Wrapper<ExamrewrongquestionEntity> queryWrapper = new EntityWrapper<ExamrewrongquestionEntity>().eq("yonghu_id", examrewrongquestion.getYonghuId()).eq("exampaper_id", examrewrongquestion.getExampaperId()).eq("examquestion_id", examrewrongquestion.getExamquestionId()).eq("examredetails_myanswer", examrewrongquestion.getExamredetailsMyanswer());logger.info("sql语句:"+queryWrapper.getSqlSegment());ExamrewrongquestionEntity examrewrongquestionEntity = examrewrongquestionService.selectOne(queryWrapper);if(examrewrongquestionEntity==null){examrewrongquestion.setInsertTime(new Date());examrewrongquestion.setCreateTime(new Date());examrewrongquestionService.insert(examrewrongquestion);return R.ok();}else {return R.error(511,"表中有相同数据");}}}
六、论文参考
七、源码获取:
点赞、收藏、关注、评论啦。有任何问题欢迎咨询
👇🏻获取联系方式在文章末尾👇🏻