学生管理邮箱手机绑定

hehai
mzh820631607 4 years ago
parent ea48c4e74c
commit bfa0273c69
  1. 5
      pom.xml
  2. 2
      src/main/java/com/msdw/tms/api/EvaluationRecordControllerApi.java
  3. 3
      src/main/java/com/msdw/tms/api/QuestionsControllerApi.java
  4. 13
      src/main/java/com/msdw/tms/api/StudentControllerApi.java
  5. 22
      src/main/java/com/msdw/tms/common/utils/ConstantUtils.java
  6. 109
      src/main/java/com/msdw/tms/common/utils/ExcelImportHelper.java
  7. 5
      src/main/java/com/msdw/tms/controller/EvaluationRecordController.java
  8. 61
      src/main/java/com/msdw/tms/controller/QuestionsController.java
  9. 115
      src/main/java/com/msdw/tms/controller/StudentController.java
  10. 25
      src/main/java/com/msdw/tms/controller/UserInfoController.java
  11. 7
      src/main/java/com/msdw/tms/dao/QuestionsDao.java
  12. 17
      src/main/java/com/msdw/tms/dao/StudentDao.java
  13. 20
      src/main/java/com/msdw/tms/dao/UserInfoDao.java
  14. 16
      src/main/java/com/msdw/tms/entity/StudentEntity.java
  15. 5
      src/main/java/com/msdw/tms/entity/UserInfoEntity.java
  16. 18
      src/main/java/com/msdw/tms/entity/vo/RulesVo.java
  17. 15
      src/main/java/com/msdw/tms/entity/vo/StudentVo.java
  18. 16
      src/main/java/com/msdw/tms/service/QuestionsService.java
  19. 17
      src/main/java/com/msdw/tms/service/StudentService.java
  20. 12
      src/main/java/com/msdw/tms/service/UserInfoService.java
  21. 34
      src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java
  22. 220
      src/main/java/com/msdw/tms/service/impl/StudentServiceImpl.java
  23. 80
      src/main/java/com/msdw/tms/service/impl/UserInfoServiceImpl.java
  24. 2
      src/main/resources/application.yml
  25. BIN
      src/main/resources/excel-template/学生导入模板.xlsx
  26. 6
      src/main/resources/mapper/tms/QuestionsDao.xml
  27. 91
      src/main/resources/mapper/tms/StudentDao.xml
  28. 69
      src/main/resources/mapper/tms/UserInfoDao.xml
  29. 25
      src/test/java/com/msdw/tms/JedisTest.java
  30. 12
      src/test/java/com/msdw/tms/service/QuestionsServiceTest.java
  31. 5
      src/test/java/com/msdw/tms/service/StudentTest.java

@ -35,6 +35,11 @@
<artifactId>poi-ooxml-schemas</artifactId> <artifactId>poi-ooxml-schemas</artifactId>
<version>4.0.1</version> <version>4.0.1</version>
</dependency> </dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.3</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

@ -40,7 +40,7 @@ public interface EvaluationRecordControllerApi {
* 开始测评返回第一题的数据 * 开始测评返回第一题的数据
*/ */
@ApiOperation(value = "开始测评", notes = "开始测评") @ApiOperation(value = "开始测评", notes = "开始测评")
R startEvaluation(Integer userId,Integer type); R startEvaluation(Integer userId);
/** /**
* 上一题 * 上一题

@ -4,6 +4,7 @@ import com.msdw.tms.common.utils.R;
import com.msdw.tms.entity.request.QuestionsAddRequest; import com.msdw.tms.entity.request.QuestionsAddRequest;
import com.msdw.tms.entity.request.QuestionsQueryRequest; import com.msdw.tms.entity.request.QuestionsQueryRequest;
import com.msdw.tms.entity.request.QuestionsUpdateRequest; import com.msdw.tms.entity.request.QuestionsUpdateRequest;
import com.msdw.tms.entity.vo.RulesVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
@ -51,6 +52,8 @@ public interface QuestionsControllerApi {
/** /**
* 是否禁用试题 * 是否禁用试题
*/ */
// @ApiOperation(value = "是否禁用试题", notes = "是否禁用试题")
// R isNable(RulesVo rulesVo);
@ApiOperation(value = "是否禁用试题", notes = "是否禁用试题") @ApiOperation(value = "是否禁用试题", notes = "是否禁用试题")
R isNable(@ApiParam(name = "id", value = "试题主键", required = true) List<Integer> idList); R isNable(@ApiParam(name = "id", value = "试题主键", required = true) List<Integer> idList);
// 2020.09.18 // 2020.09.18

@ -6,7 +6,10 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List; import java.util.List;
@Api(value = "学生管理", tags = "学生管理") @Api(value = "学生管理", tags = "学生管理")
@ -25,8 +28,14 @@ public interface StudentControllerApi {
public R updateStudent(StudentVo studentVo); public R updateStudent(StudentVo studentVo);
@ApiOperation(value = "重置密码",notes = "重置密码") @ApiOperation(value = "重置密码",notes = "重置密码")
public R reSetPassword(Integer userId); public R reSetPassword(List<Integer> userId);
@ApiOperation(value = "禁用账号",notes = "禁用账号") @ApiOperation(value = "禁用账号",notes = "禁用账号")
public R disableAccount(Integer userId); public R disableAccount(StudentVo studentIds);
@ApiOperation(value = "下载导入模板", notes = "下载导入模板")
public R downloadFiles(HttpServletResponse response) throws IOException;
@ApiOperation(value = "批量导入学生信息",notes = "批量导入学生信息")
public R uploadFile(MultipartFile file) throws IOException;
} }

@ -0,0 +1,22 @@
package com.msdw.tms.common.utils;
/**
* 此类用于公用常量设置
*/
public class ConstantUtils {
//绑定电子科大的schoolId
public static final Integer Keda_schoolId = 2105;
//绑定角色ID
public static final Integer STUDENT_ROLE = 4;
public static final String STR_STUDENT_ROLE = "4";
//平台id
public static final Integer PLATFORMID= 1;
//excel模板信息表id
public static final int XLSX_TEMPLATE_ID = 2;
//用户初始密码
public static final String INITIAL_PASSWORD = "huoran123";
}

