如何使用ssm实现学生考勤管理系统的设计与实现+vue

news2024/9/26 21:51:22

@TOC

ssm703学生考勤管理系统的设计与实现+vue

绪论

  1. 课题背景

身处网络时代,随着网络系统体系发展的不断成熟和完善,人们的生活也随之发生了很大的变化。目前,人们在追求较高物质生活的同时,也在想着如何使自身的精神内涵得到提升,而读书就是人们获得精神享受非常重要的途径[1]。纸质版的校园失物比较沉重,携带不方便,而由于手机、平板不仅能够储存大量的校园失物信息数据,而且重量轻,可随身携带,因此现在的人们更愿意通过手机、平板等来进行在线阅读[2]。由此,开发一款学生考勤管理系统非常符合人们阅读的需求。

过去人们看书需要到书店或者图书馆,而现在只要有网络,人们就可以通过手机、平板或电脑想什么时候看书就可以什么时候看,想看什么样的书就可以看什么样的书,非常的方便,并且人们把平时的闲碎时间全部利用起来进行阅读,使阅读效率大大提高,生活也变得丰富多彩起来。另外,通过学生考勤管理系统,想要阅读哪本书,搜索下就能够快速找到,并且还可以对校园失物进行归类、统计和规范管理。该学生考勤管理系统的界面非常清晰,使用简单,识字的人们都可以使用,并且它的功能齐全,能够满足各种各样的人的要求。

本文不仅从需求分析、设计分析、功能分析对该电子书在线系统进行了全面的分析,而且还从开发背景、开发环境、目标、流程、数据库、系统维护对该学生考勤管理系统进行了总体的规划和设计。该学生考勤管理系统利用vue技术和MYSQL数据库进行开发,具有很好的稳定性和可发展性。

  1. 研究现状

国外信息技术的发展步伐一直没有停止,源源不断的计算机应用软件被研发出来,并且软件技术也在不断迭代,目前世界各国的软件行业都已新兴了起来[3-5]。

与国外相比,我国信息技术的发展相对晚一些,不过后面,经过我们的不断追赶,我国的信息技术已经有了很大的进步,我国对现有的软件开发技术进行了细致的专研,目前我国已经能够独立的开发系统,并且也已经将这些软件系统应用于人们的生活中和各行各业中,目前,软件行业是我国非常受欢迎的行业[6-9]。

信息数字化使人们的各种信息能够快速传播,使人们的各种信息能够得到充分利用,同时,也大大宣传了信息数字化背后的软件系统[10-12]。软件开发团队的能力越来越强,开发技术功能越来越强大,软件系统大大提高了信息处理的效率,节省了处理者的处理时间。在阅读校园失物方面,人们阅读纸质版的校园失物,现在已经显得有些过时[13-14]。利用目前的软件开发技术开发出一款学生考勤管理系统能够大大的满足人们的阅读需求,人们通过该学生考勤管理系统能够快速查找、在线阅读自己喜欢的校园失物,并且也大大提高了人们阅读的效率。

  1. 研究内容

本论文主要阐述了该学生考勤管理系统的开发技术、系统需求分析、系统设计、系统功能实现和系统测试。为了开发该系统,我在下面花费了很多功夫和心思,例如,到图书馆阅读vue技术、MYSQL数据库等方面的编程校园失物,又在网上搜索了很多别人做的相类似的系统,将他们比较好的设计理念应用到自己的设计当中,最后才有了现在的成果。

本论文主要分为7部分,包括:

一、绪论:阐述了该系统的背景技术、研究现状和开发意义;

二、相关技术:介绍了开发该系统所用到的各种技术;

三、系统需求分析:阐述了开发该系统的可行性分析和功能需求分析;

四、系统设计:阐述了该系统的功能模块设计和数据库设计;

五、系统实现:展示了该系统的主要功能模块界面;

六、系统测试:对开发出的该系统进行测试;

七、系统总结:总结开发该系统的整个工作过程。

  1. 系统开发环境

    1. vue技术

Vue (读音 /vjuː/,类似于 view) 是一套用于构建用户界面的渐进式JavaScript框架。 [5]  与其它大型框架不同的是,Vue 被设计为可以自底向上逐层应用。Vue 的核心库只关注视图层,不仅易于上手,还便于与第三方库或既有项目整合。另一方面,当与现代化的工具链以及各种支持类库结合使用时,Vue 也完全能够为复杂的单页应用(SPA)提供驱动

Vue.js目前最火的的一个前端框架,三大主流前端框架之一。 Vue.js是一套构建用户界面的框架(一套完整的解决方案,对项目侵入性大,中途 需要跟换框架则需要重构整个项目),只关注视图层,易上手,有配套的第三方类库。提高开发效率,帮助减少不必要的dom操作;双向数据绑定,通过框架提供的指 令,前端只需要关注业务逻辑,不再关心dom如何渲染。

  1. JAVA技术

Java编程语言具有跨平台、分布式、可移植等多种特性,很多平台Java都能运行,世界各地都能够运行Java编写的程序。1995年,开发出了JAVA编程语言。JAVA编程语言具有多种特性,例如:简单、安全、可移植、鲁棒性(Robust)、编写能效高、线程多等。在互联网飞速发展的时代,Java编程语言应用也越来越普遍[19]。它的特点具有:

一、面向对象:JAVA适用于分布式环境,JAVA能够完全面向对象,包括对象的设计及联系;

二、分布式:JAVA工作的同时,带动其他计算节点工作,只要有网络,就可以访问其他对象;

三、健壮性:JAVA能够自动处理垃圾和异常,并且机制类型强;

四、安全性:当指针和内存被删除时,非法的内存就可以避免。

  1. MYSQL数据库

数据库在每个网站的开发中都是必不可少的,过去数据库只具有数据的保存和管理功能,但随着后来的不断更新和迭代,目前的数据库不仅能够进行数据的处理,而且还能够储存不计其数的数据[20]。

该学生考勤管理系统所使用的就是MYSQL数据库,当初是微软公司开发出的MYSQL数据库。MYSQL数据库总共建立了十几个相对应的表,它们之间独立联系,数据库和程序是密不可分的[21]。

MYSQL数据库的特点包括:能够应用于多种操作系统中;查询SQL时优化了算法,搜索速度提高的不少;还可以进行数据库的管理、控制、优化等操作;一个数据库可以记录不计其数的数据。

  1. B/S结构

