add REST search API

user / Organization search
This commit is contained in:
MaxKey 2023-05-22 11:38:41 +08:00
parent 1cb66a7e5f
commit b05f8f7ef0
2 changed files with 27 additions and 0 deletions

View File

@ -19,13 +19,18 @@ package org.maxkey.web.apis.identity.rest;
import java.io.IOException; import java.io.IOException;
import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.entity.Message;
import org.maxkey.entity.Organizations; import org.maxkey.entity.Organizations;
import org.maxkey.persistence.service.OrganizationsService; import org.maxkey.persistence.service.OrganizationsService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller; 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.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -91,4 +96,12 @@ public class RestOrganizationController {
organizationsService.remove(id); 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();
}
} }

View File

@ -19,7 +19,9 @@ package org.maxkey.web.apis.identity.rest;
import java.io.IOException; import java.io.IOException;
import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.entity.ChangePassword; import org.maxkey.entity.ChangePassword;
import org.maxkey.entity.Message;
import org.maxkey.entity.UserInfo; import org.maxkey.entity.UserInfo;
import org.maxkey.persistence.service.UserInfoService; import org.maxkey.persistence.service.UserInfoService;
import org.slf4j.Logger; 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.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller; 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.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -114,4 +119,13 @@ public class RestUserInfoController {
_logger.debug("UserInfo id {} ", id ); _logger.debug("UserInfo id {} ", id );
userInfoService.logicDelete(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();
}
} }