添加权限管理子系统相关接口;继续完善错误管理子系统;添加了对于部分数据更新接口的相关支持(JSON Patch);
This commit is contained in:
parent
e09f373fc0
commit
565e9ea835
6
pom.xml
6
pom.xml
@ -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>
|
||||
|
||||
|
@ -1,21 +1,18 @@
|
||||
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;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
@ -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;
|
||||
|
@ -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.*;
|
||||
@ -48,7 +51,7 @@ public class DataExcelReader implements DataReader {
|
||||
Row titleRow = sheet.getRow(0);
|
||||
colNumber = titleRow.getLastCellNum();
|
||||
// 表头项目个数不可为0
|
||||
if(colNumber == 0) throw new DataIllegalTableFormatException();
|
||||
if(colNumber == 0) throw new DataIllegalTableFormatException();
|
||||
Collection<String> title = new ArrayList<>();
|
||||
for(int cellIdx = 0; cellIdx < colNumber; cellIdx++){
|
||||
title.add(readCell(titleRow.getCell(cellIdx)));
|
||||
|
@ -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.*;
|
||||
|
||||
// 描述一张数据表
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
@ -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));
|
||||
|
||||
|
@ -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()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import com.codesdream.ase.component.activity.NullValueAttributes;
|
||||
import com.codesdream.ase.component.datamanager.JSONParameter;
|
||||
import com.codesdream.ase.component.json.respond.JSONStandardFailedRespond;
|
||||
import com.codesdream.ase.configure.ActivityFormConfigure;
|
||||
import com.codesdream.ase.exception.InvalidFormFormatException;
|
||||
import com.codesdream.ase.exception.innerservererror.InvalidFormFormatException;
|
||||
import com.codesdream.ase.model.activity.Activity;
|
||||
import com.codesdream.ase.model.activity.UserActivity;
|
||||
import com.codesdream.ase.model.permission.User;
|
||||
@ -20,7 +20,6 @@ import com.codesdream.ase.validator.JSONFormValidator;
|
||||
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;
|
||||
|
||||
@ -28,7 +27,6 @@ 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
|
||||
|
@ -1,9 +0,0 @@
|
||||
package com.codesdream.ase.exception;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class DataIOException extends RuntimeException {
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.codesdream.ase.exception;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class DataIllegalTableFormatException extends RuntimeException {
|
||||
}
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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 {
|
||||
}
|
@ -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 {
|
||||
}
|
@ -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){
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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";
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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.*;
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
|
@ -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.*;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user