修改标签接口;添加FPC与SPC接口;完善权限管理子系统服务层;
This commit is contained in:
parent
5168d6e2d9
commit
b2903bb130
@ -0,0 +1,30 @@
|
||||
package com.codesdream.ase.component.json.model;
|
||||
|
||||
import com.codesdream.ase.model.permission.FunctionalPermissionContainer;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import springfox.documentation.spring.web.json.Json;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@ApiModel("功能性权限容器")
|
||||
public class JsonableFPC {
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
private boolean deleted;
|
||||
|
||||
public JsonableFPC(FunctionalPermissionContainer fpc){
|
||||
this.id = fpc.getId();
|
||||
this.name = fpc.getName();
|
||||
this.description = fpc.getDescription();
|
||||
this.enabled = fpc.isEnabled();
|
||||
this.deleted = fpc.isDeleted();
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.codesdream.ase.component.json.model;
|
||||
|
||||
import com.codesdream.ase.model.permission.FunctionalPermissionContainer;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@ApiModel("功能性权限容器所属角色集合")
|
||||
public class JsonableRoleList {
|
||||
private Integer id;
|
||||
private Set<String> roles = new HashSet<>();
|
||||
|
||||
public JsonableRoleList(FunctionalPermissionContainer fpc){
|
||||
this.id = fpc.getId();
|
||||
if(fpc.getRoles() != null) {
|
||||
this.roles.addAll(fpc.getRoles());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.codesdream.ase.component.json.model;
|
||||
|
||||
import com.codesdream.ase.model.permission.ScopePermissionContainer;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@ApiModel("范围性权限容器")
|
||||
public class JsonableSPC {
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
private boolean deleted;
|
||||
|
||||
public JsonableSPC(ScopePermissionContainer spc){
|
||||
this.id = spc.getId();
|
||||
this.name = spc.getName();
|
||||
this.description = spc.getDescription();
|
||||
this.enabled = spc.isEnabled();
|
||||
this.deleted = spc.isDeleted();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.codesdream.ase.controller.permission;
|
||||
|
||||
import com.codesdream.ase.component.json.model.JsonableFPC;
|
||||
import com.codesdream.ase.component.json.model.JsonableRoleList;
|
||||
import com.codesdream.ase.exception.badrequest.AlreadyExistException;
|
||||
import com.codesdream.ase.exception.notfound.NotFoundException;
|
||||
import com.codesdream.ase.model.permission.FunctionalPermissionContainer;
|
||||
import com.codesdream.ase.service.PermissionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "pmt")
|
||||
@Api(tags = "功能性权限容器接口")
|
||||
public class FPCController {
|
||||
|
||||
@Resource
|
||||
private PermissionService permissionService;
|
||||
|
||||
@GetMapping("fpc")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ApiOperation(value = "查找功能性权限容器")
|
||||
public JsonableFPC getFPC(@RequestParam(value = "id") Integer id){
|
||||
Optional<FunctionalPermissionContainer> fpc = permissionService.findFPC(id);
|
||||
if(!fpc.isPresent()) throw new NotFoundException(id.toString());
|
||||
return new JsonableFPC(fpc.get());
|
||||
}
|
||||
|
||||
@PostMapping("fpc")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
@ApiOperation(value = "创建新的功能性权限容器")
|
||||
public JsonableFPC createFPC(@RequestBody JsonableFPC fpc){
|
||||
if(permissionService.findFPC(fpc.getName()).isPresent()) throw new AlreadyExistException(fpc.getName());
|
||||
FunctionalPermissionContainer functionalPermissionContainer = new FunctionalPermissionContainer();
|
||||
|
||||
functionalPermissionContainer.setName(fpc.getName());
|
||||
functionalPermissionContainer.setDescription(fpc.getDescription());
|
||||
functionalPermissionContainer.setEnabled(fpc.isEnabled());
|
||||
functionalPermissionContainer.setDeleted(fpc.isDeleted());
|
||||
|
||||
return new JsonableFPC(permissionService.save(functionalPermissionContainer));
|
||||
}
|
||||
|
||||
@GetMapping("fpcs")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ApiOperation(value = "获得所有功能性权限容器的信息")
|
||||
public Set<JsonableFPC> listFPC(){
|
||||
Iterable<FunctionalPermissionContainer> fpcs = permissionService.findAllFPC();
|
||||
Set<JsonableFPC> jsonableFPCS = new HashSet<>();
|
||||
for(FunctionalPermissionContainer fpc : fpcs){
|
||||
jsonableFPCS.add(new JsonableFPC(fpc));
|
||||
}
|
||||
return jsonableFPCS;
|
||||
}
|
||||
|
||||
@GetMapping("fpc/role")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ApiOperation(value = "获得功能性权限容器所属角色")
|
||||
public JsonableRoleList getFPCRoleList(@RequestParam(value = "id") Integer id){
|
||||
Optional<FunctionalPermissionContainer> functionalPermissionContainer =
|
||||
permissionService.findFPC(id);
|
||||
if(!functionalPermissionContainer.isPresent()) throw new NotFoundException(id.toString());
|
||||
|
||||
return new JsonableRoleList(functionalPermissionContainer.get());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package com.codesdream.ase.controller.permission;
|
||||
|
||||
import com.codesdream.ase.component.json.model.JsonableSPC;
|
||||
import com.codesdream.ase.component.json.model.JsonableTag;
|
||||
import com.codesdream.ase.exception.badrequest.AlreadyExistException;
|
||||
import com.codesdream.ase.exception.notfound.NotFoundException;
|
||||
import com.codesdream.ase.model.permission.ScopePermissionContainer;
|
||||
import com.codesdream.ase.model.permission.Tag;
|
||||
import com.codesdream.ase.service.PermissionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "pmt")
|
||||
@Api(tags = "范围性权限容器接口")
|
||||
public class SPCController {
|
||||
|
||||
@Resource
|
||||
private PermissionService permissionService;
|
||||
|
||||
@GetMapping(value = "spc")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ApiOperation(value = "获得范围性权限容器信息")
|
||||
public JsonableSPC getSPC(@RequestParam(value = "id") Integer id){
|
||||
Optional<ScopePermissionContainer> spc = permissionService.findSPC(id);
|
||||
if(!spc.isPresent()) throw new NotFoundException(id.toString());
|
||||
|
||||
return new JsonableSPC(spc.get());
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value = "spcs")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ApiOperation(value = "获得所有的范围性权限容器信息")
|
||||
public Set<JsonableSPC> listSPC(){
|
||||
Iterable<ScopePermissionContainer> spcs = permissionService.findALLSPC();
|
||||
Set<JsonableSPC> jsonableSPCS = new HashSet<>();
|
||||
for(ScopePermissionContainer spc : spcs){
|
||||
jsonableSPCS.add(new JsonableSPC(spc));
|
||||
}
|
||||
return jsonableSPCS;
|
||||
}
|
||||
|
||||
@GetMapping(value = "spc/tag")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ApiOperation(value = "查询范围性权限容器下的所有标签集合")
|
||||
public Set<JsonableTag> listSPCTag(@RequestParam(value = "id") Integer id){
|
||||
Optional<ScopePermissionContainer> spc = permissionService.findSPC(id);
|
||||
if(!spc.isPresent()) throw new NotFoundException(id.toString());
|
||||
|
||||
Set<JsonableTag> tags = new HashSet<>();
|
||||
for(Tag tag : spc.get().getTags()){
|
||||
tags.add(new JsonableTag(tag));
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
@PostMapping(value = "spc")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
@ApiOperation(value = "创建范围性权限容器")
|
||||
public JsonableSPC createSPC(@RequestBody JsonableSPC spc) {
|
||||
if(permissionService.findSPC(spc.getName()).isPresent()) throw new AlreadyExistException(spc.getName());
|
||||
|
||||
ScopePermissionContainer defaultSPC = permissionService.getDefaultSPC(spc.getName());
|
||||
defaultSPC.setDeleted(spc.isDeleted());
|
||||
defaultSPC.setEnabled(spc.isEnabled());
|
||||
defaultSPC.setDescription(spc.getDescription());
|
||||
|
||||
return new JsonableSPC(permissionService.save(defaultSPC));
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.codesdream.ase.controller;
|
||||
package com.codesdream.ase.controller.permission;
|
||||
|
||||
import com.codesdream.ase.component.datamanager.JsonPathParameter;
|
||||
import com.codesdream.ase.component.json.model.JsonablePCCList;
|
||||
@ -14,18 +14,17 @@ 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 io.swagger.models.auth.In;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.spring.web.json.Json;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.jws.soap.SOAPBinding;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@ -33,8 +32,8 @@ import java.util.Set;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("pmt")
|
||||
@Api(tags = "权限管理接口")
|
||||
public class PermissionController {
|
||||
@Api(tags = "标签管理接口")
|
||||
public class TagController {
|
||||
|
||||
@Resource
|
||||
private PermissionService permissionService;
|
||||
@ -64,20 +63,18 @@ public class PermissionController {
|
||||
@GetMapping("tag")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ApiOperation("搜索标签信息")
|
||||
@ApiImplicitParam(name = "name", value = "标签名")
|
||||
public JsonableTag checkTag(@RequestParam(value = "name") String name){
|
||||
Optional<Tag> tagOptional = permissionService.findTag(name);
|
||||
public JsonableTag checkTag(@RequestParam(value = "id") Integer id){
|
||||
Optional<Tag> tagOptional = permissionService.findTag(id);
|
||||
if(tagOptional.isPresent()){
|
||||
return new JsonableTag(tagOptional.get());
|
||||
}
|
||||
else throw new NotFoundException(name);
|
||||
else throw new NotFoundException(id.toString());
|
||||
}
|
||||
|
||||
// 根据名字搜索标签的简要信息
|
||||
@GetMapping("tags")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ApiOperation("列出所有的标签信息")
|
||||
@ApiImplicitParam(name = "name", value = "标签名")
|
||||
public Set<JsonableTag> listTag(){
|
||||
Iterable<Tag> tagIterable = permissionService.findAllTag();
|
||||
Set<JsonableTag> jsonableTagSet = new HashSet<>();
|
||||
@ -91,10 +88,9 @@ public class PermissionController {
|
||||
@DeleteMapping("tag")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
@ApiOperation("删除标签")
|
||||
@ApiImplicitParam(name = "name", value = "标签名")
|
||||
public void deleteTag(@RequestParam(value = "name") String name){
|
||||
Optional<Tag> tag = permissionService.findTag(name);
|
||||
if(!tag.isPresent()) throw new NotFoundException(name);
|
||||
public void deleteTag(@RequestParam(value = "id") Integer id){
|
||||
Optional<Tag> tag = permissionService.findTag(id);
|
||||
if(!tag.isPresent()) throw new NotFoundException(id.toString());
|
||||
|
||||
// 检查外键关联
|
||||
if(tag.get().getUsers().size() > 0) throw new RelatedObjectsExistException();
|
||||
@ -104,13 +100,12 @@ public class PermissionController {
|
||||
}
|
||||
|
||||
// 根据名字搜索标签的简要信息
|
||||
@PatchMapping(path = "tag", consumes = "application/json-patch+json")
|
||||
@PatchMapping(path = "tag")
|
||||
@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);
|
||||
public JsonableTag updateTag(@RequestParam(value = "id") Integer id, @RequestBody JsonPatch patch){
|
||||
Optional<Tag> tag = permissionService.findTag(id);
|
||||
if(!tag.isPresent()) throw new NotFoundException(id.toString());
|
||||
|
||||
JsonableTag jsonableTag = new JsonableTag(tag.get());
|
||||
jsonableTag = pathParameter.parsePathToObject(patch, jsonableTag);
|
||||
@ -122,34 +117,42 @@ public class PermissionController {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("tag/users")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ApiOperation("搜索单个标签所属用户集合信息")
|
||||
public JsonableUserList getUserTag(@RequestParam(value = "name") String name){
|
||||
Optional<Tag> tag = permissionService.findTag(name);
|
||||
if(!tag.isPresent()) throw new NotFoundException(name);
|
||||
return new JsonableUserList(tag.get());
|
||||
public Set<JsonableUser> getUserTag(@RequestParam(value = "id") Integer id){
|
||||
Optional<Tag> tag = permissionService.findTag(id);
|
||||
if(!tag.isPresent()) throw new NotFoundException(id.toString());
|
||||
Set<JsonableUser> jsonableUsers = new HashSet<>();
|
||||
for(User user : tag.get().getUsers()){
|
||||
jsonableUsers.add(new JsonableUser(user));
|
||||
}
|
||||
return jsonableUsers;
|
||||
}
|
||||
|
||||
@PutMapping("tag/users")
|
||||
@ApiOperation("更新索单个标签所属用户集合信息")
|
||||
public JsonableUserList setUserTag(@RequestParam String name, @RequestBody JsonableUserList userList){
|
||||
Optional<Tag> tag = permissionService.findTag(name);
|
||||
if(!tag.isPresent()) throw new NotFoundException(name);
|
||||
public Set<JsonableUser> setUserTag(@RequestParam(value = "id") Integer id,
|
||||
@RequestBody JsonableUserList userList){
|
||||
Optional<Tag> tag = permissionService.findTag(id);
|
||||
if(!tag.isPresent()) throw new NotFoundException(id.toString());
|
||||
|
||||
Set<Integer> userSet = new HashSet<>(userList.getUsers());
|
||||
tag.get().setUsers(userService.findUsersById(userSet));
|
||||
|
||||
return new JsonableUserList(permissionService.save(tag.get()));
|
||||
Set<JsonableUser> jsonableUsers = new HashSet<>();
|
||||
for(User user : tag.get().getUsers()){
|
||||
jsonableUsers.add(new JsonableUser(user));
|
||||
}
|
||||
return jsonableUsers;
|
||||
}
|
||||
|
||||
@PostMapping("tag/users")
|
||||
@ApiOperation("更新单个标签所属用户集合中添加一个或多个用户")
|
||||
public JsonableUserList addUserTag(@RequestParam String name, @RequestBody JsonableUserList userList){
|
||||
Optional<Tag> tag = permissionService.findTag(name);
|
||||
if(!tag.isPresent()) throw new NotFoundException(name);
|
||||
public Set<JsonableUser> addUserTag(@RequestParam(value = "id") Integer id,
|
||||
@RequestBody JsonableUserList userList){
|
||||
Optional<Tag> tag = permissionService.findTag(id);
|
||||
if(!tag.isPresent()) throw new NotFoundException(id.toString());
|
||||
Set<User> newUserSet = userService.findUsersById(new HashSet<>(userList.getUsers()));
|
||||
|
||||
Set<User> userSet = tag.get().getUsers();
|
||||
@ -157,30 +160,38 @@ public class PermissionController {
|
||||
userSet.addAll(newUserSet);
|
||||
tag.get().setUsers(userSet);
|
||||
|
||||
return new JsonableUserList(permissionService.save(tag.get()));
|
||||
Set<JsonableUser> jsonableUsers = new HashSet<>();
|
||||
for(User user : tag.get().getUsers()){
|
||||
jsonableUsers.add(new JsonableUser(user));
|
||||
}
|
||||
return jsonableUsers;
|
||||
}
|
||||
|
||||
@DeleteMapping("tag/users")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ApiOperation("从单个标签所属用户集合中删除一个或多个用户")
|
||||
@ApiImplicitParam(name = "name", value = "标签名")
|
||||
public JsonableUserList deleteUserTag(@RequestParam String name, @RequestBody JsonableUserList userList){
|
||||
Optional<Tag> tag = permissionService.findTag(name);
|
||||
if(!tag.isPresent()) throw new NotFoundException(name);
|
||||
public Set<JsonableUser> deleteUserTag(@RequestParam Integer id,
|
||||
@RequestBody JsonableUserList userList){
|
||||
Optional<Tag> tag = permissionService.findTag(id);
|
||||
if(!tag.isPresent()) throw new NotFoundException(id.toString());
|
||||
Set<User> userSet = tag.get().getUsers();
|
||||
Set<User> deleteUserSet = userService.findUsersById(new HashSet<>(userList.getUsers()));
|
||||
|
||||
userSet.removeAll(deleteUserSet);
|
||||
tag.get().setUsers(userSet);
|
||||
|
||||
return new JsonableUserList(permissionService.save(tag.get()));
|
||||
Set<JsonableUser> jsonableUsers = new HashSet<>();
|
||||
for(User user : tag.get().getUsers()){
|
||||
jsonableUsers.add(new JsonableUser(user));
|
||||
}
|
||||
return jsonableUsers;
|
||||
}
|
||||
|
||||
@GetMapping("tags/users")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@ApiOperation("搜索多个标签所属用户集合信息")
|
||||
public Set<JsonableUser> getUserTags(@RequestParam(value = "name") List<String> names){
|
||||
Set<Tag> tagSet = permissionService.findTags(names);
|
||||
public Set<JsonableUser> getUserTags(@RequestParam(value = "id") List<Integer> ids){
|
||||
Set<Tag> tagSet = permissionService.findTags(ids);
|
||||
Set<User> userSet = new HashSet<>();
|
||||
Set<JsonableUser> jsonableUsers = new HashSet<>();
|
||||
for(Tag tag : tagSet){
|
||||
@ -195,9 +206,9 @@ public class PermissionController {
|
||||
@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);
|
||||
public JsonablePCCList getPCCTag(@RequestParam(value = "id") Integer id){
|
||||
Optional<Tag> tagOptional = permissionService.findTag(id);
|
||||
if(!tagOptional.isPresent()) throw new NotFoundException(id.toString());
|
||||
|
||||
return new JsonablePCCList(tagOptional.get());
|
||||
}
|
||||
@ -205,9 +216,9 @@ public class PermissionController {
|
||||
@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);
|
||||
public JsonablePCCList addPCCTag(@RequestParam(value = "id") Integer id, JsonablePCCList jsonablePCCList){
|
||||
Optional<Tag> tagOptional = permissionService.findTag(id);
|
||||
if(!tagOptional.isPresent()) throw new NotFoundException(id.toString());
|
||||
|
||||
Set<PermissionContainersCollection> pccs = tagOptional.get().getPermissionContainersCollections();
|
||||
pccs.addAll(permissionService.findPCCs(new HashSet<Integer>(jsonablePCCList.getPccIdList())));
|
@ -3,10 +3,7 @@ package com.codesdream.ase.service;
|
||||
import com.codesdream.ase.model.permission.*;
|
||||
import javafx.util.Pair;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public interface IPermissionService {
|
||||
|
||||
@ -27,17 +24,21 @@ public interface IPermissionService {
|
||||
// 列出所有的标签
|
||||
Iterable<Tag> findAllTag();
|
||||
|
||||
Set<Tag> findTags(List<String> names);
|
||||
Set<Tag> findTags(List<Integer> ids);
|
||||
|
||||
// 查找功能性权限容器
|
||||
Optional<FunctionalPermissionContainer> findFPC(String name);
|
||||
|
||||
Iterable<FunctionalPermissionContainer> findAllFPC();
|
||||
|
||||
// 查找范围性权限容器
|
||||
Optional<ScopePermissionContainer> findSPC(String name);
|
||||
|
||||
// 根据id查找功能性权限容器
|
||||
Optional<FunctionalPermissionContainer> findFPC(int id);
|
||||
|
||||
Iterable<ScopePermissionContainer> findALLSPC();
|
||||
|
||||
// 根据id查找范围性权限容器
|
||||
Optional<ScopePermissionContainer> findSPC(int id);
|
||||
|
||||
|
@ -9,7 +9,6 @@ import com.codesdream.ase.repository.permission.PermissionContainersCollectionRe
|
||||
import com.codesdream.ase.repository.permission.ScopePermissionContainerRepository;
|
||||
import com.codesdream.ase.repository.permission.TagRepository;
|
||||
import javafx.util.Pair;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -75,11 +74,11 @@ public class PermissionService implements IPermissionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tag> findTags(List<String> names) {
|
||||
public Set<Tag> findTags(List<Integer> ids) {
|
||||
Set<Tag> tagSet = new HashSet<>();
|
||||
for(String name : names){
|
||||
Optional<Tag> tag = findTag(name);
|
||||
if(!tag.isPresent()) throw new NotFoundException(name);
|
||||
for(Integer id : ids){
|
||||
Optional<Tag> tag = findTag(id);
|
||||
if(!tag.isPresent()) throw new NotFoundException(id.toString());
|
||||
tagSet.add(tag.get());
|
||||
}
|
||||
return tagSet;
|
||||
@ -90,6 +89,10 @@ public class PermissionService implements IPermissionService {
|
||||
return fpcRepository.findByName(name);
|
||||
}
|
||||
|
||||
public Iterable<FunctionalPermissionContainer> findAllFPC() {
|
||||
return fpcRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ScopePermissionContainer> findSPC(String name) {
|
||||
return spcRepository.findByName(name);
|
||||
@ -100,6 +103,11 @@ public class PermissionService implements IPermissionService {
|
||||
return fpcRepository.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<ScopePermissionContainer> findALLSPC() {
|
||||
return spcRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ScopePermissionContainer> findSPC(int id) {
|
||||
return spcRepository.findById(id);
|
||||
|
Loading…
Reference in New Issue
Block a user