diff --git a/openchs-server-api/src/main/java/org/openchs/dao/OrganisationRepository.java b/openchs-server-api/src/main/java/org/openchs/dao/OrganisationRepository.java index 1cd640421..7da8c4e61 100644 --- a/openchs-server-api/src/main/java/org/openchs/dao/OrganisationRepository.java +++ b/openchs-server-api/src/main/java/org/openchs/dao/OrganisationRepository.java @@ -6,7 +6,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.repository.CrudRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; -import org.springframework.data.rest.core.annotation.RestResource; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Repository; @@ -33,8 +32,6 @@ default Organisation findOne(Long organisationId) { Organisation findByIdAndAccount_AccountAdmin_User_Id(Long id, Long userId); - @PreAuthorize("hasAnyAuthority('admin')") - @RestResource(path = "findAllById", rel = "findAllById") - Page findAllByIdInAndIsVoidedFalse(List ids, Pageable pageable); + Page findAllByIdInAndIsVoidedFalse(Long[] ids, Pageable pageable); } diff --git a/openchs-server-api/src/main/java/org/openchs/web/OrganisationController.java b/openchs-server-api/src/main/java/org/openchs/web/OrganisationController.java index c0749052a..0826aa9cc 100644 --- a/openchs-server-api/src/main/java/org/openchs/web/OrganisationController.java +++ b/openchs-server-api/src/main/java/org/openchs/web/OrganisationController.java @@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.data.repository.query.Param; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; @@ -153,6 +154,12 @@ public Page find(@RequestParam(value = "name", required = return organisations.map(OrganisationContract::fromEntity); } + @RequestMapping(value = "organisation/search/findAllById", method = RequestMethod.GET) + @PreAuthorize(value = "hasAnyAuthority('admin')") + public Page findAllById(@Param("ids") Long[] ids, Pageable pageable) { + return organisationRepository.findAllByIdInAndIsVoidedFalse(ids, pageable); + } + private void setAttributesOnOrganisation(@RequestBody OrganisationContract request, Organisation organisation) { organisation.setName(request.getName()); organisation.setUsernameSuffix(request.getUsernameSuffix());