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包
---
java110-service/src/main/java/com/java110/service/api/BusinessApi.java | 151 ++++++++++++++++++++++++++++++++++++--------------
1 files changed, 108 insertions(+), 43 deletions(-)
diff --git a/java110-service/src/main/java/com/java110/service/api/BusinessApi.java b/java110-service/src/main/java/com/java110/service/api/BusinessApi.java
index 652d911..9a6910d 100644
--- a/java110-service/src/main/java/com/java110/service/api/BusinessApi.java
+++ b/java110-service/src/main/java/com/java110/service/api/BusinessApi.java
@@ -1,106 +1,171 @@
package com.java110.service.api;
-import com.java110.common.constant.ResponseConstant;
-import com.java110.common.factory.DataQueryFactory;
-import com.java110.common.factory.DataTransactionFactory;
+import com.java110.utils.constant.CommonConstant;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.util.Assert;
+import com.java110.service.context.DataQueryFactory;
+import com.java110.core.factory.DataTransactionFactory;
import com.java110.core.base.controller.BaseController;
-import com.java110.entity.service.DataQuery;
+import com.java110.service.context.DataQuery;
import com.java110.service.smo.IQueryServiceSMO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
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;
/**
* 鏌ヨ鏈嶅姟
- * Created by wuxw on 2018/4/20.
+ * add by wuxw on 2018/4/20.
+ * modify by wuxw on 2019/4/20.
+ *
+ * @version 1.1
*/
@RestController
+@Api(value = "鏌ヨ涓氬姟缁熶竴鎻愪緵鏈嶅姟")
public class BusinessApi extends BaseController {
+
+ private final static Logger logger = LoggerFactory.getLogger(BusinessApi.class);
@Autowired
private IQueryServiceSMO queryServiceSMOImpl;
- @RequestMapping(path = "/businessApi/query",method= RequestMethod.GET)
- public String queryGet(HttpServletRequest request) {
- return DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR,"涓嶆敮鎸丟et鏂规硶璇锋眰").toJSONString();
+
+ @RequestMapping(path = "/businessApi/query", method = RequestMethod.GET)
+ @ApiOperation(value = "涓氬姟鏌ヨget璇锋眰", notes = "test: 杩斿洖 2XX 琛ㄧず鏈嶅姟姝e父")
+ @ApiImplicitParam(paramType = "query", name = "method", value = "鐢ㄦ埛缂栧彿", required = true, dataType = "String")
+ @Deprecated
+ public ResponseEntity<String> service(HttpServletRequest request) {
+ try {
+ Map<String, Object> headers = new HashMap<String, Object>();
+ this.getRequestInfo(request, headers);
+ Assert.isNotNull(headers, CommonConstant.HTTP_SERVICE.toLowerCase(), "璇锋眰淇℃伅涓病鏈夊寘鍚玸ervice淇℃伅");
+ //Assert.isNotNull(headers, CommonConstant.HTTP_PARAM,"璇锋眰淇℃伅涓病鏈夊寘鍚弬鏁帮紙params锛変俊鎭�");
+ Map readOnlyMap = super.getParameterStringMap(request);
+ headers.put("params", readOnlyMap);
+ DataQuery dataQuery = DataQueryFactory.newInstance().builder(headers);
+ initConfig(dataQuery);
+ queryServiceSMOImpl.commonQueryService(dataQuery);
+ return dataQuery.getResponseEntity();
+ } catch (Exception e) {
+ logger.error("璇锋眰璁㈠崟寮傚父", e);
+ //DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR,e.getMessage()+e).toJSONString();
+ return new ResponseEntity<String>("璇锋眰鍙戠敓寮傚父锛�" + e.getMessage() + e, HttpStatus.INTERNAL_SERVER_ERROR);
+
+ }
}
/**
* {
- "bId":"12345678",
- "serviceCode": "querycustinfo",
- "serviceName": "鏌ヨ瀹㈡埛",
- "remark": "澶囨敞",
- "datas": {
- "params": {
- //杩欎釜鍋氭煡璇㈡椂鐨勫弬鏁�
- }
- //杩欓噷鏄叿浣撲笟鍔�
- }
- }
+ * "bId":"12345678",
+ * "serviceCode": "querycustinfo",
+ * "serviceName": "鏌ヨ瀹㈡埛",
+ * "remark": "澶囨敞",
+ * "datas": {
+ * "params": {
+ * //杩欎釜鍋氭煡璇㈡椂鐨勫弬鏁�
+ * }
+ * //杩欓噷鏄叿浣撲笟鍔�
+ * }
+ * }
+ *
* @param businessInfo
* @return
*/
- @RequestMapping(path = "/businessApi/query",method= RequestMethod.POST)
- public String queryPost(@RequestBody String businessInfo) {
+ @RequestMapping(path = "/businessApi/query", method = RequestMethod.POST)
+ @ApiOperation(value = "涓氬姟鏌ヨpost璇锋眰", notes = "test: 杩斿洖 2XX 琛ㄧず鏈嶅姟姝e父")
+ @ApiImplicitParam(paramType = "query", name = "method", value = "鐢ㄦ埛缂栧彿", required = true, dataType = "String")
+ @Deprecated
+ public ResponseEntity<String> queryPost(@RequestBody String businessInfo) {
try {
DataQuery dataQuery = DataQueryFactory.newInstance().builder(businessInfo);
initConfig(dataQuery);
queryServiceSMOImpl.commonQueryService(dataQuery);
- return dataQuery.getResponseInfo().toJSONString();
- }catch (Exception e){
- logger.error("璇锋眰璁㈠崟寮傚父",e);
- return DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR,e.getMessage()+e).toJSONString();
+ return dataQuery.getResponseEntity();
+ } catch (Exception e) {
+ logger.error("璇锋眰璁㈠崟寮傚父", e);
+ //DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR,e.getMessage()+e).toJSONString();
+ return new ResponseEntity<String>("璇锋眰鍙戠敓寮傚父锛�" + e.getMessage() + e, HttpStatus.INTERNAL_SERVER_ERROR);
+
}
}
+
@Deprecated
- @RequestMapping(path = "/businessApi/do",method= RequestMethod.GET)
+ @RequestMapping(path = "/businessApi/do", method = RequestMethod.GET)
public String doGet(HttpServletRequest request) {
- return DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR,"涓嶆敮鎸丟et鏂规硶璇锋眰").toJSONString();
+ return DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR, "涓嶆敮鎸丟et鏂规硶璇锋眰").toJSONString();
}
/**
* {
- "bId":"12345678",
- "serviceCode": "querycustinfo",
- "serviceName": "鏌ヨ瀹㈡埛",
- "remark": "澶囨敞",
- "datas": {
- "params": {
- //杩欎釜鍋氭煡璇㈡椂鐨勫弬鏁�
- }
- //杩欓噷鏄叿浣撲笟鍔�
- }
- }
+ * "bId":"12345678",
+ * "serviceCode": "querycustinfo",
+ * "serviceName": "鏌ヨ瀹㈡埛",
+ * "remark": "澶囨敞",
+ * "datas": {
+ * "params": {
+ * //杩欎釜鍋氭煡璇㈡椂鐨勫弬鏁�
+ * }
+ * //杩欓噷鏄叿浣撲笟鍔�
+ * }
+ * }
+ *
* @param businessInfo
* @return
*/
@Deprecated
- @RequestMapping(path = "/businessApi/do",method= RequestMethod.POST)
+ @RequestMapping(path = "/businessApi/do", method = RequestMethod.POST)
public String doPost(@RequestBody String businessInfo) {
try {
DataQuery dataQuery = DataQueryFactory.newInstance().builder(businessInfo);
initConfig(dataQuery);
+ //杩欓噷搴旇娣诲姞 鍙湁閰嶇疆绫绘暟鎹墠鑳藉鐞嗘暟鎹紝涓氬姟绫绘暟鎹笉鑳芥搷浣� 閫昏緫
queryServiceSMOImpl.commonDoService(dataQuery);
return dataQuery.getResponseInfo().toJSONString();
- }catch (Exception e){
- logger.error("璇锋眰璁㈠崟寮傚父",e);
- return DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR,e.getMessage()+e).toJSONString();
+ } catch (Exception e) {
+ logger.error("璇锋眰璁㈠崟寮傚父", e);
+ return DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR, e.getMessage() + e).toJSONString();
}
}
/**
* 鍒濆鍖栭厤缃�
+ *
* @param dataQuery
*/
- private void initConfig(DataQuery dataQuery){
+ private void initConfig(DataQuery dataQuery) {
dataQuery.setServiceSql(DataQueryFactory.getServiceSql(dataQuery));
}
+
+ /**
+ * 鑾峰彇璇锋眰淇℃伅
+ *
+ * @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);
+ throw e;
+ }
+ }
+
public IQueryServiceSMO getQueryServiceSMOImpl() {
return queryServiceSMOImpl;
}
--
Gitblit v1.8.0