当前位置:   article > 正文

基于springboot+vue在线教育系统源码和论文_springboot+vue论文

springboot+vue论文

计算机技术不断进步的过程中,各个行业已经离不开计算机的应用,例如在信息管理、在线学习等方面处处都是计算机的身影。随着在线教育逐步的推广与普及,各教育机构以及学生个人等,也逐步采用了专门的在线学习系统来授课或学习。在线学习系统是实现教育信息化的重要过程,其能够对学习质量的提升起到较为显著的效果,也为企业内部的学习资源获取提供了更多的途径。

论文主要围绕在线教育系统的设计与实现展开研究,遵循软件工程设计流程,在需求分析的基础上,明确了在线教育平台的各项功能。利用springboot、 mybatis等技术,设计实现了一个基于B/S模式的在线教育平台,提供一站学习平台,平台内会发布课程,课程包括免费课程和VIP课程,提供签到获取金币机制,金币用于兑换学习资料,平台内可发布技术文章或书单推荐,还包括课程预告和线下班报名功能;管理后台包括用户管理、课程管理、营销管理、审核管理四大模块,并对该平台的各个功能模块进行测试。所设计的用户操作界面布局合理、交互友好。

关键字: 在线教育;B/S模式;springboot;mysql

【730】基于springboot+vue在线教育系统源码和论文含测试报告

ABSTRACT

In the process of continuous progress of computer technology, various industries have been inseparable from the application of computers, such as information management, online learning and so on. With the gradual promotion and popularization of online education, various educational institutions and individual students have also gradually adopted special online learning systems to teach or learn. Online learning system is an important process to realize education informatization, which can play a more significant role in improving the quality of learning, and also provides more ways to obtain learning resources within the enterprise.

The paper mainly focuses on the design and implementation of online education system, follows the software engineering design process, and clarifies the functions of online education platform on the basis of demand analysis. By using spring boot, mybatis and other technologies, an online education platform based on B/S mode is designed and implemented, which provides a one-stop learning platform. The platform will release courses, including free courses and VIP courses, and a mechanism to sign in and obtain gold coins. Gold coins are used to exchange learning materials. The platform can release technical articles or book list recommendations, and also includes the function of course preview and online off duty registration; The management background includes four modules: user management, course management, marketing management and audit management, and tests each functional module of the platform. The user interface designed is reasonable in layout and friendly in interaction.

Keywords: online education; B/S mode; springboot; mysql

表5-1 权限表

编号

字段名

类型

长度

可否为空

是否主键

默认值

说明

1

auth_id

int

10

非空

自增

权限ID

2

auth_name

varchar

30

非空

权限名称

3

auth_url

varchar

50

非空

权限路径

4

auth_time

timestamp

非空

添加时间

5

auth_describe

varchar

300

非空

描述

  1. 管理员表用来记录地球云教育后台管理员信息

表5-2 管理员表

编号

字段名

类型

长度

可否为空

是否主键

默认值

说明

1

manager_id

int

10

非空

自增

管理员id

2

manager_account

varchar

30

非空

管理员账户

3

manager_name

varchar

30

非空

管理员姓名

4

manager_password

varchar

30

非空

密码

5

manager_gender

varchar

6

非空

性别

6

manager_phone

varchar

11

非空

手机号

7

register_time

timestamp

非空

创建时间

8

login_time

timestamp

非空

登录时间

9

manager_state

tinyint

1

非空

1

用户状态

10

avatar_url

varchar

200

非空

头像

11

department_id

int

10

非空

部门id

12

department_name

varchar

30

非空

部门名称

13

id_card

varchar

18

非空

身份证

14

update_time

timestamp

非空

修改时间

  1. 部门表用来记录企业中所有的部门信息。

表5-4 部门表

编号

字段名

类型

长度

可否为空

是否主键

默认值

说明

1

department_id

int

10

非空

自增

部门id

2

department_name

varchar

30

非空

部门名称

3

description

varchar

300

非空

部门描述

4

update_time

timestamp

非空

修改时间

  1. 课程类别表用来记录课程类别

表5-5 课程类别表

编号

字段名

类型

长度

可否为空

