|
|
|
@ -34,6 +34,12 @@ import java.util.List; |
|
|
|
@RequestMapping("/api") |
|
|
|
public class EntityRelationController extends BaseController { |
|
|
|
|
|
|
|
public static final String TO_TYPE = "toType"; |
|
|
|
public static final String FROM_ID = "fromId"; |
|
|
|
public static final String FROM_TYPE = "fromType"; |
|
|
|
public static final String RELATION_TYPE = "relationType"; |
|
|
|
public static final String TO_ID = "toId"; |
|
|
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
|
|
|
@RequestMapping(value = "/relation", method = RequestMethod.POST) |
|
|
|
@ResponseStatus(value = HttpStatus.OK) |
|
|
|
@ -52,18 +58,18 @@ public class EntityRelationController extends BaseController { |
|
|
|
} |
|
|
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
|
|
|
@RequestMapping(value = "/relation", method = RequestMethod.DELETE, params = {"fromId", "fromType", "relationType", "toId", "toType"}) |
|
|
|
@RequestMapping(value = "/relation", method = RequestMethod.DELETE, params = {FROM_ID, FROM_TYPE, RELATION_TYPE, TO_ID, TO_TYPE}) |
|
|
|
@ResponseStatus(value = HttpStatus.OK) |
|
|
|
public void deleteRelation(@RequestParam("fromId") String strFromId, |
|
|
|
@RequestParam("fromType") String strFromType, |
|
|
|
@RequestParam("relationType") String strRelationType, |
|
|
|
public void deleteRelation(@RequestParam(FROM_ID) String strFromId, |
|
|
|
@RequestParam(FROM_TYPE) String strFromType, |
|
|
|
@RequestParam(RELATION_TYPE) String strRelationType, |
|
|
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup, |
|
|
|
@RequestParam("toId") String strToId, @RequestParam("toType") String strToType) throws ThingsboardException { |
|
|
|
checkParameter("fromId", strFromId); |
|
|
|
checkParameter("fromType", strFromType); |
|
|
|
checkParameter("relationType", strRelationType); |
|
|
|
checkParameter("toId", strToId); |
|
|
|
checkParameter("toType", strToType); |
|
|
|
@RequestParam(TO_ID) String strToId, @RequestParam(TO_TYPE) String strToType) throws ThingsboardException { |
|
|
|
checkParameter(FROM_ID, strFromId); |
|
|
|
checkParameter(FROM_TYPE, strFromType); |
|
|
|
checkParameter(RELATION_TYPE, strRelationType); |
|
|
|
checkParameter(TO_ID, strToId); |
|
|
|
checkParameter(TO_TYPE, strToType); |
|
|
|
EntityId fromId = EntityIdFactory.getByTypeAndId(strFromType, strFromId); |
|
|
|
EntityId toId = EntityIdFactory.getByTypeAndId(strToType, strToId); |
|
|
|
checkEntityId(fromId); |
|
|
|
@ -96,19 +102,19 @@ public class EntityRelationController extends BaseController { |
|
|
|
} |
|
|
|
|
|
|
|
@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 = {FROM_ID, FROM_TYPE, RELATION_TYPE, TO_ID, TO_TYPE}) |
|
|
|
@ResponseBody |
|
|
|
public EntityRelation getRelation(@RequestParam("fromId") String strFromId, |
|
|
|
@RequestParam("fromType") String strFromType, |
|
|
|
@RequestParam("relationType") String strRelationType, |
|
|
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup, |
|
|
|
@RequestParam("toId") String strToId, @RequestParam("toType") String strToType) throws ThingsboardException { |
|
|
|
public EntityRelation getRelation(@RequestParam(FROM_ID) String strFromId, |
|
|
|
@RequestParam(FROM_TYPE) String strFromType, |
|
|
|
@RequestParam(RELATION_TYPE) String strRelationType, |
|
|
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup, |
|
|
|
@RequestParam(TO_ID) String strToId, @RequestParam(TO_TYPE) String strToType) throws ThingsboardException { |
|
|
|
try { |
|
|
|
checkParameter("fromId", strFromId); |
|
|
|
checkParameter("fromType", strFromType); |
|
|
|
checkParameter("relationType", strRelationType); |
|
|
|
checkParameter("toId", strToId); |
|
|
|
checkParameter("toType", strToType); |
|
|
|
checkParameter(FROM_ID, strFromId); |
|
|
|
checkParameter(FROM_TYPE, strFromType); |
|
|
|
checkParameter(RELATION_TYPE, strRelationType); |
|
|
|
checkParameter(TO_ID, strToId); |
|
|
|
checkParameter(TO_TYPE, strToType); |
|
|
|
EntityId fromId = EntityIdFactory.getByTypeAndId(strFromType, strFromId); |
|
|
|
EntityId toId = EntityIdFactory.getByTypeAndId(strToType, strToId); |
|
|
|
checkEntityId(fromId); |
|
|
|
@ -121,13 +127,13 @@ public class EntityRelationController extends BaseController { |
|
|
|
} |
|
|
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
|
|
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {"fromId", "fromType"}) |
|
|
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE}) |
|
|
|
@ResponseBody |
|
|
|
public List<EntityRelation> findByFrom(@RequestParam("fromId") String strFromId, |
|
|
|
@RequestParam("fromType") String strFromType, |
|
|
|
public List<EntityRelation> findByFrom(@RequestParam(FROM_ID) String strFromId, |
|
|
|
@RequestParam(FROM_TYPE) String strFromType, |
|
|
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException { |
|
|
|
checkParameter("fromId", strFromId); |
|
|
|
checkParameter("fromType", strFromType); |
|
|
|
checkParameter(FROM_ID, strFromId); |
|
|
|
checkParameter(FROM_TYPE, strFromType); |
|
|
|
EntityId entityId = EntityIdFactory.getByTypeAndId(strFromType, strFromId); |
|
|
|
checkEntityId(entityId); |
|
|
|
RelationTypeGroup typeGroup = parseRelationTypeGroup(strRelationTypeGroup, RelationTypeGroup.COMMON); |
|
|
|
@ -139,13 +145,13 @@ public class EntityRelationController extends BaseController { |
|
|
|
} |
|
|
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
|
|
|
@RequestMapping(value = "/relations/info", method = RequestMethod.GET, params = {"fromId", "fromType"}) |
|
|
|
@RequestMapping(value = "/relations/info", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE}) |
|
|
|
@ResponseBody |
|
|
|
public List<EntityRelationInfo> findInfoByFrom(@RequestParam("fromId") String strFromId, |
|
|
|
@RequestParam("fromType") String strFromType, |
|
|
|
public List<EntityRelationInfo> findInfoByFrom(@RequestParam(FROM_ID) String strFromId, |
|
|
|
@RequestParam(FROM_TYPE) String strFromType, |
|
|
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException { |
|
|
|
checkParameter("fromId", strFromId); |
|
|
|
checkParameter("fromType", strFromType); |
|
|
|
checkParameter(FROM_ID, strFromId); |
|
|
|
checkParameter(FROM_TYPE, strFromType); |
|
|
|
EntityId entityId = EntityIdFactory.getByTypeAndId(strFromType, strFromId); |
|
|
|
checkEntityId(entityId); |
|
|
|
RelationTypeGroup typeGroup = parseRelationTypeGroup(strRelationTypeGroup, RelationTypeGroup.COMMON); |
|
|
|
@ -157,15 +163,15 @@ public class EntityRelationController extends BaseController { |
|
|
|
} |
|
|
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
|
|
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {"fromId", "fromType", "relationType"}) |
|
|
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {FROM_ID, FROM_TYPE, RELATION_TYPE}) |
|
|
|
@ResponseBody |
|
|
|
public List<EntityRelation> findByFrom(@RequestParam("fromId") String strFromId, |
|
|
|
@RequestParam("fromType") String strFromType, |
|
|
|
@RequestParam("relationType") String strRelationType, |
|
|
|
public List<EntityRelation> findByFrom(@RequestParam(FROM_ID) String strFromId, |
|
|
|
@RequestParam(FROM_TYPE) String strFromType, |
|
|
|
@RequestParam(RELATION_TYPE) String strRelationType, |
|
|
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException { |
|
|
|
checkParameter("fromId", strFromId); |
|
|
|
checkParameter("fromType", strFromType); |
|
|
|
checkParameter("relationType", strRelationType); |
|
|
|
checkParameter(FROM_ID, strFromId); |
|
|
|
checkParameter(FROM_TYPE, strFromType); |
|
|
|
checkParameter(RELATION_TYPE, strRelationType); |
|
|
|
EntityId entityId = EntityIdFactory.getByTypeAndId(strFromType, strFromId); |
|
|
|
checkEntityId(entityId); |
|
|
|
RelationTypeGroup typeGroup = parseRelationTypeGroup(strRelationTypeGroup, RelationTypeGroup.COMMON); |
|
|
|
@ -177,13 +183,13 @@ public class EntityRelationController extends BaseController { |
|
|
|
} |
|
|
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
|
|
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {"toId", "toType"}) |
|
|
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {TO_ID, TO_TYPE}) |
|
|
|
@ResponseBody |
|
|
|
public List<EntityRelation> findByTo(@RequestParam("toId") String strToId, |
|
|
|
@RequestParam("toType") String strToType, |
|
|
|
public List<EntityRelation> findByTo(@RequestParam(TO_ID) String strToId, |
|
|
|
@RequestParam(TO_TYPE) String strToType, |
|
|
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException { |
|
|
|
checkParameter("toId", strToId); |
|
|
|
checkParameter("toType", strToType); |
|
|
|
checkParameter(TO_ID, strToId); |
|
|
|
checkParameter(TO_TYPE, strToType); |
|
|
|
EntityId entityId = EntityIdFactory.getByTypeAndId(strToType, strToId); |
|
|
|
checkEntityId(entityId); |
|
|
|
RelationTypeGroup typeGroup = parseRelationTypeGroup(strRelationTypeGroup, RelationTypeGroup.COMMON); |
|
|
|
@ -195,13 +201,13 @@ public class EntityRelationController extends BaseController { |
|
|
|
} |
|
|
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
|
|
|
@RequestMapping(value = "/relations/info", method = RequestMethod.GET, params = {"toId", "toType"}) |
|
|
|
@RequestMapping(value = "/relations/info", method = RequestMethod.GET, params = {TO_ID, TO_TYPE}) |
|
|
|
@ResponseBody |
|
|
|
public List<EntityRelationInfo> findInfoByTo(@RequestParam("toId") String strToId, |
|
|
|
@RequestParam("toType") String strToType, |
|
|
|
public List<EntityRelationInfo> findInfoByTo(@RequestParam(TO_ID) String strToId, |
|
|
|
@RequestParam(TO_TYPE) String strToType, |
|
|
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException { |
|
|
|
checkParameter("toId", strToId); |
|
|
|
checkParameter("toType", strToType); |
|
|
|
checkParameter(TO_ID, strToId); |
|
|
|
checkParameter(TO_TYPE, strToType); |
|
|
|
EntityId entityId = EntityIdFactory.getByTypeAndId(strToType, strToId); |
|
|
|
checkEntityId(entityId); |
|
|
|
RelationTypeGroup typeGroup = parseRelationTypeGroup(strRelationTypeGroup, RelationTypeGroup.COMMON); |
|
|
|
@ -213,15 +219,15 @@ public class EntityRelationController extends BaseController { |
|
|
|
} |
|
|
|
|
|
|
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
|
|
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {"toId", "toType", "relationType"}) |
|
|
|
@RequestMapping(value = "/relations", method = RequestMethod.GET, params = {TO_ID, TO_TYPE, RELATION_TYPE}) |
|
|
|
@ResponseBody |
|
|
|
public List<EntityRelation> findByTo(@RequestParam("toId") String strToId, |
|
|
|
@RequestParam("toType") String strToType, |
|
|
|
@RequestParam("relationType") String strRelationType, |
|
|
|
public List<EntityRelation> findByTo(@RequestParam(TO_ID) String strToId, |
|
|
|
@RequestParam(TO_TYPE) String strToType, |
|
|
|
@RequestParam(RELATION_TYPE) String strRelationType, |
|
|
|
@RequestParam(value = "relationTypeGroup", required = false) String strRelationTypeGroup) throws ThingsboardException { |
|
|
|
checkParameter("toId", strToId); |
|
|
|
checkParameter("toType", strToType); |
|
|
|
checkParameter("relationType", strRelationType); |
|
|
|
checkParameter(TO_ID, strToId); |
|
|
|
checkParameter(TO_TYPE, strToType); |
|
|
|
checkParameter(RELATION_TYPE, strRelationType); |
|
|
|
EntityId entityId = EntityIdFactory.getByTypeAndId(strToType, strToId); |
|
|
|
checkEntityId(entityId); |
|
|
|
RelationTypeGroup typeGroup = parseRelationTypeGroup(strRelationTypeGroup, RelationTypeGroup.COMMON); |
|
|
|
|