Conflicts:
	src/main/java/com/codesdream/ase/controller/activity/ActivityCreatorController.java
This commit is contained in:
yourtree 2020-03-29 18:25:56 +08:00
commit 801f3a2c7d
35 changed files with 348 additions and 80 deletions

View File

@ -177,6 +177,12 @@
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.github.java-json-tools</groupId>
<artifactId>json-patch</artifactId>
<version>1.12</version>
</dependency>
</dependencies>

View File

@ -1,17 +1,15 @@
package com.codesdream.ase.component.activity;
import com.alibaba.fastjson.JSONObject;
import com.codesdream.ase.exception.DataInvalidFormatException;
import com.codesdream.ase.exception.innerservererror.DataInvalidFormatException;
import com.codesdream.ase.model.activity.Activity;
import com.codesdream.ase.model.activity.Attendance;
import com.codesdream.ase.model.activity.Period;
import com.codesdream.ase.model.permission.User;
import com.codesdream.ase.repository.activity.ActivityRepository;
import com.codesdream.ase.service.ActivityService;
import com.codesdream.ase.service.AttendanceService;
import com.codesdream.ase.service.PeriodService;
import com.codesdream.ase.service.UserService;
import javafx.util.converter.LocalDateTimeStringConverter;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;

View File

@ -1,7 +1,7 @@
package com.codesdream.ase.component.datamanager;
import com.codesdream.ase.exception.notfound.DataFileNotFoundException;
import com.codesdream.ase.exception.DataIOException;
import com.codesdream.ase.exception.innerservererror.DataIOException;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

View File

@ -2,6 +2,9 @@ package com.codesdream.ase.component.datamanager;
import com.codesdream.ase.exception.*;
import com.codesdream.ase.exception.innerservererror.DataIOException;
import com.codesdream.ase.exception.innerservererror.DataIllegalTableFormatException;
import com.codesdream.ase.exception.innerservererror.DataInvalidFormatException;
import com.codesdream.ase.exception.notfound.DataFileNotFoundException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;

View File

@ -1,11 +1,9 @@
package com.codesdream.ase.component.datamanager;
import com.codesdream.ase.exception.DataIllegalTableFormatException;
import com.codesdream.ase.exception.innerservererror.DataIllegalTableFormatException;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.persistence.Table;
import javax.swing.text.html.Option;
import java.util.*;
// 描述一张数据表

View File

@ -0,0 +1,23 @@
package com.codesdream.ase.component.datamanager;
import com.codesdream.ase.exception.innerservererror.HandlingErrorsException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.fge.jsonpatch.JsonPatch;
import com.github.fge.jsonpatch.JsonPatchException;
import org.springframework.stereotype.Controller;
@Controller
public class JsonPathParameter {
public <T> T parsePathToObject(JsonPatch patch, T object){
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode patched = patch.apply(mapper.convertValue(object, JsonNode.class));
return (T) mapper.treeToValue(patched, object.getClass());
} catch (JsonPatchException | JsonProcessingException e) {
throw new HandlingErrorsException(e.getMessage());
}
}
}

View File

@ -0,0 +1,22 @@
package com.codesdream.ase.component.json.model;
import com.codesdream.ase.model.permission.PermissionContainersCollection;
import com.codesdream.ase.model.permission.Tag;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@ApiModel("权限容器集合列表")
public class JsonablePCCList {
List<Integer> pccIdList;
public JsonablePCCList(Tag tag){
for(PermissionContainersCollection pcc : tag.getPermissionContainersCollections()){
pccIdList.add(pcc.getId());
}
}
}

View File

