From bfa0273c69bdf8df3f94692564f92530769a43bc Mon Sep 17 00:00:00 2001 From: mzh820631607 Date: Tue, 20 Oct 2020 10:42:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E7=AE=A1=E7=90=86=E9=82=AE?= =?UTF-8?q?=E7=AE=B1=E6=89=8B=E6=9C=BA=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 5 + .../api/EvaluationRecordControllerApi.java | 2 +- .../msdw/tms/api/QuestionsControllerApi.java | 3 + .../msdw/tms/api/StudentControllerApi.java | 13 +- .../msdw/tms/common/utils/ConstantUtils.java | 22 ++ .../tms/common/utils/ExcelImportHelper.java | 109 +++++++++ .../EvaluationRecordController.java | 5 +- .../tms/controller/QuestionsController.java | 61 ++++- .../tms/controller/StudentController.java | 115 +++++++-- .../tms/controller/UserInfoController.java | 25 +- .../java/com/msdw/tms/dao/QuestionsDao.java | 7 + .../java/com/msdw/tms/dao/StudentDao.java | 17 +- .../java/com/msdw/tms/dao/UserInfoDao.java | 20 +- .../com/msdw/tms/entity/StudentEntity.java | 16 +- .../com/msdw/tms/entity/UserInfoEntity.java | 5 +- .../java/com/msdw/tms/entity/vo/RulesVo.java | 18 ++ .../com/msdw/tms/entity/vo/StudentVo.java | 15 +- .../msdw/tms/service/QuestionsService.java | 16 +- .../com/msdw/tms/service/StudentService.java | 17 +- .../com/msdw/tms/service/UserInfoService.java | 12 +- .../service/impl/QuestionsServiceImpl.java | 34 ++- .../tms/service/impl/StudentServiceImpl.java | 220 ++++++++++++++++-- .../tms/service/impl/UserInfoServiceImpl.java | 82 +++++-- src/main/resources/application.yml | 2 +- .../excel-template/学生导入模板.xlsx | Bin 0 -> 9387 bytes .../resources/mapper/tms/QuestionsDao.xml | 6 + src/main/resources/mapper/tms/StudentDao.xml | 147 +++++++----- src/main/resources/mapper/tms/UserInfoDao.xml | 69 +++++- src/test/java/com/msdw/tms/JedisTest.java | 25 ++ .../tms/service/QuestionsServiceTest.java | 12 +- .../com/msdw/tms/service/StudentTest.java | 5 +- 31 files changed, 934 insertions(+), 171 deletions(-) create mode 100644 src/main/java/com/msdw/tms/common/utils/ConstantUtils.java create mode 100644 src/main/java/com/msdw/tms/common/utils/ExcelImportHelper.java create mode 100644 src/main/java/com/msdw/tms/entity/vo/RulesVo.java create mode 100644 src/main/resources/excel-template/学生导入模板.xlsx create mode 100644 src/test/java/com/msdw/tms/JedisTest.java diff --git a/pom.xml b/pom.xml index b9db35f..cfc7e35 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,11 @@ poi-ooxml-schemas 4.0.1 + + redis.clients + jedis + 2.9.3 + org.springframework.boot diff --git a/src/main/java/com/msdw/tms/api/EvaluationRecordControllerApi.java b/src/main/java/com/msdw/tms/api/EvaluationRecordControllerApi.java index 2ec18f6..5556157 100644 --- a/src/main/java/com/msdw/tms/api/EvaluationRecordControllerApi.java +++ b/src/main/java/com/msdw/tms/api/EvaluationRecordControllerApi.java @@ -40,7 +40,7 @@ public interface EvaluationRecordControllerApi { * 开始测评,返回第一题的数据 */ @ApiOperation(value = "开始测评", notes = "开始测评") - R startEvaluation(Integer userId,Integer type); + R startEvaluation(Integer userId); /** * 上一题 diff --git a/src/main/java/com/msdw/tms/api/QuestionsControllerApi.java b/src/main/java/com/msdw/tms/api/QuestionsControllerApi.java index 3086fcd..2d67884 100644 --- a/src/main/java/com/msdw/tms/api/QuestionsControllerApi.java +++ b/src/main/java/com/msdw/tms/api/QuestionsControllerApi.java @@ -4,6 +4,7 @@ import com.msdw.tms.common.utils.R; import com.msdw.tms.entity.request.QuestionsAddRequest; import com.msdw.tms.entity.request.QuestionsQueryRequest; import com.msdw.tms.entity.request.QuestionsUpdateRequest; +import com.msdw.tms.entity.vo.RulesVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -51,6 +52,8 @@ public interface QuestionsControllerApi { /** * 是否禁用试题 */ +// @ApiOperation(value = "是否禁用试题", notes = "是否禁用试题") +// R isNable(RulesVo rulesVo); @ApiOperation(value = "是否禁用试题", notes = "是否禁用试题") R isNable(@ApiParam(name = "id", value = "试题主键", required = true) List idList); // 2020.09.18 diff --git a/src/main/java/com/msdw/tms/api/StudentControllerApi.java b/src/main/java/com/msdw/tms/api/StudentControllerApi.java index dec5a8c..faac6bd 100644 --- a/src/main/java/com/msdw/tms/api/StudentControllerApi.java +++ b/src/main/java/com/msdw/tms/api/StudentControllerApi.java @@ -6,7 +6,10 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.RequestBody; 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; @Api(value = "学生管理", tags = "学生管理") @@ -25,8 +28,14 @@ public interface StudentControllerApi { public R updateStudent(StudentVo studentVo); @ApiOperation(value = "重置密码",notes = "重置密码") - public R reSetPassword(Integer userId); + public R reSetPassword(List userId); @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; } diff --git a/src/main/java/com/msdw/tms/common/utils/ConstantUtils.java b/src/main/java/com/msdw/tms/common/utils/ConstantUtils.java new file mode 100644 index 0000000..5fd6312 --- /dev/null +++ b/src/main/java/com/msdw/tms/common/utils/ConstantUtils.java @@ -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"; +} diff --git a/src/main/java/com/msdw/tms/common/utils/ExcelImportHelper.java b/src/main/java/com/msdw/tms/common/utils/ExcelImportHelper.java new file mode 100644 index 0000000..e17d364 --- /dev/null +++ b/src/main/java/com/msdw/tms/common/utils/ExcelImportHelper.java @@ -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 readStudent(MultipartFile file) { + List list = new ArrayList(); + + 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; + } +} diff --git a/src/main/java/com/msdw/tms/controller/EvaluationRecordController.java b/src/main/java/com/msdw/tms/controller/EvaluationRecordController.java index a2cdf17..32dc244 100644 --- a/src/main/java/com/msdw/tms/controller/EvaluationRecordController.java +++ b/src/main/java/com/msdw/tms/controller/EvaluationRecordController.java @@ -57,9 +57,10 @@ public class EvaluationRecordController implements EvaluationRecordControllerApi @Override @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); - evaluationRecordVO.setTypes(type); +// evaluationRecordVO.setTypes(type); return R.ok().put("data", evaluationRecordVO); } diff --git a/src/main/java/com/msdw/tms/controller/QuestionsController.java b/src/main/java/com/msdw/tms/controller/QuestionsController.java index 6c05485..b4402e2 100644 --- a/src/main/java/com/msdw/tms/controller/QuestionsController.java +++ b/src/main/java/com/msdw/tms/controller/QuestionsController.java @@ -1,14 +1,20 @@ package com.msdw.tms.controller; 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.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.request.QuestionsAddRequest; import com.msdw.tms.entity.request.QuestionsQueryRequest; 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.QuestionsDetailVO; +import com.msdw.tms.entity.vo.RulesVo; import com.msdw.tms.service.QuestionsService; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; @@ -86,13 +92,12 @@ public class QuestionsController implements QuestionsControllerApi { return update ? R.ok() : R.error(); } + /** * 是否禁用试题 */ -// @Override + @Override @PutMapping("/isenable") -// 2020.09.18 -// @RequiresPermissions("qms:questions:isenable") // public R isNable(@RequestBody Integer id) { public R isNable(@RequestBody List idList) { Integer id = idList.get(0); @@ -101,6 +106,56 @@ public class QuestionsController implements QuestionsControllerApi { 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 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 userIds){ + Integer userId = userIds.get(0); + 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 */ @Override @PutMapping("/disableAccount") - public R disableAccount(@RequestBody Integer studentId) { - boolean disable = studentService.disableAccount(studentId); - return disable ? R.ok() : R.error(); + public R disableAccount(@RequestBody StudentVo studentIds) { + + 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 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); + } } diff --git a/src/main/java/com/msdw/tms/controller/UserInfoController.java b/src/main/java/com/msdw/tms/controller/UserInfoController.java index 5b25442..552db3d 100644 --- a/src/main/java/com/msdw/tms/controller/UserInfoController.java +++ b/src/main/java/com/msdw/tms/controller/UserInfoController.java @@ -7,6 +7,7 @@ import com.msdw.tms.common.utils.R; import com.msdw.tms.entity.UserEntity; import com.msdw.tms.entity.UserInfoEntity; import com.msdw.tms.entity.vo.UserEntityVo; +import com.msdw.tms.service.StudentService; import com.msdw.tms.service.UserInfoService; import com.msdw.tms.service.UserService; import org.springframework.beans.factory.annotation.Autowired; @@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.Arrays; +import java.util.List; import java.util.Map; @RestController @@ -22,6 +24,9 @@ public class UserInfoController implements UserInfoControllerApi { @Autowired private UserInfoService userInfoService; + @Autowired + private StudentService studentService; + /** * 列表 */ @@ -46,9 +51,26 @@ public class UserInfoController implements UserInfoControllerApi { /** * 注册 */ + @Override + @Transactional @PostMapping("/add") 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(); } @@ -56,6 +78,7 @@ public class UserInfoController implements UserInfoControllerApi { /** * 修改 */ + @Override @PutMapping("/update") public R update(@RequestBody UserInfoEntity userEntity){ userInfoService.updateById(userEntity); diff --git a/src/main/java/com/msdw/tms/dao/QuestionsDao.java b/src/main/java/com/msdw/tms/dao/QuestionsDao.java index 0a64cba..a5399e1 100644 --- a/src/main/java/com/msdw/tms/dao/QuestionsDao.java +++ b/src/main/java/com/msdw/tms/dao/QuestionsDao.java @@ -1,7 +1,9 @@ package com.msdw.tms.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.msdw.tms.entity.EvaluationRulesEntity; import com.msdw.tms.entity.QuestionsEntity; +import com.msdw.tms.entity.vo.QuestionsDetailVO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -23,4 +25,9 @@ public interface QuestionsDao extends BaseMapper { Integer countTotalMultiplenum(); Integer countTotalJudgmentnum(); + + EvaluationRulesEntity queryNumberOfQuestions(); + + EvaluationRulesEntity queryNumberOfTatolQuestions(); + } diff --git a/src/main/java/com/msdw/tms/dao/StudentDao.java b/src/main/java/com/msdw/tms/dao/StudentDao.java index c036ef3..320d1aa 100644 --- a/src/main/java/com/msdw/tms/dao/StudentDao.java +++ b/src/main/java/com/msdw/tms/dao/StudentDao.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.msdw.tms.entity.StudentEntity; +import com.msdw.tms.entity.UserInfoEntity; import com.msdw.tms.entity.vo.StudentVo; import org.apache.ibatis.annotations.Mapper; import org.apache.poi.ss.formula.functions.T; @@ -13,17 +14,23 @@ import java.util.List; @Mapper public interface StudentDao extends BaseMapper { - List queryStudentIdNumber(String studentIdNumber); + List queryStudentIdNumber(String workNumber,Integer schoolId); boolean saveStudent(StudentVo studentVo); IPage queryStudent(Page tpage,String searchContent,Integer schoolId); - boolean deleteStudent(List studentId); + Integer deleteStudent(List 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 querySchoolName(String schoolAppellationName); + + int bacthAddStudents(List students); + + int querySchoolAppellationName(String schoolAppellationName); } diff --git a/src/main/java/com/msdw/tms/dao/UserInfoDao.java b/src/main/java/com/msdw/tms/dao/UserInfoDao.java index 0fb9efe..c5e8b6f 100644 --- a/src/main/java/com/msdw/tms/dao/UserInfoDao.java +++ b/src/main/java/com/msdw/tms/dao/UserInfoDao.java @@ -2,19 +2,37 @@ package com.msdw.tms.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.msdw.tms.common.utils.R; +import com.msdw.tms.entity.StudentEntity; import com.msdw.tms.entity.UserEntity; import com.msdw.tms.entity.UserInfoEntity; +import com.msdw.tms.entity.vo.StudentVo; import com.msdw.tms.entity.vo.UserEntityVo; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; @Mapper public interface UserInfoDao extends BaseMapper { - Boolean add(UserInfoEntity userEntity); + int add(UserInfoEntity userEntity); void userInfupdateUserInfoById(UserInfoEntity entity); String queryUserPassword(Integer userid); int saveUserInfo(UserInfoEntity userInfo); + + Integer initialPassword(Integer userId, String password); + + Integer disableAccount(StudentVo studentIds); + + List queryStudentAccount(String account,Integer schoolId); + + List queryStudentPhone(String phone,Integer schoolId); + + int bacthAddStudents(List students); + + int batchSaveUserInfo(StudentVo studentVo); + } diff --git a/src/main/java/com/msdw/tms/entity/StudentEntity.java b/src/main/java/com/msdw/tms/entity/StudentEntity.java index 453ba5b..c536303 100644 --- a/src/main/java/com/msdw/tms/entity/StudentEntity.java +++ b/src/main/java/com/msdw/tms/entity/StudentEntity.java @@ -7,7 +7,7 @@ import lombok.Data; import lombok.experimental.Accessors; @Data -@TableName("tms_student") +@TableName("student") @Accessors(chain = true) public class StudentEntity { @@ -19,17 +19,25 @@ public class StudentEntity { //绑定用户Id private Integer userId; //学号 - private String studentIdNumber; + private String workNumber; //绑定专业Id private Integer professionalId; + //绑定专业名称 + private String professionalName; //绑定年级Id private Integer gradeId; + //绑定年级名称 + private String gradeName; //绑定班级Id、 private Integer classId; + //绑定班级名称 + private String className; //绑定角色Id private Integer roleId; + //登录次数 + private Integer loginNumber; //是否删除(0未删除,1已删除) private Integer isdel; - //是否禁用账号(0禁用,1不禁用,默认0) - private Integer disableAccount; + //绑定平台id(默认手写1) + private Integer platformId; } diff --git a/src/main/java/com/msdw/tms/entity/UserInfoEntity.java b/src/main/java/com/msdw/tms/entity/UserInfoEntity.java index b69bda4..646ddb8 100644 --- a/src/main/java/com/msdw/tms/entity/UserInfoEntity.java +++ b/src/main/java/com/msdw/tms/entity/UserInfoEntity.java @@ -54,5 +54,8 @@ public class UserInfoEntity { private Integer isdel; //角色id private String roleId; - + //是否禁用(0未禁用1已禁用默认0) + private Integer disableAccount; + //所属院校id + private Integer schoolAppellationId; } diff --git a/src/main/java/com/msdw/tms/entity/vo/RulesVo.java b/src/main/java/com/msdw/tms/entity/vo/RulesVo.java new file mode 100644 index 0000000..8fb7d77 --- /dev/null +++ b/src/main/java/com/msdw/tms/entity/vo/RulesVo.java @@ -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; + +} diff --git a/src/main/java/com/msdw/tms/entity/vo/StudentVo.java b/src/main/java/com/msdw/tms/entity/vo/StudentVo.java index 5d4fe9d..5983c85 100644 --- a/src/main/java/com/msdw/tms/entity/vo/StudentVo.java +++ b/src/main/java/com/msdw/tms/entity/vo/StudentVo.java @@ -14,21 +14,26 @@ import java.util.List; @Accessors(chain = true) public class StudentVo extends StudentEntity { - private UserInfoEntity userInfo; - //学校名称 private String schoolName; //用户姓名 private String userName; //用户账号 private String account; - //登陆次数 - private Integer logInNumber; + //密码 + private String password; //最后登陆时间 private String lastLoginTime; //电话 private String phone; //邮箱 private String email; - + //禁用状态 + private Integer disableAccount; + //所属院校 + private String schoolAppellation; + //唯一性标识账号 + private String uniqueIdentificationAccount; + //绑定所属院校名称 + private String schoolAppellationName; } diff --git a/src/main/java/com/msdw/tms/service/QuestionsService.java b/src/main/java/com/msdw/tms/service/QuestionsService.java index d8bf9b3..54698a4 100644 --- a/src/main/java/com/msdw/tms/service/QuestionsService.java +++ b/src/main/java/com/msdw/tms/service/QuestionsService.java @@ -3,12 +3,16 @@ package com.msdw.tms.service; import com.baomidou.mybatisplus.extension.service.IService; import com.msdw.tms.common.utils.FilesResult; 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.request.QuestionsAddRequest; import com.msdw.tms.entity.request.QuestionsQueryRequest; import com.msdw.tms.entity.request.QuestionsUpdateRequest; import com.msdw.tms.entity.vo.EvaluationVO; 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 javax.servlet.http.HttpServletResponse; @@ -35,8 +39,6 @@ public interface QuestionsService extends IService { boolean isEnable(Integer id); - boolean deleteByIds(List asList); - Map importQuestion(MultipartFile file) throws IOException; FilesResult uploadFiles(MultipartFile file) throws IOException; @@ -50,5 +52,15 @@ public interface QuestionsService extends IService { String getEvaluationRemainingTime(Integer userId); void exportFailureRecord(HttpServletResponse response, String token) throws Exception; + + + + +// EvaluationRulesEntity queryNumberOfQuestions(); +// boolean isEnable(RulesVo rules,QuestionsEntity questionsEntity); +boolean deleteByIds(List asList); +//测评设置是否禁用试题 +// EvaluationRulesEntity queryNumberOfTatolQuestions(); + } diff --git a/src/main/java/com/msdw/tms/service/StudentService.java b/src/main/java/com/msdw/tms/service/StudentService.java index 1e03410..d26d8f4 100644 --- a/src/main/java/com/msdw/tms/service/StudentService.java +++ b/src/main/java/com/msdw/tms/service/StudentService.java @@ -2,15 +2,20 @@ package com.msdw.tms.service; import com.baomidou.mybatisplus.extension.service.IService; 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.UserInfoEntity; 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; public interface StudentService extends IService{ - Integer queryStudentIdNumber(String studentIdNumber); + Integer queryStudentIdNumber(String workNumber,Integer schoolId); boolean saveStudent(StudentVo studentvo); @@ -20,7 +25,13 @@ public interface StudentService extends IService{ 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 upload(MultipartFile file, Integer schoolId) throws IOException; + + void exportFailureRecord(HttpServletResponse response,String token); } diff --git a/src/main/java/com/msdw/tms/service/UserInfoService.java b/src/main/java/com/msdw/tms/service/UserInfoService.java index 356be7a..1fda227 100644 --- a/src/main/java/com/msdw/tms/service/UserInfoService.java +++ b/src/main/java/com/msdw/tms/service/UserInfoService.java @@ -4,14 +4,16 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.msdw.tms.common.utils.PageUtils; import com.msdw.tms.common.utils.R; import com.msdw.tms.entity.UserInfoEntity; +import com.msdw.tms.entity.vo.StudentVo; +import java.util.List; import java.util.Map; public interface UserInfoService extends IService { PageUtils queryPage(Map params); - R add(UserInfoEntity userInfoEntity); + int add(UserInfoEntity userInfoEntity); void updateUserInfoById(UserInfoEntity entity); @@ -19,4 +21,12 @@ public interface UserInfoService extends IService { int saveUserInfo(UserInfoEntity userInfo); + Integer initialPassword(Integer userId); + + void disableAccount(StudentVo studentIds); + + Integer queryStudentAccount(String account,Integer schoolId); + + Integer queryStudentPhone(String phone,Integer schoolId); + } diff --git a/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java index 9cbceff..f121590 100644 --- a/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java @@ -7,13 +7,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.PageUtils; -import com.msdw.tms.common.utils.Query; +import com.msdw.tms.common.utils.*; import com.msdw.tms.common.utils.poi.ExcelExportUtil; import com.msdw.tms.common.utils.poi.ExcelImportUtil; import com.msdw.tms.dao.QuestionsDao; +import com.msdw.tms.entity.EvaluationRulesEntity; import com.msdw.tms.entity.QuestionsEntity; import com.msdw.tms.entity.XlsxTemplateEntity; import com.msdw.tms.entity.request.QuestionsAddRequest; @@ -28,6 +26,7 @@ import com.msdw.tms.service.QuestionsService; import com.msdw.tms.service.XlsxTemplateService; import org.apache.commons.lang.StringUtils; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ClassPathResource; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.ValueOperations; @@ -54,11 +53,11 @@ public class QuestionsServiceImpl extends ServiceImpl asList) { @@ -631,4 +637,18 @@ public class QuestionsServiceImpl extends ServiceImpl im @Autowired private StudentDao studentDao; - /** - * 初始密码 - */ - private static final String INITIAL_PASSWORD = "huoran123"; + @Resource + XlsxTemplateService xlsxTemplateService; + + @Resource + AliyunOssService ossService; + + @Autowired + private UserInfoDao userInfoDao; @Override - public Integer queryStudentIdNumber(String studentIdNumber) { - List result = studentDao.queryStudentIdNumber(studentIdNumber); + public Integer queryStudentIdNumber(String workNumber,Integer schoolId) { + List result = studentDao.queryStudentIdNumber(workNumber,schoolId); if (result.size()==1){ return 1; + }else{ + return 0; } - return 0; } @Transactional @@ -56,30 +74,192 @@ public class StudentServiceImpl extends ServiceImpl im @Override public boolean deleteStudent(List studentId) { - boolean delete = studentDao.deleteStudent(studentId); - return delete; + try { + Integer delete = studentDao.deleteStudent(studentId); + return true; + }catch (RuntimeException e){ + e.printStackTrace(); + return false; + } } @Transactional @Override public boolean updateStudent(StudentVo studentVo) { - boolean update = studentDao.updateStudent(studentVo); - return update; + try { + Integer update = studentDao.updateStudent(studentVo); + return true; + }catch (RuntimeException e){ + e.printStackTrace(); + return false; + } } - @Transactional @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); - return initial; + @Override + public void downloadFiles(HttpServletResponse response) throws IOException { + XlsxTemplateEntity xlsxTemplate = xlsxTemplateService.getById(ConstantUtils.XLSX_TEMPLATE_ID); + ossService.downloadFiles(response, xlsxTemplate.getFileName()); } @Transactional @Override - public boolean disableAccount(Integer studentId) { - boolean disable = studentDao.disableAccount(studentId); - return disable; + public HashMap upload(MultipartFile file, Integer schoolId) throws IOException{ + List students = ExcelImportHelper.readStudent(file); + + // 参数合法性校验,只能上传.xlsx后缀的文件 + if (StringUtils.isBlank(file.getOriginalFilename()) + || !file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")).equals(Constant.EXCEL_SUFFIX)) { + ExceptionCast.cast(CommonCode.EXCEL_FILE_INVALID); + } + + HashMap map = new HashMap<>(); + try { + for (int i = 0;i result1 = studentDao.queryStudentIdNumber(workNumber,schoolId); + String email = student.getEmail(); + if (phone!=null&&phone!=""){ + List 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 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 readStudent(Integer schoolId, MultipartFile file) { +// HashMap resp = new HashMap(); +// try { +// // 读取excel文件中的学生信息 +// List students = ExcelImportHelper.readStudent(file); +// List users = new ArrayList(); +// // 循环员工信息,将员工信息与用户信息进行对比 +// 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; +// } } diff --git a/src/main/java/com/msdw/tms/service/impl/UserInfoServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/UserInfoServiceImpl.java index cbb7310..a10b937 100644 --- a/src/main/java/com/msdw/tms/service/impl/UserInfoServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/UserInfoServiceImpl.java @@ -3,21 +3,21 @@ package com.msdw.tms.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.msdw.tms.common.utils.Constant; -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.common.utils.*; import com.msdw.tms.dao.UserInfoDao; +import com.msdw.tms.entity.StudentEntity; import com.msdw.tms.entity.UserInfoEntity; import com.msdw.tms.entity.response.CommonCode; import com.msdw.tms.entity.response.ResponseResult; import com.msdw.tms.entity.response.ResultCode; +import com.msdw.tms.entity.vo.StudentVo; import com.msdw.tms.service.UserInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.HashMap; +import java.util.List; import java.util.Map; @Service("userInfoService") @@ -25,6 +25,7 @@ public class UserInfoServiceImpl extends ServiceImpl params) { @@ -35,21 +36,30 @@ public class UserInfoServiceImpl extends ServiceImpl result = userInfoDao.queryStudentAccount(account,schoolId); + if (result.size()==1){ + return 1; + }else{ + return 0; + } + } + + @Override + public Integer queryStudentPhone(String phone,Integer schoolId) { + List result = userInfoDao.queryStudentPhone(phone,schoolId); + if (result.size()==1){ + return 1; + }else{ + return 0; + } + } + } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index bcfc268..5537c11 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -17,7 +17,7 @@ spring: # port: 6379 # password: huoran redis: - host: 47.102.214.131 + host: 192.168.31.125 port: 6379 password: mybatis-plus: diff --git a/src/main/resources/excel-template/学生导入模板.xlsx b/src/main/resources/excel-template/学生导入模板.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..a7be4bcf80188501292de5651042558c2b9cd32e GIT binary patch literal 9387 zcmaJ{1yoe+)~35dTDphs?va+34(Xbq1f;t`Kv23-N&)FE>Fyk9B&554(0lLq>HYru zt~GPcn%QyAv(MgVul>9#3b1e}P>(BAc}4v3`0s`MaAF2FRdE74IJ2odh~Yi_fb>&r zNKzk~0~!iS00s&Q>+fPF4i2pD_IBxUZSt@jSRwlX`&dq;){$Web`e=CG63zS?jLp} zGfI*c`ns8&k%(=42W#^T7lamkS$cgE>TMsC7NfAIsz@B=PV7zTpGD?)&)67dFVOynd=*3rz% z#eKy5ryI@C&t3{XB}bmYs>SJ3y}(!#aGVNeH=0`8JltH;_k+#DF zwVo=~-0WC?!mM|5Q+EaPJG@WX@~ovE;MIPB7yIw#|vJBznALu zOf@rgMzu#|@^qrmR`o*dg*>qziBE7ctG;9PrpTc`@->^AKz9b&{LctdWAWDA|W-0z{z4-?9lJ9rK zt)WvcyT;Lg zB`T4HcQt%BowKU-S$T-qCSK6Plu-g*hH3dAZyZzHx8DRIA@23K)!wB+b|p!b+|XQ- zd*w-9WyH}hNE;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9)gj2Xq_o&ACqDxD2@gk8RP5}1PKV6E*#hY7-|N;CK zBs%)TVEd8%(~|;&T+Bf(MjEdj%$*G$6aG^|zcLI5UdTCJb4Q*Ym%4*Vl!@`Oc_GaT z?8I3s_sP4AfP=FPMq?NW|EN?s!QIQ2`h11`JbJKSMh~uR*mV$F1B%F|O5_-Y9b&#fGnXAflMX6+S5l3#54mGGv0Ai( zJ)4ABn-rGRl6BE}Nrl@q0E$c*FHSsHX#ym)gh5ZLOH#tIqTW%(sW-c9`>BDD@ijMi zW;Xr!%mNQ{gIqVbHa5cIG%7cp(yay9yyVEiz|l|wP?o7oQxN~6DLMhz}6V4 zE)h@kr=g@n7t6ReQy^bA`;3jg?`_`EzVFn8*m5x-IpKFkB7=SDj84vP^Kh^(azW-9ccqkcvssD!u|6e!#$OZpe zk2g&Z_b+Dn@pk_?B)_9nME17=_2-5DS;-##{6cB;?`r>5*Z#EgX9M?_9jXUT>z~@W zKP~(@{QS!T!voj-XyHGj(EkP2@ArQ7zNyyQRI znZFDmll(OBci8^dML&}Hzt&@fWq(EZH){X)EB}++f7JaIHJAU={fp{XQGoxMtk@6R NUl1SUVkjQ<{tuz%6z~85 literal 0 HcmV?d00001 diff --git a/src/main/resources/mapper/tms/QuestionsDao.xml b/src/main/resources/mapper/tms/QuestionsDao.xml index 6e26302..ffdfec9 100644 --- a/src/main/resources/mapper/tms/QuestionsDao.xml +++ b/src/main/resources/mapper/tms/QuestionsDao.xml @@ -53,6 +53,12 @@ + + \ No newline at end of file diff --git a/src/main/resources/mapper/tms/StudentDao.xml b/src/main/resources/mapper/tms/StudentDao.xml index 3b05e44..5b67ea0 100644 --- a/src/main/resources/mapper/tms/StudentDao.xml +++ b/src/main/resources/mapper/tms/StudentDao.xml @@ -2,92 +2,111 @@ - + + + - INSERT INTO tms_student ( schoolId, userId, studentIdNumber, professionalId, gradeId, classId, roleId, isdel ) + INSERT INTO student ( schoolId, userId, workNumber, roleId, isdel,platformId ) VALUES - ( #{schoolId},#{userId},#{studentIdNumber},#{professionalId},#{gradeId},#{classId},#{roleId},#{isdel} + ( #{schoolId},#{userId},#{workNumber},#{roleId},#{isdel},#{platformId} + ) + + + INSERT INTO student(schoolId,userId,roleId,isdel,platformId) + VALUES + ( #{schoolId},#{userId},4,0,1 ) + + INSERT INTO student( schoolId, userId, workNumber, roleId, isdel,platformId ) + VALUES + + ( #{studentVo.schoolId},#{studentVo.userId},#{studentVo.workNumber},4,0,1) + + - UPDATE tms_student - SET isdel = 1 + UPDATE student s,hr_user_info u + SET s.isdel = 1,u.isdel = 1 WHERE studentId IN ( #{studentId} ) + AND + s.userId = u.userId - UPDATE - tms_student s,hr_user_info u - - s.schoolId = #{schoolId}, - s.studentIdNumber = #{studentIdNumber}, - s.professionalId = #{professionalId}, - s.gradeId = #{gradeId}, - s.classId = #{classId}, - u.userName = #{userName}, - u.schoolId = #{schoolId}, - u.account = #{account}, - u.phone = #{phone}, - u.phone = NULL, - u.email = #{email} - u.email = NULL - - WHERE + UPDATE + student s,hr_user_info u + + s.schoolId = #{schoolId}, + s.workNumber = #{workNumber}, + s.professionalId = #{professionalId}, + s.professionalName = #{professionalName}, + s.gradeId = #{gradeId}, + s.gradeName = #{gradeName}, + s.classId = #{classId}, + s.className = #{className}, + u.userName = #{userName}, + u.schoolId = #{schoolId}, + u.account = #{account}, + u.phone = #{phone}, + u.phone = NULL, + u.email = #{email} + u.email = NULL + u.schoolAppellationId = #{schoolAppellationId}> + + WHERE u.userId = s.userId - AND - u.userId = #{userId} - AND + AND s.studentId = #{studentId} - - UPDATE - hr_user_info - SET - password = #{password} - WHERE - userId = #{userId} + + update student set workNumber = #{workNumber} - - UPDATE - tms_student - SET - disableAccount = 1 - WHERE - studentId = #{studentId} - \ No newline at end of file diff --git a/src/main/resources/mapper/tms/UserInfoDao.xml b/src/main/resources/mapper/tms/UserInfoDao.xml index 60ccddf..79c66ca 100644 --- a/src/main/resources/mapper/tms/UserInfoDao.xml +++ b/src/main/resources/mapper/tms/UserInfoDao.xml @@ -3,13 +3,13 @@ - + insert into hr_user_info( userName, uniqueIdentificationAccount, provinceId, - cityId, schoolId, phone,account,password,roleId) + cityId, schoolId, phone,account,password,roleId,schoolAppellationId) values( #{userName}, #{uniqueIdentificationAccount}, #{provinceId}, - #{cityId}, #{schoolId},#{phone}, #{account},#{password},#{roleId}) + #{cityId}, #{schoolId},#{phone}, #{account},#{password},#{roleId},#{schoolAppellationId}) @@ -59,10 +59,69 @@ + + - 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 - ( #{userName},#{email},#{phone},#{uniqueIdentificationAccount}, #{schoolId}, #{account}, 4 ,#{isdel}) + ( #{userName},#{email},#{phone},#{uniqueIdentificationAccount}, #{schoolId}, #{account}, #{password}, 4 ,0,#{schoolAppellationId}) + + + insert into hr_user_info( + userName, uniqueIdentificationAccount, schoolId, phone,account,password,roleId, schoolAppellationId) + values + + (#{studentVo.userName}, #{studentVo.uniqueIdentificationAccount},#{studentVo.schoolId}, + #{studentVo.phone}, #{studentVo.account},#{studentVo.password},#{studentVo.roleId}, + (SELECT schoolId FROM school WHERE schoolName = #{studentVo.schoolAppellationName})) + + + 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})) + + + + UPDATE + hr_user_info + SET + password = #{password} + WHERE + userId = #{userId} + + + + UPDATE + student stu, + hr_user_info u + SET + u.disableAccount = #{disableAccount} + WHERE + stu.studentId = #{studentId} + AND + stu.userId = u.userId + \ No newline at end of file diff --git a/src/test/java/com/msdw/tms/JedisTest.java b/src/test/java/com/msdw/tms/JedisTest.java new file mode 100644 index 0000000..8339c90 --- /dev/null +++ b/src/test/java/com/msdw/tms/JedisTest.java @@ -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(); + } + } + } + +} diff --git a/src/test/java/com/msdw/tms/service/QuestionsServiceTest.java b/src/test/java/com/msdw/tms/service/QuestionsServiceTest.java index e8aa298..58631db 100644 --- a/src/test/java/com/msdw/tms/service/QuestionsServiceTest.java +++ b/src/test/java/com/msdw/tms/service/QuestionsServiceTest.java @@ -67,12 +67,12 @@ class QuestionsServiceTest { System.out.println(questionsService.updateQuestionById(questions)); } - @Test - @Transactional - void isnable() { - Integer id = 1; - System.out.println(questionsService.isEnable(id)); - } +// @Test +// @Transactional +// void isnable() { +// Integer id = 1; +// System.out.println(questionsService.isEnable(id)); +// } @Test @Transactional diff --git a/src/test/java/com/msdw/tms/service/StudentTest.java b/src/test/java/com/msdw/tms/service/StudentTest.java index 3fbe752..60d248d 100644 --- a/src/test/java/com/msdw/tms/service/StudentTest.java +++ b/src/test/java/com/msdw/tms/service/StudentTest.java @@ -30,10 +30,9 @@ public class StudentTest { Integer a = 1; UserInfoEntity userInfoEntity = new UserInfoEntity(); userInfoEntity.setAccount("123456").setUserName("michonne").setSchoolId(a); - studentVo.setSchoolId(a).setStudentIdNumber("888888").setRoleId(4).setProfessionalId(1).setGradeId(1).setClassId(1); - studentVo.setUserInfo(userInfoEntity); + studentVo.setSchoolId(a).setWorkNumber("888888").setRoleId(4).setProfessionalId(1).setGradeId(1).setClassId(1); +// studentVo.setUserInfo(userInfoEntity); boolean aa= studentService.saveStudent(studentVo); -// boolean bb = userInfoService.saveUserInfo(userInfoEntity); System.out.println(aa ? "添加成功" : "添加失败"); }