基于Spring Boot的大学校园生存信息平台的设计与实现pf

打印 上一主题 下一主题

主题 506|帖子 506|积分 1518

@TOC
springboot523基于Spring Boot的大学校园生存信息平台的设计与实现pf

绪论

1.1 研究背景

当前社会各行业范畴竞争压力非常大,随着当前时代的信息化,科学化发展,让社会各行业范畴都争相使用新的信息技术,对行业内的各种相关数据进行科学化,规范化管理。如许的大环境让那些止步不前,不接受信息改革带来的信息技术的企业随时面临被淘汰,被取代的风险。所以当今,各个行业范畴,不管是传统的教育行业,餐饮行业,还是旅游行业,医疗行业等范畴都将使用新的信息技术进行信息革命,改变传统的纸质化,需要人手工处理工作事务的办公环境。软件信息技术能够覆盖社会各行业范畴是时代的发展要求,各种数据以及文件真正实现电子化是信息社会发展的不可逆转的必然趋势。本大学校园生存信息平台也是紧跟科学技术的发展,运用当今一流的软件技术实现软件系统的开辟,让员工信息完全通过管理系统实现科学化,规范化,程序化管理。从而资助信息管理者节流事务处理的时间,低沉数据处理的错误率,对于基础数据的管理水平可以起到促进作用,也从一定程度上对随意的业务管理工作进行了避免,同时,大学校园生存信息平台的数据库里面存储的各种动态信息,也为上层管理人员作出重大决策提供了大量的事实依据。总之,大学校园生存信息平台是一款可以真正提升管理者的办公效率的软件系统。
1.2 目标和意义

信息数据的处理完全依赖人工进行操作,会泯灭大量的人工成本,特殊是面临大量的数据信息时,传统人工操作不但不能对数据的出错率进行保证,还轻易出现各种信息资源的低利用率与低安全性问题。更有甚者,延长大量的宝贵时间,尤其是对信息的更新,归纳与统计更是耗财耗力的过程。所以电子化信息管理的出现就能缓解以及改变传统人工方式面临的处境,一方面可以确保信息数据在短时间被高效处理,还能节流人力成本,另一方面可以确保信息数据的安全性,可靠性,并可以实现信息数据的快速检索与修改操作,这些优点是之前的旧操作模式无法相比的。因此大学校园生存信息平台为数据信息的管理模式的升级与改革提供了紧张的窗口。
1.3 论文结构安排

为了资助用户更好的了解和明白程序的开辟流程与相关内容,本文将通过六个章节进行内容阐述。
第一章:形貌了程序的开辟背景,程序运用于实际生存的目标与意义,以及程序文档的结构安排信息;
第二章:形貌了程序的开辟环境,包罗程序开辟涉及到的技术,程序开辟使用的数据存储工具等信息;
第三章:形貌了程序动手进行开辟时,会面临的可行性问题,并对程序功能以及性能要求进行形貌;
第四章:形貌了程序大功能模块下的功能细分信息,以及存储程序数据的数据库表文件结构的设计信息等;
第五章:形貌了程序的功能实现界面的内容,也对程序操作人员操作的部分功能进行了形貌;
第六章:形貌了程序功能的测试内容,并先容了系统测试的概念与方法。
2 相关技术

2.1 SpringBoot框架先容

本课题程序开辟使用到的框架技术,英文名称缩写是SpringBoot,在JavaWeb开辟中使用的流行框架有SSH、SSM、SpringBoot、SpringMVC等,作为一个课题程序采用SSH框架也可以,SSM框架也可以,SpringMVC也可以。SSH框架是属于重量级别的框架,配置繁琐,不敷灵活,修改程序需要修改很多多少个文件,而且运行起来也占用内存较高,CPU使用率相对也高,SpringBoot是基础Spring开辟的一套整合架构,更灵活更好用,SpringBoot框架取中心值,既没有SSH臃肿,也没有SpringMVC简化,属于中心级别的,在配置过程和使用过程中更能编写和明白。SpringBoot框架取代Hibernate框架是因为它更灵活,不需要完全在框架里操作,它在数据操作上可以写出更灵活的代码,它的性能也比Hibernate框架更稳定。总的来说,使用SpringBoot框架是通过综合考虑而使用的,网上有很多的使用教程和心得体会,而且SpringBoot又是这么的流行,用SpringBoot框架开辟是顺其天然的。
2.2 VUE先容

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

开辟的程序面向用户的只是程序的功能界面,让用户操作程序界面的各个功能,那么很多人就会问,用户使用程序功能生成的数据信息放在哪里的?这个就需要涉及到数据库的知识了,一般来说,程序开辟通常就会对常用数据存储工具的特点进行分析比对,比如Mysql数据库的特点与优势,Access数据库的特点与优势,Sqlserver数据库的特点与优势等,最终看哪个数据库与需要开辟的程序比较匹配,也符合程序功能运行需要的数据存储要求,比如,需要开辟商业级别的程序,存储的数据对数据库要求较高,可以选用Oracle,如果只是比较简单的程序,对数据存储没有过多要求,可以选用微软旗下的Access,当开辟程序要求数据库占用空间小,并能满意程序数据存储要求时,就可以考虑Oracle公司从瑞典MySQL AB公司在很早之前就收购过一个关系型数据库,它是现在的Mysql数据库。在数据库工具里面它是最受认可的此中一个应用软件。需要阐明的信息就是,本程序的开辟就运用到了此数据库。它将程序数据通过使用不同的数据表格进行保存,在增长了程序数据的存储速率的时间,也提高了数据库的灵活性。 图2.2展示的就是MySQL的架构图。

图2.2 MySQL数据库架构图
3 系统分析

当用户确定开辟一款程序时,是需要遵循下面的顺序进行工作,概括为:系统分析-->系统设计-->系统开辟-->系统测试,无论这个过程是否有变更或者迭代,都是按照如许的顺序开展工作的。系统分析就是分析系统需要做什么的问题,主要目标就是确定系统的功能,这也为接下来的工作做了一个好的开端。
3.1 系统可行性分析

开辟一款程序软件不但需要时间,也需要人力,物力资源。而进行可行性分析这个环节就是办理用户这方面的疑问,看看程序在当前的条件下是否可以进行开辟。
3.1.1 技术可行性分析

此程序选用的开辟语言是Java,这种编程语言有着丰富的数据类型,在指令控制语句上也比较美满,更紧张的就是对类与对象的大力支持,这些优点为程序开辟者提供了技术保障,尤其是现在代码都渐渐模块化,有关系统功能开辟的源码在网络上都公开展示了,所以让具备一定计算机开辟基础的开辟人员独立开辟系统在技术上也渐渐轻易。
3.1.2 经济可行性分析

开辟此程序最关键的装备就是一台电脑,无论是学校计算机室配备的电脑,还是自己入学以来购置的条记本,都是可以符合开辟要求的装备,另外在网络上,学校本已完全覆盖了校园网,所以在装备以及网络上无须考虑经济问题。
3.1.3 运行可行性分析

随着电脑软件以及配套硬件的美满升级,当下的计算机环境是一片大好,尤其是计算机已经广泛普及到家家户户,所以计算机装备现在是随处可见,由于本次开辟的程序占有的资源泯灭较小,在一般的电脑或条记本上都能轻松运转起来。
通过上面的可行性形貌,可以从经济,技术,运行方面办理程序开辟是否可行的问题。因此可以以为该程序软件是可以进行开辟的。
3.2 系统性能分析

系统性能分析也是比较紧张的内容,进行系统性能分析就是为了确保系统的功能要能够在生存中运行使用时,到达规定的指标,因此一个完备的系统软件,是需要进行系统的性能分析这个步调的。本次进行性能分析主要从易用性指标,可扩展性指标,系统健壮性指标,系统安全性指标这几个方面进行分析。
3.2.1 易用性指标

本次程序软件的开辟的目标就是让使用者可以通过使用该软件提高信息数据的管理效率,同时该程序软件也需要针对不同的操作用户设置对应的功能,因此,此程序的操作流程应该尽量与用户日常操作软件的举动习惯相贴合,另外,程序软件的设计与开辟也应考虑非计算机专业用户的计算机操作水平,要让大部分使用者都可以轻松操作程序提供的各个功能。
3.2.2 可扩展性指标

