Jelajahi Sumber

add REST search API

user / Organization search
MaxKey 2 tahun lalu
induk
melakukan
b05f8f7ef0

+ 13 - 0
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<JpaPageResults<Organizations>>(
+				organizationsService.queryPageResults(org)).buildResponse();
+	}
 }

+ 14 - 0
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<JpaPageResults<UserInfo>>(
+				userInfoService.queryPageResults(userInfo)).buildResponse();
+	}
+
 }