当前比较流行的网络化结构模式是B/S(浏览器/服务器)结构,它能够在服务器上面集中系统的所有核心功能,使系统开发人员的工作变得简单,并且开发出的系统也更容易使用和后期维护。用于比较熟悉的浏览器有360浏览器、谷歌浏览器、QQ浏览器等,用于比较熟悉的数据库有sqlserver、mysql数据库等,上边这些数据库和浏览器都可以安装在客户端上。B/S结构没有什么限制,并且还不需要专门的安装软件,只要笔记本、电脑有网络就能够访问系统。采用B/S结构开发的程序,比较好维护,只需要在客户端就可处理,不需要非得在服务器上处理,并且跟用户的交互性比较好,刷新浏览器就可进行数据信息的实时更新[22]。B/S架构如图2-1所示:

图2-1 B/S模式架构图

  1. SSM框架技术

该学生考勤管理系统是基于Spring、SpringMVC、Mybatis框架开发出来的。

2004年,Spring 框架才第一次亮相,后面也进行了很多次的更新。Spring框架包括SpringCore、Spring AOP、Spring ORM、Spring DAO、Spring Web Flow、Spring Context和Spring Web MVC等七个模块,企业应用程序就是通过这七个模块气筒不同的平台来进行开发的,Spring Web MVC中的各个元素之间形成了松散耦合[23-25]。

  1. 系统分析

    1. 可行性分析

开发者在进行开发系统之前,都需要进行可行性分析,保证该系统能够被成功开发出来。

  1. 技术可行性

开发该学生考勤管理系统所采用的技术是vue和MYSQL数据库。计算机专业的学生在学校期间已经比较系统的学习了很多编程方面的知识,同时也接触了很多编程软件,所以在技术开发方面还是比较有信心的。

  1. 操作可行性

该学生考勤管理系统的界面简洁清楚,操作简单,用户一看就会操作。操作界面上每一步都有提示,用户只要按照提示进行操作就可以了。该学生考勤管理系统具有操作可行性。

  1. 经济可行性

我现在还是一名学生,还没有一份稳定的经济收入,所以我会将开发程序的成本控制在自己所能接受的范围内。我所使用的开发软件、数据库还有设计界面用的photoshop软件都是在网上免费下载的,另外程序编写阶段所用到的源代码也是在网上免费得到的,现在在网上能下载很多有用的、免费的东西,所以开发该系统基本不花钱,具有经济可行性。

  1. 法律可行性

我是通过图书馆、百度文库、百度网页等获得的开发该学生考勤管理系统所需要用到的资料和软件,都是采用的合法渠道,另外源代码和论文内容都是我自己一字一字写出来的,没有抄袭别人的,具有法律可行性。

通过上述的技术可行性、操作可行性、经济可行性以及法律可行性分析,可以看出,该学生考勤管理系统完全可以进行顺利开发。

  1. 系统性能分析

  2. 存储性:该学生考勤管理系统的数据库功能比较强大,能够录入很多纷繁复杂的信息,且能够保证数据的实时性;

二、易学性:该学生考勤管理系统使用起来非常简单,用户一看就会,不需要进行专门的培训,非常好上手,使用个一两次就能够熟练操作;

三、数据要求:录入的数据准确可靠,能够及时进行更新,可以独立保存,删除一些不需要的数据;

四、稳定性:该学生考勤管理系统能够稳定的运行,界面清晰明了;

五、可靠性:该学生考勤管理系统安装有拦截器,可以对病毒等进行拦截,并且还对信息进行了保护措施,用户可以放心使用。

  1. 系统功能分析

    1. 角色需求

该学生考勤管理系统主要为管理员和用户两类用户角色提供需求,管理员在后台可以对系统进行全面管理,用户在前台可以进行查看系统信息,注册登录,查询校园失物,评论,下载校园失物等操作。

用户静态结构如图3-1所示。

图3-1 用户静态结构图

  1. 系统流程分析

    1. 注册流程

用户注册之后才可以登录系统,用户注册流程如图3-2所示:

图3-2 注册流程图

  1. 登录流程

用户需要登录系统之后,才可以进行校园失物评论、校园失物下载等操作。而管理员也只有登录系统之后,可以对系统各个方面的内容进行管理,不受任何限制。用户登录流程如图3-3所示。

图3-3 登录流程图

  1. 系统设计

    1. 系统概要设计

本文通过B/S结构(Browser/Server,浏览器/服务器结构)开发的该学生考勤管理系统,B/S结构的优点很多,例如:开发容易、强的共享性、便于维护等,只要有网络,用户可以随时随地进行使用。

系统工作原理如图4-1所示。

图4-1 系统工作原理图

  1. 系统结构设计

系统结构设计就像一个树状结构一样,一个树干有很多分支,大任务相当于树干,小任务相当于树枝,只有需求分析信息弄清楚之后,才能保证每个小任务都能实现目标,对初步设计好的系统再进行不断优化,最终得到一个具体现实的系统结构。

管理员功能模块和用户功能模块是该学生考勤管理系统的两大部分,系统结构如图4-2所示。

学生考勤管理系统

学生信息管理

公告信息管理

课程信息管理

课程类型管理

教师信息管理

学生信息修改

学生信息新增

教师信息添加

教师信息删除

教师信息修改

课程类型添加

课程类型修改

课程类型删除

公告信息添加

公告信息删改

公告信息删除

课程信息添加

课程信息修改

课程信息删除

公告类型管理

公告类型修改

公告类型删除

公告类型添加

图4-2 系统结构图

4.3 数据库设计

开发一个系统也需要提前设计数据库。这里的数据库是相关数据的集合,存储在一起的这些数据也是按照一定的组织方式进行的。目前,数据库能够服务于多种应用程序,则是源于它存储方式最佳,具备数据冗余率低的优势。虽然数据库为程序提供信息存储服务,但它与程序之间也可以保持较高的独立性。总而言之,数据库经历了很长一段时间的发展,从最初的不为人知,到现在的人尽皆知,其相关技术也越发成熟,同时也拥有着坚实的理论基础。

4.3.1 数据库概念设计

这部分内容需要借助数据库关系图来完成,也需要使用专门绘制数据库关系图的工具,比如Visio工具就可以设计E-R图(数据库关系图)。设计数据库,也需要按照设计的流程进行,首先还是要根据需求完成实体的确定,分析实体具有的特征,还有对实体间的关联关系进行确定。最后才是使用E-R模型的表示方法,绘制本系统的E-R图。不管是使用亿图软件,还是Visio工具,对于E-R模型的表示符号都一样,通常矩形代表实体,实体间存在的关系用菱形符号表示,实体的属性也就是实体的特征用符号椭圆表示。最后使用直线将矩形,菱形和椭圆等符号连接起来。接下来就开始对本系统的E-R图进行绘制。

