🍊作者:计算机编程-吉哥
🍊简介:专业从事JavaWeb程序开发,微信小程序开发,定制化项目、 源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事,生活就是快乐的。
🍊心愿:点赞 👍 收藏 ⭐评论 📝
🍅 文末获取源码联系👇🏻 精彩专栏推荐订阅 👇🏻 不然下次找不到哟~
Java毕业设计项目~热门选题推荐《1000套》
目录
1.技术选型
2.数据库表结构
3.开发工具
4.功能
4.1【角色】
4.2【用户功能模块】
4.3【管理功能模块】
5.项目演示截图
5.1 登录
5.2 公告类型管理
5.3 绩效管理
5.4 培训管理
5.5 员工管理
5.6 人事调动管理
5.7 薪资管理
5.8 招聘管理
6.数据库文件设计
7.核心代码
7.1 Controller
7.2 Service
7.3 ServiceImpl
7.4 DAO
8.参考文档
1.技术选型
springboot、mybatisplus、vue、elementui、html、css、js、mysql、jdk1.8
2.数据库表结构
16张
3.开发工具
idea、navicat
4.功能
4.1【角色】
管理员、用户
4.2【用户功能模块】
- 登录
- 首页
- 个人中心
- 公告管理
- 绩效管理
- 培训管理
- 人事调动管理
- 薪资管理
- 员工考勤管理
- 员工请假管理
- 招聘管理
4.3【管理功能模块】
- 登录
- 首页
- 个人中心
- 管理员管理
- 基础数据管理
- 公告管理
- 绩效管理
- 培训管理
- 人事调动管理
- 薪资管理
- 员工管理
- 员工考勤管理
- 员工请假管理
- 招聘管理
5.项目演示截图
5.1 登录
5.2 公告类型管理
5.3 绩效管理
5.4 培训管理
5.5 员工管理
5.6 人事调动管理
5.7 薪资管理
5.8 招聘管理
6.数据库文件设计
CREATE TABLE `config` (`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',`name` varchar(100) DEFAULT NULL COMMENT '配置参数名称',`value` varchar(100) DEFAULT NULL COMMENT '配置参数值',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='配置文件';CREATE TABLE `dictionary` (`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',`dic_code` varchar(200) DEFAULT NULL COMMENT '字段',`dic_name` varchar(200) DEFAULT NULL COMMENT '字段名',`code_index` int(11) DEFAULT NULL COMMENT '编码',`index_name` varchar(200) DEFAULT NULL COMMENT '编码名字 Search111 ',`super_id` int(11) DEFAULT NULL COMMENT '父字段id',`beizhu` varchar(200) DEFAULT NULL COMMENT '备注',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=utf8 COMMENT='字典';CREATE TABLE `gonggao` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键 ',`gonggao_name` varchar(200) DEFAULT NULL COMMENT '公告名称 Search111 ',`gonggao_photo` varchar(200) DEFAULT NULL COMMENT '公告图片',`gonggao_types` int(11) NOT NULL COMMENT '公告类型 Search111 ',`insert_time` timestamp NULL DEFAULT NULL COMMENT '公告发布时间 ',`gonggao_content` longtext COMMENT '公告详情 ',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show1 show2 nameShow',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT='公告';CREATE TABLE `jixiao` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键 ',`yuangong_id` int(11) DEFAULT NULL COMMENT '员工',`jixiao_uuid_number` varchar(200) DEFAULT NULL COMMENT '绩效编号',`jixiao_name` varchar(200) DEFAULT NULL COMMENT '绩效标题 Search111 ',`jixiao_file` varchar(200) DEFAULT NULL COMMENT '附件 Search111 ',`jixiao_types` int(11) DEFAULT NULL COMMENT '绩效类型 Search111',`jixiao_dafen` decimal(10,2) DEFAULT NULL COMMENT '绩效打分',`pinggu_time` timestamp NULL DEFAULT NULL COMMENT '评估时间',`jixiao_content` longtext COMMENT '打分缘由 ',`insert_time` timestamp NULL DEFAULT NULL COMMENT '记录时间',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show3 photoShow',PRIMARY KEY (`id`)
) CREATE TABLE `single_seach` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',`single_seach_name` varchar(200) DEFAULT NULL COMMENT '名字 Search111 ',`single_seach_types` int(11) DEFAULT NULL COMMENT '数据类型',`single_seach_photo` varchar(200) DEFAULT NULL COMMENT '图片',`single_seach_content` longtext COMMENT '内容',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show2 nameShow',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='单页数据';CREATE TABLE `token` (`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',`userid` bigint(20) NOT NULL COMMENT '员工id',`username` varchar(100) NOT NULL COMMENT '员工名',`tablename` varchar(100) DEFAULT NULL COMMENT '表名',`role` varchar(100) DEFAULT NULL COMMENT '角色',`token` varchar(200) NOT NULL COMMENT '密码',`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '新增时间',`expiratedtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '过期时间',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT='token表';CREATE TABLE `users` (`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',`username` varchar(100) NOT NULL COMMENT '员工名',`password` varchar(100) NOT NULL COMMENT '密码',`role` varchar(100) DEFAULT '管理员' COMMENT '角色',`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '新增时间',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='管理员';CREATE TABLE `xinzi` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',`yuangong_id` int(11) DEFAULT NULL COMMENT '员工',`xinzi_uuid_number` varchar(200) DEFAULT NULL COMMENT '薪资编号 Search111 ',`xinzi_name` varchar(200) DEFAULT NULL COMMENT '标题 Search111 ',`xinzi_month` varchar(200) DEFAULT NULL COMMENT '月份 Search111 ',`jiben_jine` decimal(10,2) DEFAULT NULL COMMENT '基本工资',`jiangjin_jine` decimal(10,2) DEFAULT NULL COMMENT '奖金',`jixiao_jine` decimal(10,2) DEFAULT NULL COMMENT '绩效',`butie_jine` decimal(10,2) DEFAULT NULL COMMENT '补贴',`shifa_jine` decimal(10,2) DEFAULT NULL COMMENT '实发',`xinzi_content` longtext COMMENT '备注 ',`insert_time` timestamp NULL DEFAULT NULL COMMENT '添加时间',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COMMENT='薪资';CREATE TABLE `yonghu` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',`username` varchar(200) DEFAULT NULL COMMENT '账户',`password` varchar(200) DEFAULT NULL COMMENT '密码',`yonghu_name` varchar(200) DEFAULT NULL COMMENT '用户姓名 Search111 ',`yonghu_phone` varchar(200) DEFAULT NULL COMMENT '用户手机号',`yonghu_id_number` varchar(200) DEFAULT NULL COMMENT '用户身份证号',`yonghu_photo` varchar(200) DEFAULT NULL COMMENT '用户头像',`sex_types` int(11) DEFAULT NULL COMMENT '性别',`yonghu_email` varchar(200) DEFAULT NULL COMMENT '用户邮箱',`jinyong_types` int(11) DEFAULT NULL COMMENT '账户状态 Search111 ',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='用户';CREATE TABLE `yuangong` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',`username` varchar(200) DEFAULT NULL COMMENT '账户',`password` varchar(200) DEFAULT NULL COMMENT '密码',`yuangong_name` varchar(200) DEFAULT NULL COMMENT '员工姓名 Search111 ',`yuangong_phone` varchar(200) DEFAULT NULL COMMENT '员工手机号',`yuangong_id_number` varchar(200) DEFAULT NULL COMMENT '员工身份证号',`yuangong_photo` varchar(200) DEFAULT NULL COMMENT '员工头像',`sex_types` int(11) DEFAULT NULL COMMENT '性别',`bumen_types` int(11) DEFAULT NULL COMMENT '部门 Search111 ',`zhiwei_types` int(11) DEFAULT NULL COMMENT '职位 Search111 ',`yuangong_email` varchar(200) DEFAULT NULL COMMENT '员工邮箱',`xueli_types` int(11) DEFAULT NULL COMMENT '学历状态 Search111 ',`yuangong_jiaoyu_content` longtext COMMENT '教育经历',`yuangong_gongzuo_content` longtext COMMENT '工作经历',`shangpin_shixi_content` longtext COMMENT '实习经历',`shangpin_rongu_content` longtext COMMENT '所获荣誉',`jinyong_types` int(11) DEFAULT NULL COMMENT '账户状态 Search111 ',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='员工';CREATE TABLE `yuangong_kaoqin` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',`yuangong_kaoqin_uuid_number` varchar(200) DEFAULT NULL COMMENT '考勤唯一编号 Search111 ',`yuangong_kaoqin_name` varchar(200) DEFAULT NULL COMMENT '考勤标题 Search111 ',`yuangong_kaoqin_types` int(11) DEFAULT NULL COMMENT '员工考勤类型 Search111',`bumen_types` int(11) DEFAULT NULL COMMENT '部门 Search111 ',`yuangong_kaoqin_content` longtext COMMENT '考勤详情',`insert_time` timestamp NULL DEFAULT NULL COMMENT '考勤发起时间',`jiezhi_time` timestamp NULL DEFAULT NULL COMMENT '考勤截止时间',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COMMENT='员工考勤';CREATE TABLE `yuangong_kaoqin_list` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',`yuangong_id` int(11) DEFAULT NULL COMMENT '员工',`yuangong_kaoqin_id` int(11) DEFAULT NULL COMMENT '考勤',`yuangong_kaoqin_list_types` int(11) DEFAULT NULL COMMENT '打卡状态',`insert_time` timestamp NULL DEFAULT NULL COMMENT '添加时间',`update_time` timestamp NULL DEFAULT NULL COMMENT '打卡时间',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show3 listShow',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 COMMENT='员工考勤详情';CREATE TABLE `yuangongqingjia` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',`yuangong_id` int(200) DEFAULT NULL COMMENT '员工',`yuangongqingjia_name` varchar(200) DEFAULT NULL COMMENT '请假标题 Search111 ',`yuangongqingjia_text` longtext COMMENT '请假缘由',`yuangongqingjia_types` int(11) DEFAULT NULL COMMENT '请假类型 Search111',`insert_time` timestamp NULL DEFAULT NULL COMMENT '申请时间',`yuangongqingjia_time` timestamp NULL DEFAULT NULL COMMENT '请假时间',`yuangongqingjia_number` int(200) DEFAULT NULL COMMENT '请假天数',`yuangongqingjia_yesno_types` int(11) DEFAULT NULL COMMENT '申请状态 Search111 ',`yuangongqingjia_yesno_text` longtext COMMENT '处理意见',`yuangongqingjia_shenhe_time` timestamp NULL DEFAULT NULL COMMENT '审核时间',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show3 listShow',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COMMENT='员工请假';CREATE TABLE `zhaopin` (`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键 ',`zhaopin_uuid_number` varchar(200) DEFAULT NULL COMMENT '招聘编号',`zhaopin_name` varchar(200) DEFAULT NULL COMMENT '招聘标题 Search111 ',`zhaopin_photo` varchar(200) DEFAULT NULL COMMENT '招聘图片',`zhaopin_address` varchar(200) DEFAULT NULL COMMENT '招聘地点',`zhaopin_file` varchar(200) DEFAULT NULL COMMENT '招聘附件',`zhaopin_types` int(11) DEFAULT NULL COMMENT '招聘类型 Search111',`zhaopin_number` int(11) DEFAULT NULL COMMENT '招聘人数',`zhaopin_time` timestamp NULL DEFAULT NULL COMMENT '招聘时间',`zhaopin_content` longtext COMMENT '招聘详情',`insert_time` timestamp NULL DEFAULT NULL COMMENT '录入时间',`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间 show1 show2 photoShow',PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COMMENT='招聘';
7.核心代码
7.1 Controller
package com.controller;/*** 员工* 后端接口* @author 计算机编程-吉哥* @email
*/
@RestController
@Controller
@RequestMapping("/yuangong")
public class YuangongController {private static final Logger logger = LoggerFactory.getLogger(YuangongController.class);private static final String TABLE_NAME = "yuangong";@Autowiredprivate YuangongService yuangongService;@Autowiredprivate TokenService tokenService;@Autowiredprivate DictionaryService dictionaryService;//字典@Autowiredprivate GonggaoService gonggaoService;//公告@Autowiredprivate JixiaoService jixiaoService;//绩效@Autowiredprivate PeixunService peixunService;//培训@Autowiredprivate RenshidiaodongService renshidiaodongService;//人事调动@Autowiredprivate XinziService xinziService;//薪资@Autowiredprivate YuangongKaoqinService yuangongKaoqinService;//员工考勤@Autowiredprivate YuangongKaoqinListService yuangongKaoqinListService;//员工考勤详情@Autowiredprivate YuangongqingjiaService yuangongqingjiaService;//员工请假@Autowiredprivate ZhaopinService zhaopinService;//招聘@Autowiredprivate UsersService usersService;//管理员/*** 后端列表*/@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("yuangongId",request.getSession().getAttribute("userId"));CommonUtil.checkMap(params);PageUtils page = yuangongService.queryPage(params);//字典表数据转换List<YuangongView> list =(List<YuangongView>)page.getList();for(YuangongView 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);YuangongEntity yuangong = yuangongService.selectById(id);if(yuangong !=null){//entity转viewYuangongView view = new YuangongView();BeanUtils.copyProperties( yuangong , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 后端保存*/@RequestMapping("/save")public R save(@RequestBody YuangongEntity yuangong, HttpServletRequest request){logger.debug("save方法:,,Controller:{},,yuangong:{}",this.getClass().getName(),yuangong.toString());String role = String.valueOf(request.getSession().getAttribute("role"));if(false)return R.error(511,"永远不会进入");Wrapper<YuangongEntity> queryWrapper = new EntityWrapper<YuangongEntity>().eq("username", yuangong.getUsername()).or().eq("yuangong_phone", yuangong.getYuangongPhone()).or().eq("yuangong_id_number", yuangong.getYuangongIdNumber());logger.info("sql语句:"+queryWrapper.getSqlSegment());YuangongEntity yuangongEntity = yuangongService.selectOne(queryWrapper);if(yuangongEntity==null){yuangong.setCreateTime(new Date());yuangong.setPassword("123456");yuangongService.insert(yuangong);return R.ok();}else {return R.error(511,"账户或者员工手机号或者员工身份证号已经被使用");}}/*** 后端修改*/@RequestMapping("/update")public R update(@RequestBody YuangongEntity yuangong, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {logger.debug("update方法:,,Controller:{},,yuangong:{}",this.getClass().getName(),yuangong.toString());YuangongEntity oldYuangongEntity = yuangongService.selectById(yuangong.getId());//查询原先数据String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");if("".equals(yuangong.getYuangongPhoto()) || "null".equals(yuangong.getYuangongPhoto())){yuangong.setYuangongPhoto(null);}yuangongService.updateById(yuangong);//根据id更新return R.ok();}/*** 删除*/@RequestMapping("/delete")public R delete(@RequestBody Integer[] ids, HttpServletRequest request){logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());List<YuangongEntity> oldYuangongList =yuangongService.selectBatchIds(Arrays.asList(ids));//要删除的数据yuangongService.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 yuangongId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))try {List<YuangongEntity> yuangongList = 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){//循环YuangongEntity yuangongEntity = new YuangongEntity();yuangongList.add(yuangongEntity);//把要查询是否重复的字段放入map中//账户if(seachFields.containsKey("username")){List<String> username = seachFields.get("username");username.add(data.get(0));//要改的}else{List<String> username = new ArrayList<>();username.add(data.get(0));//要改的seachFields.put("username",username);}//员工手机号if(seachFields.containsKey("yuangongPhone")){List<String> yuangongPhone = seachFields.get("yuangongPhone");yuangongPhone.add(data.get(0));//要改的}else{List<String> yuangongPhone = new ArrayList<>();yuangongPhone.add(data.get(0));//要改的seachFields.put("yuangongPhone",yuangongPhone);}//员工身份证号if(seachFields.containsKey("yuangongIdNumber")){List<String> yuangongIdNumber = seachFields.get("yuangongIdNumber");yuangongIdNumber.add(data.get(0));//要改的}else{List<String> yuangongIdNumber = new ArrayList<>();yuangongIdNumber.add(data.get(0));//要改的seachFields.put("yuangongIdNumber",yuangongIdNumber);}}//查询是否重复//账户List<YuangongEntity> yuangongEntities_username = yuangongService.selectList(new EntityWrapper<YuangongEntity>().in("username", seachFields.get("username")));if(yuangongEntities_username.size() >0 ){ArrayList<String> repeatFields = new ArrayList<>();for(YuangongEntity s:yuangongEntities_username){repeatFields.add(s.getUsername());}return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());}//员工手机号List<YuangongEntity> yuangongEntities_yuangongPhone = yuangongService.selectList(new EntityWrapper<YuangongEntity>().in("yuangong_phone", seachFields.get("yuangongPhone")));if(yuangongEntities_yuangongPhone.size() >0 ){ArrayList<String> repeatFields = new ArrayList<>();for(YuangongEntity s:yuangongEntities_yuangongPhone){repeatFields.add(s.getYuangongPhone());}return R.error(511,"数据库的该表中的 [员工手机号] 字段已经存在 存在数据为:"+repeatFields.toString());}//员工身份证号List<YuangongEntity> yuangongEntities_yuangongIdNumber = yuangongService.selectList(new EntityWrapper<YuangongEntity>().in("yuangong_id_number", seachFields.get("yuangongIdNumber")));if(yuangongEntities_yuangongIdNumber.size() >0 ){ArrayList<String> repeatFields = new ArrayList<>();for(YuangongEntity s:yuangongEntities_yuangongIdNumber){repeatFields.add(s.getYuangongIdNumber());}return R.error(511,"数据库的该表中的 [员工身份证号] 字段已经存在 存在数据为:"+repeatFields.toString());}yuangongService.insertBatch(yuangongList);return R.ok();}}}}catch (Exception e){e.printStackTrace();return R.error(511,"批量插入数据异常,请联系管理员");}}/*** 登录*/@IgnoreAuth@RequestMapping(value = "/login")public R login(String username, String password, String captcha, HttpServletRequest request) {YuangongEntity yuangong = yuangongService.selectOne(new EntityWrapper<YuangongEntity>().eq("username", username));if(yuangong==null || !yuangong.getPassword().equals(password))return R.error("账号或密码不正确");else if(yuangong.getJinyongTypes() != 1)return R.error("账户已被禁用");String token = tokenService.generateToken(yuangong.getId(),username, "yuangong", "员工");R r = R.ok();r.put("token", token);r.put("role","员工");r.put("username",yuangong.getYuangongName());r.put("tableName","yuangong");r.put("userId",yuangong.getId());return r;}/*** 注册*/@IgnoreAuth@PostMapping(value = "/register")public R register(@RequestBody YuangongEntity yuangong, HttpServletRequest request) {
// ValidatorUtils.validateEntity(user);Wrapper<YuangongEntity> queryWrapper = new EntityWrapper<YuangongEntity>().eq("username", yuangong.getUsername()).or().eq("yuangong_phone", yuangong.getYuangongPhone()).or().eq("yuangong_id_number", yuangong.getYuangongIdNumber());YuangongEntity yuangongEntity = yuangongService.selectOne(queryWrapper);if(yuangongEntity != null)return R.error("账户或者员工手机号或者员工身份证号已经被使用");yuangong.setJinyongTypes(1);//启用yuangong.setCreateTime(new Date());yuangongService.insert(yuangong);return R.ok();}/*** 重置密码*/@GetMapping(value = "/resetPassword")public R resetPassword(Integer id, HttpServletRequest request) {YuangongEntity yuangong = yuangongService.selectById(id);yuangong.setPassword("123456");yuangongService.updateById(yuangong);return R.ok();}/*** 修改密码*/@GetMapping(value = "/updatePassword")public R updatePassword(String oldPassword, String newPassword, HttpServletRequest request) {YuangongEntity yuangong = yuangongService.selectById((Integer)request.getSession().getAttribute("userId"));if(newPassword == null){return R.error("新密码不能为空") ;}if(!oldPassword.equals(yuangong.getPassword())){return R.error("原密码输入错误");}if(newPassword.equals(yuangong.getPassword())){return R.error("新密码不能和原密码一致") ;}yuangong.setPassword(newPassword);yuangongService.updateById(yuangong);return R.ok();}/*** 忘记密码*/@IgnoreAuth@RequestMapping(value = "/resetPass")public R resetPass(String username, HttpServletRequest request) {YuangongEntity yuangong = yuangongService.selectOne(new EntityWrapper<YuangongEntity>().eq("username", username));if(yuangong!=null){yuangong.setPassword("123456");yuangongService.updateById(yuangong);return R.ok();}else{return R.error("账号不存在");}}/*** 获取用户的session用户信息*/@RequestMapping("/session")public R getCurrYuangong(HttpServletRequest request){Integer id = (Integer)request.getSession().getAttribute("userId");YuangongEntity yuangong = yuangongService.selectById(id);if(yuangong !=null){//entity转viewYuangongView view = new YuangongView();BeanUtils.copyProperties( yuangong , view );//把实体数据重构到view中//修改对应字典表字段dictionaryService.dictionaryConvert(view, request);return R.ok().put("data", view);}else {return R.error(511,"查不到数据");}}/*** 退出*/@GetMapping(value = "logout")public R logout(HttpServletRequest request) {request.getSession().invalidate();return R.ok("退出成功");}}
7.2 Service
package com.service;import com.baomidou.mybatisplus.service.IService;
import com.utils.PageUtils;
import com.entity.YuangongEntity;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.lang.Nullable;
import java.util.List;/*** 员工 服务类*/
public interface YuangongService extends IService<YuangongEntity> {/*** @param params 查询参数* @return 带分页的查询出来的数据*/PageUtils queryPage(Map<String, Object> params);}
7.3 ServiceImpl
package com.service.impl;/*** 员工 服务实现类*/
@Service("yuangongService")
@Transactional
public class YuangongServiceImpl extends ServiceImpl<YuangongDao, YuangongEntity> implements YuangongService {@Overridepublic PageUtils queryPage(Map<String,Object> params) {Page<YuangongView> page =new Query<YuangongView>(params).getPage();page.setRecords(baseMapper.selectListView(page,params));return new PageUtils(page);}}
7.4 DAO
package com.dao;import com.entity.YuangongEntity;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;import org.apache.ibatis.annotations.Param;
import com.entity.view.YuangongView;/*** 员工 Dao 接口** @author */
public interface YuangongDao extends BaseMapper<YuangongEntity> {List<YuangongView> selectListView(Pagination page,@Param("params")Map<String,Object> params);}
8.参考文档
你可能还有感兴趣的项目👇🏻👇🏻👇🏻
更多项目推荐:计算机毕业设计项目
如果大家有任何疑虑,请在下方咨询或评论