是否主键

默认值

说明

1

type_id

int

10

非空

自增

类别id

2

type_name

varchar

30

非空

类别名称

3

description

varchar

300

非空

类别描述

  1. 课程表用来存放视频课程信息

表5-6课程表

编号

字段名

类型

长度

可否为空

是否主键

默认值

说明

1

course_id

int

10

非空

自增

课程id

2

course_name

varchar

30

非空

课程名称

3

type_id

int

10

非空

类别表

类别id

4

type_name

varchar

30

非空

类别表

类别名称

5

description

varchar

300

非空

课程简介

6

teacher_id

int

10

非空

讲师id

7

time_length

varchar

10

非空

课程时长

8

vip_state

tinyint

1

非空

是否VIP

9

publish_state

tinyint

1

非空

0

发布状态

10

audit_state

tinyint

1

非空

0

审核状态

11

put_time

timestamp

非空

上架时间

12

update_time

timestamp

非空

修改时间

13

cover_url

varchar

200

非空

课程封面

14

play_count

int

10

非空

0

播放量

15

publisher

varchar

30

非空

发布人

16

publisher_id

int

10

非空

发布人id

17

online

tinyint

1

非空

是否线上

18

price

double

允许

价格

  1. 课程目录表用来存放课程的目录

表5-7课程目录表

编号

字段名

类型

长度

可否为空

是否主键

默认值

说明

1

list_id

int

10

非空

自增

课程目录id

2

list_name

varchar

30

非空

课程目录名称

4

course_id

int

10

非空

课程id

5

video_url

varchar

200

非空

视频url

6

time_length

varchar

10

非空

视频时长

7

lock_state

tinyint

1

非空

是否锁定

  1. 讲师表用来记录课程中讲课老师的信息

表5-8讲师表

编号

字段名

类型

长度

可否为空

是否主键

默认值

说明

1

teacher_id

int

10

非空

讲师id

2

teacher_name

varchar

30

非空

讲师姓名

3

description

varchar

300

非空

讲师介绍

4

avatar_url

varchar

200

非空

头像

5

teacher_gender

varchar

6

非空

性别

6

teacher_phone

varchar

11

非空

讲师电话

7

id_card

varchar

18

非空

身份证

8

entry_time

timestamp

非空

入职时间

9

leave_time

timestamp

非空

