自动生成配置文件和mapper xml

newBigdata
xiaoCJ 11 months ago
parent 93dd731bbe
commit e8fda05a6b

@ -88,7 +88,12 @@
<artifactId>spring-security-jwt</artifactId>
<version>1.1.1.RELEASE</version>
</dependency>
<!-- 其他依赖项 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- 其他依赖项 -->
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>

@ -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());

@ -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<StuUser> 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;
}
}

@ -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<String> authorityCodes;
private String studentId;
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {

@ -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;
/**
*

@ -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("未知文件工具类注入类型");
}
}
}

@ -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();
}
}

@ -88,7 +88,7 @@ public class StuKnowledgeNote {
@GetMapping("/getReport")
@ApiOperation("获取单个学生报告接口")
@ApiOperation("知识概要--获取单个学生报告接口")
@AnonymousAccess
public ResponseEntity<FileSystemResource> getReport(@RequestParam String chapterId, HttpServletResponse response) {
SysKnowledgeSummary sysKnowledgeSummary = sysKnowledgeSummaryMapper.selectByPrimaryKey(chapterId);

@ -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, "上传成功!");
}
}

@ -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<PageInfo<TeaExamManageCountDto>> getExamInfo(@RequestParam Integer index,
// @RequestParam Integer size,
// @ApiParam("ManyAnswer为考试时间JudgeAnswer为发布人") @RequestParam String schoolId) {
//
// List<TeaExamManage> teaExamManages = teaExamManageMapper.selectBySchoolId(schoolId);
// List<TeaExamManageCountDto>teaExamManageCountDtos =new AstList();
// for (TeaExamManage teaExamManage : teaExamManages) {
// List<String> 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<PageInfo<TeaExamManageCountDto>> getExamInfo(@RequestParam Integer index,
@RequestParam Integer size,
@ApiParam("ManyAnswer为考试时间JudgeAnswer为发布人") @RequestParam String schoolId) {
TeaExamManageExample teaExamManageExample = new TeaExamManageExample();
teaExamManageExample.createCriteria().andSchoolIdEqualTo(schoolId);
List<TeaExamManage> teaExamManages = teaExamManageMapper.selectByExample(teaExamManageExample);
List<TeaExamManage> teaExamManages = teaExamManageMapper.selectBySchoolId(schoolId);
List<TeaExamManageCountDto> teaExamManageCountDtos = new ArrayList<>();
// 批量查询班级信息
List<String> examIds = new ArrayList<>();
for (TeaExamManage teaExamManage : teaExamManages) {
List<String> 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<TeaExamManageCountDto>>(pageInfo);
}
@AnonymousAccess
@PostMapping("/getExamInfoAndRank")
@ApiOperation("考试模式--成绩排名和成绩情况展示") //TODO 图片可能需要一个接口去取
@ -312,14 +329,28 @@ public class TeaGradeManageController {
@AnonymousAccess
@PostMapping("/getReportBySchoolID")
@ApiOperation("练习模式--实训报告展示")
public ResultEntity<PageInfo<TrainingReport>> getReportBySchoolID(@RequestParam Integer index,
@RequestParam Integer size,
@RequestParam String schoolId) {
public ResultEntity<PageInfo<TrainingReportDto>> getReportBySchoolID(@RequestParam Integer index,
@RequestParam Integer size,
@RequestParam String schoolId) {
PageHelper.startPage(index, size);
TrainingReportExample reportExample = new TrainingReportExample();
reportExample.createCriteria().andSchoolIdEqualTo(schoolId);
List<TrainingReportDto> list = new AstList();
List<TrainingReport> trainingReports = reportMapper.selectByExampleWithBLOBs(reportExample);
return new ResultEntity<PageInfo<TrainingReport>>(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<List<String>> getReportCorrect() {
List<String> list = sysCourseMapper.selectNameByCourseID();
return new ResultEntity<>(list);
}
@Value("${file.path}")
private String filePath;
@GetMapping("/getReportByReportId")
@ApiOperation("评阅--获取单个学生报告接口")
@AnonymousAccess
public ResponseEntity<FileSystemResource> 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("练习模式--实训报告评阅页面老师评分或评语")

@ -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<String, Object> 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

@ -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;
}

@ -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<StuClass> selectByPrimaryKeys(@Param("classIds") List<String> classIds);
}

@ -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("<script>" +
"select COUNT(*) FROM stu_userinfo WHERE class_id IN("
+"<foreach collection='classIdList' separator=',' item='id'>"
+ "#{id} "
+ "</foreach> "
+")</script>")
int selectNumByClass(@Param("classIdList") List<String> classIdList);
List<Integer> selectNumByClasss(List<String> classIdList);
}

@ -41,4 +41,6 @@ public interface SysCourseMapper {
List<SysCourse> 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<String> selectNameByCourseID();
}

@ -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);
}

@ -44,4 +44,6 @@ public interface TeaExamManageMapper {
@Select("select * from tea_exam_manage where user_id = #{userId}")
List<TeaExamManageWithBLOBs> selectByUserId(@Param("userId") String userId);
List<TeaExamManage> selectBySchoolId(@Param("schoolId")String schoolId);
}

@ -1,196 +1,203 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sztzjy.financial_bigdata.mapper.StuClassMapper">
<resultMap id="BaseResultMap" type="com.sztzjy.financial_bigdata.entity.StuClass">
<id column="class_id" jdbcType="VARCHAR" property="classId" />
<result column="class_name" jdbcType="VARCHAR" property="className" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="school_name" jdbcType="VARCHAR" property="schoolName" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
<resultMap id="BaseResultMap" type="com.sztzjy.financial_bigdata.entity.StuClass">
<id column="class_id" jdbcType="VARCHAR" property="classId"/>
<result column="class_name" jdbcType="VARCHAR" property="className"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="school_name" jdbcType="VARCHAR" property="schoolName"/>
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</trim>
</where>
</sql>
<sql id="Base_Column_List">
class_id
, class_name, create_time, school_name
</sql>
<select id="selectByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuClassExample"
resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List"/>
from stu_class
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from stu_class
where class_id = #{classId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete
from stu_class
where class_id = #{classId,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuClassExample">
delete from stu_class
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
class_id, class_name, create_time, school_name
</sql>
<select id="selectByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuClassExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from stu_class
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from stu_class
where class_id = #{classId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from stu_class
where class_id = #{classId,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuClassExample">
delete from stu_class
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.sztzjy.financial_bigdata.entity.StuClass">
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>
<insert id="insertSelective" parameterType="com.sztzjy.financial_bigdata.entity.StuClass">
insert into stu_class
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="classId != null">
class_id,
</if>
<if test="className != null">
class_name,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="schoolName != null">
school_name,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="classId != null">
#{classId,jdbcType=VARCHAR},
</if>
<if test="className != null">
#{className,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="schoolName != null">
#{schoolName,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuClassExample" resultType="java.lang.Long">
select count(*) from stu_class
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update stu_class
<set>
<if test="record.classId != null">
class_id = #{record.classId,jdbcType=VARCHAR},
</if>
<if test="record.className != null">
</delete>
<insert id="insert" parameterType="com.sztzjy.financial_bigdata.entity.StuClass">
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>
<insert id="insertSelective" parameterType="com.sztzjy.financial_bigdata.entity.StuClass">
insert into stu_class
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="classId != null">
class_id,
</if>
<if test="className != null">
class_name,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="schoolName != null">
school_name,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="classId != null">
#{classId,jdbcType=VARCHAR},
</if>
<if test="className != null">
#{className,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="schoolName != null">
#{schoolName,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.sztzjy.financial_bigdata.entity.StuClassExample"
resultType="java.lang.Long">
select count(*) from stu_class
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update stu_class
<set>
<if test="record.classId != null">
class_id = #{record.classId,jdbcType=VARCHAR},
</if>
<if test="record.className != null">
class_name = #{record.className,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.schoolName != null">
school_name = #{record.schoolName,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByExample" parameterType="map">
update stu_class
set class_id = #{record.classId,jdbcType=VARCHAR},
class_name = #{record.className,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.schoolName != null">
school_name = #{record.schoolName,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
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}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.financial_bigdata.entity.StuClass">
update stu_class
<set>
<if test="className != null">
class_name = #{className,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="schoolName != null">
school_name = #{schoolName,jdbcType=VARCHAR},
</if>
</set>
where class_id = #{classId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.sztzjy.financial_bigdata.entity.StuClass">
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}
</update>
school_name = #{record.schoolName,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.financial_bigdata.entity.StuClass">
update stu_class
<set>
<if test="className != null">
class_name = #{className,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="schoolName != null">
school_name = #{schoolName,jdbcType=VARCHAR},
</if>
</set>
where class_id = #{classId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.sztzjy.financial_bigdata.entity.StuClass">
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}
</update>
</mapper>

@ -523,4 +523,13 @@
case_score = #{caseScore,jdbcType=DECIMAL}
where exam_manage_id = #{examManageId,jdbcType=VARCHAR}
</update>
<select id="selectBySchoolId" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
from tea_exam_manage
where school_id = #{schoolId,jdbcType=VARCHAR}
</select>
</mapper>
Loading…
Cancel
Save