From f8d3059067516fc277c8ac6e01421beb3c4d09ed Mon Sep 17 00:00:00 2001 From: Beri <37876310+BeriBoss@users.noreply.github.com> Date: Mon, 13 Jan 2025 09:50:45 +0100 Subject: [PATCH] refactor: simplify endpoint paths in ResourceTypesRest (#824) --- .../io/src/app/resource/resource-types.service.ts | 12 ++++++------ .../mobiliar/rest/resources/ResourceTypesRest.java | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/AMW_angular/io/src/app/resource/resource-types.service.ts b/AMW_angular/io/src/app/resource/resource-types.service.ts index b1908d3ff..d6669b459 100644 --- a/AMW_angular/io/src/app/resource/resource-types.service.ts +++ b/AMW_angular/io/src/app/resource/resource-types.service.ts @@ -38,26 +38,26 @@ export class ResourceTypesService extends BaseService { getResourceType(id: number): Observable { return this.http - .get(`${this.getBaseUrl()}/resources/resourceTypes/${id}`, { + .get(`${this.getBaseUrl()}/resourceTypes/${id}`, { headers: this.getHeaders(), }) .pipe(catchError(this.handleError)); } getAllResourceTypes(): Observable { - return this.http.get(`${this.getBaseUrl()}/resources/resourceTypes`); + return this.http.get(`${this.getBaseUrl()}/resourceTypes`); } getPredefinedResourceTypes(): Observable { - return this.http.get(`${this.getBaseUrl()}/resources/predefinedResourceTypes`); + return this.http.get(`${this.getBaseUrl()}/resourceTypes/predefinedResourceTypes`); } getRootResourceTypes(): Observable { - return this.http.get(`${this.getBaseUrl()}/resources/rootResourceTypes`); + return this.http.get(`${this.getBaseUrl()}/resourceTypes/rootResourceTypes`); } addNewResourceType(resourceTypeRequest: ResourceTypeRequest): Observable { - return this.http.post(`${this.getBaseUrl()}/resources/resourceTypes`, resourceTypeRequest); + return this.http.post(`${this.getBaseUrl()}/resourceTypes`, resourceTypeRequest); } refreshData() { @@ -66,7 +66,7 @@ export class ResourceTypesService extends BaseService { delete(id: number): Observable { return this.http - .delete(`${this.getBaseUrl()}/resources/resourceTypes/${id}`, { + .delete(`${this.getBaseUrl()}/resourceTypes/${id}`, { headers: this.getHeaders(), }) .pipe(catchError(this.handleError)); diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceTypesRest.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceTypesRest.java index 1411b2e3b..dc7bd3c5f 100644 --- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceTypesRest.java +++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceTypesRest.java @@ -52,8 +52,8 @@ import static javax.ws.rs.core.Response.Status.NO_CONTENT; @RequestScoped -@Path("/resources") -@Api(value = "/resources") +@Path("/resourceTypes") +@Api(value = "/resourceTypes") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) public class ResourceTypesRest { @@ -67,7 +67,7 @@ public class ResourceTypesRest { @Inject private ResourceTypeDomainService resourceTypeDomainService; - @Path("/resourceTypes") + @Path("/") @GET @ApiOperation(value = "Get all resource types") public List getAllResourceTypes() { @@ -77,7 +77,7 @@ public List getAllResourceTypes() { } @GET - @Path("/resourceTypes/{id : \\d+}") + @Path("/{id : \\d+}") @ApiOperation(value = "Get a resourceType by id") @Produces(MediaType.APPLICATION_JSON) public Response getById(@ApiParam("ResourceType ID") @PathParam("id") Integer id) throws NotFoundException { @@ -102,7 +102,7 @@ public List getRootResourceTypes() { .collect(Collectors.toList()); } - @Path("/resourceTypes") + @Path("/") @POST @ApiOperation(value = "Add a new resource type") @Consumes("application/json") @@ -127,7 +127,7 @@ public Response addNewResourceType(ResourceTypeRequestDTO request) @DELETE - @Path("/resourceTypes/{id : \\d+}") + @Path("/{id : \\d+}") @ApiOperation(value = "Delete a resource type") public Response deleteResourceType(@PathParam("id") Integer id) throws NotAuthorizedException, NotFoundException { try {