@ -12,13 +12,13 @@ import java.util.List;
@Data
@NoArgsConstructor
@ApiModel("标签所属用户集合")
public class JsonableTagUserList {
public class JsonableUserList {
@ApiModelProperty(name = "用户列表")
private List<Integer> users;
public JsonableTagUserList(Tag tag){
public JsonableUserList(Tag tag){
for(User user : tag.getUsers()){
users.add(user.getId());
}

View File

@ -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;
}

View File

@ -1,7 +1,15 @@
package com.codesdream.ase.component.json.request;
import lombok.Data;
import java.util.Date;
@Data
public class UserLeaveRequest {
private String UserId;//用户名
private String Type;//请假类型
private String Reason;//请假原因
private String Addon;//附件
private Date Starttime;//开始时间
private Date EndTime;//结束时间
}

View File

@ -0,0 +1,8 @@
package com.codesdream.ase.component.json.request;
import lombok.Data;
@Data
public class UserSGettudentLeaveListRequest {
private int studentId;
}

View File

@ -3,7 +3,11 @@ package com.codesdream.ase.controller;
import com.codesdream.ase.component.api.QuickJSONRespond;
import com.codesdream.ase.component.json.respond.ErrorInfoJSONRespond;
import com.codesdream.ase.exception.badrequest.AlreadyExistException;
import com.codesdream.ase.exception.badrequest.IllegalException;
import com.codesdream.ase.exception.conflict.RelatedObjectsExistException;
import com.codesdream.ase.exception.innerservererror.FormatException;
import com.codesdream.ase.exception.innerservererror.HandlingErrorsException;
import com.codesdream.ase.exception.innerservererror.RuntimeIOException;
import com.codesdream.ase.exception.notfound.NotFoundException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -21,7 +25,8 @@ public class ASEControllerAdvice {
@ExceptionHandler(value = {
NullPointerException.class,
AlreadyExistException.class
AlreadyExistException.class,
IllegalException.class
})
public ResponseEntity<Object> handleBadRequest(Exception ex) {
return getResponse(HttpStatus.BAD_REQUEST, ex);
@ -43,6 +48,14 @@ public class ASEControllerAdvice {
return getResponse(HttpStatus.CONFLICT, ex);
}
@ExceptionHandler(value = {
HandlingErrorsException.class,
FormatException.class,
RuntimeIOException.class})
public ResponseEntity<Object> handleInnerServerError(Exception ex){
return getResponse(HttpStatus.INTERNAL_SERVER_ERROR, ex);
}
private ResponseEntity<Object> getResponse(HttpStatus status, Exception ex){
return ResponseEntity.status(status).body(getJSON(status, ex));

View File

@ -1,9 +1,17 @@
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.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;
@ -14,6 +22,8 @@ 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;
@ -27,34 +37,79 @@ public class LeavesController {
@Resource
private JSONParameter jsonParameter;
@Resource
private QuickJSONRespond quickJSONRespond;
@Resource
private LeavesService leavesService;
@Resource
private ASEUsernameEncoder usernameEncoder;
@RequestMapping(value = "/leave")
/* @RequestMapping(value = "/")
String printLeave(Model model) {
return "Leave";
}
}*/
//提交请假申请
@RequestMapping(value = "/leave/check", method = RequestMethod.POST)
@RequestMapping(value = "/Leave/check", method = RequestMethod.POST)
@ResponseBody
String requestLeave(HttpServletRequest request){
String leaveRequest(HttpServletRequest request){
// 检查是否为JSON
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");
}
}
//列出某人
}

View File

@ -1,30 +1,31 @@
package com.codesdream.ase.controller;
import com.alibaba.fastjson.JSONObject;
import com.codesdream.ase.component.datamanager.JSONParameter;
import com.codesdream.ase.component.api.QuickJSONRespond;
import com.codesdream.ase.component.datamanager.JsonPathParameter;
import com.codesdream.ase.component.json.model.JsonablePCCList;
import com.codesdream.ase.component.json.model.JsonableTag;
import com.codesdream.ase.component.json.model.JsonableTagUserList;
import com.codesdream.ase.component.json.model.JsonableUserList;
import com.codesdream.ase.component.json.model.JsonableUser;
import com.codesdream.ase.component.json.respond.PermissionJSONRespond;
import com.codesdream.ase.exception.badrequest.AlreadyExistException;
import com.codesdream.ase.exception.conflict.RelatedObjectsExistException;
import com.codesdream.ase.exception.notfound.NotFoundException;
import com.codesdream.ase.exception.notfound.TagNotFoundException;
import com.codesdream.ase.model.permission.PermissionContainersCollection;
import com.codesdream.ase.model.permission.Tag;
import com.codesdream.ase.model.permission.User;
import com.codesdream.ase.service.IUserService;
import com.codesdream.ase.service.PermissionService;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.fge.jsonpatch.JsonPatch;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.spring.web.json.Json;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
@ -41,6 +42,9 @@ public class PermissionController {
@Resource
private IUserService userService;
@Resource
private JsonPathParameter pathParameter;
// 根据名字创建新的标签
@PostMapping("tag")
@ResponseStatus(HttpStatus.CREATED)
@ -99,31 +103,51 @@ public class PermissionController {
permissionService.delete(tag.get());
}
// 根据名字搜索标签的简要信息
@PatchMapping(path = "tag", consumes = "application/json-patch+json")
@ResponseStatus(HttpStatus.CREATED)
@ApiOperation("修改标签属性")
@ApiImplicitParam(name = "name", value = "标签名")
public JsonableTag updateTag(@RequestParam(value = "name") String name, @RequestBody JsonPatch patch){
Optional<Tag> tag = permissionService.findTag(name);
if(!tag.isPresent()) throw new NotFoundException(name);
JsonableTag jsonableTag = new JsonableTag(tag.get());
jsonableTag = pathParameter.parsePathToObject(patch, jsonableTag);
tag.get().setName(jsonableTag.getName());
tag.get().setDescription(jsonableTag.getDescription());
return new JsonableTag(permissionService.save(tag.get()));
}
@GetMapping("tag/users")
@ResponseStatus(HttpStatus.OK)
@ApiOperation("搜索单个标签所属用户集合信息")
public JsonableTagUserList getUserTag(@RequestParam(value = "name") String name){
public JsonableUserList getUserTag(@RequestParam(value = "name") String name){
Optional<Tag> tag = permissionService.findTag(name);
if(!tag.isPresent()) throw new NotFoundException(name);
return new JsonableTagUserList(tag.get());
return new JsonableUserList(tag.get());
}
@PutMapping("tag/users")
@ApiOperation("更新索单个标签所属用户集合信息")
public JsonableTagUserList setUserTag(@RequestParam String name, @RequestBody JsonableTagUserList userList){
public JsonableUserList setUserTag(@RequestParam String name, @RequestBody JsonableUserList userList){
Optional<Tag> tag = permissionService.findTag(name);
if(!tag.isPresent()) throw new NotFoundException(name);
Set<Integer> userSet = new HashSet<>(userList.getUsers());
tag.get().setUsers(userService.findUsersById(userSet));
return new JsonableTagUserList(permissionService.save(tag.get()));
return new JsonableUserList(permissionService.save(tag.get()));
}
@PostMapping("tag/users")
@ApiOperation("更新单个标签所属用户集合中添加一个或多个用户")
public JsonableTagUserList addUserTag(@RequestParam String name, @RequestBody JsonableTagUserList userList){
public JsonableUserList addUserTag(@RequestParam String name, @RequestBody JsonableUserList userList){
Optional<Tag> tag = permissionService.findTag(name);
if(!tag.isPresent()) throw new NotFoundException(name);
Set<User> newUserSet = userService.findUsersById(new HashSet<>(userList.getUsers()));
@ -133,13 +157,14 @@ public class PermissionController {
userSet.addAll(newUserSet);
tag.get().setUsers(userSet);
return new JsonableTagUserList(permissionService.save(tag.get()));
return new JsonableUserList(permissionService.save(tag.get()));
}
@DeleteMapping("tag/users")
@ResponseStatus(HttpStatus.OK)
@ApiOperation("从单个标签所属用户集合中删除一个或多个用户")
@ApiImplicitParam(name = "name", value = "标签名")
public JsonableTagUserList deleteUserTag(@RequestParam String name, @RequestBody JsonableTagUserList userList){
public JsonableUserList deleteUserTag(@RequestParam String name, @RequestBody JsonableUserList userList){
Optional<Tag> tag = permissionService.findTag(name);
if(!tag.isPresent()) throw new NotFoundException(name);
Set<User> userSet = tag.get().getUsers();
@ -148,7 +173,7 @@ public class PermissionController {
userSet.removeAll(deleteUserSet);
tag.get().setUsers(userSet);
return new JsonableTagUserList(permissionService.save(tag.get()));
return new JsonableUserList(permissionService.save(tag.get()));
}
@GetMapping("tags/users")
@ -167,6 +192,31 @@ public class PermissionController {
return jsonableUsers;
}
@GetMapping("tag/pcc")
@ResponseStatus(HttpStatus.OK)
@ApiOperation("获取标签所含权限容器集合列表")
public JsonablePCCList getPCCTag(@RequestParam(value = "name") String name){
Optional<Tag> tagOptional = permissionService.findTag(name);
if(!tagOptional.isPresent()) throw new NotFoundException(name);
return new JsonablePCCList(tagOptional.get());
}
@PostMapping("tag/pcc")
@ResponseStatus(HttpStatus.CREATED)
@ApiOperation("在指定标签的权限列表中添加一个或多个权限容器")
public JsonablePCCList addPCCTag(@RequestParam(value = "name") String name, JsonablePCCList jsonablePCCList){
Optional<Tag> tagOptional = permissionService.findTag(name);
if(!tagOptional.isPresent()) throw new NotFoundException(name);
Set<PermissionContainersCollection> pccs = tagOptional.get().getPermissionContainersCollections();
pccs.addAll(permissionService.findPCCs(new HashSet<Integer>(jsonablePCCList.getPccIdList())));
tagOptional.get().setPermissionContainersCollections(pccs);
return new JsonablePCCList(permissionService.save(tagOptional.get()));
}
}

View File

@ -1,9 +0,0 @@
package com.codesdream.ase.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class DataIOException extends RuntimeException {
}

View File

@ -1,9 +0,0 @@
package com.codesdream.ase.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class DataIllegalTableFormatException extends RuntimeException {
}

View File

@ -1,11 +1,11 @@
package com.codesdream.ase.exception;
package com.codesdream.ase.exception.badrequest;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class BaseInformationIllegalException extends RuntimeException {
public class BaseInformationIllegalException extends IllegalException {
String type;
String value;

View File

@ -0,0 +1,10 @@
package com.codesdream.ase.exception.badrequest;
import lombok.NoArgsConstructor;
@NoArgsConstructor
public class IllegalException extends RuntimeException {
public IllegalException(String msg){
super(msg);
}
}

View File

@ -1,11 +1,11 @@
package com.codesdream.ase.exception;
package com.codesdream.ase.exception.badrequest;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class UserInformationIllegalException extends RuntimeException {
public class UserInformationIllegalException extends IllegalException {
String username;

View File

@ -0,0 +1,9 @@
package com.codesdream.ase.exception.innerservererror;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class DataIOException extends RuntimeIOException {
}

View File

@ -0,0 +1,9 @@
package com.codesdream.ase.exception.innerservererror;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class DataIllegalTableFormatException extends FormatException {
}

View File

@ -1,11 +1,11 @@
package com.codesdream.ase.exception;
package com.codesdream.ase.exception.innerservererror;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class DataInvalidFormatException extends RuntimeException {
public class DataInvalidFormatException extends FormatException {
String information;
public DataInvalidFormatException(Exception e){

View File

@ -0,0 +1,10 @@
package com.codesdream.ase.exception.innerservererror;
import lombok.NoArgsConstructor;
@NoArgsConstructor
public class FormatException extends RuntimeException {
public FormatException(String msg){
super(msg);
}
}

View File

@ -0,0 +1,13 @@
package com.codesdream.ase.exception.innerservererror;
import lombok.Data;
import lombok.NoArgsConstructor;
// 处理错误对应的异常类
@Data
@NoArgsConstructor
public class HandlingErrorsException extends RuntimeException {
public HandlingErrorsException(String msg){
super(msg);
}
}

View File

@ -1,4 +1,4 @@
package com.codesdream.ase.exception;
package com.codesdream.ase.exception.innerservererror;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -7,7 +7,7 @@ import javax.persistence.criteria.CriteriaBuilder;
@EqualsAndHashCode(callSuper = true)
@Data
public class InvalidFormFormatException extends Throwable {
public class InvalidFormFormatException extends FormatException {
private String message = "Invalid form format";

View File

@ -0,0 +1,10 @@
package com.codesdream.ase.exception.innerservererror;
import lombok.NoArgsConstructor;
@NoArgsConstructor
public class RuntimeIOException extends RuntimeException {
public RuntimeIOException(String msg){
super(msg);
}
}

View File

@ -9,12 +9,13 @@ import javax.persistence.*;
@Entity
@Table(name = "leaves")
public class Leave {
//请假的编号
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
//发出人
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private User userFrom;
@Column
private String userFrom;
//审批人容器
@ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
private Set <User> userTo;
@ -28,7 +29,7 @@ public class Leave {
private String type;
//批准状态
@Column(nullable = false)
private String authentication;
private String authentication="Pending";
//审核备注
@Column

View File

@ -2,7 +2,7 @@ package com.codesdream.ase.service;
import com.codesdream.ase.component.datamanager.DataTable;
import com.codesdream.ase.exception.badrequest.BaseInformationAlreadyExistException;
import com.codesdream.ase.exception.BaseInformationIllegalException;
import com.codesdream.ase.exception.badrequest.BaseInformationIllegalException;
import com.codesdream.ase.exception.notfound.BaseInformationNotFoundException;
import com.codesdream.ase.model.information.*;
import com.codesdream.ase.repository.information.*;

View File

@ -4,6 +4,7 @@ import com.codesdream.ase.model.leaves.Leave;
import java.util.Optional;
import java.util.OptionalInt;
public interface ILeavesService {
//通过标题查找活动
@ -12,6 +13,8 @@ public interface ILeavesService {
//通过创建人姓名查找活动
Optional<Leave> findLeaveByCreator(String creatorName);
Optional<Leave>findLeaveById(int id);
//活动
Leave save(Leave leave);
@ -21,7 +24,6 @@ public interface ILeavesService {
//请假信息更新
Leave update(Leave Leave);
//创建请假条目
Leave createLeave(Leave Leave);

View File

@ -44,6 +44,10 @@ public interface IPermissionService {
// 标签下所有的获得权限容器集合列表
Collection<PermissionContainersCollection> getPCCs(Tag tag);
Set<PermissionContainersCollection> findPCCs(Set<Integer> pccs);
Optional<PermissionContainersCollection> findPCC(Integer id);
// 获得范围性权限容器下的所有标签列表
Collection<Tag> getTagsFromSPC(
ScopePermissionContainer spc);

View File

@ -29,6 +29,12 @@ public class LeavesService implements ILeavesService {
return leaveRepository.save(leave);
}
@Override
public Optional<Leave> findLeaveById(int id) {
return leaveRepository.findById(id);
}
@Override
public void delete(Leave leave) {
@ -45,6 +51,7 @@ public class LeavesService implements ILeavesService {
return leaveRepository.save(leave);
}
/*@Override
public Leave findActivitiesInTheCharge(User user) {

View File

@ -110,6 +110,22 @@ public class PermissionService implements IPermissionService {
return new ArrayList<>(tag.getPermissionContainersCollections());
}
@Override
public Set<PermissionContainersCollection> findPCCs(Set<Integer> pccs) {
Set<PermissionContainersCollection> set = new HashSet<>();
for(Integer id : pccs){
Optional<PermissionContainersCollection> pcc = findPCC(id);
if(!pcc.isPresent()) throw new NotFoundException(String.format("PCCId: %d",id));
set.add(pcc.get());
}
return set;
}
@Override
public Optional<PermissionContainersCollection> findPCC(Integer id) {
return pccRepository.findById(id);
}
@Override
public Collection<Tag> getTagsFromSPC(ScopePermissionContainer spc) {
return new ArrayList<>(spc.getTags());

View File

@ -3,7 +3,7 @@ package com.codesdream.ase.service;
import com.codesdream.ase.component.auth.ASEPasswordEncoder;
import com.codesdream.ase.component.auth.ASEUsernameEncoder;
import com.codesdream.ase.component.permission.UserRolesListGenerator;
import com.codesdream.ase.exception.UserInformationIllegalException;
import com.codesdream.ase.exception.badrequest.UserInformationIllegalException;
import com.codesdream.ase.exception.notfound.UserNotFoundException;
import com.codesdream.ase.exception.badrequest.UsernameAlreadyExistException;
import com.codesdream.ase.model.information.BaseStudentInfo;

View File

@ -1,8 +1,6 @@
package com.codesdream.ase.validator;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.codesdream.ase.exception.DataIllegalTableFormatException;
import org.springframework.stereotype.Component;
import java.util.*;

View File

@ -2,13 +2,10 @@ package com.codesdream.ase.test;
import com.alibaba.fastjson.JSONObject;
import com.codesdream.ase.component.ASESpringUtil;
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.innerservererror.InvalidFormFormatException;
import com.codesdream.ase.validator.JSONFormValidator;
import com.fasterxml.jackson.databind.util.JSONPObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;