CusHttpServletRequest问题修复
parent
24faa6c603
commit
28f6159601
|
@ -1,14 +1,12 @@
|
|||
package aiyh.utils.httpUtil.cushttpclasses;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.Principal;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
@ -95,6 +93,11 @@ public class CusHttpServletRequest implements HttpServletRequest {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String changeSessionId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequestedSessionId() {
|
||||
return null;
|
||||
|
@ -143,6 +146,36 @@ public class CusHttpServletRequest implements HttpServletRequest {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean authenticate(HttpServletResponse httpServletResponse) throws IOException, ServletException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void login(String s, String s1) throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logout() throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Part> getParts() throws IOException, ServletException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Part getPart(String s) throws IOException, ServletException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends HttpUpgradeHandler> T upgrade(Class<T> aClass) throws IOException, ServletException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocol() {
|
||||
return null;
|
||||
|
@ -218,6 +251,11 @@ public class CusHttpServletRequest implements HttpServletRequest {
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getContentLengthLong() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return null;
|
||||
|
@ -271,4 +309,59 @@ public class CusHttpServletRequest implements HttpServletRequest {
|
|||
public String getRealPath(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemotePort() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalAddr() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLocalPort() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncContext startAsync() throws IllegalStateException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAsyncStarted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAsyncSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncContext getAsyncContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DispatcherType getDispatcherType() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,10 @@ import aiyh.utils.Util;
|
|||
import aiyh.utils.excention.CustomerException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.api.xuanran.wang.eny.workflow.mapper.ExchangeRateMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.seconddev.ey.zhangm.util.EYSeconddevUtil;
|
||||
|
@ -16,8 +18,10 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -40,9 +44,9 @@ public class GetExchangeRate {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public String exchangeRate(@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response,
|
||||
@RequestBody Map<String, Object> params){
|
||||
@Context HttpServletResponse response){
|
||||
try {
|
||||
Map<String, Object> params = parseBody(request);
|
||||
if(eySeconddevUtil == null){
|
||||
eySeconddevUtil = new EYSeconddevUtil();
|
||||
}
|
||||
|
@ -101,4 +105,25 @@ public class GetExchangeRate {
|
|||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> parseBody(HttpServletRequest request) {
|
||||
try {
|
||||
InputStream inputStream = request.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
StringBuilder requestBody = new StringBuilder();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
requestBody.append(line);
|
||||
}
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> body = objectMapper.readValue(requestBody.toString(), Map.class);
|
||||
if(MapUtils.isEmpty(body)){
|
||||
throw new CustomerException("parse body map is empty!");
|
||||
}
|
||||
return body;
|
||||
}catch (Exception e){
|
||||
throw new CustomerException("解析请求体json error : " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.api.xuanran.wang.xk_hospital.data_async.controller;
|
|||
|
||||
import aiyh.utils.ApiResult;
|
||||
import aiyh.utils.Util;
|
||||
import com.api.xuanran.wang.xk_hospital.data_async.service.XkHospitalCommonDataAsyncService;
|
||||
import com.api.xuanran.wang.xk_hospital.data_async.service.impl.XkHospitalCommonDataAsyncServiceImpl;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
@ -23,19 +25,23 @@ public class CommonDataAsyncController {
|
|||
|
||||
private final Logger logger = Util.getLogger();
|
||||
|
||||
private final XkHospitalCommonDataAsyncService service = new XkHospitalCommonDataAsyncServiceImpl();
|
||||
|
||||
@POST
|
||||
@Path("/{configId}}")
|
||||
@Path("/{type}/{configId}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public String async(@Context HttpServletRequest request,
|
||||
@Context HttpServletResponse response,
|
||||
@PathParam("configId") String configId,
|
||||
@PathParam("type") String type,
|
||||
@RequestBody Map<String, Object> params){
|
||||
try {
|
||||
return "";
|
||||
service.async(configId, type, params);
|
||||
return ApiResult.successNoData();
|
||||
}catch (Exception e){
|
||||
logger.error("CommonDataAsyncController error : " + e.getMessage());
|
||||
Util.logErrorStr(e, logger);
|
||||
Util.logErrorStr(e);
|
||||
return ApiResult.error("数据同步失败! [ " + e.getMessage() + " ]");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue