From 4c9ea0178f5ff244ba6657488d9f108570df61ed Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期一, 22 六月 2020 12:49:55 +0800
Subject: [PATCH] 优化查询属性 不校验分页信息
---
service-api/src/main/java/com/java110/api/rest/RestApi.java | 47 +++++++++++++++++++++++++++++++++++++++++------
1 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/service-api/src/main/java/com/java110/api/rest/RestApi.java b/service-api/src/main/java/com/java110/api/rest/RestApi.java
index 9a81498..9cba1b8 100644
--- a/service-api/src/main/java/com/java110/api/rest/RestApi.java
+++ b/service-api/src/main/java/com/java110/api/rest/RestApi.java
@@ -2,9 +2,10 @@
import com.alibaba.fastjson.JSONObject;
import com.java110.api.smo.IApiServiceSMO;
-import com.java110.utils.constant.CommonConstant;
import com.java110.core.base.controller.BaseController;
import com.java110.core.smo.user.IUserInnerServiceSMO;
+import com.java110.utils.constant.CommonConstant;
+import com.java110.vo.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
@@ -33,6 +34,8 @@
public class RestApi extends BaseController {
private static Logger logger = LoggerFactory.getLogger(RestApi.class);
+ private static final String VERSION = "version";
+ private static final String VERSION_2 = "2.0";
@Autowired
private IApiServiceSMO apiServiceSMOImpl;
@@ -78,8 +81,9 @@
@RequestBody String postInfo,
HttpServletRequest request) {
ResponseEntity<String> responseEntity = null;
+ Map<String, String> headers = new HashMap<String, String>();
try {
- Map<String, String> headers = new HashMap<String, String>();
+
this.getRequestInfo(request, headers);
headers.put(CommonConstant.HTTP_SERVICE, service);
headers.put(CommonConstant.HTTP_METHOD, CommonConstant.HTTP_METHOD_POST);
@@ -90,7 +94,13 @@
responseEntity = new ResponseEntity<String>("璇锋眰鍙戠敓寮傚父锛�" + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
logger.debug("api锛歿} 杩斿洖淇℃伅涓猴細{}", service, responseEntity);
-
+ if (responseEntity.getStatusCode() == HttpStatus.OK) {
+ return responseEntity;
+ }
+ //褰� 鎺ュ彛鐗堟湰鍙蜂负2.0鏃� 杩斿洖閿欒澶勭悊
+ if (headers.containsKey(VERSION) && VERSION_2.equals(headers.get(VERSION))) {
+ return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, responseEntity.getBody());
+ }
return responseEntity;
}
@@ -108,8 +118,8 @@
public ResponseEntity<String> serviceGet(@PathVariable String service,
HttpServletRequest request) {
ResponseEntity<String> responseEntity = null;
+ Map<String, String> headers = new HashMap<String, String>();
try {
- Map<String, String> headers = new HashMap<String, String>();
this.getRequestInfo(request, headers);
headers.put(CommonConstant.HTTP_SERVICE, service);
headers.put(CommonConstant.HTTP_METHOD, CommonConstant.HTTP_METHOD_GET);
@@ -120,6 +130,14 @@
responseEntity = new ResponseEntity<String>("璇锋眰鍙戠敓寮傚父锛�" + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
logger.debug("api锛歿} 杩斿洖淇℃伅涓猴細{}", service, responseEntity);
+
+ if (responseEntity.getStatusCode() == HttpStatus.OK) {
+ return responseEntity;
+ }
+ //褰� 鎺ュ彛鐗堟湰鍙蜂负2.0鏃� 杩斿洖閿欒澶勭悊
+ if (headers.containsKey(VERSION) && VERSION_2.equals(headers.get(VERSION))) {
+ return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, responseEntity.getBody());
+ }
return responseEntity;
}
@@ -140,8 +158,9 @@
@RequestBody String postInfo,
HttpServletRequest request) {
ResponseEntity<String> responseEntity = null;
+ Map<String, String> headers = new HashMap<String, String>();
try {
- Map<String, String> headers = new HashMap<String, String>();
+
this.getRequestInfo(request, headers);
headers.put(CommonConstant.HTTP_SERVICE, service);
headers.put(CommonConstant.HTTP_METHOD, CommonConstant.HTTP_METHOD_PUT);
@@ -152,6 +171,14 @@
responseEntity = new ResponseEntity<String>("璇锋眰鍙戠敓寮傚父锛�" + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
logger.debug("api锛歿} 杩斿洖淇℃伅涓猴細{}", service, responseEntity);
+ if (responseEntity.getStatusCode() == HttpStatus.OK) {
+ return responseEntity;
+ }
+ //褰� 鎺ュ彛鐗堟湰鍙蜂负2.0鏃� 杩斿洖閿欒澶勭悊
+ if (headers.containsKey(VERSION) && VERSION_2.equals(headers.get(VERSION))) {
+ return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, responseEntity.getBody());
+ }
+
return responseEntity;
}
@@ -169,8 +196,9 @@
public ResponseEntity<String> serviceDelete(@PathVariable String service,
HttpServletRequest request) {
ResponseEntity<String> responseEntity = null;
+ Map<String, String> headers = new HashMap<String, String>();
try {
- Map<String, String> headers = new HashMap<String, String>();
+
this.getRequestInfo(request, headers);
headers.put(CommonConstant.HTTP_SERVICE, service);
headers.put(CommonConstant.HTTP_METHOD, CommonConstant.HTTP_METHOD_DELETE);
@@ -183,6 +211,13 @@
}
logger.debug("api锛歿} 杩斿洖淇℃伅涓猴細{}", service, responseEntity);
+ if (responseEntity.getStatusCode() == HttpStatus.OK) {
+ return responseEntity;
+ }
+ //褰� 鎺ュ彛鐗堟湰鍙蜂负2.0鏃� 杩斿洖閿欒澶勭悊
+ if (headers.containsKey(VERSION) && VERSION_2.equals(headers.get(VERSION))) {
+ return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, responseEntity.getBody());
+ }
return responseEntity;
}
--
Gitblit v1.8.0