From cbc1f9db3d796683d88d6d30df3659984dfbeda3 Mon Sep 17 00:00:00 2001
From: webapp <webapp@home-server.attdns.com>
Date: 星期一, 30 九月 2019 22:56:12 +0800
Subject: [PATCH] 取消java110-common jar包,提升为CommonService服务,将之前的Java110-common内容变更为Java110-utils包
---
Api/src/main/java/com/java110/api/rest/RestApi.java | 164 ++++++++++++++++++++++++++++++++----------------------
1 files changed, 98 insertions(+), 66 deletions(-)
diff --git a/Api/src/main/java/com/java110/api/rest/RestApi.java b/Api/src/main/java/com/java110/api/rest/RestApi.java
index 3496050..9a81498 100644
--- a/Api/src/main/java/com/java110/api/rest/RestApi.java
+++ b/Api/src/main/java/com/java110/api/rest/RestApi.java
@@ -2,8 +2,9 @@
import com.alibaba.fastjson.JSONObject;
import com.java110.api.smo.IApiServiceSMO;
-import com.java110.common.constant.CommonConstant;
+import com.java110.utils.constant.CommonConstant;
import com.java110.core.base.controller.BaseController;
+import com.java110.core.smo.user.IUserInnerServiceSMO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
@@ -12,14 +13,17 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
- *
* rest api
* Created by wuxw on 2018/10/16.
*/
@@ -28,154 +32,174 @@
@Api(value = "瀵瑰缁熶竴鎻愪緵鏈嶅姟鎺ュ彛鏈嶅姟")
public class RestApi extends BaseController {
- private final static Logger logger = LoggerFactory.getLogger(RestApi.class);
+ private static Logger logger = LoggerFactory.getLogger(RestApi.class);
@Autowired
private IApiServiceSMO apiServiceSMOImpl;
+
+ @Autowired
+ private IUserInnerServiceSMO userInnerServiceSMOImpl;
+
/**
* 鍋ュ悍妫�鏌� 鏈嶅姟
+ *
* @return
*/
- @RequestMapping(path = "/health",method = RequestMethod.GET)
- @ApiOperation(value="鏈嶅姟鍋ュ悍妫�鏌�", notes="test: 杩斿洖 2XX 琛ㄧず鏈嶅姟姝e父")
- public String health(){
+ @RequestMapping(path = "/health", method = RequestMethod.GET)
+ @ApiOperation(value = "鏈嶅姟鍋ュ悍妫�鏌�", notes = "test: 杩斿洖 2XX 琛ㄧず鏈嶅姟姝e父")
+ public String health() {
return "";
+ }
+
+ /**
+ * 鍋ュ悍妫�鏌� 鏈嶅姟
+ *
+ * @return
+ */
+ @RequestMapping(path = "/checkUserServiceVersion", method = RequestMethod.GET)
+ @ApiOperation(value = "妫�鏌ョ敤鏈嶅姟鐗堟湰", notes = "test: 杩斿洖 2XX 琛ㄧず鏈嶅姟姝e父")
+ public String checkUserServiceVersion() {
+ return userInnerServiceSMOImpl.getUserServiceVersion("test");
}
/**
* 璧勬簮璇锋眰 post鏂瑰紡
- * @param service 璇锋眰鎺ュ彛鏂瑰紡
+ *
+ * @param service 璇锋眰鎺ュ彛鏂瑰紡
* @param postInfo post鍐呭
- * @param request 璇锋眰瀵硅薄 鏌ヨ澶翠俊鎭� url绛変俊鎭�
+ * @param request 璇锋眰瀵硅薄 鏌ヨ澶翠俊鎭� url绛変俊鎭�
* @return http status 200 鎴愬姛 鍏朵粬澶辫触
*/
- @RequestMapping(path = "/{service:.+}",method = RequestMethod.POST )
- @ApiOperation(value="璧勬簮post璇锋眰", notes="test: 杩斿洖 2XX 琛ㄧず鏈嶅姟姝e父")
- @ApiImplicitParam(paramType="query", name = "service", value = "鐢ㄦ埛缂栧彿", required = true, dataType = "String")
+ @RequestMapping(path = "/{service:.+}", method = RequestMethod.POST)
+ @ApiOperation(value = "璧勬簮post璇锋眰", notes = "test: 杩斿洖 2XX 琛ㄧず鏈嶅姟姝e父")
+ @ApiImplicitParam(paramType = "query", name = "service", value = "鐢ㄦ埛缂栧彿", required = true, dataType = "String")
public ResponseEntity<String> servicePost(@PathVariable String service,
@RequestBody String postInfo,
- HttpServletRequest request){
+ HttpServletRequest request) {
ResponseEntity<String> responseEntity = null;
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);
- logger.debug("api锛歿} 璇锋眰鎶ユ枃涓猴細{},header淇℃伅涓猴細{}",service,postInfo,headers);
- responseEntity = apiServiceSMOImpl.service(postInfo,headers);
- }catch (Throwable e){
- logger.error("璇锋眰post 鏂规硶["+service+"]澶辫触锛�"+postInfo,e);
- responseEntity = new ResponseEntity<String>("璇锋眰鍙戠敓寮傚父锛�"+e.getMessage(),HttpStatus.INTERNAL_SERVER_ERROR);
+ headers.put(CommonConstant.HTTP_SERVICE, service);
+ headers.put(CommonConstant.HTTP_METHOD, CommonConstant.HTTP_METHOD_POST);
+ logger.debug("api锛歿} 璇锋眰鎶ユ枃涓猴細{},header淇℃伅涓猴細{}", service, postInfo, headers);
+ responseEntity = apiServiceSMOImpl.service(postInfo, headers);
+ } catch (Throwable e) {
+ logger.error("璇锋眰post 鏂规硶[" + service + "]澶辫触锛�" + postInfo, e);
+ responseEntity = new ResponseEntity<String>("璇锋眰鍙戠敓寮傚父锛�" + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
- logger.debug("api锛歿} 杩斿洖淇℃伅涓猴細{}",service,responseEntity);
+ logger.debug("api锛歿} 杩斿洖淇℃伅涓猴細{}", service, responseEntity);
return responseEntity;
}
/**
* 璧勬簮璇锋眰 get鏂瑰紡
+ *
* @param service 璇锋眰鎺ュ彛鏂瑰紡
* @param request 璇锋眰瀵硅薄 鏌ヨ澶翠俊鎭� url绛変俊鎭�
* @return http status 200 鎴愬姛 鍏朵粬澶辫触
*/
- @RequestMapping(path = "/{service:.+}",method = RequestMethod.GET )
- @ApiOperation(value="璧勬簮get璇锋眰", notes="test: 杩斿洖 2XX 琛ㄧず鏈嶅姟姝e父")
- @ApiImplicitParam(paramType="query", name = "service", value = "鐢ㄦ埛缂栧彿", required = true, dataType = "String")
+ @RequestMapping(path = "/{service:.+}", method = RequestMethod.GET)
+ @ApiOperation(value = "璧勬簮get璇锋眰", notes = "test: 杩斿洖 2XX 琛ㄧず鏈嶅姟姝e父")
+ @ApiImplicitParam(paramType = "query", name = "service", value = "鐢ㄦ埛缂栧彿", required = true, dataType = "String")
public ResponseEntity<String> serviceGet(@PathVariable String service,
- HttpServletRequest request){
+ HttpServletRequest request) {
ResponseEntity<String> responseEntity = null;
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);
- logger.debug("api锛歿} 璇锋眰鎶ユ枃涓猴細{},header淇℃伅涓猴細{}","",headers);
- responseEntity = apiServiceSMOImpl.service(JSONObject.toJSONString(getParameterStringMap(request)),headers);
- }catch (Throwable e){
- logger.error("璇锋眰get 鏂规硶["+service+"]澶辫触锛�",e);
- responseEntity = new ResponseEntity<String>("璇锋眰鍙戠敓寮傚父锛�"+e.getMessage(),HttpStatus.INTERNAL_SERVER_ERROR);
+ headers.put(CommonConstant.HTTP_SERVICE, service);
+ headers.put(CommonConstant.HTTP_METHOD, CommonConstant.HTTP_METHOD_GET);
+ logger.debug("api锛歿} 璇锋眰鎶ユ枃涓猴細{},header淇℃伅涓猴細{}", "", headers);
+ responseEntity = apiServiceSMOImpl.service(JSONObject.toJSONString(getParameterStringMap(request)), headers);
+ } catch (Throwable e) {
+ logger.error("璇锋眰get 鏂规硶[" + service + "]澶辫触锛�", e);
+ responseEntity = new ResponseEntity<String>("璇锋眰鍙戠敓寮傚父锛�" + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
- logger.debug("api锛歿} 杩斿洖淇℃伅涓猴細{}",service,responseEntity);
+ logger.debug("api锛歿} 杩斿洖淇℃伅涓猴細{}", service, responseEntity);
return responseEntity;
}
/**
* 璧勬簮璇锋眰 put鏂瑰紡
- * @param service 璇锋眰鎺ュ彛鏂瑰紡
+ *
+ * @param service 璇锋眰鎺ュ彛鏂瑰紡
* @param postInfo 淇敼鍐呭
- * @param request 璇锋眰瀵硅薄 鏌ヨ澶翠俊鎭� url绛変俊鎭�
+ * @param request 璇锋眰瀵硅薄 鏌ヨ澶翠俊鎭� url绛変俊鎭�
* @return http status 200 鎴愬姛 鍏朵粬澶辫触
*/
- @RequestMapping(path = "/{service:.+}",method = RequestMethod.PUT )
- @ApiOperation(value="璧勬簮put璇锋眰", notes="test: 杩斿洖 2XX 琛ㄧず鏈嶅姟姝e父")
- @ApiImplicitParam(paramType="query", name = "service", value = "鐢ㄦ埛缂栧彿", required = true, dataType = "String")
+ @RequestMapping(path = "/{service:.+}", method = RequestMethod.PUT)
+ @ApiOperation(value = "璧勬簮put璇锋眰", notes = "test: 杩斿洖 2XX 琛ㄧず鏈嶅姟姝e父")
+ @ApiImplicitParam(paramType = "query", name = "service", value = "鐢ㄦ埛缂栧彿", required = true, dataType = "String")
public ResponseEntity<String> servicePut(@PathVariable String service,
@RequestBody String postInfo,
- HttpServletRequest request){
+ HttpServletRequest request) {
ResponseEntity<String> responseEntity = null;
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);
- logger.debug("api锛歿} 璇锋眰鎶ユ枃涓猴細{},header淇℃伅涓猴細{}",service,postInfo,headers);
- responseEntity = apiServiceSMOImpl.service(postInfo,headers);
- }catch (Throwable e){
- logger.error("璇锋眰put 鏂规硶["+service+"]澶辫触锛�",e);
- responseEntity = new ResponseEntity<String>("璇锋眰鍙戠敓寮傚父锛�"+e.getMessage(),HttpStatus.INTERNAL_SERVER_ERROR);
+ headers.put(CommonConstant.HTTP_SERVICE, service);
+ headers.put(CommonConstant.HTTP_METHOD, CommonConstant.HTTP_METHOD_PUT);
+ logger.debug("api锛歿} 璇锋眰鎶ユ枃涓猴細{},header淇℃伅涓猴細{}", service, postInfo, headers);
+ responseEntity = apiServiceSMOImpl.service(postInfo, headers);
+ } catch (Throwable e) {
+ logger.error("璇锋眰put 鏂规硶[" + service + "]澶辫触锛�", e);
+ responseEntity = new ResponseEntity<String>("璇锋眰鍙戠敓寮傚父锛�" + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
- logger.debug("api锛歿} 杩斿洖淇℃伅涓猴細{}",service,responseEntity);
+ logger.debug("api锛歿} 杩斿洖淇℃伅涓猴細{}", service, responseEntity);
return responseEntity;
}
/**
* 璧勬簮璇锋眰 delete鏂瑰紡
+ *
* @param service 璇锋眰鎺ュ彛鏂瑰紡
* @param request 璇锋眰瀵硅薄 鏌ヨ澶翠俊鎭� url绛変俊鎭�
* @return http status 200 鎴愬姛 鍏朵粬澶辫触
*/
- @RequestMapping(path = "/{service:.+}",method = RequestMethod.DELETE )
- @ApiOperation(value="璧勬簮delete璇锋眰", notes="test: 杩斿洖 2XX 琛ㄧず鏈嶅姟姝e父")
- @ApiImplicitParam(paramType="query", name = "service", value = "鐢ㄦ埛缂栧彿", required = true, dataType = "String")
+ @RequestMapping(path = "/{service:.+}", method = RequestMethod.DELETE)
+ @ApiOperation(value = "璧勬簮delete璇锋眰", notes = "test: 杩斿洖 2XX 琛ㄧず鏈嶅姟姝e父")
+ @ApiImplicitParam(paramType = "query", name = "service", value = "鐢ㄦ埛缂栧彿", required = true, dataType = "String")
public ResponseEntity<String> serviceDelete(@PathVariable String service,
- HttpServletRequest request){
+ HttpServletRequest request) {
ResponseEntity<String> responseEntity = null;
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);
- logger.debug("api锛歿} 璇锋眰鎶ユ枃涓猴細{},header淇℃伅涓猴細{}",service,"",headers);
+ headers.put(CommonConstant.HTTP_SERVICE, service);
+ headers.put(CommonConstant.HTTP_METHOD, CommonConstant.HTTP_METHOD_DELETE);
+ logger.debug("api锛歿} 璇锋眰鎶ユ枃涓猴細{},header淇℃伅涓猴細{}", service, "", headers);
- responseEntity = apiServiceSMOImpl.service(JSONObject.toJSONString(getParameterStringMap(request)),headers);
- }catch (Throwable e){
- logger.error("璇锋眰delete 鏂规硶["+service+"]澶辫触锛�",e);
- responseEntity = new ResponseEntity<String>("璇锋眰鍙戠敓寮傚父锛�"+e.getMessage(),HttpStatus.INTERNAL_SERVER_ERROR);
+ responseEntity = apiServiceSMOImpl.service(JSONObject.toJSONString(getParameterStringMap(request)), headers);
+ } catch (Throwable e) {
+ logger.error("璇锋眰delete 鏂规硶[" + service + "]澶辫触锛�", e);
+ responseEntity = new ResponseEntity<String>("璇锋眰鍙戠敓寮傚父锛�" + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
- logger.debug("api锛歿} 杩斿洖淇℃伅涓猴細{}",service,responseEntity);
+ logger.debug("api锛歿} 杩斿洖淇℃伅涓猴細{}", service, responseEntity);
return responseEntity;
}
-
/**
* 鑾峰彇璇锋眰淇℃伅
+ *
* @param request
* @param headers
* @throws RuntimeException
*/
- private void getRequestInfo(HttpServletRequest request,Map headers) throws Exception{
- try{
- super.initHeadParam(request,headers);
- super.initUrlParam(request,headers);
- }catch (Exception e){
- logger.error("鍔犺浇澶翠俊鎭け璐�",e);
+ private void getRequestInfo(HttpServletRequest request, Map headers) throws Exception {
+ try {
+ super.initHeadParam(request, headers);
+ super.initUrlParam(request, headers);
+ } catch (Exception e) {
+ logger.error("鍔犺浇澶翠俊鎭け璐�", e);
throw e;
}
}
@@ -188,4 +212,12 @@
public void setApiServiceSMOImpl(IApiServiceSMO apiServiceSMOImpl) {
this.apiServiceSMOImpl = apiServiceSMOImpl;
}
+
+ public IUserInnerServiceSMO getUserInnerServiceSMOImpl() {
+ return userInnerServiceSMOImpl;
+ }
+
+ public void setUserInnerServiceSMOImpl(IUserInnerServiceSMO userInnerServiceSMOImpl) {
+ this.userInnerServiceSMOImpl = userInnerServiceSMOImpl;
+ }
}
--
Gitblit v1.8.0