From e8fda05a6b91c89be290093125c97e9e013c78d3 Mon Sep 17 00:00:00 2001
From: xiaoCJ <406612557@qq.com>
Date: Sun, 28 Apr 2024 09:34:35 +0800
Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E9=85=8D?=
=?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E5=92=8Cmapper=20xml?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 7 +-
.../config/security/AuthenticationFilter.java | 2 +-
.../security/AuthenticationService.java | 73 ++--
.../config/security/JwtUser.java | 2 +-
.../config/security/LoginResult.java | 3 -
.../config/security/WebConfigurerAdapter.java | 18 +-
.../config/security/WebSecurityConfig.java | 3 +-
.../controller/stu/StuKnowledgeNote.java | 2 +-
.../controller/stu/StuScoreController.java | 2 +-
.../tea/TeaGradeManageController.java | 167 +++++---
.../controller/tea/UserController.java | 64 +--
.../entity/tea_dto/TrainingReportDto.java | 61 +++
.../mapper/StuClassMapper.java | 2 +
.../mapper/StuUserMapper.java | 12 +-
.../mapper/SysCourseMapper.java | 2 +
.../mapper/TeaAndStudentExamMapper.java | 8 +-
.../mapper/TeaExamManageMapper.java | 2 +
src/main/resources/mapper/StuClassMapper.xml | 381 +++++++++---------
.../resources/mapper/TeaExamManageMapper.xml | 9 +
19 files changed, 491 insertions(+), 329 deletions(-)
create mode 100644 src/main/java/com/sztzjy/financial_bigdata/entity/tea_dto/TrainingReportDto.java
diff --git a/pom.xml b/pom.xml
index 21b8c96..78e27ea 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,7 +88,12 @@
spring-security-jwt
1.1.1.RELEASE
-
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
com.nimbusds
nimbus-jose-jwt
diff --git a/src/main/java/com/sztzjy/financial_bigdata/config/security/AuthenticationFilter.java b/src/main/java/com/sztzjy/financial_bigdata/config/security/AuthenticationFilter.java
index abbf4d8..17c6661 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/config/security/AuthenticationFilter.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/config/security/AuthenticationFilter.java
@@ -55,7 +55,7 @@ public class AuthenticationFilter extends OncePerRequestFilter {
}
JwtUser currentUser;
try {
- currentUser = TokenProvider.getJWTUser(token);
+ currentUser = com.sztzjy.financial_bigdata.config.security.TokenProvider.getJWTUser(token);
response.setCharacterEncoding("UTF-8");
} catch (ExpiredJwtException e1) {
response.setStatus(HttpStatus.UNAUTHORIZED.value());
diff --git a/src/main/java/com/sztzjy/financial_bigdata/config/security/AuthenticationService.java b/src/main/java/com/sztzjy/financial_bigdata/config/security/AuthenticationService.java
index 9445994..8623b54 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/config/security/AuthenticationService.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/config/security/AuthenticationService.java
@@ -1,33 +1,40 @@
-//package com.sztzjy.financial_bigdata.config.security;
-//
-//import com.sztzjy.financial_bigdata.entity.User;
-//import com.sztzjy.financial_bigdata.service.IUserService;
-//import io.jsonwebtoken.lang.Assert;
-//import org.springframework.security.core.userdetails.UserDetails;
-//import org.springframework.security.core.userdetails.UserDetailsService;
-//import org.springframework.security.core.userdetails.UsernameNotFoundException;
-//import org.springframework.stereotype.Service;
-//
-//import javax.annotation.Resource;
-//
-//
-//@Service
-//public class AuthenticationService implements UserDetailsService {
-// @Resource
-// private IUserService userService;
-//
-//
-// @Override
-// public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
-// User user = userService.findByUsername(username);
-// Assert.notNull(user, "用户不存在");
-//
-// JwtUser jwtUser = new JwtUser();
-// jwtUser.setUsername(user.getUsername());
-// jwtUser.setPassword(user.getPassword());
-// jwtUser.setUserId(user.getUserid());
-// jwtUser.setName(user.getName());
-// jwtUser.setRoleId(user.getRoleId());
-// return jwtUser;
-// }
-//}
+package com.sztzjy.financial_bigdata.config.security;
+
+import com.sztzjy.financial_bigdata.entity.StuUser;
+import com.sztzjy.financial_bigdata.entity.StuUserExample;
+import com.sztzjy.financial_bigdata.mapper.StuUserMapper;
+import io.jsonwebtoken.lang.Assert;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+
+@Service
+public class AuthenticationService implements UserDetailsService {
+ @Resource
+ private StuUserMapper stuUserMapper;
+
+
+ @Override
+ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
+ StuUserExample stuUserExample = new StuUserExample();
+ stuUserExample.createCriteria().andUsernameEqualTo(username);
+ List list = stuUserMapper.selectByExample(stuUserExample);
+ Assert.notNull(list, "用户不存在");
+ StuUser user = list.get(0);
+ com.sztzjy.financial_bigdata.config.security.JwtUser jwtUser = new com.sztzjy.financial_bigdata.config.security.JwtUser();
+ jwtUser.setUsername(user.getUsername());
+ jwtUser.setPassword(new BCryptPasswordEncoder().encode(user.getPassword())); //不加密会报错Encoded password does not look like BCrypt
+ jwtUser.setUserId(user.getUserid());
+ jwtUser.setName(user.getName());
+ jwtUser.setRoleId(user.getRoleId());
+ jwtUser.setStudentId(user.getStudentId());
+ return jwtUser;
+ }
+
+}
diff --git a/src/main/java/com/sztzjy/financial_bigdata/config/security/JwtUser.java b/src/main/java/com/sztzjy/financial_bigdata/config/security/JwtUser.java
index 8a77a13..ea17d1e 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/config/security/JwtUser.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/config/security/JwtUser.java
@@ -1,6 +1,5 @@
package com.sztzjy.financial_bigdata.config.security;
-import io.swagger.models.auth.In;
import lombok.Getter;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;
@@ -30,6 +29,7 @@ public class JwtUser implements UserDetails {
private int collegeId;
private String collegeName;
private List authorityCodes;
+ private String studentId;
@Override
public Collection extends GrantedAuthority> getAuthorities() {
diff --git a/src/main/java/com/sztzjy/financial_bigdata/config/security/LoginResult.java b/src/main/java/com/sztzjy/financial_bigdata/config/security/LoginResult.java
index 1e08e57..f4bcc82 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/config/security/LoginResult.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/config/security/LoginResult.java
@@ -4,11 +4,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
-import org.springframework.security.core.GrantedAuthority;
import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
/**
* 用户登录结果集
diff --git a/src/main/java/com/sztzjy/financial_bigdata/config/security/WebConfigurerAdapter.java b/src/main/java/com/sztzjy/financial_bigdata/config/security/WebConfigurerAdapter.java
index ba26afe..376b7f0 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/config/security/WebConfigurerAdapter.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/config/security/WebConfigurerAdapter.java
@@ -32,16 +32,6 @@ public class WebConfigurerAdapter implements WebMvcConfigurer {
private String fileType;
@Value("${file.path}")
private String filePath;
-
- @Bean
- public IFileUtil getFileUtil() {
- if (fileType.equals("local")) {
- return new LocalFileUtil(filePath);
- } else {
- throw new IllegalArgumentException("未知文件工具类注入类型");
- }
- }
-
@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
@@ -77,4 +67,12 @@ public class WebConfigurerAdapter implements WebMvcConfigurer {
}
}
+ @Bean
+ public IFileUtil getFileUtil() {
+ if (fileType.equals("local")) {
+ return new LocalFileUtil(filePath);
+ } else {
+ throw new IllegalArgumentException("未知文件工具类注入类型");
+ }
+ }
}
diff --git a/src/main/java/com/sztzjy/financial_bigdata/config/security/WebSecurityConfig.java b/src/main/java/com/sztzjy/financial_bigdata/config/security/WebSecurityConfig.java
index b20555b..1e55324 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/config/security/WebSecurityConfig.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/config/security/WebSecurityConfig.java
@@ -22,7 +22,6 @@ import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
-import javax.annotation.Resource;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
@@ -113,7 +112,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Bean
public SessionRegistry sessionRegistry() {
- return new CustomSessionRegistry();
+ return new com.sztzjy.financial_bigdata.config.security.CustomSessionRegistry();
}
}
diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuKnowledgeNote.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuKnowledgeNote.java
index 945934b..759cc6c 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuKnowledgeNote.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuKnowledgeNote.java
@@ -88,7 +88,7 @@ public class StuKnowledgeNote {
@GetMapping("/getReport")
- @ApiOperation("获取单个学生报告接口")
+ @ApiOperation("知识概要--获取单个学生报告接口")
@AnonymousAccess
public ResponseEntity getReport(@RequestParam String chapterId, HttpServletResponse response) {
SysKnowledgeSummary sysKnowledgeSummary = sysKnowledgeSummaryMapper.selectByPrimaryKey(chapterId);
diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuScoreController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuScoreController.java
index 1dfe127..0eb23ab 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuScoreController.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/StuScoreController.java
@@ -141,7 +141,7 @@ public class StuScoreController {
trainingReport.setReportSize(size);
StuTrainingWithBLOBs stuTrainingWithBLOBs = stuTrainingMapper.selectByPrimaryKey(trainingId);
stuTrainingWithBLOBs.setReportId(trainingReport.getReportId()); // 第一次上传时设置实训表的报告ID
- stuTrainingMapper.updateByPrimaryKeyWithBLOBs(stuTrainingWithBLOBs);
+ trainingReportMapper.insert(trainingReport);
return new ResultEntity<>(HttpStatus.OK, "上传成功!");
}
}
diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java
index af76f5e..33fe60a 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaGradeManageController.java
@@ -20,16 +20,21 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
+import org.python.core.AstList;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
import java.util.*;
/**
@@ -61,65 +66,77 @@ public class TeaGradeManageController {
@Autowired
private StuTheoryExamMapper stuTheoryExamMapper;
+// @AnonymousAccess
+// @PostMapping("/getExamInfo")
+// @ApiOperation("考试模式--页面展示(学生端实战考核复用)")
+// public ResultEntity> getExamInfo(@RequestParam Integer index,
+// @RequestParam Integer size,
+// @ApiParam("ManyAnswer为考试时间,JudgeAnswer为发布人") @RequestParam String schoolId) {
+//
+// List teaExamManages = teaExamManageMapper.selectBySchoolId(schoolId);
+// ListteaExamManageCountDtos =new AstList();
+// for (TeaExamManage teaExamManage : teaExamManages) {
+// List nameList = new ArrayList<>();
+// TeaExamManageCountDto copyexamManageWithBLOBs = new TeaExamManageCountDto();
+// int num = 0;
+// //获取班级和考试人数
+// String classId = teaAndStudentExamMapper.selectByExamId(teaExamManage.getExamManageId());
+// String[] split = classId.split(",");
+// for (String s : split) {
+// StuClass stuClass = stuClassMapper.selectByPrimaryKey(s);
+// String className = stuClass.getClassName();
+// nameList.add(className);
+// int count = userMapper.selectNumByClass(s);
+// num = num + count;
+// }
+// copyexamManageWithBLOBs.setExamClass(nameList);
+// copyexamManageWithBLOBs.setExamNum(num);
+// BeanUtils.copyProperties(teaExamManage, copyexamManageWithBLOBs);
+// Date now = new Date(); // 当前日期
+// Date endTime = teaExamManage.getEndTime(); // 从 teaExamManage 对象中获取的日期
+// Date startTime = teaExamManage.getStartTime();
+//
+// if (now.compareTo(endTime) > 0) {
+// copyexamManageWithBLOBs.setExamStatus("已结束");
+// } else if (now.compareTo(startTime) < 0) {
+// copyexamManageWithBLOBs.setExamStatus("未开始");
+// } else {
+// copyexamManageWithBLOBs.setExamStatus("进行中");
+// }
+// String concatenatedTimeString = startTime + " -- " + endTime;
+// copyexamManageWithBLOBs.setExamTime(concatenatedTimeString); //考试时间
+// String userId = teaExamManage.getUserId();
+// StuUser stuUser = userMapper.selectByPrimaryKey(userId);
+// copyexamManageWithBLOBs.setName(stuUser.getName()); //发布人
+// teaExamManageCountDtos.add(copyexamManageWithBLOBs);
+// }
+// PageUtil.pageHelper(teaExamManageCountDtos, index, size);
+// return new ResultEntity<>(new PageInfo<>(teaExamManageCountDtos));
+// }
+
+
@AnonymousAccess
@PostMapping("/getExamInfo")
@ApiOperation("考试模式--页面展示(学生端实战考核复用)")
public ResultEntity> getExamInfo(@RequestParam Integer index,
@RequestParam Integer size,
@ApiParam("ManyAnswer为考试时间,JudgeAnswer为发布人") @RequestParam String schoolId) {
- TeaExamManageExample teaExamManageExample = new TeaExamManageExample();
- teaExamManageExample.createCriteria().andSchoolIdEqualTo(schoolId);
- List teaExamManages = teaExamManageMapper.selectByExample(teaExamManageExample);
+
+ List teaExamManages = teaExamManageMapper.selectBySchoolId(schoolId);
List teaExamManageCountDtos = new ArrayList<>();
+ // 批量查询班级信息
+ List examIds = new ArrayList<>();
for (TeaExamManage teaExamManage : teaExamManages) {
- List nameList = new ArrayList<>();
- TeaExamManageCountDto copyexamManageWithBLOBs = new TeaExamManageCountDto();
- int num = 0;
- //获取班级和考试人数
- String classId = teaAndStudentExamMapper.selectByExamId(teaExamManage.getExamManageId());
- String[] split = classId.split(",");
- for (String s : split) {
- StuClass stuClass = stuClassMapper.selectByPrimaryKey(s);
- String className = stuClass.getClassName();
- nameList.add(className);
- int count = userMapper.selectNumByClass(s);
- num = num + count;
- }
- copyexamManageWithBLOBs.setExamClass(nameList);
- copyexamManageWithBLOBs.setExamNum(num);
- BeanUtils.copyProperties(teaExamManage, copyexamManageWithBLOBs);
- Date startTime = teaExamManage.getStartTime();
- Date endTime = teaExamManage.getEndTime();
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String startTimeString = formatter.format(startTime);
- String endTimeString = formatter.format(endTime);
- Date date = new Date(); // 当前日期
- Date endtimeDtae = teaExamManage.getEndTime(); // 从 teaExamManage 对象中获取的日期
- Date startTimeDtae = teaExamManage.getStartTime();
- long now = date.getTime();
- long end = endtimeDtae.getTime();
- long start = startTimeDtae.getTime();
- if (now > end) {
- // 当前 大于 结束时间
- copyexamManageWithBLOBs.setExamStatus("已结束");
- } else if (now < start) {
- // 当前 小于 开始时间
- copyexamManageWithBLOBs.setExamStatus("未开始");
- } else {
- copyexamManageWithBLOBs.setExamStatus("进行中");
- }
- String concatenatedTimeString = startTimeString + " -- " + endTimeString;
- copyexamManageWithBLOBs.setExamTime(concatenatedTimeString); //考试时间
- String userId = teaExamManage.getUserId();
- StuUser stuUser = userMapper.selectByPrimaryKey(userId);
- copyexamManageWithBLOBs.setName(stuUser.getName()); //发布人
- teaExamManageCountDtos.add(copyexamManageWithBLOBs);
+ examIds.add(teaExamManage.getExamManageId());
}
- PageUtil.pageHelper(teaExamManageCountDtos, index, size);
- return new ResultEntity<>(new PageInfo<>(teaExamManageCountDtos));
+
+
+ PageInfo pageInfo = PageUtil.pageHelper(teaExamManageCountDtos, index, size);
+ return new ResultEntity>(pageInfo);
}
+
@AnonymousAccess
@PostMapping("/getExamInfoAndRank")
@ApiOperation("考试模式--成绩排名和成绩情况展示") //TODO 图片可能需要一个接口去取
@@ -312,14 +329,28 @@ public class TeaGradeManageController {
@AnonymousAccess
@PostMapping("/getReportBySchoolID")
@ApiOperation("练习模式--实训报告展示")
- public ResultEntity> getReportBySchoolID(@RequestParam Integer index,
- @RequestParam Integer size,
- @RequestParam String schoolId) {
+ public ResultEntity> getReportBySchoolID(@RequestParam Integer index,
+ @RequestParam Integer size,
+ @RequestParam String schoolId) {
PageHelper.startPage(index, size);
TrainingReportExample reportExample = new TrainingReportExample();
reportExample.createCriteria().andSchoolIdEqualTo(schoolId);
+ List list = new AstList();
List trainingReports = reportMapper.selectByExampleWithBLOBs(reportExample);
- return new ResultEntity>(new PageInfo<>(trainingReports));
+ if (!trainingReports.isEmpty()) {
+ for (TrainingReport trainingReport : trainingReports) {
+ TrainingReportDto trainingReportDto = new TrainingReportDto();
+ BeanUtils.copyProperties(trainingReport, trainingReportDto);
+ StuUser user = userMapper.selectByPrimaryKey(trainingReport.getUserId());
+ trainingReportDto.setName(user.getName());
+ trainingReportDto.setStudentId(user.getStudentId());
+ StuClass stuClass = stuClassMapper.selectByPrimaryKey(user.getClassId());
+ trainingReportDto.setClassName(stuClass.getClassName());
+ list.add(trainingReportDto);
+ }
+ }
+ PageInfo pageInfo = PageUtil.pageHelper(list, index, size);
+ return new ResultEntity<>(pageInfo);
}
@AnonymousAccess
@@ -335,6 +366,38 @@ public class TeaGradeManageController {
return new ResultEntity<>(iTeaGradeManageService.getReportCorrect(schoolId, index, size, module, classId, keyWord));
}
+
+ @AnonymousAccess
+ @PostMapping("/getChapterName")
+ @ApiOperation("评阅-章节下拉框")
+ public ResultEntity> getReportCorrect() {
+ List list = sysCourseMapper.selectNameByCourseID();
+ return new ResultEntity<>(list);
+ }
+
+
+ @Value("${file.path}")
+ private String filePath;
+
+ @GetMapping("/getReportByReportId")
+ @ApiOperation("评阅--获取单个学生报告接口")
+ @AnonymousAccess
+ public ResponseEntity getReport(@RequestParam String reportId, HttpServletResponse response) {
+ TrainingReport trainingReport = reportMapper.selectByPrimaryKey(reportId);
+ String fileUrl = trainingReport.getFilePath();
+ String videoPath = filePath + fileUrl;
+ File videoFile = new File(videoPath);
+ if (videoFile.exists()) {
+ FileSystemResource fileSystemResource = new FileSystemResource(videoFile);
+ return ResponseEntity.ok()
+ .contentType(MediaType.parseMediaType("application/pdf"))
+ .body(fileSystemResource);
+ } else {
+ return ResponseEntity.notFound().build();
+ }
+ }
+
+
@AnonymousAccess
@PostMapping("/updateScoreOrComment")
@ApiOperation("练习模式--实训报告评阅页面老师评分或评语")
diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java
index 7998a05..851173b 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/UserController.java
@@ -9,7 +9,6 @@ import com.sztzjy.financial_bigdata.config.security.JwtUser;
import com.sztzjy.financial_bigdata.config.security.LoginResult;
import com.sztzjy.financial_bigdata.config.security.TokenProvider;
import com.sztzjy.financial_bigdata.entity.*;
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import com.sztzjy.financial_bigdata.entity.stu_dto.StuUserDto;
import com.sztzjy.financial_bigdata.mapper.StuClassMapper;
import com.sztzjy.financial_bigdata.mapper.StuUserMapper;
@@ -27,6 +26,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
@@ -53,7 +53,7 @@ public class UserController {
private ITeaUserService userService;
@Autowired
private SysLoginLogMapper sysLoginLogMapper;
- @Autowired
+ @Resource
private AuthenticationManagerBuilder authenticationManagerBuilder;
// 用户登录时记录的信息
@@ -69,16 +69,23 @@ public class UserController {
public ResultEntity login(@RequestParam String passwordEncode,
@RequestParam String userName,
HttpServletRequest request,
- @RequestParam(required = false) String TOKEN) throws Exception {
+ @RequestParam(required = false) String TOKEN) {
JwtUser jwtUser;
- String passWord = RsaUtil.decryptByPrivateKey(passwordEncode);
+ String passWord;
+ try {
+ passWord = RsaUtil.decryptByPrivateKey(passwordEncode);
+ } catch (Exception e) {
+ return new ResultEntity(HttpStatus.BAD_REQUEST, "密码错误");
+ }
if (StringUtils.isBlank(TOKEN)) {
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(userName, passWord);
- System.out.println(authenticationToken);
+ System.out.println(userName);
+ System.out.println(passWord);
Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken);
SecurityContextHolder.getContext().setAuthentication(authentication);
- JwtUser jwtUser1 = (JwtUser) authentication.getPrincipal();
- String token = TokenProvider.createToken(jwtUser1);
+ jwtUser = (JwtUser) authentication.getPrincipal();
+ String token = TokenProvider.createToken(jwtUser);
+
// 1、子系统直接登录
StuUserExample stuUserExample = new StuUserExample();
stuUserExample.createCriteria().andUsernameEqualTo(userName).andPasswordEqualTo(passWord);
@@ -87,7 +94,7 @@ public class UserController {
if (stuUsers.isEmpty()) {
throw new UnAuthorizedException("用户名或密码错误");
} else {
- //保存用户的登录信息
+// 保存用户的登录信息
Map map = new HashMap<>();
StuUser user = stuUsers.get(0);
map.put("name", user.getName());
@@ -128,30 +135,28 @@ public class UserController {
map.put("classId", loginResult.getClassId());
map.put("userId", loginResult.getUserId());
map.put("token", token);
- String uuid = getIPAndPlace(request, loginResult.getName(), loginResult.getUserId(), jwtUser.getUsername()); //todo 学号暂时没有
+ String uuid = getIPAndPlace(request, loginResult.getName(), loginResult.getUserId(), jwtUser.getStudentId());
map.put("logId", uuid);
return new ResultEntity(HttpStatus.OK, map); //todo 从智云登录后将用户添加到本地用户表
}
}
-
- private String getIPAndPlace(HttpServletRequest request,String name,String userId,String studentId){
- String ip = request.getRemoteAddr();
- String ipHomePlace = userService.getIpAddress(ip);
- SysLoginLog sysLoginLog =new SysLoginLog();
- String uuid = IdUtil.randomUUID();
- sysLoginLog.setLogId(uuid);
- sysLoginLog.setLoginIp(ip);
- sysLoginLog.setUserid(userId);
- sysLoginLog.setName(name);
- sysLoginLog.setStudentId(studentId);
- sysLoginLog.setLoginTime(new Date());
- sysLoginLog.setIpAddress(ipHomePlace);
- sysLoginLogMapper.insert(sysLoginLog);
- return uuid;
- }
-
+ private String getIPAndPlace(HttpServletRequest request, String name, String userId, String studentId) {
+ String ip = request.getRemoteAddr();
+ String ipHomePlace = userService.getIpAddress(ip);
+ SysLoginLog sysLoginLog = new SysLoginLog();
+ String uuid = IdUtil.randomUUID();
+ sysLoginLog.setLogId(uuid);
+ sysLoginLog.setLoginIp(ip);
+ sysLoginLog.setUserid(userId);
+ sysLoginLog.setName(name);
+ sysLoginLog.setStudentId(studentId);
+ sysLoginLog.setLoginTime(new Date());
+ sysLoginLog.setIpAddress(ipHomePlace);
+ sysLoginLogMapper.insert(sysLoginLog);
+ return uuid;
+ }
@PostMapping("/setLoginDuration")
@@ -160,15 +165,13 @@ public class UserController {
SysLoginLog sysLoginLog = sysLoginLogMapper.selectByPrimaryKey(logID);
Date loginTime = sysLoginLog.getLoginTime();
Date date = new Date();
- long diffInMillis = date.getTime() - loginTime.getTime()/1000; //得到秒为单位的时间
- Date date1 =new Date(diffInMillis);
+ long diffInMillis = date.getTime() - loginTime.getTime() / 1000; //得到秒为单位的时间
+ Date date1 = new Date(diffInMillis);
sysLoginLog.setLoginDuration(date1);
sysLoginLogMapper.updateByPrimaryKey(sysLoginLog);
}
-
-
@ApiOperation("根据用户Code查询该用户是否存在个人赛用户数据,存在则返回,不存在则新增后返回,用于智云3.0创建用户后调用该接口创建用户个人赛")
@PostMapping("/checkOrCreateForexSimulationUser")
@AnonymousAccess
@@ -325,7 +328,6 @@ public class UserController {
// }
-
/*
* @author xcj
* @Date 2024/3/12
diff --git a/src/main/java/com/sztzjy/financial_bigdata/entity/tea_dto/TrainingReportDto.java b/src/main/java/com/sztzjy/financial_bigdata/entity/tea_dto/TrainingReportDto.java
new file mode 100644
index 0000000..b5b4f73
--- /dev/null
+++ b/src/main/java/com/sztzjy/financial_bigdata/entity/tea_dto/TrainingReportDto.java
@@ -0,0 +1,61 @@
+package com.sztzjy.financial_bigdata.entity.tea_dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 实训报告表
+ *
+ * @author xcj
+ * training_report
+ */
+@Data
+@NoArgsConstructor
+public class TrainingReportDto {
+ @ApiModelProperty("实训报告ID")
+ private String reportId;
+
+ @ApiModelProperty("章节ID")
+ private String chapterId;
+
+ @ApiModelProperty("章节名称")
+ private String chapterName;
+
+ @ApiModelProperty("用户ID")
+ private String userId;
+
+ @ApiModelProperty("姓名")
+ private String name;
+
+ @ApiModelProperty("学号")
+ private String studentId;
+
+ @ApiModelProperty("班级")
+ private String className;
+
+ @ApiModelProperty("实训报告名称")
+ private String reportName;
+
+ @ApiModelProperty("实训报告上传时间")
+ private Date uploadTime;
+
+ @ApiModelProperty("实训报告大小/单位MB")
+ private Integer reportSize;
+
+ @ApiModelProperty("教师评分")
+ private BigDecimal teacherScore;
+
+ @ApiModelProperty("文件地址")
+ private String filePath;
+
+ @ApiModelProperty("学校ID")
+ private String schoolId;
+
+ @ApiModelProperty("教师评语")
+ private String teacherComment;
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuClassMapper.java b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuClassMapper.java
index 23ae202..eec139c 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuClassMapper.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuClassMapper.java
@@ -37,4 +37,6 @@ public interface StuClassMapper {
@Select("SELECT s.class_name FROM stu_class s, stu_userinfo u WHERE s.class_id = u.class_id and s.class_id = #{classId};")
String selectClassNameByClassId(@Param("classId")String classId);
+
+ List selectByPrimaryKeys(@Param("classIds") List classIds);
}
\ No newline at end of file
diff --git a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuUserMapper.java b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuUserMapper.java
index 04f9e25..d530319 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/mapper/StuUserMapper.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/mapper/StuUserMapper.java
@@ -46,6 +46,14 @@ public interface StuUserMapper {
@Param("keyWord") String keyWord);
- @Select("select count(*) from stu_userinfo where class_id = #{s}")
- int selectNumByClass(@Param("s") String s);
+ @Select("")
+ int selectNumByClass(@Param("classIdList") List classIdList);
+
+
+ List selectNumByClasss(List classIdList);
}
\ No newline at end of file
diff --git a/src/main/java/com/sztzjy/financial_bigdata/mapper/SysCourseMapper.java b/src/main/java/com/sztzjy/financial_bigdata/mapper/SysCourseMapper.java
index 5e0c42b..18ea27c 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/mapper/SysCourseMapper.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/mapper/SysCourseMapper.java
@@ -41,4 +41,6 @@ public interface SysCourseMapper {
List getBySchoolId();
+ @Select("select scc.chapter_name from sys_course_chapter scc join sys_course sc on scc.course_id = sc.course_id where sc.input_type = '1'")
+ List selectNameByCourseID();
}
\ No newline at end of file
diff --git a/src/main/java/com/sztzjy/financial_bigdata/mapper/TeaAndStudentExamMapper.java b/src/main/java/com/sztzjy/financial_bigdata/mapper/TeaAndStudentExamMapper.java
index 071c563..58818fc 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/mapper/TeaAndStudentExamMapper.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/mapper/TeaAndStudentExamMapper.java
@@ -2,12 +2,12 @@ package com.sztzjy.financial_bigdata.mapper;
import com.sztzjy.financial_bigdata.entity.TeaAndStudentExam;
import com.sztzjy.financial_bigdata.entity.TeaAndStudentExamExample;
-import java.util.List;
-
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
+import java.util.List;
+
@Mapper
public interface TeaAndStudentExamMapper {
long countByExample(TeaAndStudentExamExample example);
@@ -32,6 +32,6 @@ public interface TeaAndStudentExamMapper {
int updateByPrimaryKey(TeaAndStudentExam record);
- @Select("select class_id from tea_and_student_exam where exam_manage_id =#{examManageId}")
- String selectByExamId(@Param("examManageId") String examManageId);
+// @Select("select class_id from tea_and_student_exam where exam_manage_id =#{examManageId}")
+// String selectByExamId(@Param("examManageId") String examManageId);
}
\ No newline at end of file
diff --git a/src/main/java/com/sztzjy/financial_bigdata/mapper/TeaExamManageMapper.java b/src/main/java/com/sztzjy/financial_bigdata/mapper/TeaExamManageMapper.java
index 123ed7a..2da98ff 100644
--- a/src/main/java/com/sztzjy/financial_bigdata/mapper/TeaExamManageMapper.java
+++ b/src/main/java/com/sztzjy/financial_bigdata/mapper/TeaExamManageMapper.java
@@ -44,4 +44,6 @@ public interface TeaExamManageMapper {
@Select("select * from tea_exam_manage where user_id = #{userId}")
List selectByUserId(@Param("userId") String userId);
+
+ List selectBySchoolId(@Param("schoolId")String schoolId);
}
\ No newline at end of file
diff --git a/src/main/resources/mapper/StuClassMapper.xml b/src/main/resources/mapper/StuClassMapper.xml
index 6ff4609..dc2ca42 100644
--- a/src/main/resources/mapper/StuClassMapper.xml
+++ b/src/main/resources/mapper/StuClassMapper.xml
@@ -1,196 +1,203 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- and ${criterion.condition}
-
-
- and ${criterion.condition} #{criterion.value}
-
-
- and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
-
-
- and ${criterion.condition}
-
- #{listItem}
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ and ${criterion.condition}
+
+
+ and ${criterion.condition} #{criterion.value}
+
+
+ and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+
+
+ and ${criterion.condition}
+
+ #{listItem}
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
- and ${criterion.condition}
-
-
- and ${criterion.condition} #{criterion.value}
-
-
- and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
-
-
- and ${criterion.condition}
-
- #{listItem}
-
-
-
+
+
+
+
+
+
+
+
+
+
+ and ${criterion.condition}
+
+
+ and ${criterion.condition} #{criterion.value}
+
+
+ and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+
+
+ and ${criterion.condition}
+
+ #{listItem}
+
+
+
+
+
+
-
+
+
+
+ class_id
+ , class_name, create_time, school_name
+
+
+
+
+ delete
+ from stu_class
+ where class_id = #{classId,jdbcType=VARCHAR}
+
+
+ delete from stu_class
+
+
-
-
-
-
- class_id, class_name, create_time, school_name
-
-
-
-
- delete from stu_class
- where class_id = #{classId,jdbcType=VARCHAR}
-
-
- delete from stu_class
-
-
-
-
-
- insert into stu_class (class_id, class_name, create_time,
- school_name)
- values (#{classId,jdbcType=VARCHAR}, #{className,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
- #{schoolName,jdbcType=VARCHAR})
-
-
- insert into stu_class
-
-
- class_id,
-
-
- class_name,
-
-
- create_time,
-
-
- school_name,
-
-
-
-
- #{classId,jdbcType=VARCHAR},
-
-
- #{className,jdbcType=VARCHAR},
-
-
- #{createTime,jdbcType=TIMESTAMP},
-
-
- #{schoolName,jdbcType=VARCHAR},
-
-
-
-
-
- update stu_class
-
-
- class_id = #{record.classId,jdbcType=VARCHAR},
-
-
+
+
+ insert into stu_class (class_id, class_name, create_time,
+ school_name)
+ values (#{classId,jdbcType=VARCHAR}, #{className,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
+ #{schoolName,jdbcType=VARCHAR})
+
+
+ insert into stu_class
+
+
+ class_id,
+
+
+ class_name,
+
+
+ create_time,
+
+
+ school_name,
+
+
+
+
+ #{classId,jdbcType=VARCHAR},
+
+
+ #{className,jdbcType=VARCHAR},
+
+
+ #{createTime,jdbcType=TIMESTAMP},
+
+
+ #{schoolName,jdbcType=VARCHAR},
+
+
+
+
+
+ update stu_class
+
+
+ class_id = #{record.classId,jdbcType=VARCHAR},
+
+
+ class_name = #{record.className,jdbcType=VARCHAR},
+
+
+ create_time = #{record.createTime,jdbcType=TIMESTAMP},
+
+
+ school_name = #{record.schoolName,jdbcType=VARCHAR},
+
+
+
+
+
+
+
+ update stu_class
+ set class_id = #{record.classId,jdbcType=VARCHAR},
class_name = #{record.className,jdbcType=VARCHAR},
-
-
create_time = #{record.createTime,jdbcType=TIMESTAMP},
-
-
- school_name = #{record.schoolName,jdbcType=VARCHAR},
-
-
-
-
-
-
-
- update stu_class
- set class_id = #{record.classId,jdbcType=VARCHAR},
- class_name = #{record.className,jdbcType=VARCHAR},
- create_time = #{record.createTime,jdbcType=TIMESTAMP},
- school_name = #{record.schoolName,jdbcType=VARCHAR}
-
-
-
-
-
- update stu_class
-
-
- class_name = #{className,jdbcType=VARCHAR},
-
-
- create_time = #{createTime,jdbcType=TIMESTAMP},
-
-
- school_name = #{schoolName,jdbcType=VARCHAR},
-
-
- where class_id = #{classId,jdbcType=VARCHAR}
-
-
- update stu_class
- set class_name = #{className,jdbcType=VARCHAR},
- create_time = #{createTime,jdbcType=TIMESTAMP},
- school_name = #{schoolName,jdbcType=VARCHAR}
- where class_id = #{classId,jdbcType=VARCHAR}
-
+ school_name = #{record.schoolName,jdbcType=VARCHAR}
+
+
+
+
+
+ update stu_class
+
+
+ class_name = #{className,jdbcType=VARCHAR},
+
+
+ create_time = #{createTime,jdbcType=TIMESTAMP},
+
+
+ school_name = #{schoolName,jdbcType=VARCHAR},
+
+
+ where class_id = #{classId,jdbcType=VARCHAR}
+
+
+ update stu_class
+ set class_name = #{className,jdbcType=VARCHAR},
+ create_time = #{createTime,jdbcType=TIMESTAMP},
+ school_name = #{schoolName,jdbcType=VARCHAR}
+ where class_id = #{classId,jdbcType=VARCHAR}
+
+
\ No newline at end of file
diff --git a/src/main/resources/mapper/TeaExamManageMapper.xml b/src/main/resources/mapper/TeaExamManageMapper.xml
index e2c579a..0981cbe 100644
--- a/src/main/resources/mapper/TeaExamManageMapper.xml
+++ b/src/main/resources/mapper/TeaExamManageMapper.xml
@@ -523,4 +523,13 @@
case_score = #{caseScore,jdbcType=DECIMAL}
where exam_manage_id = #{examManageId,jdbcType=VARCHAR}
+
+
+
+
\ No newline at end of file