当前需要开辟的程序软件是根据当下的用户需求进行设计开辟的,但是随着时间的推移,社会大环境的改变,开辟出的程序也是需要与时俱进的,需要根据用户不绝变换的需求进行相应的功能内容的扩展,需要注意的就是,当对成型的程序进行功能模块新增时,仍旧需要保证程序原有架构以及功能不能受到影响,新增的功能模块在系统中也能够运行正常,该指标达标也就可以保证此程序是可以在满意信息管理要求下,从容应对市场环境的变革。
3.2.3 健壮性指标

程序软件的开辟就是为了投入使用时,可以不绝稳定的处理各种数据信息,程序软件一旦不稳定,也会给使用者带来干扰。因此从性能分析的角度,就要要求程序软件在应对使用者的误操作,或者是使用者因为各种原因,填写有误的数据等环境时,程序要不绝保持稳定,并能够正常让使用者进行使用。当程序的某个功能模块出现异常时,程序的其它功能模块也要能够确保正常使用。程序的健壮性指标达标可以让使用者产生精良的用户体验。
3.2.4 安全性指标

程序软件的安全问题是首要问题,究竟程序对应数据库里面存放的数据信息是庞大的,里面也包罗了许多紧张的个人信息,这就对程序要具备一个美满的安全机制提出了要求。因此程序必须要设置登录功能用以进行用户身份的查抄,以及身份和权限的匹配,通过对不同用户身份进行功能约束,绝不容忍用户越权操作程序。另外,也需要时刻防范计算机病毒,另有黑客,通过接纳针对性的办法进行安全应对,确保程序时刻处于安全的环境,让使用者放心使用。
3.3 系统流程分析

3.3.1 操作流程分析

程序上交给用户进行使用时,需要提供程序的操作流程图(如图3.1所示),如许便于用户轻易明白程序的具体工作步调,现如今程序的操作流程都有一个大致的标准,即先通过登录页面提交登录数据,通过程序验证正确之后,用户才能在程序功能操作区页面操作对应的功能。

图3.1 程序操作流程图
3.3.2 登录流程分析

在这个部分,需要对程序的登录功能模块的运行流程(如图3.2所示),进行单独阐明。程序设置登录模块也是为了安全起见,让用户使用放心,登录模块主要就是让用户提交登录信息,程序进行数据验证,验证通过的用户才能够乐成登录程序。

图3.2 程序登录流程图
3.3.3 信息添加流程分析

程序的添加功能就是提供给操作者录入信息的功能,不管是涉及到用户信息添加,还是其它功能模块涉及到的信息添加,程序的信息添加流程(如图3.3所示)都是一致的。程序都是先对操作者录入的数据进行判定,这个判定规则是一段提前编写完成的程序代码,当程序判定数据符合要求时,才会把操作者录入的数据登记在数据表里面,比如添加的用户信息,就会把新添加的用户信息写入用户信息的数据表文件里面。

图3.3 信息添加流程图
3.3.4 信息删除流程分析

当从程序里面删除某种无效数据时,遵循程序的信息删除流程(如图3.4所示),先要选中操作者需要删除的数据,程序为了预防操作者误删信息,也会进行提示,当操作者真正确定要删选中的信息时,该信息就会从数据库中被永久删除。

图3.4 信息删除流程图
4 系统设计

大学校园生存信息平台的设计方案比如功能框架的设计,比如数据库的设计的优劣也就决定了该系统在开辟层面是否高效,以及在系统维护层面是否轻易维护和升级,因为在系统实现阶段是需要考虑用户的所有需求,要是在设计阶段没有经过全方位考虑,那么系统实现的部分也就无从动手,所以系统设计部分也是至关紧张的一个环节,只有根据用户需求进行细致全面的考虑,才有希望开辟出功能健全稳定的程序软件。
4.1 系统概要设计

本次拟开辟的系统为了节省开辟成本,也为了后期在维护和升级上的便利性,计划通过浏览器来实现系统功能界面的展示,让程序软件的主要事务集中在背景的服务器端处理,前端部分只用处理少量的事务逻辑。下面使用一张图(如图4.1所示)来阐明程序的工作原理。

图4.1 程序工作的原理图
4.2 系统功能结构设计

在分析并得出使用者对程序的功能要求时,就可以进行程序设计了。如图4.2展示的就是管理员功能结构图,管理员主要负责添补员工和其种别信息,并对已添补的数据进行维护,包罗修改与删除,管理员也需要对奖惩对培训,对考,对薪资等进行管理。

图4.2 系统功能结构图
4.3 数据库设计

程序功能操作不管是添加,修改,还是删除等功能产生的数据都是经由数据库进行数据保存和更新的,所以一个数据库设计的优劣也是程序是否优劣的判定标准,因为程序的乐成,有一半的功劳都是靠数据库的优秀设计。数据库一旦设计得精良是可以减轻开辟人员的开辟负担的。
4.3.1 数据库E-R图设计

这个部分的设计需要使用到E-R图绘制工具,常用的工具就是Visio工具来绘制E-R模型图,这款工具不但可以快速创建需要的E-R模型图,而且该工具提供的操作界面很简单,可以短时间内修改绘图界面的图形或者是笔墨的属性。在绘制E-R模型图时,要分清楚各个图形代表的含义,以免绘制出错,E-R模型图由长方形(实体),椭圆形(属性),菱形(关系)这三部分图形符号组成,绘制期间要区分开来,用准确的图形符号代表相应的数据元素。
(1)下图是活动实体和其具备的属性。

活动实体属性图
(2)下图是用户实体和其具备的属性。

用户实体属性图
(3)下图是测验记录表实体和其具备的属性。

测验记录表实体属性图
(4)下图是答题详情表实体和其具备的属性。

答题详情表实体属性图
(5)下图是试卷选题实体和其具备的属性。

试卷选题实体属性图
(6)下图是错题表实体和其具备的属性。

错题表实体属性图
(7)下图是活动收藏实体和其具备的属性。

活动收藏实体属性图
(8)下图是论坛实体和其具备的属性。

论坛实体属性图
(9)下图是试卷实体和其具备的属性。

试卷实体属性图
(10)下图是活动留言实体和其具备的属性。

活动留言实体属性图
(11)下图是试题表实体和其具备的属性。

试题表实体属性图
(12)下图是校园资讯实体和其具备的属性。

校园资讯实体属性图
(13)下图是活动报名实体和其具备的属性。

活动报名实体属性图
各个实体之间的联系用下图的E-R图表示。绘制的系统E-R图见图4.8。
校园活动
属于
属于
查询
管理
用户
分类信息
管理员
大学校园生存信息平台
管理
管理
管理
查询
n
n
n
n
1
1
n
1
1
1

图4.8 系统E-R图
4.3.2 数据库表结构设计

