Authored by mali

Merge branch 'test6.9.17' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.17

... ... @@ -9,6 +9,7 @@ import com.yohoufo.common.exception.SessionExpireException;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.ServletUtils;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.MissingServletRequestParameterException;
... ... @@ -76,9 +77,11 @@ public class GlobalDefaultExceptionHandler {
serviceName, code, desc, request.getRequestURI(), serviceName, params);
} else if (e instanceof ServiceException) { //服务异常,不能直接返回给客户端,必须映射一下
ServiceException serviceException = (ServiceException) e;
ServiceError serviceError = serviceException.getServiceError();
code = serviceError.getMappingGatewayError().getLeft();
desc = serviceError.getMappingGatewayError().getRight();
Pair<Integer, String> codeMsgPair = getMessageCode((ServiceException) e);
code = codeMsgPair.getLeft();
desc = codeMsgPair.getRight();
if (serviceException.getParams() != null) {
desc = MessageFormat.format(desc, serviceException.getParams());
}
... ... @@ -107,4 +110,21 @@ public class GlobalDefaultExceptionHandler {
}
private Pair<Integer, String> getMessageCode(ServiceException serviceException){
ServiceError serviceError = serviceException.getServiceError();
// 该service是OTHER_ERROR 报错[系统异常]
if (serviceError == ServiceError.OTHER_ERROR){
// ex. servcieException[400, 优惠券领取中] servcie[500,系统异常]
if (serviceException.getCode() != serviceError.getCode()){
return Pair.of(serviceException.getCode(), serviceException.getMessage());
}
}
return Pair.of(serviceError.getMappingGatewayError().getLeft(), serviceError.getMappingGatewayError().getRight());
}
}
\ No newline at end of file
... ...
... ... @@ -26,6 +26,7 @@ public class HotSearchWordController {
private final Integer CLIENT_TYPE_APP = 0; // APP端
private final Integer CLIENT_TYPE_MINIAPP = 1; // 小程序端
private final Integer CLIENT_TYPE_XIANYU = 3; // 闲鱼
private final Integer WORD_TYPE_HOT = 0; // 热搜词
... ... @@ -45,6 +46,8 @@ public class HotSearchWordController {
dalClientType = CLIENT_TYPE_APP;
} else if ("iphone".equals(clientType) || "android".equals(clientType)) {
dalClientType = CLIENT_TYPE_APP;
} else if ("h5".equals(clientType)) {
dalClientType = CLIENT_TYPE_XIANYU;
} else {
dalClientType = CLIENT_TYPE_MINIAPP;
}
... ...