(1)下图是教师实体和其具备的属性。

C:\Users\Administrator\Desktop\img\xueshengkaoqinguanlia\教师.jpg 图4.1 教师实体属性图

(2)下图是公告信息实体和其具备的属性。

C:\Users\Administrator\Desktop\img\xueshengkaoqinguanlia\公告信息.jpg 图4.2 公告信息实体属性图

(3)下图是字典表实体和其具备的属性。

C:\Users\Administrator\Desktop\img\xueshengkaoqinguanlia\字典表.jpg 图4.3 字典表实体属性图

(4)下图是辅导员实体和其具备的属性。

C:\Users\Administrator\Desktop\img\xueshengkaoqinguanlia\辅导员.jpg 图4.4 辅导员实体属性图

(5)下图是院系考勤管理实体和其具备的属性。

C:\Users\Administrator\Desktop\img\xueshengkaoqinguanlia\院系考勤管理.jpg 图4.5 院系考勤管理实体属性图

(6)下图是课程信息实体和其具备的属性。

C:\Users\Administrator\Desktop\img\xueshengkaoqinguanlia\课程信息.jpg 图4.6 课程信息实体属性图

(7)下图是学生实体和其具备的属性。

C:\Users\Administrator\Desktop\img\xueshengkaoqinguanlia\学生.jpg 图4.7 学生实体属性图

(8)下图是考勤通知实体和其具备的属性。

C:\Users\Administrator\Desktop\img\xueshengkaoqinguanlia\考勤通知.jpg 图4.8 考勤通知实体属性图

(9)下图是考勤详情实体和其具备的属性。

C:\Users\Administrator\Desktop\img\xueshengkaoqinguanlia\考勤详情.jpg 图4.9 考勤详情实体属性图

(10)下图是学生请假实体和其具备的属性。

C:\Users\Administrator\Desktop\img\xueshengkaoqinguanlia\学生请假.jpg 图4.10 学生请假实体属性图

(11)下图是用户表实体和其具备的属性。

C:\Users\Administrator\Desktop\img\xueshengkaoqinguanlia\用户表.jpg 图4.11 用户表实体属性图

  1. 数据库表设计

采用MYSQL数据库对该学生考勤管理系统的数据进行存储,数据库中所包括的各个数据库表的详细信息如下所示:

表4.1字典表表

序号列名数据类型说明允许空
1IdIntid
2dic_codeString字段
3dic_nameString字段名
4code_indexInteger编码
5index_nameString编码名字
6super_idInteger父字段id
7beizhuString备注
8create_timeDate创建时间

表4.2辅导员表

序号列名数据类型说明允许空
1IdIntid
2fudaoyuan_nameString辅导员姓名
3fudaoyuan_photoString头像
4fudaoyuan_phoneString联系方式
5fudaoyuan_emailString邮箱
6create_timeDate创建时间

表4.3教师表

序号列名数据类型说明允许空
1IdIntid
2jiaoshi_nameString教师姓名
3jiaoshi_photoString图片
4jiaoshi_phoneString联系方式
5jiaoshi_emailString邮箱
6jiaoshi_deleteInteger假删
7create_timeDate创建时间

表4.4考勤通知表

序号列名数据类型说明允许空
1IdIntid
2kaoqin_uuid_numberString考勤编号
3kaoqin_nameString考勤标题
4zhuanye_typesInteger考勤专业
5kaoqin_timeDate考勤结束时间
6insert_timeDate考勤时间
7create_timeDate创建时间

表4.5院系考勤管理表

序号列名数据类型说明允许空
1IdIntid
2kaoqinguanli_nameString院系考勤管理姓名
3kaoqinguanli_photoString头像
4kaoqinguanli_phoneString联系方式
5kaoqinguanli_emailString邮箱
6create_timeDate创建时间

表4.6考勤详情表

序号列名数据类型说明允许空
1IdIntid
2kaoqin_idInteger考勤编号
3yonghu_idInteger学生
4kaoqinxiangqing_status_typesInteger考勤状态
5update_timeDate考勤时间
6create_timeDate创建时间

表4.7课程信息表

序号列名数据类型说明允许空
1IdIntid
2kecheng_nameString课程标题
3kecheng_typesInteger课程类型
4zhuanye_typesInteger专业
5kecheng_photoString课程图片
6kecheng_fileString课件下载
7jiaoshi_idInteger教师
8kecheng_contentString课程详情
9insert_timeDate发布时间
10create_timeDate创建时间

表4.8公告信息表

序号列名数据类型说明允许空
1IdIntid
2news_nameString公告标题
3news_typesInteger公告类型
4news_photoString公告图片
5insert_timeDate公告时间
6news_contentString公告详情
7create_timeDate创建时间

表4.9学生请假表

序号列名数据类型说明允许空
1IdIntid
2xueshengqingjia_nameString请假原因
3xueshengqingjia_textString详情
4xueshengqingjia_typesInteger请假类型
5xueshengqingjia_timeDate请假时间
6xueshengqingjia_numberInteger请假天数
7yonghu_idInteger学生
8xueshengqingjia_yesno_typesInteger审核结果
9xueshengqingjia_yesno_textString处理结果
10insert_timeDate创建时间
11create_timeDate创建时间

表4.10学生表

序号列名数据类型说明允许空
1IdIntid
2yonghu_nameString学生姓名
3yonghu_photoString头像
4yonghu_phoneString联系方式
5yonghu_id_numberString学生身份证号
6yonghu_emailString邮箱
7zhuanye_typesInteger专业
8yonghu_deleteInteger假删
9create_timeDate创建时间

表4.11用户表表

序号列名数据类型说明允许空
1IdIntid
2usernameString用户名
3passwordString密码
4roleString角色
5addtimeDate新增时间
  1. 系统的实现

    1. 功能模块的实现

5.1学生信息管理

如图5.1显示的就是学生信息管理页面,此页面提供给管理员的功能有:学生信息的查询管理,可以删除学生信息、修改学生信息、新增学生信息,

还进行了对用户名称的模糊查询的条件

图5.1 学生信息管理页面

5.2 教师信息管理

如图5.2显示的就是教师信息管理页面,此页面提供给管理员的功能有:查看已发布的教师信息数据,修改教师信息,教师信息作废,即可删除,还进行了对教师信息名称的模糊查询 教师信息信息的类型查询等等一些条件。