数据库系统一旦选定之后,需要根据程序要求在数据库中建立数据库文件,并在已经完成创建的数据库文件里面,为程序运行中产生的数据建立对应的数据表格,数据表结构设计就是对创建的数据表格进行字段设计,字段长度设计,字段类型设计等,当数据表格公道设计完成之后,才能正常存储相关程序运行产生的数据信息。
表4.1字典表
序号列名数据类型阐明允许空1IdIntid否2dic_codeString字段是3dic_nameString字段名是4code_indexInteger编码是5index_nameString编码名字是6super_idInteger父字段id是7beizhuString备注是8create_timeDate创建时间是 表4.2试卷表
序号列名数据类型阐明允许空1IdIntid否2exampaper_nameString试卷名称是3exampaper_dateInteger测验时长(分钟)是4exampaper_myscoreInteger试卷总分数是5kemu_typesInteger科目是6exampaper_typesInteger试卷状态是7zujuan_typesInteger组卷方式是8exampaper_deleteInteger逻辑删除(1代表未删除 2代表已删除)是9create_timeDate创建时间是 表4.3试卷选题表
序号列名数据类型阐明允许空1IdIntid否2exampaper_idInteger试卷是3examquestion_idInteger试题是4exampapertopic_numberInteger试题分数是5create_timeDate创建时间是 表4.4试题表表
序号列名数据类型阐明允许空1IdIntid否2examquestion_nameString试题名称是3kemu_typesInteger科目是4examquestion_optionsString选项,json字符串是5examquestion_answerString正确答案是6examquestion_analysisString答案剖析是7examquestion_typesInteger试题类型是8examquestion_sequenceInteger试题排序,值越大排越前面是9create_timeDate创建时间是 表4.5测验记录表表
序号列名数据类型阐明允许空1IdIntid否2examrecord_uuid_numberString测验编号是3yonghu_idInteger测验用户是4exampaper_idInteger所属试卷id(外键)是5total_scoreInteger所得总分是6insert_timeDate测验时间是7create_timeDate创建时间是 表4.6答题详情表表
序号列名数据类型阐明允许空1IdIntid否2examredetails_uuid_numberString试卷编号是3yonghu_idInteger用户id是4examquestion_idInteger试题id(外键)是5examredetails_myanswerString考生答案是6examredetails_myscoreInteger试题得分是7create_timeDate创建时间是 表4.7错题表表
序号列名数据类型阐明允许空1IdIntid否2yonghu_idInteger用户id是3exampaper_idInteger试卷(外键)是4examquestion_idInteger试题id(外键)是5examredetails_myanswerString考生作答是6insert_timeDate记录时间是7create_timeDate创建时间是 表4.8论坛表
序号列名数据类型阐明允许空1IdIntid否2forum_nameString帖子标题是3yonghu_idInteger用户是4users_idInteger管理员是5forum_contentString发布内容是6super_idsInteger父id是7forum_typesInteger帖子类型是8forum_state_typesInteger帖子状态是9insert_timeDate发帖时间是10update_timeDate修改时间是11create_timeDate创建时间是 表4.9活动表
序号列名数据类型阐明允许空1IdIntid否2huodong_nameString活动名称是3huodong_uuid_numberString活动编号是4huodong_photoString活动照片是5huodong_addressString活动地点是6huodong_typesInteger活动类型是7huodong_kucun_numberInteger活动库存是8zan_numberInteger赞是9cai_numberInteger踩是10huodong_kaishi_timeDate活动开始时间是11huodong_clicknumInteger活动热度是12huodong_contentString活动内容是13shangxia_typesInteger是否上架是14huodong_deleteInteger逻辑删除是15insert_timeDate录入时间是16create_timeDate创建时间是 表4.10活动收藏表
序号列名数据类型阐明允许空1IdIntid否2huodong_idInteger活动是3yonghu_idInteger用户是4huodong_collection_typesInteger类型是5insert_timeDate收藏时间是6create_timeDate创建时间是 表4.11活动留言表
序号列名数据类型阐明允许空1IdIntid否2huodong_idInteger活动是3yonghu_idInteger用户是4huodong_liuyan_textString留言内容是5insert_timeDate留言时间是6reply_textString回复内容是7update_timeDate回复时间是8create_timeDate创建时间是 表4.12活动报名表
序号列名数据类型阐明允许空1IdIntid否2huodong_yuyue_uuid_numberString报名编号是3huodong_idInteger活动是4yonghu_idInteger用户是5huodong_yuyue_textString报名来由是6huodong_yuyue_yesno_typesInteger报名状态是7huodong_yuyue_yesno_textString审核回复是8huodong_yuyue_shenhe_timeDate审核时间是9insert_timeDate活动报名时间是10create_timeDate创建时间是 表4.13校园资讯表
序号列名数据类型阐明允许空1IdIntid否2news_nameString资讯名称是3news_photoString资讯图片是4news_typesInteger资讯类型是5insert_timeDate资讯发布时间是6news_contentString资讯详情是7create_timeDate创建时间是 表4.14用户表
序号列名数据类型阐明允许空1IdIntid否2yonghu_nameString用户姓名是3yonghu_phoneString用户手机号是4yonghu_id_numberString用户身份证号是5yonghu_photoString用户头像是6yonghu_emailString用户邮箱是7create_timeDate创建时间是 表4.15管理员表
序号列名数据类型阐明允许空1IdIntid否2usernameString门生名是3passwordString密码是4roleString脚色是5addtimeDate新增时间是 5 系统实现

系统实现部分就是将系统分析,系统设计部分的内容通过编码进行功能实现,以一个实际应用系统的形式展示系统分析与系统设计的效果。前面提到的系统分析,系统设计最主要还是进行功能,系统操作逻辑的设计,也包罗了存储数据的数据库方面的设计等内容,系统实现就是一个最终的实施阶段,将前面的设计成果进行物理转化,最终出具可以运用于实际的软件系统。
5.1 管理员功能先容

5.1.1 校园活动管理

如图5.1表现的就是校园活动管理页面,此页面提供给管理员的功能有:检察校园活动列表,新增校园活动,修改校园活动,删除校园活动。

图5.1 校园活动管理页面
5.1.2 校园资讯管理

如图5.2表现的就是校园资讯管理页面,此页面提供给管理员的功能有:新增校园资讯,修改校园资讯,删除校园资讯。

图5.2 校园资讯管理页面
5.1.3 校园资讯类型管理

如图5.3表现的就是校园资讯类型管理页面,此页面提供给管理员的功能有:新增校园资讯类型,修改校园资讯类型,删除校园资讯类型。

图5.3 校园资讯类型管理页面
系统

