From b05f8f7ef060dd8d86045a5ae0b8595439872f90 Mon Sep 17 00:00:00 2001 From: MaxKey Date: Mon, 22 May 2023 11:38:41 +0800 Subject: [PATCH] add REST search API user / Organization search --- .../identity/rest/RestOrganizationController.java | 13 +++++++++++++ .../apis/identity/rest/RestUserInfoController.java | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/maxkey-web-apis/maxkey-web-api-rest/src/main/java/org/maxkey/web/apis/identity/rest/RestOrganizationController.java b/maxkey-web-apis/maxkey-web-api-rest/src/main/java/org/maxkey/web/apis/identity/rest/RestOrganizationController.java index db96e529e..c89a962b1 100644 --- a/maxkey-web-apis/maxkey-web-api-rest/src/main/java/org/maxkey/web/apis/identity/rest/RestOrganizationController.java +++ b/maxkey-web-apis/maxkey-web-api-rest/src/main/java/org/maxkey/web/apis/identity/rest/RestOrganizationController.java @@ -19,13 +19,18 @@ package org.maxkey.web.apis.identity.rest; import java.io.IOException; +import org.apache.mybatis.jpa.persistence.JpaPageResults; +import org.maxkey.entity.Message; import org.maxkey.entity.Organizations; import org.maxkey.persistence.service.OrganizationsService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -91,4 +96,12 @@ public class RestOrganizationController { organizationsService.remove(id); } + + @RequestMapping(value = { "/.search" }, produces = {MediaType.APPLICATION_JSON_VALUE}) + @ResponseBody + public ResponseEntity search(@ModelAttribute Organizations org) { + _logger.debug("Organizations {}" , org); + return new Message>( + organizationsService.queryPageResults(org)).buildResponse(); + } } diff --git a/maxkey-web-apis/maxkey-web-api-rest/src/main/java/org/maxkey/web/apis/identity/rest/RestUserInfoController.java b/maxkey-web-apis/maxkey-web-api-rest/src/main/java/org/maxkey/web/apis/identity/rest/RestUserInfoController.java index a1aafcb72..92962087f 100644 --- a/maxkey-web-apis/maxkey-web-api-rest/src/main/java/org/maxkey/web/apis/identity/rest/RestUserInfoController.java +++ b/maxkey-web-apis/maxkey-web-api-rest/src/main/java/org/maxkey/web/apis/identity/rest/RestUserInfoController.java @@ -19,7 +19,9 @@ package org.maxkey.web.apis.identity.rest; import java.io.IOException; +import org.apache.mybatis.jpa.persistence.JpaPageResults; import org.maxkey.entity.ChangePassword; +import org.maxkey.entity.Message; import org.maxkey.entity.UserInfo; import org.maxkey.persistence.service.UserInfoService; import org.slf4j.Logger; @@ -27,7 +29,10 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -114,4 +119,13 @@ public class RestUserInfoController { _logger.debug("UserInfo id {} ", id ); userInfoService.logicDelete(id); } + + @RequestMapping(value = { "/.search" }, produces = {MediaType.APPLICATION_JSON_VALUE}) + @ResponseBody + public ResponseEntity search(@ModelAttribute UserInfo userInfo) { + _logger.debug("UserInfo {}"+userInfo); + return new Message>( + userInfoService.queryPageResults(userInfo)).buildResponse(); + } + }