From 28c643cc4d3142503dfa5234777399586e8364e9 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期六, 30 三月 2019 11:41:36 +0800
Subject: [PATCH] 添加员工服务端bug修复
---
java110-service/src/main/java/com/java110/service/api/BusinessApi.java | 66 ++++++++++++++++++++++++++++++--
1 files changed, 61 insertions(+), 5 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 5a59f24..8e2dfad 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,32 +1,66 @@
package com.java110.service.api;
+import com.java110.common.constant.CommonConstant;
import com.java110.common.constant.ResponseConstant;
+import com.java110.common.util.Assert;
import com.java110.core.factory.DataQueryFactory;
import com.java110.core.factory.DataTransactionFactory;
import com.java110.core.base.controller.BaseController;
import com.java110.entity.service.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.
*/
@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();
+ @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);
+
+ }
}
/**
@@ -46,15 +80,20 @@
* @return
*/
@RequestMapping(path = "/businessApi/query",method= RequestMethod.POST)
- public String queryPost(@RequestBody String businessInfo) {
+ @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();
+ return dataQuery.getResponseEntity();
}catch (Exception e){
logger.error("璇锋眰璁㈠崟寮傚父",e);
- return DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR,e.getMessage()+e).toJSONString();
+ //DataTransactionFactory.createBusinessResponseJson(ResponseConstant.RESULT_CODE_ERROR,e.getMessage()+e).toJSONString();
+ return new ResponseEntity<String>("璇锋眰鍙戠敓寮傚父锛�"+e.getMessage()+e, HttpStatus.INTERNAL_SERVER_ERROR);
+
}
}
@Deprecated
@@ -102,6 +141,23 @@
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