DictionaryController.java

  1. package com.controller;
  2. import java.io.File;
  3. import java.math.BigDecimal;
  4. import java.net.URL;
  5. import java.text.SimpleDateFormat;
  6. import com.alibaba.fastjson.JSONObject;
  7. import java.util.*;
  8. import org.springframework.beans.BeanUtils;
  9. import javax.servlet.http.HttpServletRequest;
  10. import org.springframework.web.context.ContextLoader;
  11. import javax.servlet.ServletContext;
  12. import com.service.TokenService;
  13. import com.utils.*;
  14. import java.lang.reflect.InvocationTargetException;
  15. import com.service.DictionaryService;
  16. import org.apache.commons.lang3.StringUtils;
  17. import com.annotation.IgnoreAuth;
  18. import org.slf4j.Logger;
  19. import org.slf4j.LoggerFactory;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.stereotype.Controller;
  22. import org.springframework.web.bind.annotation.*;
  23. import com.baomidou.mybatisplus.mapper.EntityWrapper;
  24. import com.baomidou.mybatisplus.mapper.Wrapper;
  25. import com.entity.*;
  26. import com.entity.view.*;
  27. import com.service.*;
  28. import com.utils.PageUtils;
  29. import com.utils.R;
  30. import com.alibaba.fastjson.*;
  31. /**
  32. * 字典
  33. * 后端接口
  34. * @author
  35. * @email
  36. */
  37. @RestController
  38. @Controller
  39. @RequestMapping("/dictionary")
  40. public class DictionaryController {
  41.     private static final Logger logger = LoggerFactory.getLogger(DictionaryController.class);
  42.     private static final String TABLE_NAME = "dictionary";
  43.     @Autowired
  44.     private DictionaryService dictionaryService;
  45.     @Autowired
  46.     private TokenService tokenService;
  47.     @Autowired
  48.     private ExampaperService exampaperService;//问卷调查
  49.     @Autowired
  50.     private ExampapertopicService exampapertopicService;//问卷调查选题
  51.     @Autowired
  52.     private ExamquestionService examquestionService;//试题表
  53.     @Autowired
  54.     private ExamrecordService examrecordService;//问卷调查记录表
  55.     @Autowired
  56.     private ExamredetailsService examredetailsService;//答题详情表
  57.     @Autowired
  58.     private ExamrewrongquestionService examrewrongquestionService;//错题表
  59.     @Autowired
  60.     private ForumService forumService;//论坛
  61.     @Autowired
  62.     private HuodongService huodongService;//活动
  63.     @Autowired
  64.     private HuodongCollectionService huodongCollectionService;//活动收藏
  65.     @Autowired
  66.     private HuodongLiuyanService huodongLiuyanService;//活动留言
  67.     @Autowired
  68.     private HuodongYuyueService huodongYuyueService;//活动报名
  69.     @Autowired
  70.     private NewsService newsService;//校园资讯
  71.     @Autowired
  72.     private YonghuService yonghuService;//用户
  73.     @Autowired
  74.     private UsersService usersService;//管理员
  75.     /**
  76.     * 后端列表
  77.     */
  78.     @RequestMapping("/page")
  79.     @IgnoreAuth
  80.     public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
  81.         logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
  82.         CommonUtil.checkMap(params);
  83.         PageUtils page = dictionaryService.queryPage(params);
  84.         //字典表数据转换
  85.         List<DictionaryView> list =(List<DictionaryView>)page.getList();
  86.         for(DictionaryView c:list){
  87.             //修改对应字典表字段
  88.             dictionaryService.dictionaryConvert(c, request);
  89.         }
  90.         return R.ok().put("data", page);
  91.     }
  92.     /**
  93.     * 后端详情
  94.     */
  95.     @RequestMapping("/info/{id}")
  96.     public R info(@PathVariable("id") Long id, HttpServletRequest request){
  97.         logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
  98.         DictionaryEntity dictionary = dictionaryService.selectById(id);
  99.         if(dictionary !=null){
  100.             //entity转view
  101.             DictionaryView view = new DictionaryView();
  102.             BeanUtils.copyProperties( dictionary , view );//把实体数据重构到view中
  103.             //修改对应字典表字段
  104.             dictionaryService.dictionaryConvert(view, request);
  105.             return R.ok().put("data", view);
  106.         }else {
  107.             return R.error(511,"查不到数据");
  108.         }
  109.     }
  110.     /**
  111.     * 后端保存
  112.     */
  113.     @RequestMapping("/save")
  114.     public R save(@RequestBody DictionaryEntity dictionary, HttpServletRequest request){
  115.         logger.debug("save方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
  116.         String role = String.valueOf(request.getSession().getAttribute("role"));
  117.         if(false)
  118.             return R.error(511,"永远不会进入");
  119.         Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
  120.             .eq("dic_code", dictionary.getDicCode())
  121.             .eq("index_name", dictionary.getIndexName())
  122.             ;
  123.         if(dictionary.getDicCode().contains("_erji_types")){
  124.             queryWrapper.eq("super_id",dictionary.getSuperId());
  125.         }
  126.         logger.info("sql语句:"+queryWrapper.getSqlSegment());
  127.         DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper);
  128.         if(dictionaryEntity==null){
  129.             dictionary.setCreateTime(new Date());
  130.             dictionaryService.insert(dictionary);
  131.             //字典表新增数据,把数据再重新查出,放入监听器中
  132.             List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
  133.             ServletContext servletContext = request.getServletContext();
  134.             Map<String, Map<Integer,String>> map = new HashMap<>();
  135.             for(DictionaryEntity d :dictionaryEntities){
  136.                 Map<Integer, String> m = map.get(d.getDicCode());
  137.                 if(m ==null || m.isEmpty()){
  138.                     m = new HashMap<>();
  139.                 }
  140.                 m.put(d.getCodeIndex(),d.getIndexName());
  141.                 map.put(d.getDicCode(),m);
  142.             }
  143.             servletContext.setAttribute("dictionaryMap",map);
  144.             return R.ok();
  145.         }else {
  146.             return R.error(511,"表中有相同数据");
  147.         }
  148.     }
  149.     /**
  150.     * 后端修改
  151.     */
  152.     @RequestMapping("/update")
  153.     public R update(@RequestBody DictionaryEntity dictionary, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
  154.         logger.debug("update方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
  155.         DictionaryEntity oldDictionaryEntity = dictionaryService.selectById(dictionary.getId());//查询原先数据
  156.         String role = String.valueOf(request.getSession().getAttribute("role"));
  157. //        if(false)
  158. //            return R.error(511,"永远不会进入");
  159.             dictionaryService.updateById(dictionary);//根据id更新
  160.             //如果字典表修改数据的话,把数据再重新查出,放入监听器中
  161.             List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
  162.             ServletContext servletContext = request.getServletContext();
  163.             Map<String, Map<Integer,String>> map = new HashMap<>();
  164.             for(DictionaryEntity d :dictionaryEntities){
  165.                 Map<Integer, String> m = map.get(d.getDicCode());
  166.                 if(m ==null || m.isEmpty()){
  167.                     m = new HashMap<>();
  168.                 }
  169.                 m.put(d.getCodeIndex(),d.getIndexName());
  170.                 map.put(d.getDicCode(),m);
  171.             }
  172.             servletContext.setAttribute("dictionaryMap",map);
  173.             return R.ok();
  174.     }
  175.     /**
  176.     * 删除
  177.     */
  178.     @RequestMapping("/delete")
  179.     public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
  180.         logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
  181.         List<DictionaryEntity> oldDictionaryList =dictionaryService.selectBatchIds(Arrays.asList(ids));//要删除的数据
  182.         dictionaryService.deleteBatchIds(Arrays.asList(ids));
  183.         return R.ok();
  184.     }
  185.     /**
  186.      * 最大值
  187.      */
  188.     @RequestMapping("/maxCodeIndex")
  189.     public R maxCodeIndex(@RequestBody DictionaryEntity dictionary){
  190.         logger.debug("maxCodeIndex:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
  191.         List<String> descs = new ArrayList<>();
  192.         descs.add("code_index");
  193.         Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
  194.                 .eq("dic_code", dictionary.getDicCode())
  195.                 .orderDesc(descs);
  196.         logger.info("sql语句:"+queryWrapper.getSqlSegment());
  197.         List<DictionaryEntity> dictionaryEntityList = dictionaryService.selectList(queryWrapper);
  198.         if(dictionaryEntityList.size()>0 ){
  199.             return R.ok().put("maxCodeIndex",dictionaryEntityList.get(0).getCodeIndex()+1);
  200.         }else{
  201.             return R.ok().put("maxCodeIndex",1);
  202.         }
  203.     }
  204.     /**
  205.      * 批量上传
  206.      */
  207.     @RequestMapping("/batchInsert")
  208.     public R save( String fileName, HttpServletRequest request){
  209.         logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
  210.         Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
  211.         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  212.         try {
  213.             List<DictionaryEntity> dictionaryList = new ArrayList<>();//上传的东西
  214.             Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
  215.             Date date = new Date();
  216.             int lastIndexOf = fileName.lastIndexOf(".");
  217.             if(lastIndexOf == -1){
  218.                 return R.error(511,"该文件没有后缀");
  219.             }else{
  220.                 String suffix = fileName.substring(lastIndexOf);
  221.                 if(!".xls".equals(suffix)){
  222.                     return R.error(511,"只支持后缀为xls的excel文件");
  223.                 }else{
  224.                     URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
  225.                     File file = new File(resource.getFile());
  226.                     if(!file.exists()){
  227.                         return R.error(511,"找不到上传文件,请联系管理员");
  228.                     }else{
  229.                         List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
  230.                         dataList.remove(0);//删除第一行,因为第一行是提示
  231.                         for(List<String> data:dataList){
  232.                             //循环
  233.                             DictionaryEntity dictionaryEntity = new DictionaryEntity();
  234. //                            dictionaryEntity.setDicCode(data.get(0));                    //字段 要改的
  235. //                            dictionaryEntity.setDicName(data.get(0));                    //字段名 要改的
  236. //                            dictionaryEntity.setCodeIndex(Integer.valueOf(data.get(0)));   //编码 要改的
  237. //                            dictionaryEntity.setIndexName(data.get(0));                    //编码名字 要改的
  238. //                            dictionaryEntity.setSuperId(Integer.valueOf(data.get(0)));   //父字段id 要改的
  239. //                            dictionaryEntity.setBeizhu(data.get(0));                    //备注 要改的
  240. //                            dictionaryEntity.setCreateTime(date);//时间
  241.                             dictionaryList.add(dictionaryEntity);
  242.                             //把要查询是否重复的字段放入map中
  243.                         }
  244.                         //查询是否重复
  245.                         dictionaryService.insertBatch(dictionaryList);
  246.                         return R.ok();
  247.                     }
  248.                 }
  249.             }
  250.         }catch (Exception e){
  251.             e.printStackTrace();
  252.             return R.error(511,"批量插入数据异常,请联系管理员");
  253.         }
  254.     }
  255. }
