This commit is contained in:
Vindicator645 2020-03-15 20:25:42 +08:00
parent 2277f5c8e4
commit 4916dea891
3 changed files with 26 additions and 19 deletions

View File

@ -0,0 +1,7 @@
package com.codesdream.ase.component.json.request;
public class UserLeaveRequest {
}

View File

@ -2,11 +2,10 @@ package com.codesdream.ase.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.codesdream.ase.component.datamanager.JSONParameter; import com.codesdream.ase.component.datamanager.JSONParameter;
import com.codesdream.ase.component.json.request.UserLeaveRequest;
import com.codesdream.ase.component.json.respond.FailedSONRespond; import com.codesdream.ase.component.json.respond.FailedSONRespond;
import com.codesdream.ase.component.json.respond.JSONBaseRespondObject; import com.codesdream.ase.component.json.respond.JSONBaseRespondObject;
import com.codesdream.ase.component.permission.ASEUsernameEncoder; import com.codesdream.ase.component.permission.ASEUsernameEncoder;
import com.codesdream.ase.component.json.request.UserLeaveChecker;
import com.codesdream.ase.component.json.respond.UserLeaveCheckerJSONRespond;
import com.codesdream.ase.service.LeavesService; import com.codesdream.ase.service.LeavesService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -41,31 +40,22 @@ public class LeavesController {
return "Leave"; return "Leave";
} }
//提交请假申请
@RequestMapping(value = "/Leave/check", method = RequestMethod.POST) @RequestMapping(value = "/Leave/check", method = RequestMethod.POST)
@ResponseBody @ResponseBody
String checkLeave(HttpServletRequest request){ String requestLeave(HttpServletRequest request){
// 检查是否为JSON // 检查是否为JSON
Optional<JSONObject> json = jsonParameter.getJSONByRequest(request); Optional<JSONObject> json = jsonParameter.getJSONByRequest(request);
if(!json.isPresent()) return jsonParameter.getJSONString(new FailedSONRespond()); if(!json.isPresent()) return jsonParameter.getJSONString(new FailedSONRespond());
UserLeaveChecker LeaveChecker = json.get().toJavaObject(UserLeaveChecker.class); UserLeaveRequest LeaveChecker = json.get().toJavaObject(UserLeaveRequest.class);
// 检查类型 // 检查类型
if(LeaveChecker.getCheckType().equals("UsernameExistChecker")){
// 根据学号计算用户名
String user = usernameEncoder.encode(LeaveChecker.getUsername()) ;
// 查询用户名存在状态
boolean existStatus = userService.checkIfUserExists(user).getKey();
// 构造返回对象
UserLeaveCheckerJSONRespond respond = new UserLeaveCheckerJSONRespond();
respond.setUserExist(existStatus);
return jsonParameter.getJSONString(respond);
}
else {
// 返回失败对象
return jsonParameter.getJSONString(new JSONBaseRespondObject());
}
} }
//列出某辅导员待审核名单
//列出某人
} }

View File

@ -17,15 +17,25 @@ public class Leave {
//审批人容器 //审批人容器
@ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY) @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
private Set <User> userTo; private Set <User> userTo;
//请假原因
@Column
private String reasonToLeave;
//请假类型 病假事假等 //请假类型 病假事假等
@Column(name = "type", nullable = false) @Column(name = "type", nullable = false)
private String type; private String type;
//批准状态 //批准状态
@Column(name = "Authentication", nullable = false) @Column(name = "Authentication", nullable = false)
private Boolean Authentication; private String Authentication;
//审核备注
@Column
private String Comment;
//开始时间 //开始时间
@Column(nullable = false) @Column(nullable = false)
private Date startTime; private Date startTime;
@Column(nullable = false) @Column(nullable = false)
private Date endTime; private Date endTime;
//申请时间 //申请时间