图5.2 教师信息管理页面

5.3课程信息管理

如图5.3显示的就是课程信息管理页面,此页面提供给管理员的功能有:根据课程信息进行条件查询,还可以对课程信息进行新增、修改、查询操作等等。

图5.3 课程信息管理页面

5.1公告信息管理

如图5.4显示的就是公告信息管理页面,此页面提供给管理员的功能有:根据公告信息进行新增、修改、查询操作等等。

图5.4 公告信息管理页面

FudaoyuanController.java

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("/fudaoyuan")
public class FudaoyuanController {
    private static final Logger logger = LoggerFactory.getLogger(FudaoyuanController.class);

    @Autowired
    private FudaoyuanService fudaoyuanService;


    @Autowired
    private TokenService tokenService;
    @Autowired
    private DictionaryService dictionaryService;

    //级联表service

    @Autowired
    private YonghuService yonghuService;
    @Autowired
    private JiaoshiService jiaoshiService;
    @Autowired
    private KaoqinguanliService kaoqinguanliService;


    /**
    * 后端列表
    */
    @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"));
        else if("辅导员".equals(role))
            params.put("fudaoyuanId",request.getSession().getAttribute("userId"));
        else if("教师".equals(role))
            params.put("jiaoshiId",request.getSession().getAttribute("userId"));
        else if("院系考勤管理".equals(role))
            params.put("kaoqinguanliId",request.getSession().getAttribute("userId"));
        if(params.get("orderBy")==null || params.get("orderBy")==""){
            params.put("orderBy","id");
        }
        PageUtils page = fudaoyuanService.queryPage(params);

        //字典表数据转换
        List<FudaoyuanView> list =(List<FudaoyuanView>)page.getList();
        for(FudaoyuanView 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);
        FudaoyuanEntity fudaoyuan = fudaoyuanService.selectById(id);
        if(fudaoyuan !=null){
            //entity转view
            FudaoyuanView view = new FudaoyuanView();
            BeanUtils.copyProperties( fudaoyuan , view );//把实体数据重构到view中

            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody FudaoyuanEntity fudaoyuan, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,fudaoyuan:{}",this.getClass().getName(),fudaoyuan.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永远不会进入");

        Wrapper<FudaoyuanEntity> queryWrapper = new EntityWrapper<FudaoyuanEntity>()
            .eq("username", fudaoyuan.getUsername())
            .or()
            .eq("fudaoyuan_phone", fudaoyuan.getFudaoyuanPhone())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        FudaoyuanEntity fudaoyuanEntity = fudaoyuanService.selectOne(queryWrapper);
        if(fudaoyuanEntity==null){
            fudaoyuan.setCreateTime(new Date());
            fudaoyuan.setPassword("123456");
            fudaoyuanService.insert(fudaoyuan);
            return R.ok();
        }else {
            return R.error(511,"账户或者联系方式已经被使用");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody FudaoyuanEntity fudaoyuan, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,fudaoyuan:{}",this.getClass().getName(),fudaoyuan.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");
        //根据字段查询是否有相同数据
        Wrapper<FudaoyuanEntity> queryWrapper = new EntityWrapper<FudaoyuanEntity>()
            .notIn("id",fudaoyuan.getId())
            .andNew()
            .eq("username", fudaoyuan.getUsername())
            .or()
            .eq("fudaoyuan_phone", fudaoyuan.getFudaoyuanPhone())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        FudaoyuanEntity fudaoyuanEntity = fudaoyuanService.selectOne(queryWrapper);
        if("".equals(fudaoyuan.getFudaoyuanPhoto()) || "null".equals(fudaoyuan.getFudaoyuanPhoto())){
                fudaoyuan.setFudaoyuanPhoto(null);
        }
        if(fudaoyuanEntity==null){
            fudaoyuanService.updateById(fudaoyuan);//根据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());
        fudaoyuanService.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<FudaoyuanEntity> fudaoyuanList = 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("../../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){
                            //循环
                            FudaoyuanEntity fudaoyuanEntity = new FudaoyuanEntity();
//                            fudaoyuanEntity.setUsername(data.get(0));                    //账户 要改的
//                            //fudaoyuanEntity.setPassword("123456");//密码
//                            fudaoyuanEntity.setFudaoyuanName(data.get(0));                    //辅导员姓名 要改的
//                            fudaoyuanEntity.setFudaoyuanPhoto("");//详情和图片
//                            fudaoyuanEntity.setSexTypes(Integer.valueOf(data.get(0)));   //性别 要改的
//                            fudaoyuanEntity.setFudaoyuanPhone(data.get(0));                    //联系方式 要改的
//                            fudaoyuanEntity.setFudaoyuanEmail(data.get(0));                    //邮箱 要改的
//                            fudaoyuanEntity.setCreateTime(date);//时间
                            fudaoyuanList.add(fudaoyuanEntity);


                            //把要查询是否重复的字段放入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("fudaoyuanPhone")){
                                    List<String> fudaoyuanPhone = seachFields.get("fudaoyuanPhone");
                                    fudaoyuanPhone.add(data.get(0));//要改的
                                }else{
                                    List<String> fudaoyuanPhone = new ArrayList<>();
                                    fudaoyuanPhone.add(data.get(0));//要改的
                                    seachFields.put("fudaoyuanPhone",fudaoyuanPhone);
                                }
                        }