复制代码
ExamrecordController.java

  1. package com.controller;
  2. import java.io.File;
  3. import java.math.BigDecimal;
  4. import java.net.URL;
  5. import java.text.SimpleDateFormat;
  6. import com.alibaba.fastjson.JSONObject;
  7. import java.util.*;
  8. import org.springframework.beans.BeanUtils;
  9. import javax.servlet.http.HttpServletRequest;
  10. import org.springframework.web.context.ContextLoader;
  11. import javax.servlet.ServletContext;
  12. import com.service.TokenService;
  13. import com.utils.*;
  14. import java.lang.reflect.InvocationTargetException;
  15. import com.service.DictionaryService;
  16. import org.apache.commons.lang3.StringUtils;
  17. import com.annotation.IgnoreAuth;
  18. import org.slf4j.Logger;
  19. import org.slf4j.LoggerFactory;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.stereotype.Controller;
  22. import org.springframework.web.bind.annotation.*;
  23. import com.baomidou.mybatisplus.mapper.EntityWrapper;
  24. import com.baomidou.mybatisplus.mapper.Wrapper;
  25. import com.entity.*;
  26. import com.entity.view.*;
  27. import com.service.*;
  28. import com.utils.PageUtils;
  29. import com.utils.R;
  30. import com.alibaba.fastjson.*;
  31. /**
  32. * 问卷调查记录表
  33. * 后端接口
  34. * @author
  35. * @email
  36. */
  37. @RestController
  38. @Controller
  39. @RequestMapping("/examrecord")
  40. public class ExamrecordController {
  41.     private static final Logger logger = LoggerFactory.getLogger(ExamrecordController.class);
  42.     private static final String TABLE_NAME = "examrecord";
  43.     @Autowired
  44.     private ExamrecordService examrecordService;
  45.     @Autowired
  46.     private TokenService tokenService;
  47.     @Autowired
  48.     private DictionaryService dictionaryService;//字典
  49.     @Autowired
  50.     private ExampaperService exampaperService;//问卷调查
  51.     @Autowired
  52.     private ExampapertopicService exampapertopicService;//问卷调查选题
  53.     @Autowired
  54.     private ExamquestionService examquestionService;//试题表
  55.     @Autowired
  56.     private ExamredetailsService examredetailsService;//答题详情表
  57.     @Autowired
  58.     private ExamrewrongquestionService examrewrongquestionService;//错题表
  59.     @Autowired
  60.     private ForumService forumService;//论坛
  61.     @Autowired
  62.     private HuodongService huodongService;//活动
  63.     @Autowired
  64.     private HuodongCollectionService huodongCollectionService;//活动收藏
  65.     @Autowired
  66.     private HuodongLiuyanService huodongLiuyanService;//活动留言
  67.     @Autowired
  68.     private HuodongYuyueService huodongYuyueService;//活动报名
  69.     @Autowired
  70.     private NewsService newsService;//校园资讯
  71.     @Autowired
  72.     private YonghuService yonghuService;//用户
  73.     @Autowired
  74.     private UsersService usersService;//管理员
  75.     /**
  76.     * 后端列表
  77.     */
  78.     @RequestMapping("/page")
  79.     public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
  80.         logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
  81.         String role = String.valueOf(request.getSession().getAttribute("role"));
  82.         if(false)
  83.             return R.error(511,"永不会进入");
  84.         else if("用户".equals(role))
  85.             params.put("yonghuId",request.getSession().getAttribute("userId"));
  86.         CommonUtil.checkMap(params);
  87.         PageUtils page = examrecordService.queryPage(params);
  88.         //字典表数据转换
  89.         List<ExamrecordView> list =(List<ExamrecordView>)page.getList();
  90.         for(ExamrecordView c:list){
  91.             //修改对应字典表字段
  92.             dictionaryService.dictionaryConvert(c, request);
  93.         }
  94.         return R.ok().put("data", page);
  95.     }
  96.     /**
  97.     * 后端详情
  98.     */
  99.     @RequestMapping("/info/{id}")
  100.     public R info(@PathVariable("id") Long id, HttpServletRequest request){
  101.         logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
  102.         ExamrecordEntity examrecord = examrecordService.selectById(id);
  103.         if(examrecord !=null){
  104.             //entity转view
  105.             ExamrecordView view = new ExamrecordView();
  106.             BeanUtils.copyProperties( examrecord , view );//把实体数据重构到view中
  107.             //级联表 用户
  108.             //级联表
  109.             YonghuEntity yonghu = yonghuService.selectById(examrecord.getYonghuId());
  110.             if(yonghu != null){
  111.             BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
  112.             view.setYonghuId(yonghu.getId());
  113.             }
  114.             //级联表 问卷调查
  115.             //级联表
  116.             ExampaperEntity exampaper = exampaperService.selectById(examrecord.getExampaperId());
  117.             if(exampaper != null){
  118.             BeanUtils.copyProperties( exampaper , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
  119.             view.setExampaperId(exampaper.getId());
  120.             }
  121.             //修改对应字典表字段
  122.             dictionaryService.dictionaryConvert(view, request);
  123.             return R.ok().put("data", view);
  124.         }else {
  125.             return R.error(511,"查不到数据");
  126.         }
  127.     }
  128.     /**
  129.     * 后端保存
  130.     */
  131.     @RequestMapping("/save")
  132.     public R save(@RequestBody ExamrecordEntity examrecord, HttpServletRequest request){
  133.         logger.debug("save方法:,,Controller:{},,examrecord:{}",this.getClass().getName(),examrecord.toString());
  134.         String role = String.valueOf(request.getSession().getAttribute("role"));
  135.         if(false)
  136.             return R.error(511,"永远不会进入");
  137.         else if("用户".equals(role))
  138.             examrecord.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
  139.         Wrapper<ExamrecordEntity> queryWrapper = new EntityWrapper<ExamrecordEntity>()
  140.             .eq("yonghu_id", examrecord.getYonghuId())
  141.             .eq("exampaper_id", examrecord.getExampaperId())
  142.             .eq("total_score", examrecord.getTotalScore())
  143.             ;
  144.         logger.info("sql语句:"+queryWrapper.getSqlSegment());
  145.         ExamrecordEntity examrecordEntity = examrecordService.selectOne(queryWrapper);
  146.         if(examrecordEntity==null){
  147.             examrecord.setInsertTime(new Date());
  148.             examrecord.setCreateTime(new Date());
  149.             examrecordService.insert(examrecord);
  150.             return R.ok();
  151.         }else {
  152.             return R.error(511,"表中有相同数据");
  153.         }
  154.     }
  155.     /**
  156.     * 后端修改
  157.     */
  158.     @RequestMapping("/update")
  159.     public R update(@RequestBody ExamrecordEntity examrecord, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
  160.         logger.debug("update方法:,,Controller:{},,examrecord:{}",this.getClass().getName(),examrecord.toString());
  161.         ExamrecordEntity oldExamrecordEntity = examrecordService.selectById(examrecord.getId());//查询原先数据
  162.         String role = String.valueOf(request.getSession().getAttribute("role"));
  163. //        if(false)
  164. //            return R.error(511,"永远不会进入");
  165. //        else if("用户".equals(role))
  166. //            examrecord.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
  167.             examrecordService.updateById(examrecord);//根据id更新
  168.             return R.ok();
  169.     }
  170.     /**
  171.     * 删除
  172.     */
  173.     @RequestMapping("/delete")
  174.     public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
  175.         logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
  176.         List<ExamrecordEntity> oldExamrecordList =examrecordService.selectBatchIds(Arrays.asList(ids));//要删除的数据
  177.         examrecordService.deleteBatchIds(Arrays.asList(ids));
  178.         return R.ok();
  179.     }
  180.     /**
  181.      * 批量上传
  182.      */
  183.     @RequestMapping("/batchInsert")
  184.     public R save( String fileName, HttpServletRequest request){
  185.         logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
  186.         Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
  187.         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  188.         try {
  189.             List<ExamrecordEntity> examrecordList = new ArrayList<>();//上传的东西
  190.             Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
  191.             Date date = new Date();
  192.             int lastIndexOf = fileName.lastIndexOf(".");
  193.             if(lastIndexOf == -1){
  194.                 return R.error(511,"该文件没有后缀");
  195.             }else{
  196.                 String suffix = fileName.substring(lastIndexOf);
  197.                 if(!".xls".equals(suffix)){
  198.                     return R.error(511,"只支持后缀为xls的excel文件");
  199.                 }else{
  200.                     URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
  201.                     File file = new File(resource.getFile());
  202.                     if(!file.exists()){
  203.                         return R.error(511,"找不到上传文件,请联系管理员");
  204.                     }else{
  205.                         List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
  206.                         dataList.remove(0);//删除第一行,因为第一行是提示
  207.                         for(List<String> data:dataList){
  208.                             //循环
  209.                             ExamrecordEntity examrecordEntity = new ExamrecordEntity();
  210. //                            examrecordEntity.setExamrecordUuidNumber(data.get(0));                    //考试编号 要改的
  211. //                            examrecordEntity.setYonghuId(Integer.valueOf(data.get(0)));   //考试用户 要改的
  212. //                            examrecordEntity.setExampaperId(Integer.valueOf(data.get(0)));   //所属问卷调查id(外键) 要改的
  213. //                            examrecordEntity.setTotalScore(Integer.valueOf(data.get(0)));   //所得总分 要改的
  214. //                            examrecordEntity.setInsertTime(date);//时间
  215. //                            examrecordEntity.setCreateTime(date);//时间
  216.                             examrecordList.add(examrecordEntity);
  217.                             //把要查询是否重复的字段放入map中
  218.                                 //考试编号
  219.                                 if(seachFields.containsKey("examrecordUuidNumber")){
  220.                                     List<String> examrecordUuidNumber = seachFields.get("examrecordUuidNumber");
  221.                                     examrecordUuidNumber.add(data.get(0));//要改的
  222.                                 }else{
  223.                                     List<String> examrecordUuidNumber = new ArrayList<>();
  224.                                     examrecordUuidNumber.add(data.get(0));//要改的
  225.                                     seachFields.put("examrecordUuidNumber",examrecordUuidNumber);
  226.                                 }
  227.                         }
  228.                         //查询是否重复
  229.                          //考试编号
  230.                         List<ExamrecordEntity> examrecordEntities_examrecordUuidNumber = examrecordService.selectList(new EntityWrapper<ExamrecordEntity>().in("examrecord_uuid_number", seachFields.get("examrecordUuidNumber")));
  231.                         if(examrecordEntities_examrecordUuidNumber.size() >0 ){
  232.                             ArrayList<String> repeatFields = new ArrayList<>();
  233.                             for(ExamrecordEntity s:examrecordEntities_examrecordUuidNumber){
  234.                                 repeatFields.add(s.getExamrecordUuidNumber());
  235.                             }
  236.                             return R.error(511,"数据库的该表中的 [考试编号] 字段已经存在 存在数据为:"+repeatFields.toString());
  237.                         }
  238.                         examrecordService.insertBatch(examrecordList);
  239.                         return R.ok();
  240.                     }
  241.                 }
  242.             }
  243.         }catch (Exception e){
  244.             e.printStackTrace();
  245.             return R.error(511,"批量插入数据异常,请联系管理员");
  246.         }
  247.     }
  248.     /**
  249.     * 前端列表
  250.     */
  251.     @IgnoreAuth
  252.     @RequestMapping("/list")
  253.     public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
  254.         logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
  255.         CommonUtil.checkMap(params);
  256.         PageUtils page = examrecordService.queryPage(params);
  257.         //字典表数据转换
  258.         List<ExamrecordView> list =(List<ExamrecordView>)page.getList();
  259.         for(ExamrecordView c:list)
  260.             dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
  261.         return R.ok().put("data", page);
  262.     }
  263.     /**
  264.     * 前端详情
  265.     */
  266.     @RequestMapping("/detail/{id}")
  267.     public R detail(@PathVariable("id") Long id, HttpServletRequest request){
  268.         logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
  269.         ExamrecordEntity examrecord = examrecordService.selectById(id);
  270.             if(examrecord !=null){
  271.                 //entity转view
  272.                 ExamrecordView view = new ExamrecordView();
  273.                 BeanUtils.copyProperties( examrecord , view );//把实体数据重构到view中
  274.                 //级联表
  275.                     YonghuEntity yonghu = yonghuService.selectById(examrecord.getYonghuId());
  276.                 if(yonghu != null){
  277.                     BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
  278.                     view.setYonghuId(yonghu.getId());
  279.                 }
  280.                 //级联表
  281.                     ExampaperEntity exampaper = exampaperService.selectById(examrecord.getExampaperId());
  282.                 if(exampaper != null){
  283.                     BeanUtils.copyProperties( exampaper , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
  284.                     view.setExampaperId(exampaper.getId());
  285.                 }
  286.                 //修改对应字典表字段
  287.                 dictionaryService.dictionaryConvert(view, request);
  288.                 return R.ok().put("data", view);
  289.             }else {
  290.                 return R.error(511,"查不到数据");
  291.             }
  292.     }
  293.     /**
  294.     * 前端保存
  295.     */
  296.     @RequestMapping("/add")
  297.     public R add(@RequestBody ExamrecordEntity examrecord, HttpServletRequest request){
  298.         logger.debug("add方法:,,Controller:{},,examrecord:{}",this.getClass().getName(),examrecord.toString());
  299.         Wrapper<ExamrecordEntity> queryWrapper = new EntityWrapper<ExamrecordEntity>()
  300.             .eq("examrecord_uuid_number", examrecord.getExamrecordUuidNumber())
  301.             .eq("yonghu_id", examrecord.getYonghuId())
  302.             .eq("exampaper_id", examrecord.getExampaperId())
  303.             .eq("total_score", examrecord.getTotalScore())
  304. //            .notIn("examrecord_types", new Integer[]{102})
  305.             ;
  306.         logger.info("sql语句:"+queryWrapper.getSqlSegment());
  307.         ExamrecordEntity examrecordEntity = examrecordService.selectOne(queryWrapper);
  308.         if(examrecordEntity==null){
  309.             examrecord.setInsertTime(new Date());
  310.             examrecord.setCreateTime(new Date());
  311.         examrecordService.insert(examrecord);
  312.             return R.ok();
  313.         }else {
  314.             return R.error(511,"表中有相同数据");
  315.         }
  316.     }
  317. }
