bug--代码规范优化,升级fastjson1.2.73

This commit is contained in:
taochengbo
2020-08-29 16:17:15 +08:00
parent 574c7219ac
commit 0f05897962
64 changed files with 727 additions and 275 deletions

View File

@ -62,7 +62,9 @@ public class GlobalExceptionHandler {
Collections.sort(list);
String msg = "不能为空";
if(!list.isEmpty()) msg = list.get(0);
if(!list.isEmpty()) {
msg = list.get(0);
}
log.error(getApiCodeString(ApiCode.PARAMETER_EXCEPTION) + ":" + JSON.toJSONString(list));
return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION.getCode(), msg);
}

View File

@ -88,7 +88,9 @@ public class PermissionInterceptor extends HandlerInterceptorAdapter {
Integer uid = map.get("uid").asInt();
Integer scope = map.get("scope").asInt();
YxUser user = userService.getById(uid);
if(user == null) throw new UnAuthenticatedException(ApiCode.NOT_PERMISSION);
if(user == null) {
throw new UnAuthenticatedException(ApiCode.NOT_PERMISSION);
}
LocalUser.set(user, scope);
}

View File

@ -26,8 +26,9 @@ public class JacksonUtil {
try {
node = mapper.readTree(body);
JsonNode leaf = node.get(field);
if (leaf != null)
if (leaf != null) {
return leaf.asText();
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
@ -42,9 +43,10 @@ public class JacksonUtil {
node = mapper.readTree(body);
JsonNode leaf = node.get(field);
if (leaf != null)
if (leaf != null) {
return mapper.convertValue(leaf, new TypeReference<List<String>>() {
});
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
@ -57,8 +59,9 @@ public class JacksonUtil {
try {
node = mapper.readTree(body);
JsonNode leaf = node.get(field);
if (leaf != null)
if (leaf != null) {
return leaf.asInt();
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
@ -72,9 +75,10 @@ public class JacksonUtil {
node = mapper.readTree(body);
JsonNode leaf = node.get(field);
if (leaf != null)
if (leaf != null) {
return mapper.convertValue(leaf, new TypeReference<List<Integer>>() {
});
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
@ -88,8 +92,9 @@ public class JacksonUtil {
try {
node = mapper.readTree(body);
JsonNode leaf = node.get(field);
if (leaf != null)
if (leaf != null) {
return leaf.asBoolean();
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
}

View File

@ -34,7 +34,7 @@ public class SmsUtils {
@Autowired
public SmsUtils(RedisUtils redisUtils){
this.redisUtils = redisUtils;
SmsUtils.redisUtils = redisUtils;
}
/**
* 发送短信

View File

@ -106,7 +106,9 @@ public class StoreBargainController {
@GetMapping("/bargain/detail/{id}")
@ApiOperation(value = "砍价详情",notes = "砍价详情",response = YxStoreBargainQueryVo.class)
public ApiResult<BargainVo> getYxStoreBargain(@PathVariable Long id){
if(ObjectUtil.isNull(id)) throw new YshopException("参数错误");
if(ObjectUtil.isNull(id)) {
throw new YshopException("参数错误");
}
YxUser yxUser = LocalUser.getUser();
return ApiResult.ok(storeBargainService.getDetail(id,yxUser));
}
@ -270,7 +272,9 @@ public class StoreBargainController {
Long uid = LocalUser.getUser().getUid();
List<YxStoreBargainUserQueryVo> yxStoreBargainUserQueryVos = storeBargainUserService
.bargainUserList(uid,page,limit);
if(yxStoreBargainUserQueryVos.isEmpty()) throw new YshopException("暂无参与砍价");
if(yxStoreBargainUserQueryVos.isEmpty()) {
throw new YshopException("暂无参与砍价");
}
return ApiResult.ok(yxStoreBargainUserQueryVos);
}

View File

@ -91,7 +91,9 @@ public class StoreCombinationController {
@GetMapping("/combination/detail/{id}")
@ApiOperation(value = "拼团产品详情",notes = "拼团产品详情")
public ApiResult<StoreCombinationVo> detail(@PathVariable Long id){
if(ObjectUtil.isNull(id)) throw new YshopException("参数错误");
if(ObjectUtil.isNull(id)) {
throw new YshopException("参数错误");
}
Long uid = LocalUser.getUser().getUid();
StoreCombinationVo storeCombinationVo = storeCombinationService.getDetail(id,uid);
storeCombinationVo.setUserCollect(relationService
@ -106,7 +108,9 @@ public class StoreCombinationController {
@GetMapping("/combination/pink/{id}")
@ApiOperation(value = "拼团明细",notes = "拼团明细")
public ApiResult<PinkInfoVo> pink(@PathVariable Long id){
if(ObjectUtil.isNull(id)) throw new YshopException("参数错误");
if(ObjectUtil.isNull(id)) {
throw new YshopException("参数错误");
}
Long uid = LocalUser.getUser().getUid();
return ApiResult.ok(storePinkService.pinkInfo(id,uid));
}

View File

@ -118,7 +118,7 @@ public class StoreSeckillController {
SimpleDateFormat sdf = new SimpleDateFormat("HH");
String nowTime = sdf.format(new Date());
String index = nowTime.substring(0, 1);
int currentHour = index.equals("0") ? Integer.valueOf(nowTime.substring(1, 2)) : Integer.valueOf(nowTime);
int currentHour = "0".equals(index) ? Integer.valueOf(nowTime.substring(1, 2)) : Integer.valueOf(nowTime);
SeckillTimeDto seckillTimeDto = new SeckillTimeDto();
seckillTimeDto.setId(i.getId());
//活动结束时间

View File

@ -143,7 +143,9 @@ public class AuthController {
.eq(YxUser::getUsername,loginDTO.getUsername())
.eq(YxUser::getPassword,SecureUtil.md5(loginDTO.getPassword())),false);
if(yxUser == null) throw new YshopException("账号或者密码不正确");
if(yxUser == null) {
throw new YshopException("账号或者密码不正确");
}
String token = JwtToken.makeToken(yxUser.getUid());
String expiresTimeStr = JwtToken.getExpireTime(token);

View File

@ -106,7 +106,9 @@ public class ShoperController {
@GetMapping("/admin/order/detail/{key}")
@ApiOperation(value = "订单详情",notes = "订单详情")
public ApiResult<YxStoreOrderQueryVo> orderDetail(@PathVariable String key){
if(StrUtil.isEmpty(key)) throw new YshopException("参数错误");
if(StrUtil.isEmpty(key)) {
throw new YshopException("参数错误");
}
YxStoreOrderQueryVo storeOrder = storeOrderService.getOrderInfo(key,null);
if(ObjectUtil.isNull(storeOrder)){
throw new YshopException("订单不存在");

View File

@ -155,7 +155,9 @@ public class StoreOrderController {
//创建订单
YxStoreOrder order = storeOrderService.createOrder(yxUser,key,param);
if(ObjectUtil.isNull(order)) throw new YshopException("订单生成失败");
if(ObjectUtil.isNull(order)) {
throw new YshopException("订单生成失败");
}
String orderId = order.getOrderId();
@ -190,7 +192,9 @@ public class StoreOrderController {
Long uid = LocalUser.getUser().getUid();
YxStoreOrderQueryVo storeOrder = storeOrderService
.getOrderInfo(param.getUni(),uid);
if(ObjectUtil.isNull(storeOrder)) throw new YshopException("订单不存在");
if(ObjectUtil.isNull(storeOrder)) {
throw new YshopException("订单不存在");
}
if(OrderInfoEnum.REFUND_STATUS_1.getValue().equals(storeOrder.getPaid())) {
throw new YshopException("该订单已支付");
@ -245,7 +249,9 @@ public class StoreOrderController {
@ApiOperation(value = "订单详情",notes = "订单详情")
public ApiResult<YxStoreOrderQueryVo> detail(@PathVariable String key){
Long uid = LocalUser.getUser().getUid();
if(StrUtil.isEmpty(key)) throw new YshopException("参数错误");
if(StrUtil.isEmpty(key)) {
throw new YshopException("参数错误");
}
YxStoreOrderQueryVo storeOrder = storeOrderService.getOrderInfo(key,uid);
if(ObjectUtil.isNull(storeOrder)){
throw new YshopException("订单不存在");
@ -363,7 +369,9 @@ public class StoreOrderController {
ExpressService expressService = ExpressAutoConfiguration.expressService();
ExpressInfo expressInfo = expressService.getExpressInfo(expressInfoDo.getOrderCode(),
expressInfoDo.getShipperCode(), expressInfoDo.getLogisticCode());
if(!expressInfo.isSuccess()) throw new YshopException(expressInfo.getReason());
if(!expressInfo.isSuccess()) {
throw new YshopException(expressInfo.getReason());
}
return ApiResult.ok(expressInfo);
}
@ -378,7 +386,9 @@ public class StoreOrderController {
Long uid = LocalUser.getUser().getUid();
YxStoreOrderQueryVo orderQueryVo = storeOrderService.verificOrder(param.getVerifyCode(),
param.getIsConfirm(),uid);
if(orderQueryVo != null) return ApiResult.ok(orderQueryVo);
if(orderQueryVo != null) {
return ApiResult.ok(orderQueryVo);
}
return ApiResult.ok("核销成功");
}

View File

@ -225,7 +225,9 @@ public class StoreProductController {
@ApiOperation(value = "添加收藏",notes = "添加收藏")
public ApiResult<Boolean> collectAdd(@Validated @RequestBody YxStoreProductRelationQueryParam param){
long uid = LocalUser.getUser().getUid();
if(!NumberUtil.isNumber(param.getId())) throw new YshopException("参数非法");
if(!NumberUtil.isNumber(param.getId())) {
throw new YshopException("参数非法");
}
productRelationService.addRroductRelation(Long.valueOf(param.getId()),uid);
return ApiResult.ok();
}
@ -239,7 +241,9 @@ public class StoreProductController {
@ApiOperation(value = "取消收藏",notes = "取消收藏")
public ApiResult<Boolean> collectDel(@Validated @RequestBody YxStoreProductRelationQueryParam param){
long uid = LocalUser.getUser().getUid();
if(!NumberUtil.isNumber(param.getId())) throw new YshopException("参数非法");
if(!NumberUtil.isNumber(param.getId())) {
throw new YshopException("参数非法");
}
productRelationService.delRroductRelation(Long.valueOf(param.getId()),
uid);
return ApiResult.ok();

View File

@ -79,7 +79,9 @@ public class CreatShareProductService {
//门店
if(OrderInfoEnum.SHIPPIING_TYPE_2.getValue().equals(storeOrder.getShippingType())){
String mapKey = RedisUtil.get(SystemConfigConstants.TENGXUN_MAP_KEY);
if(StrUtil.isBlank(mapKey)) throw new YshopException("请配置腾讯地图key");
if(StrUtil.isBlank(mapKey)) {
throw new YshopException("请配置腾讯地图key");
}
String apiUrl = systemConfigService.getData(SystemConfigConstants.API_URL);
if(StrUtil.isEmpty(apiUrl)){
throw new YshopException("未配置api地址");
@ -463,9 +465,13 @@ public class CreatShareProductService {
String apiUrl,String path){
Long uid = userInfo.getUid();
YxStorePink storePink = storePinkService.getById(pinkId);
if(ObjectUtil.isNull(storePink)) throw new YshopException("拼团不存在");
if(ObjectUtil.isNull(storePink)) {
throw new YshopException("拼团不存在");
}
YxStoreCombination storeCombination = storeCombinationService.getById(storePink.getCid());
if(ObjectUtil.isNull(storeCombination)) throw new YshopException("拼团产品不存在");
if(ObjectUtil.isNull(storeCombination)) {
throw new YshopException("拼团产品不存在");
}
String userType = userInfo.getUserType();
if(StrUtil.isBlank(userType)) {

View File

@ -105,7 +105,9 @@ public class OrderSupplyService {
*/
public Map<String,Object> check(Long uid,String key, ComputeOrderParam param){
Map<String,Object> map = Maps.newHashMap();
if(StrUtil.isBlank(key)) throw new YshopException("参数错误");
if(StrUtil.isBlank(key)) {
throw new YshopException("参数错误");
}
YxStoreOrderQueryVo storeOrder = storeOrderService.getOrderInfo(key,uid);
if(ObjectUtil.isNotNull(storeOrder)){
@ -124,7 +126,9 @@ public class OrderSupplyService {
if(bargainId > 0){
YxStoreBargainUser storeBargainUser = storeBargainUserService
.getBargainUserInfo(bargainId,uid);
if(storeBargainUser == null) throw new YshopException("砍价失败");
if(storeBargainUser == null) {
throw new YshopException("砍价失败");
}
if(OrderInfoEnum.BARGAIN_STATUS_3.getValue().equals(storeBargainUser.getStatus())) {
throw new YshopException("砍价已支付");
}

View File

@ -176,7 +176,9 @@ public class UserBillController {
@RequestParam(value = "limit",defaultValue = "10") int limit,
@PathVariable String type){
int newType = 0;
if(NumberUtil.isNumber(type)) newType = Integer.valueOf(type);
if(NumberUtil.isNumber(type)) {
newType = Integer.valueOf(type);
}
Long uid = LocalUser.getUser().getUid();
return ApiResult.ok(userBillService.getUserBillList(page,limit,uid,newType));
}

View File

@ -98,7 +98,9 @@ public class UserRechargeController {
Map<String,Object> map = new LinkedHashMap<>();
map.put("type",param.getFrom());
YxSystemGroupData systemGroupData = systemGroupDataService.getById(param.getRecharId());
if(systemGroupData == null) throw new YshopException("充值方案不存在");
if(systemGroupData == null) {
throw new YshopException("充值方案不存在");
}
JSONObject jsonObject = JSON.parseObject(systemGroupData.getValue());
String price = jsonObject.getString("price");

View File

@ -134,14 +134,20 @@ public class WechatController {
public String renotify(@RequestBody String xmlData) {
try {
WxPayService wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WECHAT);
if(wxPayService == null) wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WXAPP);
if(wxPayService == null) wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.APP);
if(wxPayService == null) {
wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WXAPP);
}
if(wxPayService == null) {
wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.APP);
}
WxPayOrderNotifyResult notifyResult = wxPayService.parseOrderNotifyResult(xmlData);
String orderId = notifyResult.getOutTradeNo();
String attach = notifyResult.getAttach();
if(BillDetailEnum.TYPE_3.getValue().equals(attach)){
YxStoreOrderQueryVo orderInfo = orderService.getOrderInfo(orderId,null);
if(orderInfo == null) return WxPayNotifyResponse.success("处理成功!");
if(orderInfo == null) {
return WxPayNotifyResponse.success("处理成功!");
}
if(OrderInfoEnum.PAY_STATUS_1.getValue().equals(orderInfo.getPaid())){
return WxPayNotifyResponse.success("处理成功!");
}
@ -149,7 +155,9 @@ public class WechatController {
}else if(BillDetailEnum.TYPE_1.getValue().equals(attach)){
//处理充值
YxUserRecharge userRecharge = userRechargeService.getInfoByOrderId(orderId);
if(userRecharge == null) return WxPayNotifyResponse.success("处理成功!");
if(userRecharge == null) {
return WxPayNotifyResponse.success("处理成功!");
}
if(OrderInfoEnum.PAY_STATUS_1.getValue().equals(userRecharge.getPaid())){
return WxPayNotifyResponse.success("处理成功!");
}
@ -173,8 +181,12 @@ public class WechatController {
public String parseRefundNotifyResult(@RequestBody String xmlData) {
try {
WxPayService wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WECHAT);
if(wxPayService == null) wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WXAPP);
if(wxPayService == null) wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.APP);
if(wxPayService == null) {
wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WXAPP);
}
if(wxPayService == null) {
wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.APP);
}
WxPayRefundNotifyResult result = wxPayService.parseRefundNotifyResult(xmlData);
String orderId = result.getReqInfo().getOutTradeNo();
BigDecimal refundFee = BigNum.div(result.getReqInfo().getRefundFee(), 100);
@ -242,14 +254,18 @@ public class WechatController {
// 明文传输的消息
WxMpXmlMessage inMessage = WxMpXmlMessage.fromXml(requestBody);
WxMpXmlOutMessage outMessage = this.route(inMessage);
if(outMessage == null) return;
if(outMessage == null) {
return;
}
out = outMessage.toXml();;
} else if ("aes".equalsIgnoreCase(encType)) {
// aes加密的消息
WxMpXmlMessage inMessage = WxMpXmlMessage.fromEncryptedXml(requestBody, wxService.getWxMpConfigStorage(),
timestamp, nonce, msgSignature);
WxMpXmlOutMessage outMessage = this.route(inMessage);
if(outMessage == null) return;
if(outMessage == null) {
return;
}
out = outMessage.toEncryptedXml(wxService.getWxMpConfigStorage());
}