修改系统设置模块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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.http.converter.HttpMessageNotReadableException; 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.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
@ -59,4 +60,16 @@ public class ExceptionCatch {
ResultCode resultCode = customException.getResultCode(); ResultCode resultCode = customException.getResultCode();
return new ResponseResult(resultCode); 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 org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -32,7 +33,7 @@ public class SystemSettingController implements SystemSetttingApi {
*/ */
@Override @Override
@PostMapping("/addStaff") @PostMapping("/addStaff")
public R addStaff(@RequestBody StaffVo staffVo){ public R addStaff(@RequestBody @Valid StaffVo staffVo){
R r = systemSetttingService.addStaff(staffVo); R r = systemSetttingService.addStaff(staffVo);
return r; return r;
} }

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

@ -1,22 +1,46 @@
package com.msdw.tms.entity.response; package com.msdw.tms.entity.response;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.ToString; import lombok.ToString;
/**
* @Author: gongsj.
* @Description: 统一返回的结果集
* @Date:Created in 2020/09/07 12:28.
* @Modified By:
*/
@Data @Data
@ToString @ToString
@NoArgsConstructor @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) { public ResponseResult(ResultCode resultCode) {
this.success = resultCode.success(); this.success = resultCode.success();
@ -28,8 +52,24 @@ public class ResponseResult implements Response {
return new ResponseResult(CommonCode.SUCCESS); 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() { public static ResponseResult FAIL() {
return new ResponseResult(CommonCode.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.staffId,
s.workNumber, s.workNumber,
s.staffProfessionalArchitectureId, s.staffProfessionalArchitectureId,
s.staffProfessionalArchitectureName, spa.staffProfessionalArchitectureName,
s.staffGradeId, s.staffGradeId,
s.staffGradeName sg.staffGradeName
FROM FROM
hr_user_info u hr_user_info u
LEFT JOIN staff s ON u.userId = s.userId 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 WHERE
s.schoolId = #{schoolId} s.schoolId = #{schoolId}
AND AND
@ -109,8 +111,8 @@
AND AND
s.isdel=0 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="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="staffGradeIds!=null and staffGradeIds!='' ">AND FIND_IN_SET(s.staffGradeId,#{staffGradeIds})</if>
<if test="staffProfessionalArchitectureIds!=null and staffProfessionalArchitectureIds!=''">AND FIND_IN_SET(staffProfessionalArchitectureId,#{staffProfessionalArchitectureIds})</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 GROUP BY s.userId ORDER BY u.updateTime DESC,u.lastLoginTime DESC,creationTime DESC
</select> </select>
<select id="querystaffDetail" resultType="com.msdw.tms.entity.vo.StaffVo"> <select id="querystaffDetail" resultType="com.msdw.tms.entity.vo.StaffVo">

@ -1,145 +1,145 @@
package com.msdw.tms.service; //package com.msdw.tms.service;
//
import com.msdw.tms.common.utils.R; //import com.msdw.tms.common.utils.R;
import com.msdw.tms.dao.AchievementManagementDao; //import com.msdw.tms.dao.AchievementManagementDao;
import com.msdw.tms.entity.ProjectEntity; //import com.msdw.tms.entity.ProjectEntity;
import com.msdw.tms.entity.ProjectRecordEntity; //import com.msdw.tms.entity.ProjectRecordEntity;
import com.msdw.tms.entity.request.AchievementImportRequest; //import com.msdw.tms.entity.request.AchievementImportRequest;
import com.msdw.tms.entity.vo.AchievementManagementVo; //import com.msdw.tms.entity.vo.AchievementManagementVo;
import com.msdw.tms.entity.vo.SearchAchievementVo; //import com.msdw.tms.entity.vo.SearchAchievementVo;
import org.junit.jupiter.api.Test; //import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; //import org.springframework.boot.test.context.SpringBootTest;
//
import java.util.ArrayList; //import java.util.ArrayList;
import java.util.Date; //import java.util.Date;
import java.util.List; //import java.util.List;
//
@SpringBootTest //@SpringBootTest
public class AchievementManagementTest { //public class AchievementManagementTest {
//
@Autowired // @Autowired
private AchievementManagementService achievementManagementService; // private AchievementManagementService achievementManagementService;
//
@Autowired // @Autowired
private ProjectRecordService projectRecordService; // private ProjectRecordService projectRecordService;
//
@Autowired // @Autowired
AchievementManagementDao achievementManagementDao; // 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 // @Test
// public void addReport(){ // public void daleteReport(){
// Integer reportId = 4;
// Integer recordId = 100;
// AchievementManagementVo vo = new AchievementManagementVo(); // AchievementManagementVo vo = new AchievementManagementVo();
// ProjectRecordEntity entity = new ProjectRecordEntity(); // ProjectRecordEntity entity = new ProjectRecordEntity();
// Date date = new Date(); // entity.setRecordid(recordId);
// //用户id // vo.setReportId(reportId);
// 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); // vo.setEntity(entity);
// R r = achievementManagementService.addReport(vo); // R r = achievementManagementService.deleteReport(reportId);
// System.out.println(r); // System.out.println(r);
// } // }
//
@Test // //测试查询班级实验成绩列表
public void queryReport(){ // @Test
Integer reportId = 4; // public void queryEvaluationReport(){
Integer recordId = 100; // String searchContant = "michonne";
R r = achievementManagementService.queryReport(reportId); // // String searchContant = "";
System.out.println(r); // Integer projectId = 368;
} // Integer page = 1;
// Integer size = 2;
@Test // R r = achievementManagementService.queryEvaluationReport(searchContant,projectId,page,size);
public void updateScore(){ // System.out.println(r);
ProjectRecordEntity vo = new ProjectRecordEntity(); //}
Integer recordId = 100; //
Integer score = 99; // //筛选查询-教学实验
vo.setRecordid(recordId).setScore(score); // @Test
projectRecordService.updateScore(vo); // public void queryEvaluationReportByRecordId(){
} // Integer month = 1;
// Integer systemId = 1;
@Test // String searchContent= "";
public void daleteReport(){ // String staingTime = "";
Integer reportId = 4; // String endTime = "";
Integer recordId = 100; // List<Integer> list = achievementManagementDao.countEducationProjectId();
AchievementManagementVo vo = new AchievementManagementVo(); // List<AchievementManagementVo> result = achievementManagementDao.queryEducationRecord(systemId, searchContent, staingTime, endTime, month, list);
ProjectRecordEntity entity = new ProjectRecordEntity(); // System.out.println(result);
entity.setRecordid(recordId); // }
vo.setReportId(reportId); // //筛选查询-虚拟实验
vo.setEntity(entity); // @Test
R r = achievementManagementService.deleteReport(reportId); // public void queryFictitiousReportByRecordId(){
System.out.println(r); // Integer month = null;
} // Integer systemId = 1;
// String searchContent= "";
//测试查询班级实验成绩列表 // String staingTime = "";
@Test // String endTime = "";
public void queryEvaluationReport(){ // List<Integer> list = achievementManagementDao.countFictitiousProjectId();
String searchContant = "michonne"; // List<AchievementManagementVo> result = achievementManagementDao.queryFictitiousRecord(systemId, searchContent, staingTime, endTime, month, list);
// String searchContant = ""; // System.out.println(result);
Integer projectId = 368; // }
Integer page = 1; //
Integer size = 2; // @Test
R r = achievementManagementService.queryEvaluationReport(searchContant,projectId,page,size); // public void testQuery(){
System.out.println(r); //// String str = "184,185";
} // ArrayList<Integer> integers = new ArrayList<>();
// integers.add(184);
//筛选查询-教学实验 // integers.add(185);
@Test //
public void queryEvaluationReportByRecordId(){ // List<AchievementImportRequest> achievementImportRequests = achievementManagementDao.queryAchievement(integers);
Integer month = 1; // System.out.println(achievementImportRequests);
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