复制代码
HuodongYuyueServiceImpl.java

  1. package com.service.impl;
  2. import com.utils.StringUtil;
  3. import com.service.DictionaryService;
  4. import com.utils.ClazzDiff;
  5. import org.springframework.beans.BeanUtils;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.stereotype.Service;
  8. import java.lang.reflect.Field;
  9. import java.util.*;
  10. import com.baomidou.mybatisplus.plugins.Page;
  11. import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  12. import org.springframework.transaction.annotation.Transactional;
  13. import com.utils.PageUtils;
  14. import com.utils.Query;
  15. import org.springframework.web.context.ContextLoader;
  16. import javax.servlet.ServletContext;
  17. import javax.servlet.http.HttpServletRequest;
  18. import org.springframework.lang.Nullable;
  19. import org.springframework.util.Assert;
  20. import com.dao.HuodongYuyueDao;
  21. import com.entity.HuodongYuyueEntity;
  22. import com.service.HuodongYuyueService;
  23. import com.entity.view.HuodongYuyueView;
  24. /**
  25. * 活动报名 服务实现类
  26. */
  27. @Service("huodongYuyueService")
  28. @Transactional
  29. public class HuodongYuyueServiceImpl extends ServiceImpl<HuodongYuyueDao, HuodongYuyueEntity> implements HuodongYuyueService {
  30.     @Override
  31.     public PageUtils queryPage(Map<String,Object> params) {
  32.         Page<HuodongYuyueView> page =new Query<HuodongYuyueView>(params).getPage();
  33.         page.setRecords(baseMapper.selectListView(page,params));
  34.         return new PageUtils(page);
  35.     }
  36. }
