赞
踩
在计算机技术不断进步的过程中,各个行业已经离不开计算机的应用,例如在信息管理、在线学习等方面处处都是计算机的身影。随着在线教育逐步的推广与普及,各教育机构以及学生个人等,也逐步采用了专门的在线学习系统来授课或学习。在线学习系统是实现教育信息化的重要过程,其能够对学习质量的提升起到较为显著的效果,也为企业内部的学习资源获取提供了更多的途径。
论文主要围绕在线教育系统的设计与实现展开研究,遵循软件工程设计流程,在需求分析的基础上,明确了在线教育平台的各项功能。利用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 | 非空 | 描述 |
表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 | timestamp | 非空 | 修改时间 |
表5-4 部门表
编号 | 字段名 | 类型 | 长度 | 可否为空 | 是否主键 | 默认值 | 说明 |
1 | department_id | int | 10 | 非空 | √ | 自增 | 部门id |
2 | department_name | varchar | 30 | 非空 | 部门名称 | ||
3 | description | varchar | 300 | 非空 | 部门描述 | ||
4 | update_time | timestamp | 非空 | 修改时间 |
表5-5 课程类别表
编号 | 字段名 | 类型 | 长度 | 可否为空 | 是否主键 | 默认值 | 说明 |
1 | type_id | int | 10 | 非空 | √ | 自增 | 类别id |
2 | type_name | varchar | 30 | 非空 | 类别名称 | ||
3 | description | varchar | 300 | 非空 | 类别描述 |
表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 | 允许 | 价格 |
表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 | 非空 | 是否锁定 |
表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 | 非空 | 离职时间 |
- <?xml version="1.0" encoding="UTF-8"?>
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>top.qiudb</groupId>
- <artifactId>breadroll-education</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <name>breadroll-education</name>
- <description>Demo project for Spring Boot</description>
-
- <properties>
- <java.version>1.8</java.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <spring-boot.version>2.3.7.RELEASE</spring-boot.version>
- </properties>
-
- <dependencies>
- <!--web-->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
- <!--thymeleaf-->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-thymeleaf</artifactId>
- </dependency>
- <!-- Sa-Token 权限认证, 在线文档:http://sa-token.dev33.cn/ -->
- <dependency>
- <groupId>cn.dev33</groupId>
- <artifactId>sa-token-spring-boot-starter</artifactId>
- <version>1.18.0</version>
- </dependency>
- <!-- sa-token整合redis (使用jdk默认序列化方式) -->
- <dependency>
- <groupId>cn.dev33</groupId>
- <artifactId>sa-token-dao-redis</artifactId>
- <version>1.18.0</version>
- </dependency>
- <!-- 提供redis连接池 -->
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-pool2</artifactId>
- </dependency>
- <!-- https://mvnrepository.com/artifact/com.github.ulisesbocchio/jasypt-spring-boot-starter -->
- <dependency>
- <groupId>com.github.ulisesbocchio</groupId>
- <artifactId>jasypt-spring-boot-starter</artifactId>
- <version>3.0.3</version>
- </dependency>
- <!--lombok-->
- <dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
- </dependency>
- <!-- redis -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-data-redis</artifactId>
- </dependency>
- <!--mysql-->
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.47</version>
- </dependency>
- <!--整合mybatis-->
- <dependency>
- <groupId>org.mybatis.spring.boot</groupId>
- <artifactId>mybatis-spring-boot-starter</artifactId>
- <version>1.3.3</version>
- </dependency>
- <!--druid-->
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>druid</artifactId>
- <version>1.1.12</version>
- </dependency>
- <!-- 阿里短信依赖 -->
- <dependency>
- <groupId>com.aliyun</groupId>
- <artifactId>aliyun-java-sdk-core</artifactId>
- <version>4.4.6</version>
- </dependency>
- <dependency>
- <groupId>com.aliyun</groupId>
- <artifactId>aliyun-java-sdk-dysmsapi</artifactId>
- <version>2.1.0</version>
- </dependency>
- <!-- fastjson -->
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>fastjson</artifactId>
- <version>1.2.62</version>
- </dependency>
- <!--工具类-->
- <dependency>
- <groupId>com.github.shalousun</groupId>
- <artifactId>common-util</artifactId>
- <version>1.9.2</version>
- </dependency>
- <!-- alipay-sdk-java 依赖 -->
- <dependency>
- <groupId>com.alipay.sdk</groupId>
- <artifactId>alipay-sdk-java</artifactId>
- <version>4.10.192.ALL</version>
- </dependency>
- <!-- jave -->
- <dependency>
- <groupId>it.sauronsoftware</groupId>
- <artifactId>jave</artifactId>
- <version>1.0.2</version>
- <!-- 下面两个是使用system在pom.xml中导入jar -->
- <scope>system</scope>
- <systemPath>${project.basedir}/src/main/resources/lib/jave-1.0.2.jar</systemPath>
- </dependency>
- <!--mail-->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-mail</artifactId>
- </dependency>
- <!-- swagger2 -->
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger2</artifactId>
- <version>2.9.2</version>
- </dependency>
- <!-- 引入swagger-bootstrap-ui包 /doc.html-->
- <dependency>
- <groupId>com.github.xiaoymin</groupId>
- <artifactId>swagger-bootstrap-ui</artifactId>
- <version>1.9.1</version>
- </dependency>
- <!--page helper-->
- <dependency>
- <groupId>com.github.pagehelper</groupId>
- <artifactId>pagehelper-spring-boot-starter</artifactId>
- <version>1.2.3</version>
- </dependency>
- <!--markdown转html-->
- <dependency>
- <groupId>com.atlassian.commonmark</groupId>
- <artifactId>commonmark</artifactId>
- <version>0.10.0</version>
- </dependency>
- <dependency>
- <groupId>com.atlassian.commonmark</groupId>
- <artifactId>commonmark-ext-autolink</artifactId>
- <version>0.10.0</version>
- </dependency>
- <dependency>
- <groupId>com.atlassian.commonmark</groupId>
- <artifactId>commonmark-ext-gfm-tables</artifactId>
- <version>0.10.0</version>
- </dependency>
- <dependency>
- <groupId>com.atlassian.commonmark</groupId>
- <artifactId>commonmark-ext-gfm-strikethrough</artifactId>
- <version>0.10.0</version>
- </dependency>
- <dependency>
- <groupId>com.atlassian.commonmark</groupId>
- <artifactId>commonmark-ext-heading-anchor</artifactId>
- <version>0.10.0</version>
- </dependency>
- <!--test-->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-dependencies</artifactId>
- <version>${spring-boot.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <build>
- <finalName>breadroll-education</finalName>
- <plugins>
- <plugin>
- <groupId>com.github.ulisesbocchio</groupId>
- <artifactId>jasypt-maven-plugin</artifactId>
- <version>3.0.2</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.8.1</version>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- <encoding>UTF-8</encoding>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <version>2.3.7.RELEASE</version>
- <configuration>
- <mainClass>top.qiudb.BreadrollEducationApplication</mainClass>
- <!--将本地使用的jar打包的时候引入lib-->
- <includeSystemScope>true</includeSystemScope>
- </configuration>
- <executions>
- <execution>
- <id>repackage</id>
- <goals>
- <goal>repackage</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <!--V 2630663675-->
- <repositories>
- <repository>
- <id>maven-ali</id>
- <url>http://maven.aliyun.com/nexus/content/groups/public//</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>always</updatePolicy>
- <checksumPolicy>fail</checksumPolicy>
- </snapshots>
- </repository>
- </repositories>
- </project>
-
- package com.controller;
-
- import java.io.File;
- import java.math.BigDecimal;
- import java.net.URL;
- import java.text.SimpleDateFormat;
- import com.alibaba.fastjson.JSONObject;
- import java.util.*;
- import org.springframework.beans.BeanUtils;
- import javax.servlet.http.HttpServletRequest;
- import org.springframework.web.context.ContextLoader;
- import javax.servlet.ServletContext;
- import com.service.TokenService;
- import com.utils.*;
- import java.lang.reflect.InvocationTargetException;
-
- import com.service.DictionaryService;
- import org.apache.commons.lang3.StringUtils;
- import com.annotation.IgnoreAuth;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.*;
- import com.baomidou.mybatisplus.mapper.EntityWrapper;
- import com.baomidou.mybatisplus.mapper.Wrapper;
- import com.entity.*;
- import com.entity.view.*;
- import com.service.*;
- import com.utils.PageUtils;
- import com.utils.R;
- import com.alibaba.fastjson.*;
-
- /**
- * 员工
- * 后端接口
- * @author
- * @email
- */
- @RestController
- @Controller
- @RequestMapping("/yuangong")
- public class YuangongController {
- private static final Logger logger = LoggerFactory.getLogger(YuangongController.class);
-
- private static final String TABLE_NAME = "yuangong";
-
- @Autowired
- private YuangongService yuangongService;
-
-
- @Autowired
- private TokenService tokenService;
-
- @Autowired
- private DanganService danganService;//档案
- @Autowired
- private DictionaryService dictionaryService;//字典
- @Autowired
- private GonggaoService gonggaoService;//公告
- @Autowired
- private MenuService menuService;//菜单
- @Autowired
- private QiandaoService qiandaoService;//员工签到
- @Autowired
- private XinziService xinziService;//薪资
- @Autowired
- private YuangongchuchaiService yuangongchuchaiService;//员工出差
- @Autowired
- private YuangongqingjiaService yuangongqingjiaService;//员工请假
- @Autowired
- private UsersService usersService;//管理员
-
-
- /**
- * 后端列表
- */
- @RequestMapping("/page")
- public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
- logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
- String role = String.valueOf(request.getSession().getAttribute("role"));
- if(false)
- return R.error(511,"永不会进入");
- else if("员工".equals(role))
- params.put("yuangongId",request.getSession().getAttribute("userId"));
- CommonUtil.checkMap(params);
- PageUtils page = yuangongService.queryPage(params);
-
- //字典表数据转换
- List<YuangongView> list =(List<YuangongView>)page.getList();
- for(YuangongView c:list){
- //修改对应字典表字段
- dictionaryService.dictionaryConvert(c, request);
- }
- return R.ok().put("data", page);
- }
-
- /**
- * 后端详情
- */
- @RequestMapping("/info/{id}")
- public R info(@PathVariable("id") Long id, HttpServletRequest request){
- logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
- YuangongEntity yuangong = yuangongService.selectById(id);
- if(yuangong !=null){
- //entity转view
- YuangongView view = new YuangongView();
- BeanUtils.copyProperties( yuangong , view );//把实体数据重构到view中
- //修改对应字典表字段
- dictionaryService.dictionaryConvert(view, request);
- return R.ok().put("data", view);
- }else {
- return R.error(511,"查不到数据");
- }
-
- }
-
- /**
- * 后端保存
- */
- @RequestMapping("/save")
- public R save(@RequestBody YuangongEntity yuangong, HttpServletRequest request){
- logger.debug("save方法:,,Controller:{},,yuangong:{}",this.getClass().getName(),yuangong.toString());
-
- String role = String.valueOf(request.getSession().getAttribute("role"));
- if(false)
- return R.error(511,"永远不会进入");
-
- Wrapper<YuangongEntity> queryWrapper = new EntityWrapper<YuangongEntity>()
- .eq("username", yuangong.getUsername())
- .or()
- .eq("yuangong_phone", yuangong.getYuangongPhone())
- .or()
- .eq("yuangong_id_number", yuangong.getYuangongIdNumber())
- ;
-
- logger.info("sql语句:"+queryWrapper.getSqlSegment());
- YuangongEntity yuangongEntity = yuangongService.selectOne(queryWrapper);
- if(yuangongEntity==null){
- yuangong.setCreateTime(new Date());
- yuangong.setPassword("123456");
- yuangongService.insert(yuangong);
- return R.ok();
- }else {
- return R.error(511,"账户或者员工手机号或者员工身份证号已经被使用");
- }
- }
-
- /**
- * 后端修改
- */
- @RequestMapping("/update")
- public R update(@RequestBody YuangongEntity yuangong, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
- logger.debug("update方法:,,Controller:{},,yuangong:{}",this.getClass().getName(),yuangong.toString());
- YuangongEntity oldYuangongEntity = yuangongService.selectById(yuangong.getId());//查询原先数据
-
- String role = String.valueOf(request.getSession().getAttribute("role"));
- // if(false)
- // return R.error(511,"永远不会进入");
- if("".equals(yuangong.getYuangongPhoto()) || "null".equals(yuangong.getYuangongPhoto())){
- yuangong.setYuangongPhoto(null);
- }
-
- yuangongService.updateById(yuangong);//根据id更新
- return R.ok();
- }
-
-
-
- /**
- * 删除
- */
- @RequestMapping("/delete")
- public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
- logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
- List<YuangongEntity> oldYuangongList =yuangongService.selectBatchIds(Arrays.asList(ids));//要删除的数据
- yuangongService.deleteBatchIds(Arrays.asList(ids));
-
- return R.ok();
- }
-
-
- /**
- * 批量上传
- */
- @RequestMapping("/batchInsert")
- public R save( String fileName, HttpServletRequest request){
- logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
- Integer yuangongId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- //.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
- try {
- List<YuangongEntity> yuangongList = new ArrayList<>();//上传的东西
- Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
- Date date = new Date();
- int lastIndexOf = fileName.lastIndexOf(".");
- if(lastIndexOf == -1){
- return R.error(511,"该文件没有后缀");
- }else{
- String suffix = fileName.substring(lastIndexOf);
- if(!".xls".equals(suffix)){
- return R.error(511,"只支持后缀为xls的excel文件");
- }else{
- URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
- File file = new File(resource.getFile());
- if(!file.exists()){
- return R.error(511,"找不到上传文件,请联系管理员");
- }else{
- List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
- dataList.remove(0);//删除第一行,因为第一行是提示
- for(List<String> data:dataList){
- //循环
- YuangongEntity yuangongEntity = new YuangongEntity();
- // yuangongEntity.setUsername(data.get(0)); //账户 要改的
- // yuangongEntity.setPassword("123456");//密码
- // yuangongEntity.setYuangongUuidNumber(data.get(0)); //工号 要改的
- // yuangongEntity.setYuangongName(data.get(0)); //员工姓名 要改的
- // yuangongEntity.setYuangongPhone(data.get(0)); //员工手机号 要改的
- // yuangongEntity.setYuangongIdNumber(data.get(0)); //员工身份证号 要改的
- // yuangongEntity.setYuangongPhoto("");//详情和图片
- // yuangongEntity.setSexTypes(Integer.valueOf(data.get(0))); //性别 要改的
- // yuangongEntity.setYuangongEmail(data.get(0)); //员工邮箱 要改的
- // yuangongEntity.setBumenTypes(Integer.valueOf(data.get(0))); //部门 要改的
- // yuangongEntity.setZhiweiTypes(Integer.valueOf(data.get(0))); //职位 要改的
- // yuangongEntity.setJinyongTypes(Integer.valueOf(data.get(0))); //账户状态 要改的
- // yuangongEntity.setCreateTime(date);//时间
- yuangongList.add(yuangongEntity);
-
-
- //把要查询是否重复的字段放入map中
- //账户
- if(seachFields.containsKey("username")){
- List<String> username = seachFields.get("username");
- username.add(data.get(0));//要改的
- }else{
- List<String> username = new ArrayList<>();
- username.add(data.get(0));//要改的
- seachFields.put("username",username);
- }
- //工号
- if(seachFields.containsKey("yuangongUuidNumber")){
- List<String> yuangongUuidNumber = seachFields.get("yuangongUuidNumber");
- yuangongUuidNumber.add(data.get(0));//要改的
- }else{
- List<String> yuangongUuidNumber = new ArrayList<>();
- yuangongUuidNumber.add(data.get(0));//要改的
- seachFields.put("yuangongUuidNumber",yuangongUuidNumber);
- }
- //员工手机号
- if(seachFields.containsKey("yuangongPhone")){
- List<String> yuangongPhone = seachFields.get("yuangongPhone");
- yuangongPhone.add(data.get(0));//要改的
- }else{
- List<String> yuangongPhone = new ArrayList<>();
- yuangongPhone.add(data.get(0));//要改的
- seachFields.put("yuangongPhone",yuangongPhone);
- }
- //员工身份证号
- if(seachFields.containsKey("yuangongIdNumber")){
- List<String> yuangongIdNumber = seachFields.get("yuangongIdNumber");
- yuangongIdNumber.add(data.get(0));//要改的
- }else{
- List<String> yuangongIdNumber = new ArrayList<>();
- yuangongIdNumber.add(data.get(0));//要改的
- seachFields.put("yuangongIdNumber",yuangongIdNumber);
- }
- }
-
- //查询是否重复
- //账户
- List<YuangongEntity> yuangongEntities_username = yuangongService.selectList(new EntityWrapper<YuangongEntity>().in("username", seachFields.get("username")));
- if(yuangongEntities_username.size() >0 ){
- ArrayList<String> repeatFields = new ArrayList<>();
- for(YuangongEntity s:yuangongEntities_username){
- repeatFields.add(s.getUsername());
- }
- return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());
- }
- //工号
- List<YuangongEntity> yuangongEntities_yuangongUuidNumber = yuangongService.selectList(new EntityWrapper<YuangongEntity>().in("yuangong_uuid_number", seachFields.get("yuangongUuidNumber")));
- if(yuangongEntities_yuangongUuidNumber.size() >0 ){
- ArrayList<String> repeatFields = new ArrayList<>();
- for(YuangongEntity s:yuangongEntities_yuangongUuidNumber){
- repeatFields.add(s.getYuangongUuidNumber());
- }
- return R.error(511,"数据库的该表中的 [工号] 字段已经存在 存在数据为:"+repeatFields.toString());
- }
- //员工手机号
- List<YuangongEntity> yuangongEntities_yuangongPhone = yuangongService.selectList(new EntityWrapper<YuangongEntity>().in("yuangong_phone", seachFields.get("yuangongPhone")));
- if(yuangongEntities_yuangongPhone.size() >0 ){
- ArrayList<String> repeatFields = new ArrayList<>();
- for(YuangongEntity s:yuangongEntities_yuangongPhone){
- repeatFields.add(s.getYuangongPhone());
- }
- return R.error(511,"数据库的该表中的 [员工手机号] 字段已经存在 存在数据为:"+repeatFields.toString());
- }
- //员工身份证号
- List<YuangongEntity> yuangongEntities_yuangongIdNumber = yuangongService.selectList(new EntityWrapper<YuangongEntity>().in("yuangong_id_number", seachFields.get("yuangongIdNumber")));
- if(yuangongEntities_yuangongIdNumber.size() >0 ){
- ArrayList<String> repeatFields = new ArrayList<>();
- for(YuangongEntity s:yuangongEntities_yuangongIdNumber){
- repeatFields.add(s.getYuangongIdNumber());
- }
- return R.error(511,"数据库的该表中的 [员工身份证号] 字段已经存在 存在数据为:"+repeatFields.toString());
- }
- yuangongService.insertBatch(yuangongList);
- return R.ok();
- }
- }
- }
- }catch (Exception e){
- e.printStackTrace();
- return R.error(511,"批量插入数据异常,请联系管理员");
- }
- }
-
- /**
- * 登录
- */
- @IgnoreAuth
- @RequestMapping(value = "/login")
- public R login(String username, String password, String captcha, HttpServletRequest request) {
- YuangongEntity yuangong = yuangongService.selectOne(new EntityWrapper<YuangongEntity>().eq("username", username));
- if(yuangong==null || !yuangong.getPassword().equals(password))
- return R.error("账号或密码不正确");
- else if(yuangong.getJinyongTypes() != 1)
- return R.error("账户已被禁用");
- String token = tokenService.generateToken(yuangong.getId(),username, "yuangong", "员工");
- R r = R.ok();
- r.put("token", token);
- r.put("role","员工");
- r.put("username",yuangong.getYuangongName());
- r.put("tableName","yuangong");
- r.put("userId",yuangong.getId());
- return r;
- }
-
- /**
- * 注册
- */
- @IgnoreAuth
- @PostMapping(value = "/register")
- public R register(@RequestBody YuangongEntity yuangong, HttpServletRequest request) {
- // ValidatorUtils.validateEntity(user);
- Wrapper<YuangongEntity> queryWrapper = new EntityWrapper<YuangongEntity>()
- .eq("username", yuangong.getUsername())
- .or()
- .eq("yuangong_phone", yuangong.getYuangongPhone())
- .or()
- .eq("yuangong_id_number", yuangong.getYuangongIdNumber())
- ;
- YuangongEntity yuangongEntity = yuangongService.selectOne(queryWrapper);
- if(yuangongEntity != null)
- return R.error("账户或者员工手机号或者员工身份证号已经被使用");
- yuangong.setYuangongUuidNumber(String.valueOf(new Date().getTime()));
- yuangong.setJinyongTypes(1);//启用
- yuangong.setCreateTime(new Date());
- yuangongService.insert(yuangong);
-
- return R.ok();
- }
-
- /**
- * 重置密码
- */
- @GetMapping(value = "/resetPassword")
- public R resetPassword(Integer id, HttpServletRequest request) {
- YuangongEntity yuangong = yuangongService.selectById(id);
- yuangong.setPassword("123456");
- yuangongService.updateById(yuangong);
- return R.ok();
- }
-
- /**
- * 修改密码
- */
- @GetMapping(value = "/updatePassword")
- public R updatePassword(String oldPassword, String newPassword, HttpServletRequest request) {
- YuangongEntity yuangong = yuangongService.selectById((Integer)request.getSession().getAttribute("userId"));
- if(newPassword == null){
- return R.error("新密码不能为空") ;
- }
- if(!oldPassword.equals(yuangong.getPassword())){
- return R.error("原密码输入错误");
- }
- if(newPassword.equals(yuangong.getPassword())){
- return R.error("新密码不能和原密码一致") ;
- }
- yuangong.setPassword(newPassword);
- yuangongService.updateById(yuangong);
- return R.ok();
- }
-
-
-
- /**
- * 忘记密码
- */
- @IgnoreAuth
- @RequestMapping(value = "/resetPass")
- public R resetPass(String username, HttpServletRequest request) {
- YuangongEntity yuangong = yuangongService.selectOne(new EntityWrapper<YuangongEntity>().eq("username", username));
- if(yuangong!=null){
- yuangong.setPassword("123456");
- yuangongService.updateById(yuangong);
- return R.ok();
- }else{
- return R.error("账号不存在");
- }
- }
-
-
- /**
- * 获取用户的session用户信息
- */
- @RequestMapping("/session")
- public R getCurrYuangong(HttpServletRequest request){
- Integer id = (Integer)request.getSession().getAttribute("userId");
- YuangongEntity yuangong = yuangongService.selectById(id);
- if(yuangong !=null){
- //entity转view
- YuangongView view = new YuangongView();
- BeanUtils.copyProperties( yuangong , view );//把实体数据重构到view中
-
- //修改对应字典表字段
- dictionaryService.dictionaryConvert(view, request);
- return R.ok().put("data", view);
- }else {
- return R.error(511,"查不到数据");
- }
- }
-
-
- /**
- * 退出
- */
- @GetMapping(value = "logout")
- public R logout(HttpServletRequest request) {
- request.getSession().invalidate();
- return R.ok("退出成功");
- }
-
-
-
- }
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。