|
|
@ -97,8 +97,8 @@ public class EntityRelationController extends BaseController { |
|
|
|
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
|
|
@RequestMapping(value = "/relation", method = RequestMethod.GET, params = {"fromId", "fromType", "relationType", "toId", "toType"}) |
|
|
@RequestMapping(value = "/relation", method = RequestMethod.GET, params = {"fromId", "fromType", "relationType", "toId", "toType"}) |
|
|
@ResponseStatus(value = HttpStatus.OK) |
|
|
@ResponseBody |
|
|
public void checkRelation(@RequestParam("fromId") String strFromId, |
|
|
public EntityRelation getRelation(@RequestParam("fromId") String strFromId, |
|
|
@RequestParam("fromType") String strFromType, |
|
|
@RequestParam("fromType") String strFromType, |
|
|
@RequestParam("relationType") String strRelationType, |
|
|
@RequestParam("relationType") String strRelationType, |
|
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup, |
|
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup, |
|
|
@ -114,10 +114,7 @@ public class EntityRelationController extends BaseController { |
|
|
checkEntityId(fromId); |
|
|
checkEntityId(fromId); |
|
|
checkEntityId(toId); |
|
|
checkEntityId(toId); |
|
|
RelationTypeGroup typeGroup = parseRelationTypeGroup(strRelationTypeGroup, RelationTypeGroup.COMMON); |
|
|
RelationTypeGroup typeGroup = parseRelationTypeGroup(strRelationTypeGroup, RelationTypeGroup.COMMON); |
|
|
Boolean found = relationService.checkRelation(fromId, toId, strRelationType, typeGroup).get(); |
|
|
return checkNotNull(relationService.getRelation(fromId, toId, strRelationType, typeGroup).get()); |
|
|
if (!found) { |
|
|
|
|
|
throw new ThingsboardException("Requested item wasn't found!", ThingsboardErrorCode.ITEM_NOT_FOUND); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
throw handleException(e); |
|
|
throw handleException(e); |
|
|
} |
|
|
} |
|
|
|