From 9403588247a90cffc9184689aa20c72d6923c409 Mon Sep 17 00:00:00 2001 From: chuyan <1047381936@qq.com> Date: Tue, 1 Sep 2020 15:17:31 +0800 Subject: [PATCH] third deletion --- .../ase/controller/HomeController.java | 37 ------ .../ase/controller/LeavesController.java | 115 ------------------ .../ase/service/ILeavesService.java | 33 ----- .../codesdream/ase/service/LeavesService.java | 60 --------- 4 files changed, 245 deletions(-) delete mode 100644 src/main/java/com/codesdream/ase/controller/HomeController.java delete mode 100644 src/main/java/com/codesdream/ase/controller/LeavesController.java delete mode 100644 src/main/java/com/codesdream/ase/service/ILeavesService.java delete mode 100644 src/main/java/com/codesdream/ase/service/LeavesService.java diff --git a/src/main/java/com/codesdream/ase/controller/HomeController.java b/src/main/java/com/codesdream/ase/controller/HomeController.java deleted file mode 100644 index 1748b9c..0000000 --- a/src/main/java/com/codesdream/ase/controller/HomeController.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.codesdream.ase.controller; - -import com.codesdream.ase.model.permission.User; -import com.codesdream.ase.service.IUserService; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.RequestMapping; - -import javax.annotation.Resource; -import java.security.Principal; -import java.util.Optional; - -@Controller -public class HomeController { - @Resource - IUserService userService; - - @RequestMapping(value = "/home") - public String showHomeView(Model model, Principal principal){ - Optional userOptional = userService.findUserByUsername(principal.getName()); - if(!userOptional.isPresent()) return "error"; - User user = userOptional.get(); - // 为视图模板指定参数 - model.addAttribute("username", user.getUsername().substring(0, 18)); - model.addAttribute("real_name", user.getUserDetail().getRealName()); - model.addAttribute("sex", user.getUserDetail().getSex()); - model.addAttribute("student_id", user.getUserAuth().getStudentID()); - model.addAttribute("class_id", user.getUserDetail().getClassId()); - model.addAttribute("college", user.getUserDetail().getBaseCollege().getName()); - model.addAttribute("ethnic", user.getUserDetail().getBaseEthnic().getName()); - model.addAttribute("major", user.getUserDetail().getBaseMajor().getName()); - model.addAttribute("is_at_school", user.getUserDetail().isAtSchool()); - model.addAttribute("ethnic", user.getUserDetail().getBaseEthnic().getName()); - model.addAttribute("mail", user.getUserAuth().getMail()); - return "home"; - } -} diff --git a/src/main/java/com/codesdream/ase/controller/LeavesController.java b/src/main/java/com/codesdream/ase/controller/LeavesController.java deleted file mode 100644 index ae85621..0000000 --- a/src/main/java/com/codesdream/ase/controller/LeavesController.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.codesdream.ase.controller; - -import com.alibaba.fastjson.JSONObject; -import com.codesdream.ase.component.api.QuickJSONRespond; -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.UserSGettudentLeaveListRequest; -import com.codesdream.ase.component.json.respond.JSONStandardFailedRespond; -import com.codesdream.ase.exception.innerservererror.InvalidFormFormatException; -import com.codesdream.ase.exception.notfound.NotFoundException; -import com.codesdream.ase.model.leaves.Leave; -import com.codesdream.ase.service.LeavesService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.util.Calendar; -import java.util.Date; -import java.util.Optional; - - -/** - * 登录界面控制器类 - */ -@Slf4j -@Controller -public class LeavesController { - - @Resource - private JSONParameter jsonParameter; - - @Resource - private QuickJSONRespond quickJSONRespond; - - @Resource - private LeavesService leavesService; - - @Resource - private ASEUsernameEncoder usernameEncoder; - -/* @RequestMapping(value = "/") - String printLeave(Model model) { - return "Leave"; - }*/ - - //提交请假申请 - @RequestMapping(value = "/Leave/check", method = RequestMethod.POST) - @ResponseBody - String leaveRequest(HttpServletRequest request){ - - // 检查是否为JSON - Optional json = jsonParameter.getJSONByRequest(request); - 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); - - return quickJSONRespond.getRespond200("申请已提交"); - // 检查类型 - - } - @RequestMapping(value = "/Leave/auth", method = RequestMethod.POST) - @ResponseBody - String getLeaveAuth(HttpServletRequest request){ - - // 检查是否为JSON - Optional json = jsonParameter.getJSONByRequest(request); - if(!json.isPresent()) return jsonParameter.getJSONString(new JSONStandardFailedRespond()); - UserLeaveAuth userLeaveAuth=json.get().toJavaObject(UserLeaveAuth.class); - Optional 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 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"); - } - - } - - -} diff --git a/src/main/java/com/codesdream/ase/service/ILeavesService.java b/src/main/java/com/codesdream/ase/service/ILeavesService.java deleted file mode 100644 index 4f64f43..0000000 --- a/src/main/java/com/codesdream/ase/service/ILeavesService.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.codesdream.ase.service; - -import com.codesdream.ase.model.leaves.Leave; - - -import java.util.Optional; -import java.util.OptionalInt; - -public interface ILeavesService { - //通过标题查找活动 - Optional findLeaveByTitle(String title); - - //通过创建人姓名查找活动 - Optional findLeaveByCreator(String creatorName); - - OptionalfindLeaveById(int id); - - //活动 - Leave save(Leave leave); - - - //请假删除 - void delete(Leave Leave); - - //请假信息更新 - Leave update(Leave Leave); - //创建请假条目 - Leave createLeave(Leave Leave); - - //查询主要负责的活动 - //Leave findActivitiesInTheCharge(User user); - -} diff --git a/src/main/java/com/codesdream/ase/service/LeavesService.java b/src/main/java/com/codesdream/ase/service/LeavesService.java deleted file mode 100644 index 0e58d35..0000000 --- a/src/main/java/com/codesdream/ase/service/LeavesService.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.codesdream.ase.service; - -import com.codesdream.ase.model.leaves.Leave; -import com.codesdream.ase.repository.leaves.LeaveRepository; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.Optional; - -@Service -public class LeavesService implements ILeavesService { - - @Resource - private LeaveRepository leaveRepository; - - - @Override - public Optional findLeaveByTitle(String title) { - return Optional.empty(); - } - - @Override - public Optional findLeaveByCreator(String creatorName) { - return Optional.empty(); - } - - @Override - public Leave save( Leave leave) { - return leaveRepository.save(leave); - } - - @Override - public Optional findLeaveById(int id) { - return leaveRepository.findById(id); - } - - - - @Override - public void delete(Leave leave) { - leaveRepository.delete(leave); - } - - @Override - public Leave update(Leave leave) { - return leaveRepository.save(leave); - } - - @Override - public Leave createLeave(Leave leave) { - return leaveRepository.save(leave); - } - - -/*@Override - public Leave findActivitiesInTheCharge(User user) { - - }*/ - -}