Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a61cf68ef0
@ -0,0 +1,16 @@
|
|||||||
|
package com.codesdream.ase.component.json.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserLeaveAuth {
|
||||||
|
/*
|
||||||
|
备注
|
||||||
|
*/
|
||||||
|
private int id;
|
||||||
|
private String Comment;
|
||||||
|
/*
|
||||||
|
审核结果
|
||||||
|
*/
|
||||||
|
private String newStat;
|
||||||
|
}
|
@ -1,7 +1,15 @@
|
|||||||
package com.codesdream.ase.component.json.request;
|
package com.codesdream.ase.component.json.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
@Data
|
||||||
public class UserLeaveRequest {
|
public class UserLeaveRequest {
|
||||||
|
private String UserId;//用户名
|
||||||
|
private String Type;//请假类型
|
||||||
|
private String Reason;//请假原因
|
||||||
|
private String Addon;//附件
|
||||||
|
private Date Starttime;//开始时间
|
||||||
|
private Date EndTime;//结束时间
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.codesdream.ase.component.json.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserSGettudentLeaveListRequest {
|
||||||
|
private int studentId;
|
||||||
|
}
|
@ -1,9 +1,19 @@
|
|||||||
package com.codesdream.ase.controller;
|
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.api.QuickJSONRespond;
|
||||||
import com.codesdream.ase.component.json.request.UserLeaveRequest;
|
|
||||||
import com.codesdream.ase.component.auth.ASEUsernameEncoder;
|
import com.codesdream.ase.component.auth.ASEUsernameEncoder;
|
||||||
|
import com.codesdream.ase.component.datamanager.JSONParameter;
|
||||||
|
|
||||||
|
import com.codesdream.ase.component.json.request.UserLeaveAuth;
|
||||||
|
import com.codesdream.ase.component.json.request.UserLeaveRequest;
|
||||||
|
import com.codesdream.ase.component.json.request.UserLoginChecker;
|
||||||
|
import com.codesdream.ase.component.json.request.UserSGettudentLeaveListRequest;
|
||||||
|
import com.codesdream.ase.component.json.respond.JSONBaseRespondObject;
|
||||||
|
import com.codesdream.ase.component.json.respond.JSONStandardFailedRespond;
|
||||||
|
import com.codesdream.ase.exception.InvalidFormFormatException;
|
||||||
|
import com.codesdream.ase.exception.notfound.NotFoundException;
|
||||||
|
import com.codesdream.ase.model.leaves.Leave;
|
||||||
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;
|
||||||
@ -11,9 +21,12 @@ import org.springframework.ui.Model;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
@ -27,34 +40,79 @@ public class LeavesController {
|
|||||||
@Resource
|
@Resource
|
||||||
private JSONParameter jsonParameter;
|
private JSONParameter jsonParameter;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private QuickJSONRespond quickJSONRespond;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private LeavesService leavesService;
|
private LeavesService leavesService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ASEUsernameEncoder usernameEncoder;
|
private ASEUsernameEncoder usernameEncoder;
|
||||||
|
|
||||||
@RequestMapping(value = "/leave")
|
@RequestMapping(value = "/")
|
||||||
String printLeave(Model model) {
|
String printLeave(Model model) {
|
||||||
return "Leave";
|
return "Leave";
|
||||||
}
|
}
|
||||||
|
|
||||||
//提交请假申请
|
//提交请假申请
|
||||||
@RequestMapping(value = "/leave/check", method = RequestMethod.POST)
|
@RequestMapping(value = "/Leave/check", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
String requestLeave(HttpServletRequest request){
|
String leaveRequest(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 JSONStandardFailedRespond());
|
||||||
|
UserLeaveRequest userLeaveRequest=json.get().toJavaObject(UserLeaveRequest.class);
|
||||||
|
Leave newleave=new Leave();
|
||||||
|
newleave.setUserFrom(userLeaveRequest.getUserId());
|
||||||
|
newleave.setType(userLeaveRequest.getType());
|
||||||
|
newleave.setReasonToLeave(userLeaveRequest.getReason());
|
||||||
|
//newleave.set
|
||||||
|
newleave.setStartTime(userLeaveRequest.getStarttime());
|
||||||
|
newleave.setEndTime(userLeaveRequest.getEndTime());
|
||||||
|
Calendar calendar =Calendar.getInstance();
|
||||||
|
Date time = calendar.getTime();
|
||||||
|
newleave.setApplyTime(time);
|
||||||
|
|
||||||
|
leavesService.save(newleave);
|
||||||
|
//eturn quickJSONRespond.getRespond200(null, respond);
|
||||||
|
|
||||||
UserLeaveRequest LeaveChecker = json.get().toJavaObject(UserLeaveRequest.class);
|
return quickJSONRespond.getRespond200("申请已提交");
|
||||||
// 检查类型
|
// 检查类型
|
||||||
return jsonParameter.getJSONString(request);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//列出某辅导员待审核名单
|
@RequestMapping(value = "/Leave/auth", method = RequestMethod.POST)
|
||||||
|
@ResponseBody
|
||||||
|
String getLeaveAuth(HttpServletRequest request){
|
||||||
|
|
||||||
|
// 检查是否为JSON
|
||||||
|
Optional<JSONObject> json = jsonParameter.getJSONByRequest(request);
|
||||||
|
if(!json.isPresent()) return jsonParameter.getJSONString(new JSONStandardFailedRespond());
|
||||||
|
UserLeaveAuth userLeaveAuth=json.get().toJavaObject(UserLeaveAuth.class);
|
||||||
|
Optional<Leave> leave =leavesService.findLeaveById(userLeaveAuth.getId());
|
||||||
|
if(!leave.isPresent()){
|
||||||
|
return quickJSONRespond.getRespond500("No such entry");
|
||||||
|
}
|
||||||
|
Leave newLeave=leave.get();
|
||||||
|
newLeave.setComment(userLeaveAuth.getComment());
|
||||||
|
newLeave.setAuthentication(userLeaveAuth.getNewStat());
|
||||||
|
return quickJSONRespond.getRespond200("Authentication status updated");
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/Leave/getStuLeaveList", method = RequestMethod.POST)
|
||||||
|
@ResponseBody
|
||||||
|
Leave getStuLeavelist(HttpServletRequest request) throws InvalidFormFormatException {
|
||||||
|
Optional<JSONObject> json = jsonParameter.getJSONByRequest(request);
|
||||||
|
if(!json.isPresent()) throw new InvalidFormFormatException("json request not recognized");
|
||||||
|
UserSGettudentLeaveListRequest userSGettudentLeaveListRequest=json.get().toJavaObject(UserSGettudentLeaveListRequest.class);
|
||||||
|
if(leavesService.findLeaveById(userSGettudentLeaveListRequest.getStudentId()).isPresent()){
|
||||||
|
Leave leave =leavesService.findLeaveById(userSGettudentLeaveListRequest.getStudentId()).get();
|
||||||
|
return leave;
|
||||||
|
}else{
|
||||||
|
throw new NotFoundException("Student Does not exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//列出某人
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,13 @@ import javax.persistence.*;
|
|||||||
@Entity
|
@Entity
|
||||||
@Table(name = "leaves")
|
@Table(name = "leaves")
|
||||||
public class Leave {
|
public class Leave {
|
||||||
|
//请假的编号
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
private int id;
|
private int id;
|
||||||
//发出人
|
//发出人
|
||||||
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
@Column
|
||||||
private User userFrom;
|
private String userFrom;
|
||||||
//审批人容器
|
//审批人容器
|
||||||
@ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
|
@ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
|
||||||
private Set <User> userTo;
|
private Set <User> userTo;
|
||||||
@ -28,7 +29,7 @@ public class Leave {
|
|||||||
private String type;
|
private String type;
|
||||||
//批准状态
|
//批准状态
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private String authentication;
|
private String authentication="Pending";
|
||||||
|
|
||||||
//审核备注
|
//审核备注
|
||||||
@Column
|
@Column
|
||||||
|
@ -4,6 +4,7 @@ import com.codesdream.ase.model.leaves.Leave;
|
|||||||
|
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
public interface ILeavesService {
|
public interface ILeavesService {
|
||||||
//通过标题查找活动
|
//通过标题查找活动
|
||||||
@ -12,6 +13,8 @@ public interface ILeavesService {
|
|||||||
//通过创建人姓名查找活动
|
//通过创建人姓名查找活动
|
||||||
Optional<Leave> findLeaveByCreator(String creatorName);
|
Optional<Leave> findLeaveByCreator(String creatorName);
|
||||||
|
|
||||||
|
Optional<Leave>findLeaveById(int id);
|
||||||
|
|
||||||
//活动
|
//活动
|
||||||
Leave save(Leave leave);
|
Leave save(Leave leave);
|
||||||
|
|
||||||
@ -21,7 +24,6 @@ public interface ILeavesService {
|
|||||||
|
|
||||||
//请假信息更新
|
//请假信息更新
|
||||||
Leave update(Leave Leave);
|
Leave update(Leave Leave);
|
||||||
|
|
||||||
//创建请假条目
|
//创建请假条目
|
||||||
Leave createLeave(Leave Leave);
|
Leave createLeave(Leave Leave);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import javax.annotation.Resource;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class LeavesService implements ILeavesService {
|
public class LeavesService implements ILeavesService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private LeaveRepository leaveRepository;
|
private LeaveRepository leaveRepository;
|
||||||
@ -25,10 +25,16 @@ public class LeavesService implements ILeavesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Leave save(Leave leave) {
|
public Leave save( Leave leave) {
|
||||||
return leaveRepository.save(leave);
|
return leaveRepository.save(leave);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Leave> findLeaveById(int id) {
|
||||||
|
return leaveRepository.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(Leave leave) {
|
public void delete(Leave leave) {
|
||||||
@ -45,7 +51,8 @@ public class LeavesService implements ILeavesService {
|
|||||||
return leaveRepository.save(leave);
|
return leaveRepository.save(leave);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Override
|
|
||||||
|
/*@Override
|
||||||
public Leave findActivitiesInTheCharge(User user) {
|
public Leave findActivitiesInTheCharge(User user) {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
Loading…
Reference in New Issue
Block a user