Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
1b6bebc663
@ -0,0 +1,26 @@
|
|||||||
|
package com.codesdream.ase.component.activity;
|
||||||
|
|
||||||
|
import com.codesdream.ase.component.ASESpringUtil;
|
||||||
|
import com.codesdream.ase.model.permission.User;
|
||||||
|
import com.codesdream.ase.repository.permission.UserRepository;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.security.Principal;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
//获取当前用户的用户名
|
||||||
|
@Component
|
||||||
|
public class CurrentUserGetter {
|
||||||
|
private Optional<User> user;
|
||||||
|
public Optional<User> getCurrentUser(HttpServletRequest request){
|
||||||
|
|
||||||
|
Principal principal = request.getUserPrincipal();
|
||||||
|
String username = principal.getName();
|
||||||
|
ASESpringUtil aseSpringUtil = new ASESpringUtil();
|
||||||
|
UserRepository userRepository = aseSpringUtil.getBean(UserRepository.class);
|
||||||
|
this.user = userRepository.findByUsername(username);
|
||||||
|
return this.user;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.codesdream.ase.component.activity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
public class NullValueAttributes {
|
||||||
|
private List<String> nullValueAttributes;
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.codesdream.ase.component.json.request;
|
||||||
|
|
||||||
|
public class UserLeaveRequest {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,61 +0,0 @@
|
|||||||
package com.codesdream.ase.controller;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.codesdream.ase.component.ASESpringUtil;
|
|
||||||
import com.codesdream.ase.component.datamanager.JSONParameter;
|
|
||||||
import com.codesdream.ase.configure.ActivityFormConfigure;
|
|
||||||
import com.codesdream.ase.exception.InvalidFormFormatException;
|
|
||||||
import com.codesdream.ase.exception.LackOfActivityInformation;
|
|
||||||
import com.codesdream.ase.model.activity.Activity;
|
|
||||||
import com.codesdream.ase.service.ActivityService;
|
|
||||||
import com.codesdream.ase.validator.NullValueValidator;
|
|
||||||
import com.codesdream.ase.validator.WebFormValidator;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.constraints.Null;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
public class ActivityController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
ActivityService activityService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
JSONParameter jsonParameter;
|
|
||||||
|
|
||||||
@RequestMapping(value = "/activity_creator")
|
|
||||||
String activityCreatorView(Model model){return "activity_creator";}
|
|
||||||
|
|
||||||
@PostMapping(value = "/activity_creator")
|
|
||||||
String activityCreator(Model model, HttpServletRequest request) throws InvalidFormFormatException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
|
|
||||||
|
|
||||||
Map<String, String[]> parameterMap = request.getParameterMap();
|
|
||||||
ASESpringUtil aseSpringUtil = new ASESpringUtil();
|
|
||||||
ActivityFormConfigure activityFormConfigure = aseSpringUtil.getBean(ActivityFormConfigure.class);
|
|
||||||
WebFormValidator webFormValidator = aseSpringUtil.getBean(WebFormValidator.class);
|
|
||||||
if(!webFormValidator.check(activityFormConfigure.getStdActivityForm(), parameterMap)) {
|
|
||||||
throw new InvalidFormFormatException("Invalid activity form.");
|
|
||||||
}
|
|
||||||
// 需要检查JSON是否合法
|
|
||||||
Optional<JSONObject> jsonObject = jsonParameter.getJSONByRequest(request);
|
|
||||||
if(!jsonObject.isPresent()) return "error";
|
|
||||||
Activity activity = jsonObject.get().toJavaObject(Activity.class);
|
|
||||||
|
|
||||||
NullValueValidator nullValueValidator = aseSpringUtil.getBean(NullValueValidator.class);
|
|
||||||
List<String> nullValues = nullValueValidator.checkNullValues(activity);
|
|
||||||
|
|
||||||
return "act_created";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
|||||||
|
package com.codesdream.ase.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
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.JSONBaseRespondObject;
|
||||||
|
import com.codesdream.ase.component.permission.ASEUsernameEncoder;
|
||||||
|
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.Optional;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录界面控制器类
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
public class LeavesController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private JSONParameter jsonParameter;
|
||||||
|
|
||||||
|
@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 requestLeave(HttpServletRequest request){
|
||||||
|
|
||||||
|
// 检查是否为JSON
|
||||||
|
Optional<JSONObject> json = jsonParameter.getJSONByRequest(request);
|
||||||
|
if(!json.isPresent()) return jsonParameter.getJSONString(new FailedSONRespond());
|
||||||
|
|
||||||
|
|
||||||
|
UserLeaveRequest LeaveChecker = json.get().toJavaObject(UserLeaveRequest.class);
|
||||||
|
// 检查类型
|
||||||
|
|
||||||
|
}
|
||||||
|
//列出某辅导员待审核名单
|
||||||
|
|
||||||
|
//列出某人
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,148 @@
|
|||||||
|
package com.codesdream.ase.controller.activity;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.codesdream.ase.component.ASESpringUtil;
|
||||||
|
import com.codesdream.ase.component.activity.NullValueAttributes;
|
||||||
|
import com.codesdream.ase.component.datamanager.JSONParameter;
|
||||||
|
import com.codesdream.ase.component.json.respond.JSONBaseRespondObject;
|
||||||
|
import com.codesdream.ase.configure.ActivityFormConfigure;
|
||||||
|
import com.codesdream.ase.exception.InvalidFormFormatException;
|
||||||
|
import com.codesdream.ase.exception.UserNotFoundException;
|
||||||
|
import com.codesdream.ase.model.activity.Activity;
|
||||||
|
import com.codesdream.ase.model.activity.UserActivity;
|
||||||
|
import com.codesdream.ase.model.permission.User;
|
||||||
|
import com.codesdream.ase.repository.activity.UserActivityRepository;
|
||||||
|
import com.codesdream.ase.repository.permission.UserRepository;
|
||||||
|
import com.codesdream.ase.service.ActivityService;
|
||||||
|
import com.codesdream.ase.validator.ActivityValidator;
|
||||||
|
import com.codesdream.ase.validator.NullValueValidator;
|
||||||
|
import com.codesdream.ase.validator.WebFormValidator;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class ActivityCreatorController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ActivityService activityService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
JSONParameter jsonParameter;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ASESpringUtil aseSpringUtil;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ActivityFormConfigure activityFormConfigure;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
WebFormValidator webFormValidator;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
NullValueValidator nullValueValidator;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
NullValueAttributes nullValueAttributes;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ActivityValidator activityValidator;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
UserRepository userRepository;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
UserActivityRepository userActivityRepository;
|
||||||
|
|
||||||
|
private final String url = "/forget/activity";
|
||||||
|
|
||||||
|
@RequestMapping(value = url + "/activity_creator")
|
||||||
|
String activityCreatorView(Model model){return "activity_creator";}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(value = url + "/activity_creator")
|
||||||
|
@ResponseBody
|
||||||
|
String activityCreator(@RequestBody JSONObject jsonParam, Model model, HttpServletRequest request) throws InvalidFormFormatException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
|
||||||
|
|
||||||
|
JSONObject error = new JSONObject();
|
||||||
|
|
||||||
|
Map<String, String[]> parameterMap = request.getParameterMap();
|
||||||
|
aseSpringUtil = new ASESpringUtil();
|
||||||
|
//WebFormValidator webFormValidator = aseSpringUtil.getBean(WebFormValidator.class);
|
||||||
|
if(!webFormValidator.check(activityFormConfigure.getStdActivityForm(), parameterMap)) {
|
||||||
|
error.put("error", "Invalid form format");
|
||||||
|
return error.toJSONString();
|
||||||
|
}
|
||||||
|
// 需要检查JSON是否合法
|
||||||
|
Optional<JSONObject> jsonObject = jsonParameter.getJSONByRequest(request);
|
||||||
|
if(!jsonObject.isPresent()){
|
||||||
|
error.put("error", "Invalid type.");
|
||||||
|
return error.toJSONString();
|
||||||
|
}
|
||||||
|
Activity activity = jsonObject.get().toJavaObject(Activity.class);
|
||||||
|
|
||||||
|
//NullValueValidator nullValueValidator = aseSpringUtil.getBean(NullValueValidator.class);
|
||||||
|
List<String> nullValues = nullValueValidator.checkNullValues(activity);
|
||||||
|
//= aseSpringUtil.getBean(NullValueAttributes.class);
|
||||||
|
for (String str : nullValues){
|
||||||
|
if(str.equals("title")){
|
||||||
|
nullValueAttributes.getNullValueAttributes().add("title");
|
||||||
|
}
|
||||||
|
else if(str.equals("creator")){
|
||||||
|
nullValueAttributes.getNullValueAttributes().add("creator");
|
||||||
|
}
|
||||||
|
else if(str.equals("type")){
|
||||||
|
nullValueAttributes.getNullValueAttributes().add("type");
|
||||||
|
}
|
||||||
|
else if(str.equals("planPeriod")){
|
||||||
|
nullValueAttributes.getNullValueAttributes().add("planPeriod");
|
||||||
|
}
|
||||||
|
else if(str.equals("chiefManager")){
|
||||||
|
nullValueAttributes.getNullValueAttributes().add("chiefManager");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//如果为空,存下此活动并跳转至成功创建页面
|
||||||
|
if(nullValueAttributes.getNullValueAttributes().isEmpty()){
|
||||||
|
|
||||||
|
//ActivityValidator activityValidator = aseSpringUtil.getBean(ActivityValidator.class);
|
||||||
|
String[] errorParameters = activityValidator.check(parameterMap);
|
||||||
|
if(errorParameters != null){
|
||||||
|
JSONObject invalidParameters = new JSONObject();
|
||||||
|
invalidParameters.put("invalid_parameters", errorParameters);
|
||||||
|
return invalidParameters.toJSONString();
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//UserRepository userRepository = aseSpringUtil.getBean(UserRepository.class);
|
||||||
|
//activityService = aseSpringUtil.getBean(ActivityService.class);
|
||||||
|
activity = activityService.createActivity(activity);
|
||||||
|
String username = parameterMap.get("creator")[0];
|
||||||
|
Optional<User> user = userRepository.findByUsername(username);
|
||||||
|
//UserActivityRepository userActivityRepository = aseSpringUtil.getBean(UserActivityRepository.class);
|
||||||
|
UserActivity userActivity = userActivityRepository.findByUser(user.get());
|
||||||
|
userActivity.getCreatedActivities().add(activity);
|
||||||
|
userActivityRepository.save(userActivity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//否则返回一个JSON对象给前端,此处应该是JSP页面,动态标红
|
||||||
|
else{
|
||||||
|
JSONObject nullParameters = new JSONObject();
|
||||||
|
nullParameters.put("null_values",nullValueAttributes.getNullValueAttributes());
|
||||||
|
return nullParameters.toJSONString();
|
||||||
|
}
|
||||||
|
return url + "/act_created";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.codesdream.ase.controller.activity;
|
||||||
|
|
||||||
|
import com.codesdream.ase.component.ASESpringUtil;
|
||||||
|
import com.codesdream.ase.component.datamanager.JSONParameter;
|
||||||
|
import com.codesdream.ase.model.activity.Activity;
|
||||||
|
import com.codesdream.ase.repository.activity.ActivityRepository;
|
||||||
|
import com.codesdream.ase.service.ActivityService;
|
||||||
|
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 javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.security.Principal;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class ActivityViewerController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ActivityService activityService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ActivityRepository activityRepository;
|
||||||
|
|
||||||
|
@RequestMapping(value = "/my/participated", method = RequestMethod.GET)
|
||||||
|
String showParticipated(Model model, HttpServletRequest request){
|
||||||
|
Principal principal = request.getUserPrincipal();
|
||||||
|
String username = principal.getName();
|
||||||
|
ASESpringUtil aseSpringUtil = new ASESpringUtil();
|
||||||
|
activityRepository = aseSpringUtil.getBean(ActivityRepository.class);
|
||||||
|
//List<Activity> participatedActivities = activityRepository.findc
|
||||||
|
return "/my/participated";
|
||||||
|
}
|
||||||
|
}
|
@ -8,10 +8,15 @@ import lombok.EqualsAndHashCode;
|
|||||||
public class UserNotFoundException extends RuntimeException {
|
public class UserNotFoundException extends RuntimeException {
|
||||||
Integer id;
|
Integer id;
|
||||||
String username;
|
String username;
|
||||||
|
String message;
|
||||||
public UserNotFoundException(Integer id, String username){
|
public UserNotFoundException(Integer id, String username){
|
||||||
super();
|
super();
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserNotFoundException(String message){
|
||||||
|
super();
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,6 +129,7 @@ public class Activity {
|
|||||||
|
|
||||||
//计划开始时间
|
//计划开始时间
|
||||||
@OneToOne(cascade = CascadeType.ALL)
|
@OneToOne(cascade = CascadeType.ALL)
|
||||||
|
@JoinColumn(nullable = false)
|
||||||
private Period planPeriod;
|
private Period planPeriod;
|
||||||
|
|
||||||
//实际开始时间
|
//实际开始时间
|
||||||
@ -154,11 +155,11 @@ public class Activity {
|
|||||||
private Set<User> assistManagers;
|
private Set<User> assistManagers;
|
||||||
|
|
||||||
//是否开始
|
//是否开始
|
||||||
@Column//(name = "is_on", nullable = false)
|
@Column(name = "is_on", nullable = false)
|
||||||
boolean isOn;
|
boolean isOn;
|
||||||
|
|
||||||
//是否结束
|
//是否结束
|
||||||
@Column//(name = "is_off", nullable = false)
|
@Column(name = "is_off", nullable = false)
|
||||||
boolean isOff;
|
boolean isOff;
|
||||||
|
|
||||||
//考勤安排
|
//考勤安排
|
||||||
|
@ -18,7 +18,7 @@ public class UserActivity {
|
|||||||
|
|
||||||
//关联的用户
|
//关联的用户
|
||||||
@OneToOne(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY, mappedBy = "userActivity")
|
@OneToOne(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY, mappedBy = "userActivity")
|
||||||
@JoinColumn(nullable = false)
|
@JoinColumn(nullable = false, unique = true)
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
//主要负责的活动
|
//主要负责的活动
|
||||||
|
@ -6,7 +6,7 @@ import java.util.*;
|
|||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "leaves_archive")
|
@Table(name = "leave")
|
||||||
public class Leave {
|
public class Leave {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
@ -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;
|
||||||
//申请时间
|
//申请时间
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
package com.codesdream.ase.model.leaves;
|
|
||||||
/**
|
|
||||||
请假信息的管理系统
|
|
||||||
*/
|
|
||||||
public class LeavesSystem {
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.codesdream.ase.repository.activity;
|
||||||
|
|
||||||
|
import com.codesdream.ase.model.activity.UserActivity;
|
||||||
|
import com.codesdream.ase.model.permission.User;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface UserActivityRepository extends CrudRepository<UserActivity, Integer> {
|
||||||
|
|
||||||
|
UserActivity findByUser(User user);
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.codesdream.ase.repository.leaves;
|
||||||
|
import com.codesdream.ase.model.activity.Report;
|
||||||
|
import com.codesdream.ase.model.leaves.Leave;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface LeaveRepository extends CrudRepository<Leave, Integer>{
|
||||||
|
|
||||||
|
Optional<Leave> findByTitle(String title) ;
|
||||||
|
Optional<Leave> findByCreator(String creatorName);
|
||||||
|
}
|
31
src/main/java/com/codesdream/ase/service/ILeavesService.java
Normal file
31
src/main/java/com/codesdream/ase/service/ILeavesService.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package com.codesdream.ase.service;
|
||||||
|
|
||||||
|
import com.codesdream.ase.model.leaves.Leave;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface ILeavesService {
|
||||||
|
//通过标题查找活动
|
||||||
|
Optional<Leave> findLeaveByTitle(String title);
|
||||||
|
|
||||||
|
//通过创建人姓名查找活动
|
||||||
|
Optional<Leave> findLeaveByCreator(String creatorName);
|
||||||
|
|
||||||
|
//活动
|
||||||
|
Leave save(Leave leave);
|
||||||
|
|
||||||
|
|
||||||
|
//请假删除
|
||||||
|
void delete(Leave Leave);
|
||||||
|
|
||||||
|
//请假信息更新
|
||||||
|
Leave update(Leave Leave);
|
||||||
|
|
||||||
|
//创建请假条目
|
||||||
|
Leave createLeave(Leave Leave);
|
||||||
|
|
||||||
|
//查询主要负责的活动
|
||||||
|
//Leave findActivitiesInTheCharge(User user);
|
||||||
|
|
||||||
|
}
|
53
src/main/java/com/codesdream/ase/service/LeavesService.java
Normal file
53
src/main/java/com/codesdream/ase/service/LeavesService.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
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<Leave> findLeaveByTitle(String title) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Leave> findLeaveByCreator(String creatorName) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Leave save(Leave leave) {
|
||||||
|
return leaveRepository.save(leave);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@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) {
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.codesdream.ase.validator;
|
||||||
|
|
||||||
|
import com.codesdream.ase.model.activity.Activity;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
//检查当前活动各属性值是否合法(存在)
|
||||||
|
@Component
|
||||||
|
public class ActivityValidator {
|
||||||
|
|
||||||
|
public String[] check(Map<String, String[]> parameterMap){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -11,7 +11,7 @@ public class WebFormValidator {
|
|||||||
public boolean check(Collection<String> stdForm, Map<String, String[]> webFormMap){
|
public boolean check(Collection<String> stdForm, Map<String, String[]> webFormMap){
|
||||||
|
|
||||||
Collection<String> webForm = webFormMap.keySet();
|
Collection<String> webForm = webFormMap.keySet();
|
||||||
if(stdForm.containsAll(webForm)){
|
if(webForm.containsAll(stdForm)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user