离职时间

  1. 文章表用来记录锦囊模块中的文章信息 

 

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <groupId>top.qiudb</groupId>
  6. <artifactId>breadroll-education</artifactId>
  7. <version>0.0.1-SNAPSHOT</version>
  8. <name>breadroll-education</name>
  9. <description>Demo project for Spring Boot</description>
  10. <properties>
  11. <java.version>1.8</java.version>
  12. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  13. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  14. <spring-boot.version>2.3.7.RELEASE</spring-boot.version>
  15. </properties>
  16. <dependencies>
  17. <!--web-->
  18. <dependency>
  19. <groupId>org.springframework.boot</groupId>
  20. <artifactId>spring-boot-starter-web</artifactId>
  21. </dependency>
  22. <!--thymeleaf-->
  23. <dependency>
  24. <groupId>org.springframework.boot</groupId>
  25. <artifactId>spring-boot-starter-thymeleaf</artifactId>
  26. </dependency>
  27. <!-- Sa-Token 权限认证, 在线文档:http://sa-token.dev33.cn/ -->
  28. <dependency>
  29. <groupId>cn.dev33</groupId>
  30. <artifactId>sa-token-spring-boot-starter</artifactId>
  31. <version>1.18.0</version>
  32. </dependency>
  33. <!-- sa-token整合redis (使用jdk默认序列化方式) -->
  34. <dependency>
  35. <groupId>cn.dev33</groupId>
  36. <artifactId>sa-token-dao-redis</artifactId>
  37. <version>1.18.0</version>
  38. </dependency>
  39. <!-- 提供redis连接池 -->
  40. <dependency>
  41. <groupId>org.apache.commons</groupId>
  42. <artifactId>commons-pool2</artifactId>
  43. </dependency>
  44. <!-- https://mvnrepository.com/artifact/com.github.ulisesbocchio/jasypt-spring-boot-starter -->
  45. <dependency>
  46. <groupId>com.github.ulisesbocchio</groupId>
  47. <artifactId>jasypt-spring-boot-starter</artifactId>
  48. <version>3.0.3</version>
  49. </dependency>
  50. <!--lombok-->
  51. <dependency>
  52. <groupId>org.projectlombok</groupId>
  53. <artifactId>lombok</artifactId>
  54. </dependency>
  55. <!-- redis -->
  56. <dependency>
  57. <groupId>org.springframework.boot</groupId>
  58. <artifactId>spring-boot-starter-data-redis</artifactId>
  59. </dependency>
  60. <!--mysql-->
  61. <dependency>
  62. <groupId>mysql</groupId>
  63. <artifactId>mysql-connector-java</artifactId>
  64. <version>5.1.47</version>
  65. </dependency>
  66. <!--整合mybatis-->
  67. <dependency>
  68. <groupId>org.mybatis.spring.boot</groupId>
  69. <artifactId>mybatis-spring-boot-starter</artifactId>
  70. <version>1.3.3</version>
  71. </dependency>
  72. <!--druid-->
  73. <dependency>
  74. <groupId>com.alibaba</groupId>
  75. <artifactId>druid</artifactId>
  76. <version>1.1.12</version>
  77. </dependency>
  78. <!-- 阿里短信依赖 -->
  79. <dependency>
  80. <groupId>com.aliyun</groupId>
  81. <artifactId>aliyun-java-sdk-core</artifactId>
  82. <version>4.4.6</version>
  83. </dependency>
  84. <dependency>
  85. <groupId>com.aliyun</groupId>
  86. <artifactId>aliyun-java-sdk-dysmsapi</artifactId>
  87. <version>2.1.0</version>
  88. </dependency>
  89. <!-- fastjson -->
  90. <dependency>
  91. <groupId>com.alibaba</groupId>
  92. <artifactId>fastjson</artifactId>
  93. <version>1.2.62</version>
  94. </dependency>
  95. <!--工具类-->
  96. <dependency>
  97. <groupId>com.github.shalousun</groupId>
  98. <artifactId>common-util</artifactId>
  99. <version>1.9.2</version>
  100. </dependency>
  101. <!-- alipay-sdk-java 依赖 -->
  102. <dependency>
  103. <groupId>com.alipay.sdk</groupId>
  104. <artifactId>alipay-sdk-java</artifactId>
  105. <version>4.10.192.ALL</version>
  106. </dependency>
  107. <!-- jave -->
  108. <dependency>
  109. <groupId>it.sauronsoftware</groupId>
  110. <artifactId>jave</artifactId>
  111. <version>1.0.2</version>
  112. <!-- 下面两个是使用system在pom.xml中导入jar -->
  113. <scope>system</scope>
  114. <systemPath>${project.basedir}/src/main/resources/lib/jave-1.0.2.jar</systemPath>
  115. </dependency>
  116. <!--mail-->
  117. <dependency>
  118. <groupId>org.springframework.boot</groupId>
  119. <artifactId>spring-boot-starter-mail</artifactId>
  120. </dependency>
  121. <!-- swagger2 -->
  122. <dependency>
  123. <groupId>io.springfox</groupId>
  124. <artifactId>springfox-swagger2</artifactId>
  125. <version>2.9.2</version>
  126. </dependency>
  127. <!-- 引入swagger-bootstrap-ui包 /doc.html-->
  128. <dependency>
  129. <groupId>com.github.xiaoymin</groupId>
  130. <artifactId>swagger-bootstrap-ui</artifactId>
  131. <version>1.9.1</version>
  132. </dependency>
  133. <!--page helper-->
  134. <dependency>
  135. <groupId>com.github.pagehelper</groupId>
  136. <artifactId>pagehelper-spring-boot-starter</artifactId>
  137. <version>1.2.3</version>
  138. </dependency>
  139. <!--markdown转html-->
  140. <dependency>
  141. <groupId>com.atlassian.commonmark</groupId>
  142. <artifactId>commonmark</artifactId>
  143. <version>0.10.0</version>
  144. </dependency>
  145. <dependency>
  146. <groupId>com.atlassian.commonmark</groupId>
  147. <artifactId>commonmark-ext-autolink</artifactId>
  148. <version>0.10.0</version>
  149. </dependency>
  150. <dependency>
  151. <groupId>com.atlassian.commonmark</groupId>
  152. <artifactId>commonmark-ext-gfm-tables</artifactId>
  153. <version>0.10.0</version>
  154. </dependency>
  155. <dependency>
  156. <groupId>com.atlassian.commonmark</groupId>
  157. <artifactId>commonmark-ext-gfm-strikethrough</artifactId>
  158. <version>0.10.0</version>
  159. </dependency>
  160. <dependency>
  161. <groupId>com.atlassian.commonmark</groupId>
  162. <artifactId>commonmark-ext-heading-anchor</artifactId>
  163. <version>0.10.0</version>
  164. </dependency>
  165. <!--test-->
  166. <dependency>
  167. <groupId>org.springframework.boot</groupId>
  168. <artifactId>spring-boot-starter-test</artifactId>
  169. <scope>test</scope>
  170. <exclusions>
  171. <exclusion>
  172. <groupId>org.junit.vintage</groupId>
  173. <artifactId>junit-vintage-engine</artifactId>
  174. </exclusion>
  175. </exclusions>
  176. </dependency>
  177. </dependencies>
  178. <dependencyManagement>
  179. <dependencies>
  180. <dependency>
  181. <groupId>org.springframework.boot</groupId>
  182. <artifactId>spring-boot-dependencies</artifactId>
  183. <version>${spring-boot.version}</version>
  184. <type>pom</type>
  185. <scope>import</scope>
  186. </dependency>
  187. </dependencies>
  188. </dependencyManagement>
  189. <build>
  190. <finalName>breadroll-education</finalName>
  191. <plugins>
  192. <plugin>
  193. <groupId>com.github.ulisesbocchio</groupId>
  194. <artifactId>jasypt-maven-plugin</artifactId>
  195. <version>3.0.2</version>
  196. </plugin>
  197. <plugin>
  198. <groupId>org.apache.maven.plugins</groupId>
  199. <artifactId>maven-compiler-plugin</artifactId>
  200. <version>3.8.1</version>
  201. <configuration>
  202. <source>1.8</source>
  203. <target>1.8</target>
  204. <encoding>UTF-8</encoding>
  205. </configuration>
  206. </plugin>
  207. <plugin>
  208. <groupId>org.springframework.boot</groupId>
  209. <artifactId>spring-boot-maven-plugin</artifactId>
  210. <version>2.3.7.RELEASE</version>
  211. <configuration>
  212. <mainClass>top.qiudb.BreadrollEducationApplication</mainClass>
  213. <!--将本地使用的jar打包的时候引入lib-->
  214. <includeSystemScope>true</includeSystemScope>
  215. </configuration>
  216. <executions>
  217. <execution>
  218. <id>repackage</id>
  219. <goals>
  220. <goal>repackage</goal>
  221. </goals>
  222. </execution>
  223. </executions>
  224. </plugin>
  225. </plugins>
  226. </build>
  227. <!--V 2630663675-->
  228. <repositories>
  229. <repository>
  230. <id>maven-ali</id>
  231. <url>http://maven.aliyun.com/nexus/content/groups/public//</url>
  232. <releases>
  233. <enabled>true</enabled>
  234. </releases>
  235. <snapshots>
  236. <enabled>true</enabled>
  237. <updatePolicy>always</updatePolicy>
  238. <checksumPolicy>fail</checksumPolicy>
  239. </snapshots>
  240. </repository>
  241. </repositories>
  242. </project>
  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("/yuangong")
  40. public class YuangongController {
  41. private static final Logger logger = LoggerFactory.getLogger(YuangongController.class);
  42. private static final String TABLE_NAME = "yuangong";
  43. @Autowired
  44. private YuangongService yuangongService;
  45. @Autowired
  46. private TokenService tokenService;
  47. @Autowired
  48. private DanganService danganService;//档案
  49. @Autowired
  50. private DictionaryService dictionaryService;//字典
  51. @Autowired
  52. private GonggaoService gonggaoService;//公告
  53. @Autowired
  54. private MenuService menuService;//菜单
  55. @Autowired
  56. private QiandaoService qiandaoService;//员工签到
  57. @Autowired
  58. private XinziService xinziService;//薪资
  59. @Autowired
  60. private YuangongchuchaiService yuangongchuchaiService;//员工出差
  61. @Autowired
  62. private YuangongqingjiaService yuangongqingjiaService;//员工请假
  63. @Autowired
  64. private UsersService usersService;//管理员
  65. /**
  66. * 后端列表
  67. */
  68. @RequestMapping("/page")
  69. public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
  70. logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
  71. String role = String.valueOf(request.getSession().getAttribute("role"));
  72. if(false)
  73. return R.error(511,"永不会进入");
  74. else if("员工".equals(role))
  75. params.put("yuangongId",request.getSession().getAttribute("userId"));
  76. CommonUtil.checkMap(params);
  77. PageUtils page = yuangongService.queryPage(params);
  78. //字典表数据转换
  79. List<YuangongView> list =(List<YuangongView>)page.getList();
  80. for(YuangongView c:list){
  81. //修改对应字典表字段
  82. dictionaryService.dictionaryConvert(c, request);
  83. }
  84. return R.ok().put("data", page);
  85. }
  86. /**
  87. * 后端详情
  88. */
  89. @RequestMapping("/info/{id}")
  90. public R info(@PathVariable("id") Long id, HttpServletRequest request){
  91. logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
  92. YuangongEntity yuangong = yuangongService.selectById(id);
  93. if(yuangong !=null){
  94. //entity转view
  95. YuangongView view = new YuangongView();
  96. BeanUtils.copyProperties( yuangong , view );//把实体数据重构到view中
  97. //修改对应字典表字段
  98. dictionaryService.dictionaryConvert(view, request);
  99. return R.ok().put("data", view);
  100. }else {
  101. return R.error(511,"查不到数据");
  102. }
  103. }
  104. /**
  105. * 后端保存
  106. */
  107. @RequestMapping("/save")
  108. public R save(@RequestBody YuangongEntity yuangong, HttpServletRequest request){
  109. logger.debug("save方法:,,Controller:{},,yuangong:{}",this.getClass().getName(),yuangong.toString());
  110. String role = String.valueOf(request.getSession().getAttribute("role"));
  111. if(false)
  112. return R.error(511,"永远不会进入");
  113. Wrapper<YuangongEntity> queryWrapper = new EntityWrapper<YuangongEntity>()
  114. .eq("username", yuangong.getUsername())
  115. .or()
  116. .eq("yuangong_phone", yuangong.getYuangongPhone())
  117. .or()
  118. .eq("yuangong_id_number", yuangong.getYuangongIdNumber())
  119. ;
  120. logger.info("sql语句:"+queryWrapper.getSqlSegment());
  121. YuangongEntity yuangongEntity = yuangongService.selectOne(queryWrapper);
  122. if(yuangongEntity==null){
  123. yuangong.setCreateTime(new Date());
  124. yuangong.setPassword("123456");
  125. yuangongService.insert(yuangong);
  126. return R.ok();
  127. }else {
  128. return R.error(511,"账户或者员工手机号或者员工身份证号已经被使用");
  129. }
  130. }
  131. /**
  132. * 后端修改
  133. */
  134. @RequestMapping("/update")
  135. public R update(@RequestBody YuangongEntity yuangong, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
  136. logger.debug("update方法:,,Controller:{},,yuangong:{}",this.getClass().getName(),yuangong.toString());
  137. YuangongEntity oldYuangongEntity = yuangongService.selectById(yuangong.getId());//查询原先数据
  138. String role = String.valueOf(request.getSession().getAttribute("role"));
  139. // if(false)
  140. // return R.error(511,"永远不会进入");
  141. if("".equals(yuangong.getYuangongPhoto()) || "null".equals(yuangong.getYuangongPhoto())){
  142. yuangong.setYuangongPhoto(null);
  143. }
  144. yuangongService.updateById(yuangong);//根据id更新
  145. return R.ok();
  146. }
  147. /**
  148. * 删除
  149. */
  150. @RequestMapping("/delete")
  151. public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
  152. logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
  153. List<YuangongEntity> oldYuangongList =yuangongService.selectBatchIds(Arrays.asList(ids));//要删除的数据
  154. yuangongService.deleteBatchIds(Arrays.asList(ids));
  155. return R.ok();
  156. }
  157. /**
  158. * 批量上传
  159. */
  160. @RequestMapping("/batchInsert")
  161. public R save( String fileName, HttpServletRequest request){
  162. logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
  163. Integer yuangongId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
  164. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  165. //.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
  166. try {
  167. List<YuangongEntity> yuangongList = new ArrayList<>();//上传的东西
  168. Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
  169. Date date = new Date();
  170. int lastIndexOf = fileName.lastIndexOf(".");
  171. if(lastIndexOf == -1){
  172. return R.error(511,"该文件没有后缀");
  173. }else{
  174. String suffix = fileName.substring(lastIndexOf);
  175. if(!".xls".equals(suffix)){
  176. return R.error(511,"只支持后缀为xls的excel文件");
  177. }else{
  178. URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
  179. File file = new File(resource.getFile());
  180. if(!file.exists()){
  181. return R.error(511,"找不到上传文件,请联系管理员");
  182. }else{
  183. List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
  184. dataList.remove(0);//删除第一行,因为第一行是提示
  185. for(List<String> data:dataList){
  186. //循环
  187. YuangongEntity yuangongEntity = new YuangongEntity();
  188. // yuangongEntity.setUsername(data.get(0)); //账户 要改的
  189. // yuangongEntity.setPassword("123456");//密码
  190. // yuangongEntity.setYuangongUuidNumber(data.get(0)); //工号 要改的
  191. // yuangongEntity.setYuangongName(data.get(0)); //员工姓名 要改的
  192. // yuangongEntity.setYuangongPhone(data.get(0)); //员工手机号 要改的
  193. // yuangongEntity.setYuangongIdNumber(data.get(0)); //员工身份证号 要改的
  194. // yuangongEntity.setYuangongPhoto("");//详情和图片
  195. // yuangongEntity.setSexTypes(Integer.valueOf(data.get(0))); //性别 要改的
  196. // yuangongEntity.setYuangongEmail(data.get(0)); //员工邮箱 要改的
  197. // yuangongEntity.setBumenTypes(Integer.valueOf(data.get(0))); //部门 要改的
  198. // yuangongEntity.setZhiweiTypes(Integer.valueOf(data.get(0))); //职位 要改的
  199. // yuangongEntity.setJinyongTypes(Integer.valueOf(data.get(0))); //账户状态 要改的
  200. // yuangongEntity.setCreateTime(date);//时间
  201. yuangongList.add(yuangongEntity);
  202. //把要查询是否重复的字段放入map中
  203. //账户
  204. if(seachFields.containsKey("username")){
  205. List<String> username = seachFields.get("username");
  206. username.add(data.get(0));//要改的
  207. }else{
  208. List<String> username = new ArrayList<>();
  209. username.add(data.get(0));//要改的
  210. seachFields.put("username",username);
  211. }
  212. //工号
  213. if(seachFields.containsKey("yuangongUuidNumber")){
  214. List<String> yuangongUuidNumber = seachFields.get("yuangongUuidNumber");
  215. yuangongUuidNumber.add(data.get(0));//要改的
  216. }else{
  217. List<String> yuangongUuidNumber = new ArrayList<>();
  218. yuangongUuidNumber.add(data.get(0));//要改的
  219. seachFields.put("yuangongUuidNumber",yuangongUuidNumber);
  220. }
  221. //员工手机号
  222. if(seachFields.containsKey("yuangongPhone")){
  223. List<String> yuangongPhone = seachFields.get("yuangongPhone");
  224. yuangongPhone.add(data.get(0));//要改的
  225. }else{
  226. List<String> yuangongPhone = new ArrayList<>();
  227. yuangongPhone.add(data.get(0));//要改的
  228. seachFields.put("yuangongPhone",yuangongPhone);
  229. }
  230. //员工身份证号
  231. if(seachFields.containsKey("yuangongIdNumber")){
  232. List<String> yuangongIdNumber = seachFields.get("yuangongIdNumber");
  233. yuangongIdNumber.add(data.get(0));//要改的
  234. }else{
  235. List<String> yuangongIdNumber = new ArrayList<>();
  236. yuangongIdNumber.add(data.get(0));//要改的
  237. seachFields.put("yuangongIdNumber",yuangongIdNumber);
  238. }
  239. }
  240. //查询是否重复
  241. //账户
  242. List<YuangongEntity> yuangongEntities_username = yuangongService.selectList(new EntityWrapper<YuangongEntity>().in("username", seachFields.get("username")));
  243. if(yuangongEntities_username.size() >0 ){
  244. ArrayList<String> repeatFields = new ArrayList<>();
  245. for(YuangongEntity s:yuangongEntities_username){
  246. repeatFields.add(s.getUsername());
  247. }
  248. return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());
  249. }
  250. //工号
  251. List<YuangongEntity> yuangongEntities_yuangongUuidNumber = yuangongService.selectList(new EntityWrapper<YuangongEntity>().in("yuangong_uuid_number", seachFields.get("yuangongUuidNumber")));
  252. if(yuangongEntities_yuangongUuidNumber.size() >0 ){
  253. ArrayList<String> repeatFields = new ArrayList<>();
  254. for(YuangongEntity s:yuangongEntities_yuangongUuidNumber){
  255. repeatFields.add(s.getYuangongUuidNumber());
  256. }
  257. return R.error(511,"数据库的该表中的 [工号] 字段已经存在 存在数据为:"+repeatFields.toString());
  258. }
  259. //员工手机号
  260. List<YuangongEntity> yuangongEntities_yuangongPhone = yuangongService.selectList(new EntityWrapper<YuangongEntity>().in("yuangong_phone", seachFields.get("yuangongPhone")));
  261. if(yuangongEntities_yuangongPhone.size() >0 ){
  262. ArrayList<String> repeatFields = new ArrayList<>();
  263. for(YuangongEntity s:yuangongEntities_yuangongPhone){
  264. repeatFields.add(s.getYuangongPhone());
  265. }
  266. return R.error(511,"数据库的该表中的 [员工手机号] 字段已经存在 存在数据为:"+repeatFields.toString());
  267. }
  268. //员工身份证号
  269. List<YuangongEntity> yuangongEntities_yuangongIdNumber = yuangongService.selectList(new EntityWrapper<YuangongEntity>().in("yuangong_id_number", seachFields.get("yuangongIdNumber")));
  270. if(yuangongEntities_yuangongIdNumber.size() >0 ){
  271. ArrayList<String> repeatFields = new ArrayList<>();
  272. for(YuangongEntity s:yuangongEntities_yuangongIdNumber){
  273. repeatFields.add(s.getYuangongIdNumber());
  274. }
  275. return R.error(511,"数据库的该表中的 [员工身份证号] 字段已经存在 存在数据为:"+repeatFields.toString());
  276. }
  277. yuangongService.insertBatch(yuangongList);
  278. return R.ok();
  279. }
  280. }
  281. }
  282. }catch (Exception e){
  283. e.printStackTrace();
  284. return R.error(511,"批量插入数据异常,请联系管理员");
  285. }
  286. }
  287. /**
  288. * 登录
  289. */
  290. @IgnoreAuth
  291. @RequestMapping(value = "/login")
  292. public R login(String username, String password, String captcha, HttpServletRequest request) {
  293. YuangongEntity yuangong = yuangongService.selectOne(new EntityWrapper<YuangongEntity>().eq("username", username));
  294. if(yuangong==null || !yuangong.getPassword().equals(password))
  295. return R.error("账号或密码不正确");
  296. else if(yuangong.getJinyongTypes() != 1)
  297. return R.error("账户已被禁用");
  298. String token = tokenService.generateToken(yuangong.getId(),username, "yuangong", "员工");
  299. R r = R.ok();
  300. r.put("token", token);
  301. r.put("role","员工");
  302. r.put("username",yuangong.getYuangongName());
  303. r.put("tableName","yuangong");
  304. r.put("userId",yuangong.getId());
  305. return r;
  306. }
  307. /**
  308. * 注册
  309. */
  310. @IgnoreAuth
  311. @PostMapping(value = "/register")
  312. public R register(@RequestBody YuangongEntity yuangong, HttpServletRequest request) {
  313. // ValidatorUtils.validateEntity(user);
  314. Wrapper<YuangongEntity> queryWrapper = new EntityWrapper<YuangongEntity>()
  315. .eq("username", yuangong.getUsername())
  316. .or()
  317. .eq("yuangong_phone", yuangong.getYuangongPhone())
  318. .or()
  319. .eq("yuangong_id_number", yuangong.getYuangongIdNumber())
  320. ;
  321. YuangongEntity yuangongEntity = yuangongService.selectOne(queryWrapper);
  322. if(yuangongEntity != null)
  323. return R.error("账户或者员工手机号或者员工身份证号已经被使用");
  324. yuangong.setYuangongUuidNumber(String.valueOf(new Date().getTime()));
  325. yuangong.setJinyongTypes(1);//启用
  326. yuangong.setCreateTime(new Date());
  327. yuangongService.insert(yuangong);
  328. return R.ok();
  329. }
  330. /**
  331. * 重置密码
  332. */
  333. @GetMapping(value = "/resetPassword")
  334. public R resetPassword(Integer id, HttpServletRequest request) {
  335. YuangongEntity yuangong = yuangongService.selectById(id);
  336. yuangong.setPassword("123456");
  337. yuangongService.updateById(yuangong);
  338. return R.ok();
  339. }
  340. /**
  341. * 修改密码
  342. */
  343. @GetMapping(value = "/updatePassword")
  344. public R updatePassword(String oldPassword, String newPassword, HttpServletRequest request) {
  345. YuangongEntity yuangong = yuangongService.selectById((Integer)request.getSession().getAttribute("userId"));
  346. if(newPassword == null){
  347. return R.error("新密码不能为空") ;
  348. }
  349. if(!oldPassword.equals(yuangong.getPassword())){
  350. return R.error("原密码输入错误");
  351. }
  352. if(newPassword.equals(yuangong.getPassword())){
  353. return R.error("新密码不能和原密码一致") ;
  354. }
  355. yuangong.setPassword(newPassword);
  356. yuangongService.updateById(yuangong);
  357. return R.ok();
  358. }
  359. /**
  360. * 忘记密码
  361. */
  362. @IgnoreAuth
  363. @RequestMapping(value = "/resetPass")
  364. public R resetPass(String username, HttpServletRequest request) {
  365. YuangongEntity yuangong = yuangongService.selectOne(new EntityWrapper<YuangongEntity>().eq("username", username));
  366. if(yuangong!=null){
  367. yuangong.setPassword("123456");
  368. yuangongService.updateById(yuangong);
  369. return R.ok();
  370. }else{
  371. return R.error("账号不存在");
  372. }
  373. }
  374. /**
  375. * 获取用户的session用户信息
  376. */
  377. @RequestMapping("/session")
  378. public R getCurrYuangong(HttpServletRequest request){
  379. Integer id = (Integer)request.getSession().getAttribute("userId");
  380. YuangongEntity yuangong = yuangongService.selectById(id);
  381. if(yuangong !=null){
  382. //entity转view
  383. YuangongView view = new YuangongView();
  384. BeanUtils.copyProperties( yuangong , view );//把实体数据重构到view中
  385. //修改对应字典表字段
  386. dictionaryService.dictionaryConvert(view, request);
  387. return R.ok().put("data", view);
  388. }else {
  389. return R.error(511,"查不到数据");
  390. }
  391. }
  392. /**
  393. * 退出
  394. */
  395. @GetMapping(value = "logout")
  396. public R logout(HttpServletRequest request) {
  397. request.getSession().invalidate();
  398. return R.ok("退出成功");
  399. }
  400. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/619802
推荐阅读
相关标签
  

闽ICP备14008679号