复制代码
list.vue

  1. <template>
  2.     <div class="main-content">
  3.         <!-- 列表页 -->
  4.         <div v-if="showFlag">
  5.             <el-form :inline="true" :model="searchForm" class="form-content">
  6.                 <el-row :gutter="20" class="slt" :style="{justifyContent:contents.searchBoxPosition=='1'?'flex-start':contents.searchBoxPosition=='2'?'center':'flex-end'}">
  7.                     <el-form-item label="科目">
  8.                         <el-input prefix-icon="el-icon-search" v-model="searchForm.indexNameSearch" placeholder="科目" clearable></el-input>
  9.                     </el-form-item>
  10.                     <el-form-item>
  11.                         <el-button icon="el-icon-search" type="success" @click="search()">查询</el-button>
  12.                     </el-form-item>
  13.                 </el-row>
  14.                 <el-row class="ad" :style="{justifyContent:contents.btnAdAllBoxPosition=='1'?'flex-start':contents.btnAdAllBoxPosition=='2'?'center':'flex-end'}">
  15.                     <el-form-item>
  16.                         <el-button
  17.                                 v-if="isAuth('dictionaryKemu','新增')"
  18.                                 type="success"
  19.                                 icon="el-icon-plus"
  20.                                 @click="addOrUpdateHandler()"
  21.                         >新增</el-button>
  22.                         <el-button
  23.                                 v-if="isAuth('dictionaryKemu','删除')"
  24.                                 :disabled="dataListSelections.length <= 0"
  25.                                 type="danger"
  26.                                 icon="el-icon-delete"
  27.                                 @click="deleteHandler()"
  28.                         >删除</el-button>
  29.                     </el-form-item>
  30.                 </el-row>
  31.             </el-form>
  32.             <div class="table-content">
  33.                 <el-table class="tables" :size="contents.tableSize" :show-header="contents.tableShowHeader"
  34.                           :header-row-style="headerRowStyle" :header-cell-style="headerCellStyle"
  35.                           :border="contents.tableBorder"
  36.                           :fit="contents.tableFit"
  37.                           :stripe="contents.tableStripe"
  38.                           :row-style="rowStyle"
  39.                           :cell-style="cellStyle"
  40.                           :style="{width: '100%',fontSize:contents.tableContentFontSize,color:contents.tableContentFontColor}"
  41.                           v-if="isAuth('dictionaryKemu','查看')"
  42.                           :data="dataList"
  43.                           v-loading="dataListLoading"
  44.                           @selection-change="selectionChangeHandler">
  45.                     <el-table-column  v-if="contents.tableSelection"
  46.                                       type="selection"
  47.                                       header-align="center"
  48.                                       align="center"
  49.                                       width="50">
  50.                     </el-table-column>
  51.                     <el-table-column label="索引" v-if="contents.tableIndex" type="index" width="50" />
  52.                     <el-table-column  :sortable="contents.tableSortable" :align="contents.tableAlign"
  53.                                       prop="codeIndex"
  54.                                       header-align="center"
  55.                                       label="科目编码">
  56.                         <template slot-scope="scope">
  57.                             {{scope.row.codeIndex}}
  58.                         </template>
  59.                     </el-table-column>
  60.                     <el-table-column  :sortable="contents.tableSortable" :align="contents.tableAlign"
  61.                                       prop="indexName"
  62.                                       header-align="center"
  63.                                       label="科目名称">
  64.                         <template slot-scope="scope">
  65.                             {{scope.row.indexName}}
  66.                         </template>
  67.                     </el-table-column>
  68.                     <!--<el-table-column  :sortable="contents.tableSortable" :align="contents.tableAlign"
  69.                                       prop="beizhu"
  70.                                       header-align="center"
  71.                                       label="备注">
  72.                         <template slot-scope="scope">
  73.                             {{scope.row.beizhu}}
  74.                         </template>
  75.                     </el-table-column>-->
  76.                     <el-table-column width="300" :align="contents.tableAlign"
  77.                                      header-align="center"
  78.                                      label="操作">
  79.                         <template slot-scope="scope">
  80.                             <el-button v-if="isAuth('dictionaryKemu','查看')" type="success" icon="el-icon-tickets" size="mini" @click="addOrUpdateHandler(scope.row.id,'info')">详情</el-button>
  81.                             <el-button v-if="isAuth('dictionaryKemu','修改')" type="primary" icon="el-icon-edit" size="mini" @click="addOrUpdateHandler(scope.row.id)">修改</el-button>
  82.                             <el-button v-if="isAuth('dictionaryKemu','删除')" type="danger" icon="el-icon-delete" size="mini" @click="deleteHandler(scope.row.id)">删除</el-button>
  83.                         </template>
  84.                     </el-table-column>
  85.                 </el-table>
  86.                 <el-pagination
  87.                         clsss="pages"
  88.                         :layout="layouts"
  89.                         @size-change="sizeChangeHandle"
  90.                         @current-change="currentChangeHandle"
  91.                         :current-page="pageIndex"
  92.                         :page-sizes="[10, 20, 50, 100]"
  93.                         :page-size="Number(contents.pageEachNum)"
  94.                         :total="totalPage"
  95.                         :small="contents.pageStyle"
  96.                         class="pagination-content"
  97.                         :background="contents.pageBtnBG"
  98.                         :style="{textAlign:contents.pagePosition==1?'left':contents.pagePosition==2?'center':'right'}"
  99.                 ></el-pagination>
  100.             </div>
  101.         </div>
  102.         <!-- 添加/修改页面  将父组件的search方法传递给子组件-->
  103.         <add-or-update v-if="addOrUpdateFlag" :parent="this" ref="addOrUpdate"></add-or-update>
  104.     </div>
  105. </template>
  106. <script>
  107.     import AddOrUpdate from "./add-or-update";
  108.     import styleJs from "../../../utils/style.js";
  109.     export default {
  110.         data() {
  111.             return {
  112.                 searchForm: {
  113.                     key: ""
  114.                 },
  115.                 form:{},
  116.                 dataList: [],
  117.                 pageIndex: 1,
  118.                 pageSize: 10,
  119.                 totalPage: 0,
  120.                 dataListLoading: false,
  121.                 dataListSelections: [],
  122.                 showFlag: true,
  123.                 sfshVisiable: false,
  124.                 shForm: {},
  125.                 chartVisiable: false,
  126.                 addOrUpdateFlag:false,
  127.                 contents:null,
  128.                 layouts: '',
  129.             };
  130.         },
  131.         created() {
  132.             this.contents = styleJs.listStyle();
  133.             this.init();
  134.             this.getDataList();
  135.             this.contentStyleChange()
  136.         },
  137.         mounted() {
  138.         },
  139.         filters: {
  140.             htmlfilter: function (val) {
  141.                 return val.replace(/<[^>]*>/g).replace(/undefined/g,'');
  142.             }
  143.         },
  144.         components: {
  145.             AddOrUpdate,
  146.         },
  147.         methods: {
  148.             contentStyleChange() {
  149.                 this.contentSearchStyleChange()
  150.                 this.contentBtnAdAllStyleChange()
  151.                 this.contentSearchBtnStyleChange()
  152.                 this.contentTableBtnStyleChange()
  153.                 this.contentPageStyleChange()
  154.             },
  155.             contentSearchStyleChange() {
  156.                 this.$nextTick(()=>{
  157.                     document.querySelectorAll('.form-content .slt .el-input__inner').forEach(el=>{
  158.                     let textAlign = 'left'
  159.                     if(this.contents.inputFontPosition == 2) textAlign = 'center'
  160.                 if(this.contents.inputFontPosition == 3) textAlign = 'right'
  161.                 el.style.textAlign = textAlign
  162.                 el.style.height = this.contents.inputHeight
  163.                 el.style.lineHeight = this.contents.inputHeight
  164.                 el.style.color = this.contents.inputFontColor
  165.                 el.style.fontSize = this.contents.inputFontSize
  166.                 el.style.borderWidth = this.contents.inputBorderWidth
  167.                 el.style.borderStyle = this.contents.inputBorderStyle
  168.                 el.style.borderColor = this.contents.inputBorderColor
  169.                 el.style.borderRadius = this.contents.inputBorderRadius
  170.                 el.style.backgroundColor = this.contents.inputBgColor
  171.             })
  172.                 if(this.contents.inputTitle) {
  173.                     document.querySelectorAll('.form-content .slt .el-form-item__label').forEach(el=>{
  174.                         el.style.color = this.contents.inputTitleColor
  175.                     el.style.fontSize = this.contents.inputTitleSize
  176.                     el.style.lineHeight = this.contents.inputHeight
  177.                 })
  178.                 }
  179.                 setTimeout(()=>{
  180.                     document.querySelectorAll('.form-content .slt .el-input__prefix').forEach(el=>{
  181.                     el.style.color = this.contents.inputIconColor
  182.                 el.style.lineHeight = this.contents.inputHeight
  183.             })
  184.                 document.querySelectorAll('.form-content .slt .el-input__suffix').forEach(el=>{
  185.                     el.style.color = this.contents.inputIconColor
  186.                 el.style.lineHeight = this.contents.inputHeight
  187.             })
  188.                 document.querySelectorAll('.form-content .slt .el-input__icon').forEach(el=>{
  189.                     el.style.lineHeight = this.contents.inputHeight
  190.             })
  191.             },10)
  192.             })
  193.             },
  194.             // 搜索按钮
  195.             contentSearchBtnStyleChange() {
  196.                 this.$nextTick(()=>{
  197.                     document.querySelectorAll('.form-content .slt .el-button--success').forEach(el=>{
  198.                     el.style.height = this.contents.searchBtnHeight
  199.                 el.style.color = this.contents.searchBtnFontColor
  200.                 el.style.fontSize = this.contents.searchBtnFontSize
  201.                 el.style.borderWidth = this.contents.searchBtnBorderWidth
  202.                 el.style.borderStyle = this.contents.searchBtnBorderStyle
  203.                 el.style.borderColor = this.contents.searchBtnBorderColor
  204.                 el.style.borderRadius = this.contents.searchBtnBorderRadius
  205.                 el.style.backgroundColor = this.contents.searchBtnBgColor
  206.             })
  207.             })
  208.             },
  209.             // 新增、批量删除
  210.             contentBtnAdAllStyleChange() {
  211.                 this.$nextTick(()=>{
  212.                     document.querySelectorAll('.form-content .ad .el-button--success').forEach(el=>{
  213.                     el.style.height = this.contents.btnAdAllHeight
  214.                 el.style.color = this.contents.btnAdAllAddFontColor
  215.                 el.style.fontSize = this.contents.btnAdAllFontSize
  216.                 el.style.borderWidth = this.contents.btnAdAllBorderWidth
  217.                 el.style.borderStyle = this.contents.btnAdAllBorderStyle
  218.                 el.style.borderColor = this.contents.btnAdAllBorderColor
  219.                 el.style.borderRadius = this.contents.btnAdAllBorderRadius
  220.                 el.style.backgroundColor = this.contents.btnAdAllAddBgColor
  221.             })
  222.                 document.querySelectorAll('.form-content .ad .el-button--danger').forEach(el=>{
  223.                     el.style.height = this.contents.btnAdAllHeight
  224.                 el.style.color = this.contents.btnAdAllDelFontColor
  225.                 el.style.fontSize = this.contents.btnAdAllFontSize
  226.                 el.style.borderWidth = this.contents.btnAdAllBorderWidth
  227.                 el.style.borderStyle = this.contents.btnAdAllBorderStyle
  228.                 el.style.borderColor = this.contents.btnAdAllBorderColor
  229.                 el.style.borderRadius = this.contents.btnAdAllBorderRadius
  230.                 el.style.backgroundColor = this.contents.btnAdAllDelBgColor
  231.             })
  232.                 document.querySelectorAll('.form-content .ad .el-button--warning').forEach(el=>{
  233.                     el.style.height = this.contents.btnAdAllHeight
  234.                 el.style.color = this.contents.btnAdAllWarnFontColor
  235.                 el.style.fontSize = this.contents.btnAdAllFontSize
  236.                 el.style.borderWidth = this.contents.btnAdAllBorderWidth
  237.                 el.style.borderStyle = this.contents.btnAdAllBorderStyle
  238.                 el.style.borderColor = this.contents.btnAdAllBorderColor
  239.                 el.style.borderRadius = this.contents.btnAdAllBorderRadius
  240.                 el.style.backgroundColor = this.contents.btnAdAllWarnBgColor
  241.             })
  242.             })
  243.             },
  244.             // 表格
  245.             rowStyle({ row, rowIndex}) {
  246.                 if (rowIndex % 2 == 1) {
  247.                     if(this.contents.tableStripe) {
  248.                         return {color:this.contents.tableStripeFontColor}
  249.                     }
  250.                 } else {
  251.                     return ''
  252.                 }
  253.             },
  254.             cellStyle({ row, rowIndex}){
  255.                 if (rowIndex % 2 == 1) {
  256.                     if(this.contents.tableStripe) {
  257.                         return {backgroundColor:this.contents.tableStripeBgColor}
  258.                     }
  259.                 } else {
  260.                     return ''
  261.                 }
  262.             },
  263.             headerRowStyle({ row, rowIndex}){
  264.                 return {color: this.contents.tableHeaderFontColor}
  265.             },
  266.             headerCellStyle({ row, rowIndex}){
  267.                 return {backgroundColor: this.contents.tableHeaderBgColor}
  268.             },
  269.             // 表格按钮
  270.             contentTableBtnStyleChange(){
  271.             },
  272.             // 分页
  273.             contentPageStyleChange(){
  274.                 let arr = []
  275.                 if(this.contents.pageTotal) arr.push('total')
  276.                 if(this.contents.pageSizes) arr.push('sizes')
  277.                 if(this.contents.pagePrevNext){
  278.                     arr.push('prev')
  279.                     if(this.contents.pagePager) arr.push('pager')
  280.                     arr.push('next')
  281.                 }
  282.                 if(this.contents.pageJumper) arr.push('jumper')
  283.                 this.layouts = arr.join()
  284.                 this.contents.pageEachNum = 10
  285.             },
  286.             init () {
  287.             },
  288.             search() {
  289.                 this.pageIndex = 1;
  290.                 this.getDataList();
  291.             },
  292.             // 获取数据列表
  293.             getDataList() {
  294.                 this.dataListLoading = true;
  295.                 let params = {
  296.                     page: this.pageIndex,
  297.                     limit: this.pageSize,
  298.                     sort: 'id',
  299.                 }
  300.                 if(this.searchForm.indexNameSearch!='' && this.searchForm.indexNameSearch!=undefined){
  301.                     params['indexName'] = this.searchForm.indexNameSearch
  302.                 }
  303.                 //本表的
  304.                 params['dicCode'] = "kemu_types"//编码名字
  305.                 params['dicName'] = "科目",//汉字名字
  306.                 this.$http({
  307.                     url: "dictionary/page",
  308.                     method: "get",
  309.                     params: params
  310.                 }).then(({ data }) => {
  311.                     if (data && data.code === 0) {
  312.                     this.dataList = data.data.list;
  313.                     this.totalPage = data.data.total;
  314.                 } else {
  315.                     this.dataList = [];
  316.                     this.totalPage = 0;
  317.                 }
  318.                 this.dataListLoading = false;
  319.             });
  320.             },
  321.             // 每页数
  322.             sizeChangeHandle(val) {
  323.                 this.pageSize = val;
  324.                 this.pageIndex = 1;
  325.                 this.getDataList();
  326.             },
  327.             // 当前页
  328.             currentChangeHandle(val) {
  329.                 this.pageIndex = val;
  330.                 this.getDataList();
  331.             },
  332.             // 多选
  333.             selectionChangeHandler(val) {
  334.                 this.dataListSelections = val;
  335.             },
  336.             // 添加/修改
  337.             addOrUpdateHandler(id,type) {
  338.                 this.showFlag = false;
  339.                 this.addOrUpdateFlag = true;
  340.                 this.crossAddOrUpdateFlag = false;
  341.                 if(type!='info'){
  342.                     type = 'else';
  343.                 }
  344.                 this.$nextTick(() => {
  345.                     this.$refs.addOrUpdate.init(id,type);
  346.             });
  347.             },
  348.             // 删除
  349.             deleteHandler(id) {
  350.                 var ids = id
  351.                         ? [Number(id)]
  352.                         : this.dataListSelections.map(item => {
  353.                     return Number(item.id);
  354.             });
  355.                 this.$confirm(`确定进行[${id ? "删除" : "批量删除"}]操作?`, "提示", {
  356.                     confirmButtonText: "确定",
  357.                     cancelButtonText: "取消",
  358.                     type: "warning"
  359.                 }).then(() => {
  360.                     this.$http({
  361.                     url: "dictionary/delete",
  362.                     method: "post",
  363.                     data: ids
  364.                 }).then(({ data }) => {
  365.                     if (data && data.code === 0) {
  366.                     this.$message({
  367.                         message: "操作成功",
  368.                         type: "success",
  369.                         duration: 1500,
  370.                         onClose: () => {
  371.                         this.search();
  372.                 }
  373.                 });
  374.                 } else {
  375.                     this.$message.error(data.msg);
  376.                 }
  377.             });
  378.             });
  379.             },
  380.         }
  381.     };
  382. </script>
  383. <style lang="scss" scoped>
  384. .slt {
  385.     margin: 0 !important;
  386.     display: flex;
  387.   }
  388.   .ad {
  389.     margin: 0 !important;
  390.     display: flex;
  391.   }
  392.   .pages {
  393.     & /deep/ el-pagination__sizes{
  394.       & /deep/ el-input__inner {
  395.         height: 22px;
  396.         line-height: 22px;
  397.       }
  398.     }
  399.   }
  400.   
  401.   .el-button+.el-button {
  402.     margin:0;
  403.   }
  404.   .tables {
  405.         & /deep/ .el-button--success {
  406.                 height: 40px;
  407.                 color: #333;
  408.                 font-size: 14px;
  409.                 border-width: 1px;
  410.                 border-style: solid;
  411.                 border-color: #DCDFE6;
  412.                 border-radius: 4px;
  413.                 background-color: var(--publicMainColor);
  414.         }
  415.         & /deep/ .el-button--primary {
  416.                 height: 40px;
  417.                 color: #333;
  418.                 font-size: 14px;
  419.                 border-width: 1px;
  420.                 border-style: solid;
  421.                 border-color: #DCDFE6;
  422.                 border-radius: 4px;
  423.                 background-color: rgba(102, 204, 255, 1);
  424.         }
  425.         & /deep/ .el-button--danger {
  426.                 height: 40px;
  427.                 color: #333;
  428.                 font-size: 14px;
  429.                 border-width: 1px;
  430.                 border-style: solid;
  431.                 border-color: #DCDFE6;
  432.                 border-radius: 4px;
  433.                 background-color: rgba(204, 255, 102, 1);
  434.         }
  435.     & /deep/ .el-button {
  436.       margin: 4px;
  437.     }
  438.   }</style>
复制代码
声明

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

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

正序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

万万哇

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表