Authored by LUOXC

refactor

package com.yohoufo.common.utils;
import org.apache.commons.lang3.StringUtils;
public class IntegerUtils {
public static Integer toInteger(String value) {
return toInteger(value, null);
}
public static Integer toInteger(String value, Integer defaultValue) {
if (StringUtils.isBlank(value)) {
return defaultValue;
}
try {
return Integer.valueOf(value);
} catch (RuntimeException re) {
return defaultValue;
}
}
}
... ...
package com.yohoufo.order.controller;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.resp.ExpressInfoRespBo;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.utils.AppVersion;
import com.yohoufo.common.utils.IntegerUtils;
import com.yohoufo.order.model.response.AppraiseAddressResp;
import com.yohoufo.order.service.IExpressInfoService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -50,7 +48,7 @@ public class ExpressInfoController {
@RequestParam(value = "depotNum", required = false) String depotNum,
@RequestParam(value = "app_version") String appVersion) {
Integer depotNumInt = parseDepotNum(depotNum);
Integer depotNumInt = IntegerUtils.toInteger(depotNum);
if (Objects.isNull(depotNumInt)) {
// 大于6.9.3 版本
if (AppVersion.of(appVersion).greaterThan(AppVersion.of("6.9.3"))) {
... ... @@ -65,16 +63,6 @@ public class ExpressInfoController {
return new ApiResponse();
}
private Integer parseDepotNum(String depotNum) {
if (StringUtils.isBlank(depotNum)) {
return null;
}
try {
return Integer.valueOf(depotNum);
} catch (RuntimeException re) {
return null;
}
}
... ...