@ -0,0 +1,109 @@
package com.msdw.tms.common.utils;
import com.msdw.tms.entity.vo.StudentVo;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class ExcelImportHelper {
/**
* 读取学生管理
* @param file
* @return
*/
public static List<StudentVo> readStudent(MultipartFile file) {
List<StudentVo> list = new ArrayList<StudentVo>();
Workbook workbook=getWorkbook(file);
StudentVo student = null;
// 循环工作表Sheet
for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
Sheet hssfSheet = workbook.getSheetAt(numSheet);
if (hssfSheet == null) {
continue;
}
// 循环行Row//开始行2
for (int rowNum = 2; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
Row row = hssfSheet.getRow(rowNum);
Cell phone;
Cell email;
if (row != null) {
student = new StudentVo();
row.getCell(0).setCellType(CellType.STRING);
Cell studentName = row.getCell(0);
row.getCell(1).setCellType(CellType.STRING);
Cell schoolAppellationName = row.getCell(1);
row.getCell(2).setCellType(CellType.STRING);
Cell account = row.getCell(2);
row.getCell(3).setCellType(CellType.STRING);
Cell studentNumber = row.getCell(3);
if (row.getCell(4)!=null){
row.getCell(4).setCellType(CellType.STRING);
phone = row.getCell(4);
}else {
phone = row.createCell(4);
}
if (row.getCell(5)!=null){
row.getCell(5).setCellType(CellType.STRING);
email = row.getCell(5);
}else {
email = row.createCell(5);
}
// row.getCell(4).setCellType(CellType.STRING);
// Cell phone = row.getCell(4);
// row.getCell(5).setCellType(CellType.STRING);
// Cell email = row.getCell(5);
// 学生姓名
student.setUserName(studentName.getStringCellValue());
// 角色id
student.setRoleId(ConstantUtils.STUDENT_ROLE);
// 学生学号
student.setWorkNumber(studentNumber.getStringCellValue());
//所属院校
student.setSchoolAppellationName(schoolAppellationName.getStringCellValue());
//用户账号
student.setAccount(account.getStringCellValue());
//电话
student.setPhone(phone.getStringCellValue());
//邮箱
student.setEmail(email.getStringCellValue());
//学校id
student.setSchoolId(ConstantUtils.Keda_schoolId);
list.add(student);
}
}
}
return list;
}
private static Workbook getWorkbook(MultipartFile file) {
String fileName = file.getOriginalFilename();
Workbook workbook = null;
if (fileName.endsWith("xlsx")) {
try {
workbook = new XSSFWorkbook(file.getInputStream());
} catch (IOException e) {
e.printStackTrace();
}
}else if (fileName.endsWith("xls")) {
try {
workbook = new HSSFWorkbook(file.getInputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
return workbook;
}
}

@ -57,9 +57,10 @@ public class EvaluationRecordController implements EvaluationRecordControllerApi
@Override @Override
@GetMapping("/start") @GetMapping("/start")
public R startEvaluation(@RequestParam(value = "userId") Integer userId,Integer type) { // public R startEvaluation(@RequestParam(value = "userId") Integer userId,Integer type) {
public R startEvaluation(@RequestParam(value = "userId") Integer userId) {
TMSEvaluationRecordVO evaluationRecordVO = evaluationRecordService.startEvaluation(userId); TMSEvaluationRecordVO evaluationRecordVO = evaluationRecordService.startEvaluation(userId);
evaluationRecordVO.setTypes(type); // evaluationRecordVO.setTypes(type);
return R.ok().put("data", evaluationRecordVO); return R.ok().put("data", evaluationRecordVO);
} }

@ -1,14 +1,20 @@
package com.msdw.tms.controller; package com.msdw.tms.controller;
import com.msdw.tms.api.QuestionsControllerApi; import com.msdw.tms.api.QuestionsControllerApi;
import com.msdw.tms.common.exception.ExceptionCast;
import com.msdw.tms.common.utils.Constant;
import com.msdw.tms.common.utils.FilesResult; import com.msdw.tms.common.utils.FilesResult;
import com.msdw.tms.common.utils.PageUtils; import com.msdw.tms.common.utils.PageUtils;
import com.msdw.tms.common.utils.R; import com.msdw.tms.common.utils.R;
import com.msdw.tms.entity.EvaluationRulesEntity;
import com.msdw.tms.entity.QuestionsEntity;
import com.msdw.tms.entity.request.QuestionsAddRequest; import com.msdw.tms.entity.request.QuestionsAddRequest;
import com.msdw.tms.entity.request.QuestionsQueryRequest; import com.msdw.tms.entity.request.QuestionsQueryRequest;
import com.msdw.tms.entity.request.QuestionsUpdateRequest; import com.msdw.tms.entity.request.QuestionsUpdateRequest;
import com.msdw.tms.entity.response.CommonCode;
import com.msdw.tms.entity.vo.EvaluationVO; import com.msdw.tms.entity.vo.EvaluationVO;
import com.msdw.tms.entity.vo.QuestionsDetailVO; import com.msdw.tms.entity.vo.QuestionsDetailVO;
import com.msdw.tms.entity.vo.RulesVo;
import com.msdw.tms.service.QuestionsService; import com.msdw.tms.service.QuestionsService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -86,13 +92,12 @@ public class QuestionsController implements QuestionsControllerApi {
return update ? R.ok() : R.error(); return update ? R.ok() : R.error();
} }
/** /**
* 是否禁用试题 * 是否禁用试题
*/ */
// @Override @Override
@PutMapping("/isenable") @PutMapping("/isenable")
// 2020.09.18
// @RequiresPermissions("qms:questions:isenable")
// public R isNable(@RequestBody Integer id) { // public R isNable(@RequestBody Integer id) {
public R isNable(@RequestBody List<Integer> idList) { public R isNable(@RequestBody List<Integer> idList) {
Integer id = idList.get(0); Integer id = idList.get(0);
@ -101,6 +106,56 @@ public class QuestionsController implements QuestionsControllerApi {
return b ? R.ok() : R.error(); return b ? R.ok() : R.error();
} }
// /**
// * 是否禁用试题
// */
// @Override
// @PutMapping("/isenable")
//// 2020.09.18
//// @RequiresPermissions("qms:questions:isenable")
//// public R isNable(@RequestBody Integer id) {
// public R isNable(@RequestBody RulesVo rules) {
//// public R isNable(@RequestBody List<Integer> idList) {
//// Integer id = idList.get(0);
// QuestionsEntity questionsEntity = new QuestionsEntity();
// Integer id = rules.getQuestionId();
// questionsEntity.setId(id);
// QuestionsEntity byId = questionsService.getById(id);
// int rulesNumber = rules.getQuestionsNumber();
// if (byId.getIsEnable().equals(Constant.IsEnable.ENABLE.getType())) {
// Integer types = rules.getTypes();
//// String questionsTypes= types==1 ? "single_num" : (types==2 ? "multiple_num":"judgment_num");//根据题型获取数据库字段名
// EvaluationRulesEntity rule = questionsService.queryNumberOfTatolQuestions();
// int num = 0;
// if (types==1){
// num += rule.getSingleNum();
// }else if (types==2){
// num += rule.getMultipleNum();
// }else if (types==3){
// num += rule.getJudgmentNum();
// }
// if (num<rulesNumber-1){
// return R.error(400,"试题数量不能少于测评设置对应题的数量");
// }else{
// questionsEntity.setIsEnable(Constant.IsEnable.NOT_ENABLE.getType());
// }
//
// } else if (byId.getIsEnable().equals(Constant.IsEnable.NOT_ENABLE.getType())) {
// questionsEntity.setIsEnable(Constant.IsEnable.ENABLE.getType());
// } else {
// ExceptionCast.cast(CommonCode.INVALID_PARAM);
// }
//
// boolean b = questionsService.isEnable(rules,questionsEntity);
//
// EvaluationRulesEntity questions= questionsService.queryNumberOfQuestions();
// if (b){
// return R.ok().put("questions", questions);
// }else {
// return R.error().put("questions", questions);
// }
// }
/** /**
* 删除 * 删除
*/ */

@ -2,6 +2,8 @@ package com.msdw.tms.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.msdw.tms.api.StudentControllerApi; import com.msdw.tms.api.StudentControllerApi;
import com.msdw.tms.common.utils.Constant;
import com.msdw.tms.common.utils.ConstantUtils;
import com.msdw.tms.common.utils.PageUtils; import com.msdw.tms.common.utils.PageUtils;
import com.msdw.tms.common.utils.R; import com.msdw.tms.common.utils.R;
import com.msdw.tms.entity.StudentEntity; import com.msdw.tms.entity.StudentEntity;
@ -9,10 +11,15 @@ import com.msdw.tms.entity.UserInfoEntity;
import com.msdw.tms.entity.vo.StudentVo; import com.msdw.tms.entity.vo.StudentVo;
import com.msdw.tms.service.StudentService; import com.msdw.tms.service.StudentService;
import com.msdw.tms.service.UserInfoService; import com.msdw.tms.service.UserInfoService;
import com.sun.xml.bind.v2.model.core.ID;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**
@ -32,19 +39,38 @@ public class StudentController implements StudentControllerApi{
* @param studentVo * @param studentVo
* @return * @return
*/ */
@Transactional
@Override @Override
@PostMapping("/addStudent") @PostMapping("/addStudent")
public R addStudent(@RequestBody StudentVo studentVo){ public R addStudent(@RequestBody StudentVo studentVo){
studentVo.setSchoolId(ConstantUtils.Keda_schoolId);
String studentIdNumber = studentVo.getStudentIdNumber(); String account = studentVo.getAccount();
Integer result = studentService.queryStudentIdNumber(studentIdNumber); String phone = studentVo.getPhone();
Integer schoolId = studentVo.getSchoolId();
Integer result = studentService.queryStudentIdNumber(studentVo.getWorkNumber(),schoolId);
Integer res = userInfoService.queryStudentAccount(account,schoolId);
if (phone!=null&&phone!=""){
Integer outcome = userInfoService.queryStudentPhone(phone,schoolId);
if(outcome==1){
return R.error("手机号不能重复,只能绑定一个用户");
}
}
String email = studentVo.getEmail();
if (result==1){ if (result==1){
return R.error("学号不能重复"); return R.error("学号不能重复");
}else{ }else if (res==1){
UserInfoEntity userInfoList = studentVo.getUserInfo(); return R.error("账号不能重复");
}
else{
UserInfoEntity userInfoList = new UserInfoEntity();
userInfoList.setAccount(account)
.setPhone(phone)
.setEmail(studentVo.getEmail())
.setSchoolId(studentVo.getSchoolId())
.setUserName(studentVo.getUserName());
userInfoService.saveUserInfo(userInfoList); userInfoService.saveUserInfo(userInfoList);
studentVo.setUserId(userInfoList.getUserId()); studentVo.setUserId(userInfoList.getUserId()).setPlatformId(ConstantUtils.PLATFORMID);//暂时写死平台id(PlatformId)
boolean saveStudent = studentService.saveStudent(studentVo); boolean saveStudent = studentService.saveStudent(studentVo);
return saveStudent ? R.ok() : R.error(); return saveStudent ? R.ok() : R.error();
} }
@ -86,11 +112,20 @@ public class StudentController implements StudentControllerApi{
@Override @Override
@PutMapping("/updateStudent") @PutMapping("/updateStudent")
public R updateStudent(@RequestBody StudentVo studentVo) { public R updateStudent(@RequestBody StudentVo studentVo) {
studentVo.setSchoolId(ConstantUtils.Keda_schoolId);//设定学校id
Integer studentId = studentVo.getStudentId();
if (studentId==null){
return R.error(400,"studentId不能为空");
}
studentService.updateWorkNumber(studentId);//先将原本的学号重置为00,便于判重
Integer result = studentService.queryStudentIdNumber(studentVo.getWorkNumber(),ConstantUtils.Keda_schoolId);
Integer res = userInfoService.queryStudentAccount(studentVo.getAccount(),ConstantUtils.Keda_schoolId);
String studentIdNumber = studentVo.getStudentIdNumber();
Integer result = studentService.queryStudentIdNumber(studentIdNumber);
if (result==1){ if (result==1){
return R.error("学号不能重复"); return R.error("学号不能重复");
}else if (res==1){
return R.error("账号不能重复");
}else{ }else{
boolean saveStudent = studentService.updateStudent(studentVo); boolean saveStudent = studentService.updateStudent(studentVo);
@ -100,26 +135,74 @@ public class StudentController implements StudentControllerApi{
/** /**
* 重置密码 * 重置密码
* @param userId * @param userIds
* @return * @return
*/ */
@Override @Override
@PutMapping("/reSetPassword") @PutMapping("/reSetPassword")
public R reSetPassword(@RequestBody Integer userId){ public R reSetPassword(@RequestBody List<Integer> userIds){
boolean initial = studentService.initialPassword(userId); Integer userId = userIds.get(0);
return initial ? R.ok() : R.error(); try {
Integer initial = userInfoService.initialPassword(userId);
if (initial==0){
return R.error(400,"密码不变,更新成功");
}
}catch (RuntimeException e){
e.printStackTrace();
return R.error();
}
return R.ok();
} }
/** /**
* 禁用账号 * 禁用账号
* @param studentId * @param studentIds
* @return * @return
*/ */
@Override @Override
@PutMapping("/disableAccount") @PutMapping("/disableAccount")
public R disableAccount(@RequestBody Integer studentId) { public R disableAccount(@RequestBody StudentVo studentIds) {
boolean disable = studentService.disableAccount(studentId);
return disable ? R.ok() : R.error(); Integer state = studentIds.getDisableAccount();
if (state==0){
studentIds.setDisableAccount(1);
}else if(state==1){
studentIds.setDisableAccount(0);
}
userInfoService.disableAccount(studentIds);
return R.ok();
}
public R downLoadStudent(){
return R.ok();
} }
/**
* excel模板文件下载
*/
@Override
@GetMapping("/download")
public R downloadFiles(HttpServletResponse response) throws IOException {
studentService.downloadFiles(response);
return R.ok();
}
/**
* 批量导入学生信息
* @param file
* @return
*/
@Override
@PostMapping("/uploadFile")
public R uploadFile(MultipartFile file) throws IOException{
Integer schoolId = ConstantUtils.Keda_schoolId;
HashMap<String,Object> upload = studentService.upload(file,schoolId);
return R.ok().put("data",upload);
}
@PostMapping("/export_failure")
public void exportFailureRecord(HttpServletResponse response, String token) throws Exception{
studentService.exportFailureRecord(response,token);
}
} }

@ -7,6 +7,7 @@ import com.msdw.tms.common.utils.R;
import com.msdw.tms.entity.UserEntity; import com.msdw.tms.entity.UserEntity;
import com.msdw.tms.entity.UserInfoEntity; import com.msdw.tms.entity.UserInfoEntity;
import com.msdw.tms.entity.vo.UserEntityVo; import com.msdw.tms.entity.vo.UserEntityVo;
import com.msdw.tms.service.StudentService;
import com.msdw.tms.service.UserInfoService; import com.msdw.tms.service.UserInfoService;
import com.msdw.tms.service.UserService; import com.msdw.tms.service.UserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import java.util.Map; import java.util.Map;
@RestController @RestController
@ -22,6 +24,9 @@ public class UserInfoController implements UserInfoControllerApi {
@Autowired @Autowired
private UserInfoService userInfoService; private UserInfoService userInfoService;
@Autowired
private StudentService studentService;
/** /**
* 列表 * 列表
*/ */
@ -46,9 +51,26 @@ public class UserInfoController implements UserInfoControllerApi {
/** /**
* 注册 * 注册
*/ */
@Override
@Transactional
@PostMapping("/add") @PostMapping("/add")
public R save(@RequestBody UserInfoEntity userInfoEntity){ public R save(@RequestBody UserInfoEntity userInfoEntity){
userInfoService.add(userInfoEntity); userInfoEntity.setSchoolId(2105);
Integer schoolId = userInfoEntity.getSchoolId();
Integer integer = userInfoService.queryStudentAccount(userInfoEntity.getAccount(),schoolId);
Integer integer1 = userInfoService.queryStudentPhone(userInfoEntity.getPhone(),schoolId);
if (integer==1){
return R.error(400,"账号已存在");
}
if (integer1==1){
return R.error(400,"改手机号已被绑定");
}
int userId = userInfoService.add(userInfoEntity);
if (userId==0){
return R.error(400,"添加用户信息失败");
}
// userInfoEntity.setUserId(userId);
studentService.addStudentInfo(userInfoEntity);
return R.ok(); return R.ok();
} }
@ -56,6 +78,7 @@ public class UserInfoController implements UserInfoControllerApi {
/** /**
* 修改 * 修改
*/ */
@Override
@PutMapping("/update") @PutMapping("/update")
public R update(@RequestBody UserInfoEntity userEntity){ public R update(@RequestBody UserInfoEntity userEntity){
userInfoService.updateById(userEntity); userInfoService.updateById(userEntity);

@ -1,7 +1,9 @@
package com.msdw.tms.dao; package com.msdw.tms.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.msdw.tms.entity.EvaluationRulesEntity;
import com.msdw.tms.entity.QuestionsEntity; import com.msdw.tms.entity.QuestionsEntity;
import com.msdw.tms.entity.vo.QuestionsDetailVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -23,4 +25,9 @@ public interface QuestionsDao extends BaseMapper<QuestionsEntity> {
Integer countTotalMultiplenum(); Integer countTotalMultiplenum();
Integer countTotalJudgmentnum(); Integer countTotalJudgmentnum();
EvaluationRulesEntity queryNumberOfQuestions();
EvaluationRulesEntity queryNumberOfTatolQuestions();
} }

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.msdw.tms.entity.StudentEntity; import com.msdw.tms.entity.StudentEntity;
import com.msdw.tms.entity.UserInfoEntity;
import com.msdw.tms.entity.vo.StudentVo; import com.msdw.tms.entity.vo.StudentVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
@ -13,17 +14,23 @@ import java.util.List;
@Mapper @Mapper
public interface StudentDao extends BaseMapper<StudentEntity> { public interface StudentDao extends BaseMapper<StudentEntity> {
List<Integer> queryStudentIdNumber(String studentIdNumber); List<Integer> queryStudentIdNumber(String workNumber,Integer schoolId);
boolean saveStudent(StudentVo studentVo); boolean saveStudent(StudentVo studentVo);
IPage<StudentVo> queryStudent(Page<T> tpage,String searchContent,Integer schoolId); IPage<StudentVo> queryStudent(Page<T> tpage,String searchContent,Integer schoolId);
boolean deleteStudent(List<Integer> studentId); Integer deleteStudent(List<Integer> studentId);
boolean updateStudent(StudentVo studentVo); Integer updateStudent(StudentVo studentVo);
boolean initialPassword(Integer userId,String password); void updateWorkNumber(String workNumber);
boolean disableAccount(Integer studentId); boolean addStudentInfo(UserInfoEntity userInfoEntity);
List<Integer> querySchoolName(String schoolAppellationName);
int bacthAddStudents(List<StudentVo> students);
int querySchoolAppellationName(String schoolAppellationName);
} }

@ -2,19 +2,37 @@ package com.msdw.tms.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.msdw.tms.common.utils.R; import com.msdw.tms.common.utils.R;
import com.msdw.tms.entity.StudentEntity;
import com.msdw.tms.entity.UserEntity; import com.msdw.tms.entity.UserEntity;
import com.msdw.tms.entity.UserInfoEntity; import com.msdw.tms.entity.UserInfoEntity;
import com.msdw.tms.entity.vo.StudentVo;
import com.msdw.tms.entity.vo.UserEntityVo; import com.msdw.tms.entity.vo.UserEntityVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper @Mapper
public interface UserInfoDao extends BaseMapper<UserInfoEntity> { public interface UserInfoDao extends BaseMapper<UserInfoEntity> {
Boolean add(UserInfoEntity userEntity); int add(UserInfoEntity userEntity);
void userInfupdateUserInfoById(UserInfoEntity entity); void userInfupdateUserInfoById(UserInfoEntity entity);
String queryUserPassword(Integer userid); String queryUserPassword(Integer userid);
int saveUserInfo(UserInfoEntity userInfo); int saveUserInfo(UserInfoEntity userInfo);
Integer initialPassword(Integer userId, String password);
Integer disableAccount(StudentVo studentIds);
List<StudentEntity> queryStudentAccount(String account,Integer schoolId);
List<StudentEntity> queryStudentPhone(String phone,Integer schoolId);
int bacthAddStudents(List<StudentVo> students);
int batchSaveUserInfo(StudentVo studentVo);
} }

@ -7,7 +7,7 @@ import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
@Data @Data
@TableName("tms_student") @TableName("student")
@Accessors(chain = true) @Accessors(chain = true)
public class StudentEntity { public class StudentEntity {
@ -19,17 +19,25 @@ public class StudentEntity {
//绑定用户Id //绑定用户Id
private Integer userId; private Integer userId;
//学号 //学号
private String studentIdNumber; private String workNumber;
//绑定专业Id //绑定专业Id
private Integer professionalId; private Integer professionalId;
//绑定专业名称
private String professionalName;
//绑定年级Id //绑定年级Id
private Integer gradeId; private Integer gradeId;
//绑定年级名称
private String gradeName;
//绑定班级Id、 //绑定班级Id、
private Integer classId; private Integer classId;
//绑定班级名称
private String className;
//绑定角色Id //绑定角色Id
private Integer roleId; private Integer roleId;
//登录次数
private Integer loginNumber;
//是否删除(0未删除,1已删除) //是否删除(0未删除,1已删除)
private Integer isdel; private Integer isdel;
//是否禁用账号(0禁用,1不禁用,默认0 //绑定平台id(默认手写1
private Integer disableAccount; private Integer platformId;
} }

@ -54,5 +54,8 @@ public class UserInfoEntity {
private Integer isdel; private Integer isdel;
//角色id //角色id
private String roleId; private String roleId;
//是否禁用(0未禁用1已禁用默认0)
private Integer disableAccount;
//所属院校id
private Integer schoolAppellationId;
} }

@ -0,0 +1,18 @@
package com.msdw.tms.entity.vo;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class RulesVo {
//题型(1单选2多选3判断)
private Integer types;
//试题数量
private Integer questionsNumber;
//测评对应该试题数量
// private int rulesNumber;
//试题id
private Integer questionId;
}

@ -14,21 +14,26 @@ import java.util.List;
@Accessors(chain = true) @Accessors(chain = true)
public class StudentVo extends StudentEntity { public class StudentVo extends StudentEntity {
private UserInfoEntity userInfo;
//学校名称 //学校名称
private String schoolName; private String schoolName;
//用户姓名 //用户姓名
private String userName; private String userName;
//用户账号 //用户账号
private String account; private String account;
//登陆次数 //密码
private Integer logInNumber; private String password;
//最后登陆时间 //最后登陆时间
private String lastLoginTime; private String lastLoginTime;
//电话 //电话
private String phone; private String phone;
//邮箱 //邮箱
private String email; private String email;
//禁用状态
private Integer disableAccount;
//所属院校
private String schoolAppellation;
//唯一性标识账号
private String uniqueIdentificationAccount;
//绑定所属院校名称
private String schoolAppellationName;
} }

@ -3,12 +3,16 @@ package com.msdw.tms.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.msdw.tms.common.utils.FilesResult; import com.msdw.tms.common.utils.FilesResult;
import com.msdw.tms.common.utils.PageUtils; import com.msdw.tms.common.utils.PageUtils;
import com.msdw.tms.common.utils.R;
import com.msdw.tms.entity.EvaluationRulesEntity;
import com.msdw.tms.entity.QuestionsEntity; import com.msdw.tms.entity.QuestionsEntity;
import com.msdw.tms.entity.request.QuestionsAddRequest; import com.msdw.tms.entity.request.QuestionsAddRequest;
import com.msdw.tms.entity.request.QuestionsQueryRequest; import com.msdw.tms.entity.request.QuestionsQueryRequest;
import com.msdw.tms.entity.request.QuestionsUpdateRequest; import com.msdw.tms.entity.request.QuestionsUpdateRequest;
import com.msdw.tms.entity.vo.EvaluationVO; import com.msdw.tms.entity.vo.EvaluationVO;
import com.msdw.tms.entity.vo.QuestionsDetailVO; import com.msdw.tms.entity.vo.QuestionsDetailVO;
import com.msdw.tms.entity.vo.RulesVo;
import org.apache.tomcat.util.digester.Rules;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -35,8 +39,6 @@ public interface QuestionsService extends IService<QuestionsEntity> {
boolean isEnable(Integer id); boolean isEnable(Integer id);
boolean deleteByIds(List<Integer> asList);
Map<String, String> importQuestion(MultipartFile file) throws IOException; Map<String, String> importQuestion(MultipartFile file) throws IOException;
FilesResult uploadFiles(MultipartFile file) throws IOException; FilesResult uploadFiles(MultipartFile file) throws IOException;
@ -50,5 +52,15 @@ public interface QuestionsService extends IService<QuestionsEntity> {
String getEvaluationRemainingTime(Integer userId); String getEvaluationRemainingTime(Integer userId);
void exportFailureRecord(HttpServletResponse response, String token) throws Exception; void exportFailureRecord(HttpServletResponse response, String token) throws Exception;
// EvaluationRulesEntity queryNumberOfQuestions();
// boolean isEnable(RulesVo rules,QuestionsEntity questionsEntity);
boolean deleteByIds(List<Integer> asList);
//测评设置是否禁用试题
// EvaluationRulesEntity queryNumberOfTatolQuestions();
} }

@ -2,15 +2,20 @@ package com.msdw.tms.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.msdw.tms.common.utils.PageUtils; import com.msdw.tms.common.utils.PageUtils;
import com.msdw.tms.common.utils.R;
import com.msdw.tms.entity.StudentEntity; import com.msdw.tms.entity.StudentEntity;
import com.msdw.tms.entity.UserInfoEntity; import com.msdw.tms.entity.UserInfoEntity;
import com.msdw.tms.entity.vo.StudentVo; import com.msdw.tms.entity.vo.StudentVo;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List; import java.util.List;
public interface StudentService extends IService<StudentEntity>{ public interface StudentService extends IService<StudentEntity>{
Integer queryStudentIdNumber(String studentIdNumber); Integer queryStudentIdNumber(String workNumber,Integer schoolId);
boolean saveStudent(StudentVo studentvo); boolean saveStudent(StudentVo studentvo);
@ -20,7 +25,13 @@ public interface StudentService extends IService<StudentEntity>{
boolean updateStudent(StudentVo studentVo); boolean updateStudent(StudentVo studentVo);
boolean initialPassword(Integer userId); void updateWorkNumber(Integer studentId);
boolean disableAccount(Integer studentId); R addStudentInfo(UserInfoEntity userInfoEntity);
void downloadFiles(HttpServletResponse response) throws IOException;
HashMap<String ,Object> upload(MultipartFile file, Integer schoolId) throws IOException;
void exportFailureRecord(HttpServletResponse response,String token);
} }

@ -4,14 +4,16 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.msdw.tms.common.utils.PageUtils; import com.msdw.tms.common.utils.PageUtils;
import com.msdw.tms.common.utils.R; import com.msdw.tms.common.utils.R;
import com.msdw.tms.entity.UserInfoEntity; import com.msdw.tms.entity.UserInfoEntity;
import com.msdw.tms.entity.vo.StudentVo;
import java.util.List;
import java.util.Map; import java.util.Map;
public interface UserInfoService extends IService<UserInfoEntity> { public interface UserInfoService extends IService<UserInfoEntity> {
PageUtils queryPage(Map<String, Object> params); PageUtils queryPage(Map<String, Object> params);
R add(UserInfoEntity userInfoEntity); int add(UserInfoEntity userInfoEntity);
void updateUserInfoById(UserInfoEntity entity); void updateUserInfoById(UserInfoEntity entity);
@ -19,4 +21,12 @@ public interface UserInfoService extends IService<UserInfoEntity> {
int saveUserInfo(UserInfoEntity userInfo); int saveUserInfo(UserInfoEntity userInfo);
Integer initialPassword(Integer userId);
void disableAccount(StudentVo studentIds);
Integer queryStudentAccount(String account,Integer schoolId);
Integer queryStudentPhone(String phone,Integer schoolId);
} }

@ -7,13 +7,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.msdw.tms.common.exception.ExceptionCast; import com.msdw.tms.common.exception.ExceptionCast;
import com.msdw.tms.common.utils.Constant; import com.msdw.tms.common.utils.*;
import com.msdw.tms.common.utils.FilesResult;
import com.msdw.tms.common.utils.PageUtils;
import com.msdw.tms.common.utils.Query;
import com.msdw.tms.common.utils.poi.ExcelExportUtil; import com.msdw.tms.common.utils.poi.ExcelExportUtil;
import com.msdw.tms.common.utils.poi.ExcelImportUtil; import com.msdw.tms.common.utils.poi.ExcelImportUtil;
import com.msdw.tms.dao.QuestionsDao; import com.msdw.tms.dao.QuestionsDao;
import com.msdw.tms.entity.EvaluationRulesEntity;
import com.msdw.tms.entity.QuestionsEntity; import com.msdw.tms.entity.QuestionsEntity;
import com.msdw.tms.entity.XlsxTemplateEntity; import com.msdw.tms.entity.XlsxTemplateEntity;
import com.msdw.tms.entity.request.QuestionsAddRequest; import com.msdw.tms.entity.request.QuestionsAddRequest;
@ -28,6 +26,7 @@ import com.msdw.tms.service.QuestionsService;
import com.msdw.tms.service.XlsxTemplateService; import com.msdw.tms.service.XlsxTemplateService;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations; import org.springframework.data.redis.core.ValueOperations;
@ -54,11 +53,11 @@ public class QuestionsServiceImpl extends ServiceImpl<QuestionsDao, QuestionsEnt
@Resource @Resource
AliyunOssService ossService; AliyunOssService ossService;
@Resource @Autowired
XlsxTemplateService xlsxTemplateService; private EvaluationRulesService evaluationRulesService;
@Resource @Resource
EvaluationRulesService evaluationRulesService; XlsxTemplateService xlsxTemplateService;
@Resource @Resource
StringRedisTemplate stringRedisTemplate; StringRedisTemplate stringRedisTemplate;
@ -306,6 +305,13 @@ public class QuestionsServiceImpl extends ServiceImpl<QuestionsDao, QuestionsEnt
return this.updateById(questionsEntity); return this.updateById(questionsEntity);
} }
// @Override
// @Transactional
// public boolean isEnable(RulesVo rulesVo,QuestionsEntity questionsEntity) {
//
// return this.updateById(questionsEntity);
// }
@Override @Override
@Transactional @Transactional
public boolean deleteByIds(List<Integer> asList) { public boolean deleteByIds(List<Integer> asList) {
@ -631,4 +637,18 @@ public class QuestionsServiceImpl extends ServiceImpl<QuestionsDao, QuestionsEnt
new ExcelExportUtil(QuestionsImportFailureVO.class, Constant.ROW_INDEX, Constant.STYLE_INDEX). new ExcelExportUtil(QuestionsImportFailureVO.class, Constant.ROW_INDEX, Constant.STYLE_INDEX).
export(response, inputStream, parse, "导入失败数据表.xlsx"); export(response, inputStream, parse, "导入失败数据表.xlsx");
} }
// @Override
// public EvaluationRulesEntity queryNumberOfQuestions() {
// EvaluationRulesEntity questions = this.getBaseMapper().queryNumberOfQuestions();
// return questions;
// }
//
//测评试题是否禁用试题
// @Override
// public EvaluationRulesEntity queryNumberOfTatolQuestions() {
// EvaluationRulesEntity evaluationRulesEntity = this.getBaseMapper().queryNumberOfTatolQuestions();
// return evaluationRulesEntity;
// }
} }

@ -3,17 +3,30 @@ package com.msdw.tms.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.msdw.tms.common.utils.Constant; import com.msdw.tms.common.exception.ExceptionCast;
import com.msdw.tms.common.utils.PageUtils; import com.msdw.tms.common.utils.*;
import com.msdw.tms.dao.StudentDao; import com.msdw.tms.dao.StudentDao;
import com.msdw.tms.dao.UserInfoDao;
import com.msdw.tms.entity.StudentEntity; import com.msdw.tms.entity.StudentEntity;
import com.msdw.tms.entity.UserInfoEntity;
import com.msdw.tms.entity.XlsxTemplateEntity;
import com.msdw.tms.entity.response.CommonCode;
import com.msdw.tms.entity.vo.StudentVo; import com.msdw.tms.entity.vo.StudentVo;
import com.msdw.tms.service.AliyunOssService;
import com.msdw.tms.service.StudentService; import com.msdw.tms.service.StudentService;
import com.msdw.tms.service.XlsxTemplateService;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
@Service("studentService") @Service("studentService")
@ -22,19 +35,24 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
@Autowired @Autowired
private StudentDao studentDao; private StudentDao studentDao;
/** @Resource
* 初始密码 XlsxTemplateService xlsxTemplateService;
*/
private static final String INITIAL_PASSWORD = "huoran123"; @Resource
AliyunOssService ossService;
@Autowired
private UserInfoDao userInfoDao;
@Override @Override
public Integer queryStudentIdNumber(String studentIdNumber) { public Integer queryStudentIdNumber(String workNumber,Integer schoolId) {
List<Integer> result = studentDao.queryStudentIdNumber(studentIdNumber); List<Integer> result = studentDao.queryStudentIdNumber(workNumber,schoolId);
if (result.size()==1){ if (result.size()==1){
return 1; return 1;
} }else{
return 0; return 0;
} }
}
@Transactional @Transactional
@Override @Override
@ -56,30 +74,192 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
@Override @Override
public boolean deleteStudent(List<Integer> studentId) { public boolean deleteStudent(List<Integer> studentId) {
boolean delete = studentDao.deleteStudent(studentId); try {
return delete; Integer delete = studentDao.deleteStudent(studentId);
return true;
}catch (RuntimeException e){
e.printStackTrace();
return false;
}
} }
@Transactional @Transactional
@Override @Override
public boolean updateStudent(StudentVo studentVo) { public boolean updateStudent(StudentVo studentVo) {
boolean update = studentDao.updateStudent(studentVo); try {
return update; Integer update = studentDao.updateStudent(studentVo);
return true;
}catch (RuntimeException e){
e.printStackTrace();
return false;
}
} }
@Transactional
@Override @Override
public boolean initialPassword(Integer userId) { public void updateWorkNumber(Integer studentId) {
studentDao.updateWorkNumber("00");//将学号重置为00
}
@Override
public R addStudentInfo(UserInfoEntity userInfoEntity) {
R r = new R();
boolean result = studentDao.addStudentInfo(userInfoEntity);
if (result==false){
r.put("code",300);
r.put("errmessage","注册失败!");
return r;
}else{
r.put("code",200);
r.put("errmessage","注册成功!");
return r;
}
}
boolean initial = studentDao.initialPassword(userId,INITIAL_PASSWORD); @Override
return initial; public void downloadFiles(HttpServletResponse response) throws IOException {
XlsxTemplateEntity xlsxTemplate = xlsxTemplateService.getById(ConstantUtils.XLSX_TEMPLATE_ID);
ossService.downloadFiles(response, xlsxTemplate.getFileName());
} }
@Transactional @Transactional
@Override @Override
public boolean disableAccount(Integer studentId) { public HashMap<String, Object> upload(MultipartFile file, Integer schoolId) throws IOException{
boolean disable = studentDao.disableAccount(studentId); List<StudentVo> students = ExcelImportHelper.readStudent(file);
return disable;
// 参数合法性校验,只能上传.xlsx后缀的文件
if (StringUtils.isBlank(file.getOriginalFilename())
|| !file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")).equals(Constant.EXCEL_SUFFIX)) {
ExceptionCast.cast(CommonCode.EXCEL_FILE_INVALID);
}
HashMap<String, Object> map = new HashMap<>();
try {
for (int i = 0;i<students.size();i++){
StudentVo student = students.get(i);
String phone = student.getPhone();
String workNumber = student.getWorkNumber();
StudentVo studentVo = new StudentVo();
String schoolAppellationName = student.getSchoolAppellationName();
List<Integer> result1 = studentDao.queryStudentIdNumber(workNumber,schoolId);
String email = student.getEmail();
if (phone!=null&&phone!=""){
List<StudentEntity> result2 = userInfoDao.queryStudentPhone(phone, schoolId);
if (result2.size()==1){
log.error("该号码已被使用");
map.put("被占用电话号码序列:"+System.currentTimeMillis(),"电话号码:"+phone);
students.remove(i);
i--;
continue;
}
studentVo.setPhone(phone);
}
if (email!=null&&email!=""){
studentVo.setEmail(email);
}
List<Integer> result3 = studentDao.querySchoolName(schoolAppellationName);
// 唯一标示性账号
studentVo.setUniqueIdentificationAccount(String.valueOf(System.currentTimeMillis())).
setPassword(ConstantUtils.INITIAL_PASSWORD)
.setSchoolId(ConstantUtils.Keda_schoolId).setRoleId(ConstantUtils.STUDENT_ROLE)
;
studentVo.setAccount(student.getAccount()).setSchoolAppellationName(schoolAppellationName).setUserName(student.getUserName()).setIsdel(Constant.IsDel.NOT_DEL.getType());
if (result1.size()==1){
log.error("该学号已存在");
map.put("学号已存在序列:"+System.currentTimeMillis(),"学号:"+workNumber);
students.remove(i);
i--;
continue;
}else if(result3.size()!=1){
log.error("不存在该院校");
map.put("错误的学校名称序列:"+System.currentTimeMillis(),"学校名称:"+schoolAppellationName);
students.remove(i);
i--;
continue;
}
if (!students.isEmpty()&&students.size()>0){
userInfoDao.batchSaveUserInfo(studentVo);
student.setUserId(studentVo.getUserId()).setIsdel(Constant.IsDel.NOT_DEL.getType()).setPlatformId(ConstantUtils.PLATFORMID);
boolean b = studentDao.saveStudent(student);
if (!b){
throw new RuntimeException();
}
}
}
}catch (RuntimeException e){
log.error(e.getMessage());
throw new RuntimeException();
}
return map;
}
@Override
public void exportFailureRecord(HttpServletResponse response,String token) {
} }
// public HashMap<String, Object> readStudent(Integer schoolId, MultipartFile file) {
// HashMap<String, Object> resp = new HashMap<String, Object>();
// try {
// // 读取excel文件中的学生信息
// List<Student> students = ExcelImportHelper.readStudent(file);
// List<UserM> users = new ArrayList<UserM>();
// // 循环员工信息,将员工信息与用户信息进行对比
// for (int i = 0; i < students.size(); i++) {
// Student student = students.get(i);
// // 学校id
// student.setSchoolId(schoolId);
//
// Student stu=studentMapper.getStudent(student);
//
// if(stu!=null) {
// // 专业id
// student.setProfessionalId(stu.getProfessionalId());
// // 年级
// student.setGradeId(stu.getGradeId());
// //班级
// student.setClassId(stu.getClassId());
//
// UserM user = new UserM();
// // 用户名称
// user.setName(student.getStudentName());
// // 用户密码
// user.setPassword("huoran123");
// // 用户角色
// user.setAccountRole(student.getRoleId());
// // 工号
// user.setWorkNumber(student.getWorkNumber());
// // 手机号
// user.setPhone(student.getPhone());
// // 邮箱
// user.setEmail(student.getEmail());
// // 唯一标识性账号
// user.setUniqueIdentificationAccount(student.getUniqueIdentificationAccount());
// // 学校id
// user.setSchoolId(schoolId);
//
// users.add(user);
//
// }else {
// students.remove(i);
// i--;
// }
// }
// if (!students.isEmpty() && students.size() > 0) {
// // 批量添加学生
// studentMapper.bacthAddStudent(students);
// // 批量添加用户
// userMapper.addUserM(users);
// }
// resp.put("retcode", 200);
// } catch (RuntimeException e) {
// logger.error(e.getMessage());
// resp.put("retcode", 500);
// resp.put("retvalue", "Inquiry Failed");
// return resp;
// }
// return resp;
// }
} }

@ -3,21 +3,21 @@ package com.msdw.tms.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.msdw.tms.common.utils.Constant; import com.msdw.tms.common.utils.*;
import com.msdw.tms.common.utils.PageUtils;
import com.msdw.tms.common.utils.Query;
import com.msdw.tms.common.utils.R;
import com.msdw.tms.dao.UserInfoDao; import com.msdw.tms.dao.UserInfoDao;
import com.msdw.tms.entity.StudentEntity;
import com.msdw.tms.entity.UserInfoEntity; import com.msdw.tms.entity.UserInfoEntity;
import com.msdw.tms.entity.response.CommonCode; import com.msdw.tms.entity.response.CommonCode;
import com.msdw.tms.entity.response.ResponseResult; import com.msdw.tms.entity.response.ResponseResult;
import com.msdw.tms.entity.response.ResultCode; import com.msdw.tms.entity.response.ResultCode;
import com.msdw.tms.entity.vo.StudentVo;
import com.msdw.tms.service.UserInfoService; import com.msdw.tms.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
@Service("userInfoService") @Service("userInfoService")
@ -25,6 +25,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoDao, UserInfoEntity
@Autowired @Autowired
private UserInfoDao userInfoDao; private UserInfoDao userInfoDao;
@Override @Override
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
@ -35,21 +36,30 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoDao, UserInfoEntity
return new PageUtils(page); return new PageUtils(page);
} }
@Override @Override
public R add(UserInfoEntity userInfoEntity) { public int add(UserInfoEntity userInfoEntity) {
R r = new R();
UserInfoDao userDao = this.getBaseMapper(); UserInfoDao userDao = this.getBaseMapper();
Boolean vo = userDao.add(userInfoEntity); int userId = userDao.add(userInfoEntity);
if (vo==false){ return userId;
r.put("code",300);
r.put("errmessage","注册失败!");
return r;
}else{
r.put("code",200);
r.put("errmessage","注册成功!");
return r;
} }
} // @Override
//public R add(UserInfoEntity userInfoEntity) {
// R r = new R();
// UserInfoDao userDao = this.getBaseMapper();
// Boolean vo = userDao.add(userInfoEntity);
// if (vo==false){
// r.put("code",300);
// r.put("errmessage","注册失败!");
// return r;
// }else{
// r.put("code",200);
// r.put("errmessage","注册成功!");
// return r;
// }
//}
@Override @Override
public void updateUserInfoById(UserInfoEntity entity){ public void updateUserInfoById(UserInfoEntity entity){
userInfoDao.userInfupdateUserInfoById(entity); userInfoDao.userInfupdateUserInfoById(entity);
@ -64,8 +74,44 @@ public R add(UserInfoEntity userInfoEntity) {
@Transactional @Transactional
@Override @Override
public int saveUserInfo(UserInfoEntity userInfo) { public int saveUserInfo(UserInfoEntity userInfo) {
userInfo.setUniqueIdentificationAccount(String.valueOf(System.currentTimeMillis())).setIsdel(Constant.IsDel.NOT_DEL.getType()); userInfo.setUniqueIdentificationAccount(String.valueOf(System.currentTimeMillis()))
.setIsdel(Constant.IsDel.NOT_DEL.getType()).setPassword(ConstantUtils.INITIAL_PASSWORD);
int userId = userInfoDao.saveUserInfo(userInfo); int userId = userInfoDao.saveUserInfo(userInfo);
return userId; return userId;
} }
@Transactional
@Override
public Integer initialPassword(Integer userId) {
Integer initial = userInfoDao.initialPassword(userId, ConstantUtils.INITIAL_PASSWORD);
return initial;
}
@Transactional
@Override
public void disableAccount(StudentVo studentIds) {
userInfoDao.disableAccount(studentIds);
}
@Override
public Integer queryStudentAccount(String account,Integer schoolId) {
List<StudentEntity> result = userInfoDao.queryStudentAccount(account,schoolId);
if (result.size()==1){
return 1;
}else{
return 0;
}
}
@Override
public Integer queryStudentPhone(String phone,Integer schoolId) {
List<StudentEntity> result = userInfoDao.queryStudentPhone(phone,schoolId);
if (result.size()==1){
return 1;
}else{
return 0;
}
}
} }

@ -17,7 +17,7 @@ spring:
# port: 6379 # port: 6379
# password: huoran # password: huoran
redis: redis:
host: 47.102.214.131 host: 192.168.31.125
port: 6379 port: 6379
password: password:
mybatis-plus: mybatis-plus:

@ -53,6 +53,12 @@
<select id="countTotalJudgmentnum" resultType="int"> <select id="countTotalJudgmentnum" resultType="int">
SELECT COUNT( 1 ) FROM tms_questions WHERE is_del = 0 AND is_enable = 1 AND question_type = 3 SELECT COUNT( 1 ) FROM tms_questions WHERE is_del = 0 AND is_enable = 1 AND question_type = 3
</select> </select>
<select id="queryNumberOfQuestions" resultType="com.msdw.tms.entity.EvaluationRulesEntity">
SELECT id,evaluation_type,question_num,single_num,is_single_enable,multiple_num,multiple_num,is_multiple_enable,judgment_num,is_judgment_enable FROM tms_evaluation_rules
</select>
<select id="queryNumberOfTatolQuestions" resultType="com.msdw.tms.entity.EvaluationRulesEntity">
SELECT single_num,multiple_num,judgment_num from tms_evaluation_rules
</select>
</mapper> </mapper>

@ -8,86 +8,105 @@
l.schoolName, l.schoolName,
u.userId, u.userId,
u.userName, u.userName,
account, u.account,
logInNumber, u.logInNumber,
u.schoolAppellationId,
u.disableAccount,
lastLoginTime, lastLoginTime,
s.roleId, s.roleId,
s.studentIdNumber s.workNumber,
s.isdel ,
s.studentId
FROM FROM
hr_user_info u, hr_user_info u,
tms_student s, student s,
school l school l
WHERE WHERE
u.schoolId = #{schoolId} s.schoolId = #{schoolId}
AND u.schoolId = s.schoolId AND l.schoolId = s.schoolId
AND u.schoolId = l.schoolId AND u.userId = s.userId
<if test="searchContent!=null">AND (u.userName LIKE CONCAT('%',#{searchContent},'%') OR s.studentIdNumber LIKE CONCAT('%',#{searchContent},'%'))</if> AND u.isdel = 0
AND l.isdel = 0
AND s.isdel = 0
<if test="searchContent!=null">AND (u.userName LIKE CONCAT('%',#{searchContent},'%') OR s.workNumber LIKE CONCAT('%',#{searchContent},'%'))</if>
ORDER BY ORDER BY
lastLoginTime DESC lastLoginTime DESC,studentId
</select> </select>
<select id="queryStudentIdNumber" resultType="java.lang.Integer"> <select id="queryStudentIdNumber" resultType="java.lang.Integer">
SELECT SELECT
userId userId
FROM FROM
tms_student student
WHERE WHERE
studentIdNumber = #{studentIdNumber} workNumber = #{workNumber}
AND
schoolId = #{schoolId}
</select>
<select id="querySchoolName" resultType="java.lang.Integer">
SELECT * FROM school WHERE schoolName = #{schoolAppellationName}
</select>
<select id="querySchoolAppellationName" resultType="java.lang.Integer">
SELECT schoolAppellationId FROM school WHERE schoolName = #{schoolAppellationName}
</select> </select>
<insert id="saveStudent" useGeneratedKeys="true" keyProperty="studentId"> <insert id="saveStudent" useGeneratedKeys="true" keyProperty="studentId">
INSERT INTO tms_student ( schoolId, userId, studentIdNumber, professionalId, gradeId, classId, roleId, isdel ) INSERT INTO student ( schoolId, userId, workNumber, roleId, isdel,platformId )
VALUES
( #{schoolId},#{userId},#{workNumber},#{roleId},#{isdel},#{platformId}
)
</insert>
<insert id="addStudentInfo">
INSERT INTO student(schoolId,userId,roleId,isdel,platformId)
VALUES VALUES
( #{schoolId},#{userId},#{studentIdNumber},#{professionalId},#{gradeId},#{classId},#{roleId},#{isdel} ( #{schoolId},#{userId},4,0,1
) )
</insert> </insert>
<insert id="bacthAddStudents">
INSERT INTO student( schoolId, userId, workNumber, roleId, isdel,platformId )
VALUES
<foreach collection ="list" item="studentVo" index= "index" separator =",">
( #{studentVo.schoolId},#{studentVo.userId},#{studentVo.workNumber},4,0,1)
</foreach>
</insert>
<update id="deleteStudent" parameterType="com.msdw.tms.entity.StudentEntity"> <update id="deleteStudent" parameterType="com.msdw.tms.entity.StudentEntity">
UPDATE tms_student UPDATE student s,hr_user_info u
SET isdel = 1 SET s.isdel = 1,u.isdel = 1
WHERE studentId IN ( WHERE studentId IN (
<foreach collection="list" separator="," item="studentId">#{studentId}</foreach> <foreach collection="list" separator="," item="studentId">#{studentId}</foreach>
) )
AND
s.userId = u.userId
</update> </update>
<update id="updateStudent"> <update id="updateStudent">
UPDATE UPDATE
tms_student s,hr_user_info u student s,hr_user_info u
<set> <set>
<if test="schoolId!=null">s.schoolId = #{schoolId},</if> <if test="schoolId!=null">s.schoolId = #{schoolId},</if>
<if test="studentIdNumber!=null">s.studentIdNumber = #{studentIdNumber},</if> <if test="workNumber!=null">s.workNumber = #{workNumber},</if>
<if test="professionalId!=null">s.professionalId = #{professionalId},</if> <if test="professionalId!=null">s.professionalId = #{professionalId},</if>
<if test="professionalName!=null">s.professionalName = #{professionalName},</if>
<if test="gradeId!=null">s.gradeId = #{gradeId},</if> <if test="gradeId!=null">s.gradeId = #{gradeId},</if>
<if test="gradeName!=null">s.gradeName = #{gradeName},</if>
<if test="classId!=null">s.classId = #{classId},</if> <if test="classId!=null">s.classId = #{classId},</if>
<if test="className!=null">s.className = #{className},</if>
<if test="userName!=null">u.userName = #{userName},</if> <if test="userName!=null">u.userName = #{userName},</if>
<if test="schoolId!=null">u.schoolId = #{schoolId},</if> <if test="schoolId!=null">u.schoolId = #{schoolId},</if>
<if test="account!=null">u.account = #{account},</if> <if test="account!=null">u.account = #{account},</if>
<if test="phone!=null">u.phone = #{phone},</if> <if test="phone!=null">u.phone = #{phone},</if>
<if test="phone!==null">u.phone = NULL,</if> <if test="phone==null">u.phone = NULL,</if>
<if test="email!=null">u.email = #{email}</if> <if test="email!=null">u.email = #{email}</if>
<if test="email!==null">u.email = NULL</if> <if test="email==null">u.email = NULL</if>
<if test="schoolAppellationId!=null">u.schoolAppellationId = #{schoolAppellationId}</if>>
</set> </set>
WHERE WHERE
u.userId = s.userId u.userId = s.userId
AND
u.userId = #{userId}
AND AND
s.studentId = #{studentId} s.studentId = #{studentId}
</update> </update>
<update id="initialPassword"> <update id="updateWorkNumber">
UPDATE update student set workNumber = #{workNumber}
hr_user_info
SET
password = #{password}
WHERE
userId = #{userId}
</update> </update>
<update id="disableAccount">
UPDATE
tms_student
SET
disableAccount = 1
WHERE
studentId = #{studentId}
</update>
</mapper> </mapper>

@ -3,13 +3,13 @@
<mapper namespace="com.msdw.tms.dao.UserInfoDao"> <mapper namespace="com.msdw.tms.dao.UserInfoDao">
<insert id="add" useGeneratedKeys="true" keyProperty="userId"> <insert id="add" useGeneratedKeys="true" keyProperty="userId" keyColumn="userId">
insert into hr_user_info( insert into hr_user_info(
userName, uniqueIdentificationAccount, provinceId, userName, uniqueIdentificationAccount, provinceId,
cityId, schoolId, phone,account,password,roleId) cityId, schoolId, phone,account,password,roleId,schoolAppellationId)
values( values(
#{userName}, #{uniqueIdentificationAccount}, #{provinceId}, #{userName}, #{uniqueIdentificationAccount}, #{provinceId},
#{cityId}, #{schoolId},#{phone}, #{account},#{password},#{roleId}) #{cityId}, #{schoolId},#{phone}, #{account},#{password},#{roleId},#{schoolAppellationId})
</insert> </insert>
<update id="userInfupdateUserInfoById" parameterType="com.msdw.tms.entity.UserInfoEntity"> <update id="userInfupdateUserInfoById" parameterType="com.msdw.tms.entity.UserInfoEntity">
@ -59,10 +59,69 @@
<select id="queryUserPassword" resultType="string"> <select id="queryUserPassword" resultType="string">
SELECT `password` FROM hr_user_info WHERE userId = #{userId} SELECT `password` FROM hr_user_info WHERE userId = #{userId}
</select> </select>
<select id="queryStudentAccount" resultType="com.msdw.tms.entity.StudentEntity">
SELECT
account
FROM
hr_user_info
WHERE
account = #{account}
and
schoolId = #{schoolId}
</select>
<select id="queryStudentPhone" resultType="com.msdw.tms.entity.StudentEntity">
SELECT
phone
FROM
hr_user_info
WHERE
phone = #{phone}
and
schoolId = #{schoolId}
</select>
<insert id="saveUserInfo" useGeneratedKeys="true" keyProperty="userId" keyColumn="userId"> <insert id="saveUserInfo" useGeneratedKeys="true" keyProperty="userId" keyColumn="userId">
INSERT INTO hr_user_info ( userName,email,phone,uniqueIdentificationAccount, schoolId, account, roleId,isdel) INSERT INTO hr_user_info ( userName,email,phone,uniqueIdentificationAccount, schoolId, account,password, roleId,isdel,schoolAppellationId)
VALUES VALUES
( #{userName},#{email},#{phone},#{uniqueIdentificationAccount}, #{schoolId}, #{account}, 4 ,#{isdel}) ( #{userName},#{email},#{phone},#{uniqueIdentificationAccount}, #{schoolId}, #{account}, #{password}, 4 ,0,#{schoolAppellationId})
</insert> </insert>
<insert id="bacthAddStudents">
insert into hr_user_info(
userName, uniqueIdentificationAccount, schoolId, phone,account,password,roleId, schoolAppellationId)
values
<foreach collection ="list" item="studentVo" index= "index" separator =",">
(#{studentVo.userName}, #{studentVo.uniqueIdentificationAccount},#{studentVo.schoolId},
#{studentVo.phone}, #{studentVo.account},#{studentVo.password},#{studentVo.roleId},
(SELECT schoolId FROM school WHERE schoolName = #{studentVo.schoolAppellationName}))
</foreach>
</insert>
<insert id="batchSaveUserInfo" useGeneratedKeys="true" keyProperty="userId" keyColumn="userId">
insert into hr_user_info(
userName, uniqueIdentificationAccount, schoolId, phone,account,password,roleId, schoolAppellationId)
values
(#{userName}, #{uniqueIdentificationAccount},#{schoolId},
#{phone}, #{account},#{password},#{roleId},
(SELECT schoolId FROM school WHERE schoolName = #{schoolAppellationName}))
</insert>
<update id="initialPassword">
UPDATE
hr_user_info
SET
password = #{password}
WHERE
userId = #{userId}
</update>
<update id="disableAccount">
UPDATE
student stu,
hr_user_info u
SET
u.disableAccount = #{disableAccount}
WHERE
stu.studentId = #{studentId}
AND
stu.userId = u.userId
</update>
</mapper> </mapper>

@ -0,0 +1,25 @@
package com.msdw.tms;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import redis.clients.jedis.Jedis;
@SpringBootTest
public class JedisTest {
@Test
public void test() {
Jedis jedis = null;
try {
jedis = new Jedis("127.0.0.1", 6379);
//120.78.198.231
System.out.println(jedis.ping());
} catch (Exception e) {
e.printStackTrace();
} finally {
if (jedis != null) {
jedis.close();
}
}
}
}

@ -67,12 +67,12 @@ class QuestionsServiceTest {
System.out.println(questionsService.updateQuestionById(questions)); System.out.println(questionsService.updateQuestionById(questions));
} }
@Test // @Test
@Transactional // @Transactional
void isnable() { // void isnable() {
Integer id = 1; // Integer id = 1;
System.out.println(questionsService.isEnable(id)); // System.out.println(questionsService.isEnable(id));
} // }
@Test @Test
@Transactional @Transactional

@ -30,10 +30,9 @@ public class StudentTest {
Integer a = 1; Integer a = 1;
UserInfoEntity userInfoEntity = new UserInfoEntity(); UserInfoEntity userInfoEntity = new UserInfoEntity();
userInfoEntity.setAccount("123456").setUserName("michonne").setSchoolId(a); userInfoEntity.setAccount("123456").setUserName("michonne").setSchoolId(a);
studentVo.setSchoolId(a).setStudentIdNumber("888888").setRoleId(4).setProfessionalId(1).setGradeId(1).setClassId(1); studentVo.setSchoolId(a).setWorkNumber("888888").setRoleId(4).setProfessionalId(1).setGradeId(1).setClassId(1);
studentVo.setUserInfo(userInfoEntity); // studentVo.setUserInfo(userInfoEntity);
boolean aa= studentService.saveStudent(studentVo); boolean aa= studentService.saveStudent(studentVo);
// boolean bb = userInfoService.saveUserInfo(userInfoEntity);
System.out.println(aa ? "添加成功" : "添加失败"); System.out.println(aa ? "添加成功" : "添加失败");
} }

Loading…
Cancel
Save