                        //查询是否重复
                         //账户
                        List<FudaoyuanEntity> fudaoyuanEntities_username = fudaoyuanService.selectList(new EntityWrapper<FudaoyuanEntity>().in("username", seachFields.get("username")));
                        if(fudaoyuanEntities_username.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(FudaoyuanEntity s:fudaoyuanEntities_username){
                                repeatFields.add(s.getUsername());
                            }
                            return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                         //联系方式
                        List<FudaoyuanEntity> fudaoyuanEntities_fudaoyuanPhone = fudaoyuanService.selectList(new EntityWrapper<FudaoyuanEntity>().in("fudaoyuan_phone", seachFields.get("fudaoyuanPhone")));
                        if(fudaoyuanEntities_fudaoyuanPhone.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(FudaoyuanEntity s:fudaoyuanEntities_fudaoyuanPhone){
                                repeatFields.add(s.getFudaoyuanPhone());
                            }
                            return R.error(511,"数据库的该表中的 [联系方式] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                        fudaoyuanService.insertBatch(fudaoyuanList);
                        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) {
        FudaoyuanEntity fudaoyuan = fudaoyuanService.selectOne(new EntityWrapper<FudaoyuanEntity>().eq("username", username));
        if(fudaoyuan==null || !fudaoyuan.getPassword().equals(password))
            return R.error("账号或密码不正确");
        //  // 获取监听器中的字典表
        // ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
        // Map<String, Map<Integer, String>> dictionaryMap= (Map<String, Map<Integer, String>>) servletContext.getAttribute("dictionaryMap");
        // Map<Integer, String> role_types = dictionaryMap.get("role_types");
        // role_types.get(.getRoleTypes());
        String token = tokenService.generateToken(fudaoyuan.getId(),username, "fudaoyuan", "辅导员");
        R r = R.ok();
        r.put("token", token);
        r.put("role","辅导员");
        r.put("username",fudaoyuan.getFudaoyuanName());
        r.put("tableName","fudaoyuan");
        r.put("userId",fudaoyuan.getId());
        return r;
    }

    /**
    * 注册
    */
    @IgnoreAuth
    @PostMapping(value = "/register")
    public R register(@RequestBody FudaoyuanEntity fudaoyuan){
//    	ValidatorUtils.validateEntity(user);
        Wrapper<FudaoyuanEntity> queryWrapper = new EntityWrapper<FudaoyuanEntity>()
            .eq("username", fudaoyuan.getUsername())
            .or()
            .eq("fudaoyuan_phone", fudaoyuan.getFudaoyuanPhone())
            ;
        FudaoyuanEntity fudaoyuanEntity = fudaoyuanService.selectOne(queryWrapper);
        if(fudaoyuanEntity != null)
            return R.error("账户或者联系方式已经被使用");
        fudaoyuan.setCreateTime(new Date());
        fudaoyuanService.insert(fudaoyuan);
        return R.ok();
    }

    /**
     * 重置密码
     */
    @GetMapping(value = "/resetPassword")
    public R resetPassword(Integer  id){
        FudaoyuanEntity fudaoyuan = new FudaoyuanEntity();
        fudaoyuan.setPassword("123456");
        fudaoyuan.setId(id);
        fudaoyuanService.updateById(fudaoyuan);
        return R.ok();
    }


    /**
     * 忘记密码
     */
    @IgnoreAuth
    @RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request) {
        FudaoyuanEntity fudaoyuan = fudaoyuanService.selectOne(new EntityWrapper<FudaoyuanEntity>().eq("username", username));
        if(fudaoyuan!=null){
            fudaoyuan.setPassword("123456");
            boolean b = fudaoyuanService.updateById(fudaoyuan);
            if(!b){
               return R.error();
            }
        }else{
           return R.error("账号不存在");
        }
        return R.ok();
    }


    /**
    * 获取用户的session用户信息
    */
    @RequestMapping("/session")
    public R getCurrFudaoyuan(HttpServletRequest request){
        Integer id = (Integer)request.getSession().getAttribute("userId");
        FudaoyuanEntity fudaoyuan = fudaoyuanService.selectById(id);
        if(fudaoyuan !=null){
            //entity转view
            FudaoyuanView view = new FudaoyuanView();
            BeanUtils.copyProperties( fudaoyuan , 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("退出成功");
    }





}

DictionaryServiceImpl.java
package com.service.impl;

import com.utils.StringUtil;
import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.util.*;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import com.utils.PageUtils;
import com.utils.Query;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import com.dao.DictionaryDao;
import com.entity.DictionaryEntity;
import com.service.DictionaryService;
import com.entity.view.DictionaryView;

/**
 * 字典表 服务实现类
 */
@Service("dictionaryService")
@Transactional
public class DictionaryServiceImpl extends ServiceImpl<DictionaryDao, DictionaryEntity> implements DictionaryService {

    @Override
    public PageUtils queryPage(Map<String,Object> params) {
        if(params != null && (params.get("limit") == null || params.get("page") == null)){
            params.put("page","1");
            params.put("limit","10");
        }
        Page<DictionaryView> page =new Query<DictionaryView>(params).getPage();
        page.setRecords(baseMapper.selectListView(page,params));
        return new PageUtils(page);
    }

     /**
     * 赋值给字典表
     * @param obj view对象
     */
    public void dictionaryConvert(Object obj, HttpServletRequest request) {
        try {
            if (obj == null) return;
            //当前view和entity中的所有types的字段
            List<String> fieldNameList = new ArrayList<>();
            Class tempClass = obj.getClass();
            while (tempClass !=null) {
                Field[] declaredFields = tempClass.getDeclaredFields();
                for (Field f : declaredFields) {
                    f.setAccessible(true);
                    if (f.getType().getName().equals("java.lang.Integer") && f.getName().contains("Types")) {
                        fieldNameList.add(f.getName());
                    }
                }
                tempClass = tempClass.getSuperclass(); //得到父类,然后赋给自己
            }

            // 获取监听器中的字典表
//            ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
            ServletContext servletContext = request.getServletContext();
            Map<String, Map<Integer, String>> dictionaryMap= (Map<String, Map<Integer, String>>) servletContext.getAttribute("dictionaryMap");

            //通过Types的值给Value字段赋值
            for (String s : fieldNameList) {
                Field types = null;
                if(hasField(obj.getClass(),s)){
                    //判断view中有没有这个字段,有就通过反射取出字段
                    types= obj.getClass().getDeclaredField(s);//获取Types私有字段
                }else{
                    //本表中没有这个字段,说明它是父表中的字段,也就是entity中的字段,从entity中取值
                    types=obj.getClass().getSuperclass().getDeclaredField(s);
                }
                Field value = obj.getClass().getDeclaredField(s.replace("Types", "Value"));//获取value私有字段
                //设置权限
                types.setAccessible(true);
                value.setAccessible(true);

                //赋值
                if (StringUtil.isNotEmpty(String.valueOf(types.get(obj)))) { //types的值不为空
                    int i = Integer.parseInt(String.valueOf(types.get(obj)));//type
                    //把s1字符中的所有大写转小写,并在前面加 _
                    char[] chars = s.toCharArray();
                    StringBuffer sbf = new StringBuffer();
                    for(int  b=0; b< chars.length; b++){
                        char ch = chars[b];
                        if(ch <= 90 && ch >= 65){
                            sbf.append("_");
                            ch += 32;
                        }
                        sbf.append(ch);
                    }
                    String s2 = dictionaryMap.get(sbf.toString()).get(i);
                    value.set(obj, s2);
                } else {
                    new Exception("字典表赋值出现问题::::"+value.getName());
                    value.set(obj, "");
                }
            }
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 判断本实体有没有这个字段
     * @param c
     * @param fieldName
     * @return
     */
    public boolean hasField(Class c, String fieldName){
        Field[] fields = c.getDeclaredFields();

        for (Field f : fields) {
            if (fieldName.equals(f.getName())) {
                return true;

            }

        }

        return false;
    }

}

YonghuController.java

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("/yonghu")
public class YonghuController {
    private static final Logger logger = LoggerFactory.getLogger(YonghuController.class);

    @Autowired
    private YonghuService yonghuService;


    @Autowired
    private TokenService tokenService;
    @Autowired
    private DictionaryService dictionaryService;

    //级联表service

    @Autowired
    private FudaoyuanService fudaoyuanService;
    @Autowired
    private JiaoshiService jiaoshiService;
    @Autowired
    private KaoqinguanliService kaoqinguanliService;


    /**
    * 后端列表
    */
    @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"));
        else if("辅导员".equals(role))
            params.put("fudaoyuanId",request.getSession().getAttribute("userId"));
        else if("教师".equals(role))
            params.put("jiaoshiId",request.getSession().getAttribute("userId"));
        else if("院系考勤管理".equals(role))
            params.put("kaoqinguanliId",request.getSession().getAttribute("userId"));
        params.put("yonghuDeleteStart",1);params.put("yonghuDeleteEnd",1);
        if(params.get("orderBy")==null || params.get("orderBy")==""){
            params.put("orderBy","id");
        }
        PageUtils page = yonghuService.queryPage(params);

        //字典表数据转换
        List<YonghuView> list =(List<YonghuView>)page.getList();
        for(YonghuView 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);
        YonghuEntity yonghu = yonghuService.selectById(id);
        if(yonghu !=null){
            //entity转view
            YonghuView view = new YonghuView();
            BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中

            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永远不会进入");

        Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
            .eq("username", yonghu.getUsername())
            .or()
            .eq("yonghu_phone", yonghu.getYonghuPhone())
            .or()
            .eq("yonghu_id_number", yonghu.getYonghuIdNumber())
            .andNew()
            .eq("yonghu_delete", 1)
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
        if(yonghuEntity==null){
            yonghu.setYonghuDelete(1);
            yonghu.setCreateTime(new Date());
            yonghu.setPassword("123456");
            yonghuService.insert(yonghu);
            return R.ok();
        }else {
            return R.error(511,"账户或者联系方式或者学生身份证号已经被使用");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");
        //根据字段查询是否有相同数据
        Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
            .notIn("id",yonghu.getId())
            .andNew()
            .eq("username", yonghu.getUsername())
            .or()
            .eq("yonghu_phone", yonghu.getYonghuPhone())
            .or()
            .eq("yonghu_id_number", yonghu.getYonghuIdNumber())
            .andNew()
            .eq("yonghu_delete", 1)
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
        if("".equals(yonghu.getYonghuPhoto()) || "null".equals(yonghu.getYonghuPhoto())){
                yonghu.setYonghuPhoto(null);
        }
        if(yonghuEntity==null){
            yonghuService.updateById(yonghu);//根据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());
        ArrayList<YonghuEntity> list = new ArrayList<>();
        for(Integer id:ids){
            YonghuEntity yonghuEntity = new YonghuEntity();
            yonghuEntity.setId(id);
            yonghuEntity.setYonghuDelete(2);
            list.add(yonghuEntity);
        }
        if(list != null && list.size() >0){
            yonghuService.updateBatchById(list);
        }
        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<YonghuEntity> yonghuList = 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("../../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){
                            //循环
                            YonghuEntity yonghuEntity = new YonghuEntity();
//                            yonghuEntity.setUsername(data.get(0));                    //账户 要改的
//                            //yonghuEntity.setPassword("123456");//密码
//                            yonghuEntity.setYonghuName(data.get(0));                    //学生姓名 要改的
//                            yonghuEntity.setYonghuPhoto("");//详情和图片
//                            yonghuEntity.setSexTypes(Integer.valueOf(data.get(0)));   //性别 要改的
//                            yonghuEntity.setYonghuPhone(data.get(0));                    //联系方式 要改的
//                            yonghuEntity.setYonghuIdNumber(data.get(0));                    //学生身份证号 要改的
//                            yonghuEntity.setYonghuEmail(data.get(0));                    //邮箱 要改的
//                            yonghuEntity.setZhuanyeTypes(Integer.valueOf(data.get(0)));   //专业 要改的
//                            yonghuEntity.setYonghuDelete(1);//逻辑删除字段
//                            yonghuEntity.setCreateTime(date);//时间
                            yonghuList.add(yonghuEntity);


                            //把要查询是否重复的字段放入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("yonghuPhone")){
                                    List<String> yonghuPhone = seachFields.get("yonghuPhone");
                                    yonghuPhone.add(data.get(0));//要改的
                                }else{
                                    List<String> yonghuPhone = new ArrayList<>();
                                    yonghuPhone.add(data.get(0));//要改的
                                    seachFields.put("yonghuPhone",yonghuPhone);
                                }
                                //学生身份证号
                                if(seachFields.containsKey("yonghuIdNumber")){
                                    List<String> yonghuIdNumber = seachFields.get("yonghuIdNumber");
                                    yonghuIdNumber.add(data.get(0));//要改的
                                }else{
                                    List<String> yonghuIdNumber = new ArrayList<>();
                                    yonghuIdNumber.add(data.get(0));//要改的
                                    seachFields.put("yonghuIdNumber",yonghuIdNumber);
                                }
                        }

                        //查询是否重复
                         //账户
                        List<YonghuEntity> yonghuEntities_username = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("username", seachFields.get("username")).eq("yonghu_delete", 1));
                        if(yonghuEntities_username.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(YonghuEntity s:yonghuEntities_username){
                                repeatFields.add(s.getUsername());
                            }
                            return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                         //联系方式
                        List<YonghuEntity> yonghuEntities_yonghuPhone = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_phone", seachFields.get("yonghuPhone")).eq("yonghu_delete", 1));
                        if(yonghuEntities_yonghuPhone.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(YonghuEntity s:yonghuEntities_yonghuPhone){
                                repeatFields.add(s.getYonghuPhone());
                            }
                            return R.error(511,"数据库的该表中的 [联系方式] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                         //学生身份证号
                        List<YonghuEntity> yonghuEntities_yonghuIdNumber = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_id_number", seachFields.get("yonghuIdNumber")).eq("yonghu_delete", 1));
                        if(yonghuEntities_yonghuIdNumber.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(YonghuEntity s:yonghuEntities_yonghuIdNumber){
                                repeatFields.add(s.getYonghuIdNumber());
                            }
                            return R.error(511,"数据库的该表中的 [学生身份证号] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                        yonghuService.insertBatch(yonghuList);
                        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) {
        YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));
        if(yonghu==null || !yonghu.getPassword().equals(password))
            return R.error("账号或密码不正确");
        else if(yonghu.getYonghuDelete() != 1)
            return R.error("账户已被删除");
        //  // 获取监听器中的字典表
        // ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
        // Map<String, Map<Integer, String>> dictionaryMap= (Map<String, Map<Integer, String>>) servletContext.getAttribute("dictionaryMap");
        // Map<Integer, String> role_types = dictionaryMap.get("role_types");
        // role_types.get(.getRoleTypes());
        String token = tokenService.generateToken(yonghu.getId(),username, "yonghu", "学生");
        R r = R.ok();
        r.put("token", token);
        r.put("role","学生");
        r.put("username",yonghu.getYonghuName());
        r.put("tableName","yonghu");
        r.put("userId",yonghu.getId());
        return r;
    }

    /**
    * 注册
    */
    @IgnoreAuth
    @PostMapping(value = "/register")
    public R register(@RequestBody YonghuEntity yonghu){
//    	ValidatorUtils.validateEntity(user);
        Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
            .eq("username", yonghu.getUsername())
            .or()
            .eq("yonghu_phone", yonghu.getYonghuPhone())
            .or()
            .eq("yonghu_id_number", yonghu.getYonghuIdNumber())
            .andNew()
            .eq("yonghu_delete", 1)
            ;
        YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
        if(yonghuEntity != null)
            return R.error("账户或者联系方式或者学生身份证号已经被使用");
        yonghu.setYonghuDelete(1);
        yonghu.setCreateTime(new Date());
        yonghuService.insert(yonghu);
        return R.ok();
    }

    /**
     * 重置密码
     */
    @GetMapping(value = "/resetPassword")
    public R resetPassword(Integer  id){
        YonghuEntity yonghu = new YonghuEntity();
        yonghu.setPassword("123456");
        yonghu.setId(id);
        yonghuService.updateById(yonghu);
        return R.ok();
    }


    /**
     * 忘记密码
     */
    @IgnoreAuth
    @RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request) {
        YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));
        if(yonghu!=null){
            yonghu.setPassword("123456");
            boolean b = yonghuService.updateById(yonghu);
            if(!b){
               return R.error();
            }
        }else{
           return R.error("账号不存在");
        }
        return R.ok();
    }


    /**
    * 获取用户的session用户信息
    */
    @RequestMapping("/session")
    public R getCurrYonghu(HttpServletRequest request){
        Integer id = (Integer)request.getSession().getAttribute("userId");
        YonghuEntity yonghu = yonghuService.selectById(id);
        if(yonghu !=null){
            //entity转view
            YonghuView view = new YonghuView();
            BeanUtils.copyProperties( yonghu , 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("退出成功");
    }





}

IndexAside.vue
<template>
  <el-aside class="index-aside" width="200px">
    <div class="index-aside-inner">
      <el-menu default-active="1">
        <el-menu-item @click="menuHandler('/')" index="1">
          <!-- <i class="el-icon-s-home"></i> -->
          首页
        </el-menu-item>
        <sub-menu
          v-for="menu in menuList"
          :key="menu.menuId"
          :menu="menu"
          :dynamicMenuRoutes="dynamicMenuRoutes"
        ></sub-menu>
      </el-menu>
    </div>
  </el-aside>
</template>
<script>
import SubMenu from "@/components/index/IndexAsideSub";
export default {
  data() {
    return {
      menuList: [],
      dynamicMenuRoutes: []
    };
  },
  components: {
    SubMenu
  },
  mounted() {
    // 获取动态菜单数据并且渲染
    this.menuList = JSON.parse(sessionStorage.getItem("menuList") || "[]");
    this.dynamicMenuRoutes = JSON.parse(
      sessionStorage.getItem("dynamicMenuRoutes") || "[]"
    );
  },
  methods: {
    menuHandler(path) {
      this.$router.push({ path: path });
    }
  }
};
</script>
<style lang="scss" scoped>
.index-aside {
  margin-top: 80px;
  overflow: hidden;
  .index-aside-inner {
    width: 217px;
    height: 100%;
    overflow-y: scroll;
  }
}
</style>


声明

本博客适用于广泛的学术和教育用途,包括但不限于个人学习、开发设计,产品设计。仅供学习参考,旨在为读者提供深入理解和学术研究的材料。

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

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

相关文章

即插即用篇 | DenseNet卷土重来! YOLOv8 引入全新密集连接卷积网络 | ECCV 2024

本改进已同步到YOLO-Magic框架! 本文重新审视了密集连接卷积网络(DenseNets),并揭示了其在主流的ResNet风格架构中被低估的有效性。我们认为,由于未触及的训练方法和传统设计元素没有完全展现其能力,DenseNets的潜力被忽视了。我们的初步研究表明,通过连接实现的密集连接…

未能参加工博会的open61499

上海工博会正在如火如荼的进行中&#xff0c;各大工业板块的厂商都展示出了自家新的产品和解决方案&#xff0c;遗憾的是open61499没能到上海工博会亮相&#xff0c;只能通过写文章发自媒体的方式给大家介绍open61499。 open61499是基于IEC61499标准打造的工业编程平台&#xf…

Keil5安装arm和C51共存环境

一、安装前准备 ①Keil5 mdk安装包 ②Keil5 C51安装包 ③注册机 如下 二、安装步骤 ①建立两个文件夹用于存放Keil5 C51安装程序和keil5 mdk安装程序 如下图 ②点击c51v95a.exe进行安装&#xff0c;一路next&#xff0c;安装在Keil5_C51目录下 ③点击MDK539.ext进行安装…

Redis篇(环境搭建)

目录 一、安装包 1. Windows版下载地址 2. Linux版下载地址 二、安装Redis 1. 在Linux中安装Redis 2. 在Windows中安装Redis 3. 细节问题 三、Redis服务启动 1. 默认启动 2. 指定配置启动 3. 开机自启 四、Redis服务停止 1. Linux系统中启动和停止Redis 2. Window…

MongoDB 双活集群在运营商的实践

在现代电信行业中&#xff0c;订单中心作为核心业务系统之一&#xff0c;承担着处理客户订单、管理订单状态、与各个业务系统进行交互等重要职责。其订单中心的高效运作直接关系到客户体验和业务连续性。为了满足不断增长的业务需求和日益复杂的运营环境&#xff0c;运营商需要…

微调大模型(Finetuning Large Language Models)—Where finetuning fits in(二)

1.什么时候适合用finetune 微调&#xff08;finetuning&#xff09;对人的作用包括行为改变和知识获取。行为改变方面&#xff0c;包括学习更一致地回应、学会专注&#xff08;如适度&#xff09;以及发挥能力&#xff08;如更擅长对话&#xff09;&#xff1b;知识获取方面&am…

三、人物骨骼介绍

一、迁移骨骼包 注意&#xff1a;要迁移所有骨骼压缩包&#xff08;单独可能会有问题&#xff09; 二、认识骨骼 点击骨骼 进入骨骼页面

尚庭公寓-接口定义

5. 接口定义 5.1 后台管理系统接口定义 5.1.1 公寓信息管理 5.1.1.1 属性管理 属性管理页面包含公寓和房间各种可选的属性信息&#xff0c;其中包括房间的可选支付方式、房间的可选租期、房间的配套、公寓的配套等等。其所需接口如下 房间支付方式管理 页面如下 所需接口如…

【Linux】Linux 的 权限

一、 Linux 权限的概念 Linux下有两种用户&#xff1a;超级用户&#xff08;root&#xff09;、普通用户。 超级用户&#xff1a;可以在 linux 系统下做任何事情&#xff0c;不受限制普通用户&#xff1a;在 linux 下做有限的事情。超级用户的命令提示符是“#”&#xff0c;普…

每日一题|2535. 数组元素和与数字和的绝对差|数位运算

简单题。先加后减&#xff0c;可以剪枝。 先加后减就是对于每一个数字之间完成该数字的值-数位和&#xff0c;然后再去下一个数字。 特别的&#xff0c;对于小于10的数字&#xff0c;减自身就是0&#xff0c;没必要计算&#xff0c;可以跳过。 class Solution(object):def d…

C++之美:代码整洁、安全又跑得快的30个要诀(好书推荐)

在编程领域&#xff0c;C 以其高效性和灵活性著称&#xff0c;但同时也因其复杂性和易出错性而闻名。如何写出既整洁、又安全且高效的 C 代码&#xff0c;是每个 C 开发者都需要思考的问题。《C之美&#xff1a;代码整洁、安全又跑得快的30个要诀》这本书为我们提供了宝贵的指导…

git clone代码报错Permission denied (publickey)

git clone gerrit SSH的Clone with commit-msg hook代码连接&#xff0c;报错Permission denied (publickey). 一般在C:\Users\用户名.ssh文件夹下有一个id_rsa.pub文件 把文件里的内容复制 到gerrit网站上User Settings的SSH keys里 在New SSH key里粘贴刚刚复制的内容&…

【递归】6.LPC 44 开幕式火焰

1 题目描述 题目链接&#xff1a;开幕式火焰 2 解答思路 递归分为三步&#xff0c;接下来就按照这三步来思考问题 第一步&#xff1a;挖掘出相同的子问题 &#xff08;关系到具体函数头的设计&#xff09; 第二步&#xff1a;只关心具体子问题做了什么 &#xff08;关系…

那些年我和 ChatGPT 合谋摸鱼的日子

文章目录 那些年我和 ChatGPT 合谋摸鱼的日子1 序个言2 说正事3 这次是真正的正事4 总个结 那些年我和 ChatGPT 合谋摸鱼的日子 1 序个言 看到 CSDN 出这个活动有段时间了&#xff0c;奈何俗务缠身&#xff0c;一直没静下心来想想怎么写。今天碰巧赶上了&#xff0c;就顺便聊聊…

【Linux扩容根分区】LVM分区扩容过程踩坑记录

最近想要给自己使用的Linux操作系统的根分区进行扩容&#xff0c;解决完发现&#xff0c;原来问题如此简单。 特此记录&#xff0c;希望能帮助到有需要的人。 通过df -Th查看系统磁盘分区情况 通过vgdisplay 查看内容 实操过程中&#xff0c;原来红框中&#xff0c;Free PE …

2024年双十一买啥最划算?双十一好物推荐闭眼入!

一年一度的双十一购物狂欢节已悄然临近&#xff0c;这不仅是一场消费者的盛宴&#xff0c;更是各大品牌竞相展示实力、推出优惠的绝佳时机。在这个全民狂欢的日子里&#xff0c;数码产品作为科技与生活的桥梁&#xff0c;相信已经有不少朋友想要大买特买了。无论是追求极致性能…

《python语言程序设计》2018版第8章18题几何circle2D类(下部)

前言、从9.20激动发言到现在一直没有克制住的心情中,回到编程 比如删掉我设计的导入第二个园的x,y,radius的函数我做了之前设计的变化.建立了两个可以将x,y拿出来的函数out计算两个坐标之间的距离利用已知的两个坐标之间的距离来比对第1个园里的半径,看第2个园的坐标是否在第一…

Linux文本内容管理命令_2

find&#xff1a;-查找命令执行文件 which 命令 whereis 命令 type 命令----查看命令类型 alias &#xff08;命令别名&#xff09; cat 查看文件--更新文件时间&#xff0c;再次cat&#xff0c;时间不会改变 touch--会更新所有属性的时间&#xff0c;文件诞生时间不会改变 …

求n的阶乘的相反数(c语言)

1./请编写函数fun&#xff0c;其功能是:计算并输出下列多项式的值: // s11/1!1/2!1/3!1/4!1/5!1/6!1/7!...1/n! //例如&#xff0c;在主函数中从键盘给n输入15&#xff0c;则输出为:s 2.718282。 //注意:要求n的值大于1但不大于100。 2.我们先输入数字n,然后先讲n!的阶乘计算…

NMOS的原理

NMOS&#xff08;N型金属氧化物半导体场效应晶体管&#xff09;是常见的场效应晶体管&#xff08;FET&#xff09;的一种&#xff0c;其主要电极包括D极&#xff08;Drain&#xff09;、S极&#xff08;Source&#xff09;和G极&#xff08;Gate&#xff09;&#xff0c;每个电…