Commit 68d4df07 by wangnb

微服务调用拦截获取参数修改--think.wang

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@28100 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 323b29bd
package com.glsx.common.config; package com.glsx.common.config;
import java.util.Enumeration; import com.glsx.common.constants.Constants;
import feign.RequestInterceptor;
import javax.servlet.http.HttpServletRequest; import feign.RequestTemplate;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import com.glsx.common.constants.Constants; import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import feign.RequestInterceptor;
import feign.RequestTemplate;
@Configuration @Configuration
public class FeignConfig implements RequestInterceptor{ public class FeignConfiguration implements RequestInterceptor{
private Logger logger = LoggerFactory.getLogger(FeignConfiguration.class);
private Logger logger = LoggerFactory.getLogger(FeignConfig.class);
@Override @Override
public void apply(RequestTemplate template) { public void apply(RequestTemplate template) {
// TODO Auto-generated method stub
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder
.getRequestAttributes(); .getRequestAttributes();
if (attributes != null) { if (attributes != null) {
...@@ -31,11 +28,13 @@ public class FeignConfig implements RequestInterceptor{ ...@@ -31,11 +28,13 @@ public class FeignConfig implements RequestInterceptor{
if (headerNames != null) { if (headerNames != null) {
while (headerNames.hasMoreElements()) { while (headerNames.hasMoreElements()) {
String name = headerNames.nextElement(); String name = headerNames.nextElement();
String values = request.getHeader(name); if (Constants.REQUEST_COOKIE_KEY.equalsIgnoreCase(name)) {
continue;
}
if (Constants.USER_TOKEN_KEY.equalsIgnoreCase(name)) { if (Constants.USER_TOKEN_KEY.equalsIgnoreCase(name)) {
token = values; token = request.getHeader(name);
} }
template.header(name, values); template.header(name, request.getHeader(name));
} }
template.header(Constants.REQUEST_COOKIE_KEY, token); template.header(Constants.REQUEST_COOKIE_KEY, token);
logger.info("feign interceptor header:{}",template); logger.info("feign interceptor header:{}",template);
......
...@@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RequestMethod; ...@@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glsx.common.config.FeignConfig; import com.glsx.common.config.FeignConfiguration;
/** /**
* *
...@@ -17,7 +17,7 @@ import com.glsx.common.config.FeignConfig; ...@@ -17,7 +17,7 @@ import com.glsx.common.config.FeignConfig;
* @date 2019年2月16日 下午3:12:54 * @date 2019年2月16日 下午3:12:54
* @version 1.0.0 * @version 1.0.0
*/ */
@FeignClient(name="car-service-publicservice", configuration=FeignConfig.class) @FeignClient(name="car-service-publicservice", configuration= FeignConfiguration.class)
public interface CarBrandClient { public interface CarBrandClient {
/** /**
...@@ -50,7 +50,7 @@ public interface CarBrandClient { ...@@ -50,7 +50,7 @@ public interface CarBrandClient {
* @author zhanghj * @author zhanghj
* @Title: getCartypeList * @Title: getCartypeList
* @Description: TODO 根据汽车车系id,获取车型列表 * @Description: TODO 根据汽车车系id,获取车型列表
* @param seriesId * @param brandId
* @return * @return
* JSONObject * JSONObject
* *
...@@ -63,7 +63,7 @@ public interface CarBrandClient { ...@@ -63,7 +63,7 @@ public interface CarBrandClient {
* @author zhangxj * @author zhangxj
* @Title: getCartypeById * @Title: getCartypeById
* @Description: TODO 根据汽车车系id,获取车型列表 * @Description: TODO 根据汽车车系id,获取车型列表
* @param seriesId * @param carTypeId
* @return * @return
* JSONObject * JSONObject
* *
...@@ -76,7 +76,7 @@ public interface CarBrandClient { ...@@ -76,7 +76,7 @@ public interface CarBrandClient {
* @author zhangxj * @author zhangxj
* @Title: getCartypeById * @Title: getCartypeById
* @Description: TODO 根据汽车车系id,获取车型列表 * @Description: TODO 根据汽车车系id,获取车型列表
* @param seriesId * @param serId
* @return * @return
* JSONObject * JSONObject
* *
......
package com.glsx.common.feign.client; package com.glsx.common.feign.client;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glsx.common.config.FeignConfig; import com.glsx.common.config.FeignConfiguration;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam;
* @date 2019年2月16日 下午3:12:54 * @date 2019年2月16日 下午3:12:54
* @version 1.0.0 * @version 1.0.0
*/ */
@FeignClient(name="car-service-publicservice", configuration=FeignConfig.class) @FeignClient(name="car-service-publicservice", configuration= FeignConfiguration.class)
public interface CommonClient { public interface CommonClient {
/** /**
......
...@@ -5,7 +5,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -5,7 +5,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glsx.common.config.FeignConfig; import com.glsx.common.config.FeignConfiguration;
/** /**
* *
...@@ -16,7 +16,7 @@ import com.glsx.common.config.FeignConfig; ...@@ -16,7 +16,7 @@ import com.glsx.common.config.FeignConfig;
* @date 2019年2月14日 下午9:06:13 * @date 2019年2月14日 下午9:06:13
* @version 1.0.0 * @version 1.0.0
*/ */
@FeignClient(name="car-service-usercenter", configuration=FeignConfig.class) @FeignClient(name="car-service-usercenter", configuration= FeignConfiguration.class)
public interface MenuClient { public interface MenuClient {
/** /**
......
package com.glsx.common.feign.client; package com.glsx.common.feign.client;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glsx.common.config.FeignConfig; import com.glsx.common.config.FeignConfiguration;
import com.glsx.common.pojo.SysOrderWechatMsg; import com.glsx.common.pojo.SysOrderWechatMsg;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
@FeignClient(name="car-service-ordercenter", configuration=FeignConfig.class) @FeignClient(name="car-service-ordercenter", configuration= FeignConfiguration.class)
public interface OderWechatMsgClient { public interface OderWechatMsgClient {
/** /**
* *
......
...@@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glsx.common.config.FeignConfig; import com.glsx.common.config.FeignConfiguration;
import com.glsx.common.pojo.OperateLog; import com.glsx.common.pojo.OperateLog;
...@@ -20,7 +20,7 @@ import com.glsx.common.pojo.OperateLog; ...@@ -20,7 +20,7 @@ import com.glsx.common.pojo.OperateLog;
* @date 2019年2月2日 下午8:21:12 * @date 2019年2月2日 下午8:21:12
* @version 1.0.0 * @version 1.0.0
*/ */
@FeignClient(name="car-service-manager", configuration=FeignConfig.class) @FeignClient(name="car-service-manager", configuration= FeignConfiguration.class)
public interface OperateLogClient { public interface OperateLogClient {
/** /**
......
...@@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.RequestMethod; ...@@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glsx.common.config.FeignConfig; import com.glsx.common.config.FeignConfiguration;
import com.glsx.common.pojo.GenerateReconciliationMonthlyReq; import com.glsx.common.pojo.GenerateReconciliationMonthlyReq;
/** /**
...@@ -18,7 +18,7 @@ import com.glsx.common.pojo.GenerateReconciliationMonthlyReq; ...@@ -18,7 +18,7 @@ import com.glsx.common.pojo.GenerateReconciliationMonthlyReq;
* @Description ${todo} * @Description ${todo}
* @date 2019/3/11 16:33 * @date 2019/3/11 16:33
*/ */
@FeignClient(name="car-service-ordercenter", configuration=FeignConfig.class) @FeignClient(name="car-service-ordercenter", configuration= FeignConfiguration.class)
public interface OrderClient { public interface OrderClient {
/** /**
......
package com.glsx.common.feign.client; package com.glsx.common.feign.client;
import java.util.List; import com.alibaba.fastjson.JSONObject;
import com.glsx.common.config.FeignConfiguration;
import javax.servlet.http.HttpSession; import com.glsx.common.pojo.MerchantReq;
import com.glsx.common.pojo.OderReceivingReq;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import com.alibaba.fastjson.JSONObject; import java.util.List;
import com.glsx.common.config.FeignConfig;
import com.glsx.common.pojo.MerchantReq;
import com.glsx.common.pojo.OderReceivingReq;
...@@ -26,7 +23,7 @@ import com.glsx.common.pojo.OderReceivingReq; ...@@ -26,7 +23,7 @@ import com.glsx.common.pojo.OderReceivingReq;
* @date 2019年2月1日 上午11:06:44 * @date 2019年2月1日 上午11:06:44
* @version 1.0.0 * @version 1.0.0
*/ */
@FeignClient(name="car-service-usercenter", configuration=FeignConfig.class) @FeignClient(name="car-service-usercenter", configuration= FeignConfiguration.class)
public interface UserClient { public interface UserClient {
/** /**
...@@ -94,15 +91,13 @@ public interface UserClient { ...@@ -94,15 +91,13 @@ public interface UserClient {
JSONObject getProvider(@RequestParam("providerId")Integer providerId); JSONObject getProvider(@RequestParam("providerId")Integer providerId);
/** /**
*
* @author zhanghj * @author zhanghj
* @Title: getMerchantList * @Title: getMerchantList
* @Description: TODO 获取商户列表 * @Description: 获取商户列表
* @param id * @param groupId
* @param type * @param shopName
* @param userStatus
* @return * @return
* JSONObject
*
*/ */
@RequestMapping( method = RequestMethod.GET, value = "/carservice/usercenter/user/getMerchantList") @RequestMapping( method = RequestMethod.GET, value = "/carservice/usercenter/user/getMerchantList")
JSONObject getMerchantList(@RequestParam("groupId")Integer groupId, @RequestParam("shopName") String shopName, @RequestParam("userStatus")String userStatus); JSONObject getMerchantList(@RequestParam("groupId")Integer groupId, @RequestParam("shopName") String shopName, @RequestParam("userStatus")String userStatus);
...@@ -112,7 +107,7 @@ public interface UserClient { ...@@ -112,7 +107,7 @@ public interface UserClient {
* @author zhanghj * @author zhanghj
* @Title: getMerchantById * @Title: getMerchantById
* @Description: TODO 根据用户id获取技工信息 * @Description: TODO 根据用户id获取技工信息
* @param merchantId * @param mechanicId
* @return * @return
* JSONObject * JSONObject
* *
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!