修改系统设置模块bug

hehai
shijie 4 years ago
parent 2f4a5627ea
commit 782775acdb
  1. 13
      src/main/java/com/msdw/tms/common/exception/ExceptionCatch.java
  2. 3
      src/main/java/com/msdw/tms/controller/SystemSettingController.java
  3. 5
      src/main/java/com/msdw/tms/entity/UserInfoEntity.java
  4. 54
      src/main/java/com/msdw/tms/entity/response/ResponseResult.java
  5. 10
      src/main/resources/mapper/tms/SystemSetting.xml
  6. 278
      src/test/java/com/msdw/tms/service/AchievementManagementTest.java

@ -7,6 +7,7 @@ import com.msdw.tms.entity.response.ResultCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
@ -59,4 +60,16 @@ public class ExceptionCatch {
ResultCode resultCode = customException.getResultCode();
return new ResponseResult(resultCode);
}
@ExceptionHandler(MethodArgumentNotValidException.class)//捕获CustomException类型异常
@ResponseBody
public ResponseResult MethodArgumentNotValidException(MethodArgumentNotValidException customException) {
customException.printStackTrace();
//记录日志
LOGGER.error("catch exception:{}", customException.getMessage());
String message = customException.getBindingResult().getAllErrors().get(0).getDefaultMessage();
int code =402;
return ResponseResult.FAIL(code,message);
}
}

@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
@ -32,7 +33,7 @@ public class SystemSettingController implements SystemSetttingApi {
*/
@Override
@PostMapping("/addStaff")
public R addStaff(@RequestBody StaffVo staffVo){
public R addStaff(@RequestBody @Valid StaffVo staffVo){
R r = systemSetttingService.addStaff(staffVo);
return r;
}

@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.Pattern;
@Accessors(chain = true)
@Data
@TableName("hr_user_info")
@ -15,6 +17,7 @@ public class UserInfoEntity {
//用户姓名
private String userName;
//用户账号
@Pattern(regexp = "/^[1-9]([0-9]{1,5})?$/", message = "账号只能为数字!")
private String account;
//用户密码
private String password;
@ -60,4 +63,6 @@ public class UserInfoEntity {
private Integer schoolAppellationId;
//token
private String token;
//最后登录时间
private String lastLoginTime;
}

@ -1,22 +1,46 @@
package com.msdw.tms.entity.response;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* @Author: gongsj.
* @Description: 统一返回的结果集
* @Date:Created in 2020/09/07 12:28.
* @Modified By:
*/
@Data
@ToString
@NoArgsConstructor
public class ResponseResult implements Response {
@AllArgsConstructor
public class ResponseResult<T> {
/**
* 操作是否成功
*/
private boolean success;
//操作是否成功
boolean success = SUCCESS;
/**
* 状态码
*/
private int code;
//操作代码
int code = SUCCESS_CODE;
/**
* 返回的数据
*/
private T data;
//提示信息
String message;
/**
* 提示信息
*/
private String message;
public ResponseResult(boolean success, int code, String message) {
this.success = success;
this.code = code;
this.message = message;
}
public ResponseResult(ResultCode resultCode) {
this.success = resultCode.success();
@ -28,8 +52,24 @@ public class ResponseResult implements Response {
return new ResponseResult(CommonCode.SUCCESS);
}
public static ResponseResult SUCCESS(Object t) {
return new ResponseResult<>(true, 10000, t, "操作成功!");
}
public static ResponseResult FAIL(Object t) {
return new ResponseResult<>(false, 99999, t, "操作失败,请检查客户名称是否已存在或者文件和数据格式是否正确!");
}
public ResponseResult SUCCESS_DATA(T t) {
return new ResponseResult<>(false, 20000, t, "操作失败!");
}
public static ResponseResult FAIL() {
return new ResponseResult(CommonCode.FAIL);
}
public static ResponseResult FAIL(int code, String message) {
return new ResponseResult<>(false, code, null, message);
}
}

@ -96,12 +96,14 @@
s.staffId,
s.workNumber,
s.staffProfessionalArchitectureId,
s.staffProfessionalArchitectureName,
spa.staffProfessionalArchitectureName,
s.staffGradeId,
s.staffGradeName
sg.staffGradeName
FROM
hr_user_info u
LEFT JOIN staff s ON u.userId = s.userId
LEFT JOIN staff_professional_architecture spa on spa.staffProfessionalArchitectureId = s.staffProfessionalArchitectureId
LEFT JOIN staff_grade sg on sg.staffGradeId = s.staffGradeId
WHERE
s.schoolId = #{schoolId}
AND
@ -109,8 +111,8 @@
AND
s.isdel=0
<if test="searchContent!=null">AND (u.userName LIKE CONCAT('%',#{searchContent},'%') OR s.workNumber LIKE CONCAT('%',#{searchContent},'%') OR u.account LIKE CONCAT('%',#{searchContent},'%') )</if>
<if test="staffGradeIds!=null and staffGradeIds!='' ">AND FIND_IN_SET(staffGradeId,#{staffGradeIds})</if>
<if test="staffProfessionalArchitectureIds!=null and staffProfessionalArchitectureIds!=''">AND FIND_IN_SET(staffProfessionalArchitectureId,#{staffProfessionalArchitectureIds})</if>
<if test="staffGradeIds!=null and staffGradeIds!='' ">AND FIND_IN_SET(s.staffGradeId,#{staffGradeIds})</if>
<if test="staffProfessionalArchitectureIds!=null and staffProfessionalArchitectureIds!=''">AND FIND_IN_SET(s.staffProfessionalArchitectureId,#{staffProfessionalArchitectureIds})</if>
GROUP BY s.userId ORDER BY u.updateTime DESC,u.lastLoginTime DESC,creationTime DESC
</select>
<select id="querystaffDetail" resultType="com.msdw.tms.entity.vo.StaffVo">

@ -1,145 +1,145 @@
package com.msdw.tms.service;
import com.msdw.tms.common.utils.R;
import com.msdw.tms.dao.AchievementManagementDao;
import com.msdw.tms.entity.ProjectEntity;
import com.msdw.tms.entity.ProjectRecordEntity;
import com.msdw.tms.entity.request.AchievementImportRequest;
import com.msdw.tms.entity.vo.AchievementManagementVo;
import com.msdw.tms.entity.vo.SearchAchievementVo;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@SpringBootTest
public class AchievementManagementTest {
@Autowired
private AchievementManagementService achievementManagementService;
@Autowired
private ProjectRecordService projectRecordService;
@Autowired
AchievementManagementDao achievementManagementDao;
//测试新增实验记录
//package com.msdw.tms.service;
//
//import com.msdw.tms.common.utils.R;
//import com.msdw.tms.dao.AchievementManagementDao;
//import com.msdw.tms.entity.ProjectEntity;
//import com.msdw.tms.entity.ProjectRecordEntity;
//import com.msdw.tms.entity.request.AchievementImportRequest;
//import com.msdw.tms.entity.vo.AchievementManagementVo;
//import com.msdw.tms.entity.vo.SearchAchievementVo;
//import org.junit.jupiter.api.Test;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest;
//
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//
//@SpringBootTest
//public class AchievementManagementTest {
//
// @Autowired
// private AchievementManagementService achievementManagementService;
//
// @Autowired
// private ProjectRecordService projectRecordService;
//
// @Autowired
// AchievementManagementDao achievementManagementDao;
//
// //测试新增实验记录
//// @Test
//// public void addReport(){
//// AchievementManagementVo vo = new AchievementManagementVo();
//// ProjectRecordEntity entity = new ProjectRecordEntity();
//// Date date = new Date();
//// //用户id
//// Integer userId = 385;
////
//// entity.setUserid(userId)
//// .setProjectid(368)
//// .setScore(100)
//// .setRecordstate(0)
//// .setStartingtime(date)
//// .setEndtime(date)
//// .setSubmittime(date)
//// .setTimeSum(0)
//// .setIsdel(0);
//// vo.setUserId(userId)
//// .setEvaluationId(158)
//// .setExperimentalGoal("目标2")
//// .setPrinciple("原理2")
//// .setStep("步骤2")
//// .setAnalysis("实验分析2")
//// .setSummarize("实验总结2")
//// .setImprovement("实验建议2")
//// .setCommentId(3)
//// .setTeacherId(178)
//// .setPeriod("学时")
//// .setLaboratory("实验室名称2")
//// .setIsSignature(0)
//// .setSignatureId(4)
//// .setIsdel(0);
//// vo.setEntity(entity);
//// R r = achievementManagementService.addReport(vo);
//// System.out.println(r);
//// }
//
// @Test
// public void queryReport(){
// Integer reportId = 4;
// Integer recordId = 100;
// R r = achievementManagementService.queryReport(reportId);
// System.out.println(r);
// }
//
// @Test
// public void updateScore(){
// ProjectRecordEntity vo = new ProjectRecordEntity();
// Integer recordId = 100;
// Integer score = 99;
// vo.setRecordid(recordId).setScore(score);
// projectRecordService.updateScore(vo);
// }
//
// @Test
// public void addReport(){
// public void daleteReport(){
// Integer reportId = 4;
// Integer recordId = 100;
// AchievementManagementVo vo = new AchievementManagementVo();
// ProjectRecordEntity entity = new ProjectRecordEntity();
// Date date = new Date();
// //用户id
// Integer userId = 385;
//
// entity.setUserid(userId)
// .setProjectid(368)
// .setScore(100)
// .setRecordstate(0)
// .setStartingtime(date)
// .setEndtime(date)
// .setSubmittime(date)
// .setTimeSum(0)
// .setIsdel(0);
// vo.setUserId(userId)
// .setEvaluationId(158)
// .setExperimentalGoal("目标2")
// .setPrinciple("原理2")
// .setStep("步骤2")
// .setAnalysis("实验分析2")
// .setSummarize("实验总结2")
// .setImprovement("实验建议2")
// .setCommentId(3)
// .setTeacherId(178)
// .setPeriod("学时")
// .setLaboratory("实验室名称2")
// .setIsSignature(0)
// .setSignatureId(4)
// .setIsdel(0);
// entity.setRecordid(recordId);
// vo.setReportId(reportId);
// vo.setEntity(entity);
// R r = achievementManagementService.addReport(vo);
// R r = achievementManagementService.deleteReport(reportId);
// System.out.println(r);
// }
//
// //测试查询班级实验成绩列表
// @Test
// public void queryEvaluationReport(){
// String searchContant = "michonne";
// // String searchContant = "";
// Integer projectId = 368;
// Integer page = 1;
// Integer size = 2;
// R r = achievementManagementService.queryEvaluationReport(searchContant,projectId,page,size);
// System.out.println(r);
//}
@Test
public void queryReport(){
Integer reportId = 4;
Integer recordId = 100;
R r = achievementManagementService.queryReport(reportId);
System.out.println(r);
}
@Test
public void updateScore(){
ProjectRecordEntity vo = new ProjectRecordEntity();
Integer recordId = 100;
Integer score = 99;
vo.setRecordid(recordId).setScore(score);
projectRecordService.updateScore(vo);
}
@Test
public void daleteReport(){
Integer reportId = 4;
Integer recordId = 100;
AchievementManagementVo vo = new AchievementManagementVo();
ProjectRecordEntity entity = new ProjectRecordEntity();
entity.setRecordid(recordId);
vo.setReportId(reportId);
vo.setEntity(entity);
R r = achievementManagementService.deleteReport(reportId);
System.out.println(r);
}
//测试查询班级实验成绩列表
@Test
public void queryEvaluationReport(){
String searchContant = "michonne";
// String searchContant = "";
Integer projectId = 368;
Integer page = 1;
Integer size = 2;
R r = achievementManagementService.queryEvaluationReport(searchContant,projectId,page,size);
System.out.println(r);
}
//筛选查询-教学实验
@Test
public void queryEvaluationReportByRecordId(){
Integer month = 1;
Integer systemId = 1;
String searchContent= "";
String staingTime = "";
String endTime = "";
List<Integer> list = achievementManagementDao.countEducationProjectId();
List<AchievementManagementVo> result = achievementManagementDao.queryEducationRecord(systemId, searchContent, staingTime, endTime, month, list);
System.out.println(result);
}
//筛选查询-虚拟实验
@Test
public void queryFictitiousReportByRecordId(){
Integer month = null;
Integer systemId = 1;
String searchContent= "";
String staingTime = "";
String endTime = "";
List<Integer> list = achievementManagementDao.countFictitiousProjectId();
List<AchievementManagementVo> result = achievementManagementDao.queryFictitiousRecord(systemId, searchContent, staingTime, endTime, month, list);
System.out.println(result);
}
@Test
public void testQuery(){
// String str = "184,185";
ArrayList<Integer> integers = new ArrayList<>();
integers.add(184);
integers.add(185);
List<AchievementImportRequest> achievementImportRequests = achievementManagementDao.queryAchievement(integers);
System.out.println(achievementImportRequests);
}
}
//
// //筛选查询-教学实验
// @Test
// public void queryEvaluationReportByRecordId(){
// Integer month = 1;
// Integer systemId = 1;
// String searchContent= "";
// String staingTime = "";
// String endTime = "";
// List<Integer> list = achievementManagementDao.countEducationProjectId();
// List<AchievementManagementVo> result = achievementManagementDao.queryEducationRecord(systemId, searchContent, staingTime, endTime, month, list);
// System.out.println(result);
// }
// //筛选查询-虚拟实验
// @Test
// public void queryFictitiousReportByRecordId(){
// Integer month = null;
// Integer systemId = 1;
// String searchContent= "";
// String staingTime = "";
// String endTime = "";
// List<Integer> list = achievementManagementDao.countFictitiousProjectId();
// List<AchievementManagementVo> result = achievementManagementDao.queryFictitiousRecord(systemId, searchContent, staingTime, endTime, month, list);
// System.out.println(result);
// }
//
// @Test
// public void testQuery(){
//// String str = "184,185";
// ArrayList<Integer> integers = new ArrayList<>();
// integers.add(184);
// integers.add(185);
//
// List<AchievementImportRequest> achievementImportRequests = achievementManagementDao.queryAchievement(integers);
// System.out.println(achievementImportRequests);
// }
//}

Loading…
Cancel
Save