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

@ -90,7 +90,9 @@ public class StoreCategoryController {
}
boolean checkResult = yxStoreCategoryService.checkCategory(resources.getPid());
if(!checkResult) throw new YshopException("分类最多能添加2级哦");
if(!checkResult) {
throw new YshopException("分类最多能添加2级哦");
}
return new ResponseEntity<>(yxStoreCategoryService.save(resources),HttpStatus.CREATED);
}
@ -112,7 +114,9 @@ public class StoreCategoryController {
boolean checkResult = yxStoreCategoryService.checkCategory(resources.getPid());
if(!checkResult) throw new YshopException("分类最多能添加2级哦");
if(!checkResult) {
throw new YshopException("分类最多能添加2级哦");
}
yxStoreCategoryService.saveOrUpdate(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
@ -142,12 +146,16 @@ public class StoreCategoryController {
int count = yxStoreCategoryService.lambdaQuery()
.eq(YxStoreCategory::getPid,id)
.count();
if(count > 0) throw new YshopException("请先删除子分类");
if(count > 0) {
throw new YshopException("请先删除子分类");
}
int countP = yxStoreProductService.lambdaQuery()
.eq(YxStoreProduct::getCateId,id)
.count();
if(countP > 0) throw new YshopException("当前分类下有商品不可删除");
if(countP > 0) {
throw new YshopException("当前分类下有商品不可删除");
}
}
}

View File

@ -131,8 +131,12 @@ public class StoreOrderController {
@PutMapping(value = "/yxStoreOrder")
@PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')")
public ResponseEntity update(@Validated @RequestBody YxStoreOrder resources) {
if (StrUtil.isBlank(resources.getDeliveryName())) throw new BadRequestException("请选择快递公司");
if (StrUtil.isBlank(resources.getDeliveryId())) throw new BadRequestException("快递单号不能为空");
if (StrUtil.isBlank(resources.getDeliveryName())) {
throw new BadRequestException("请选择快递公司");
}
if (StrUtil.isBlank(resources.getDeliveryId())) {
throw new BadRequestException("快递单号不能为空");
}
yxStoreOrderService.orderDelivery(resources.getOrderId(),resources.getDeliveryId(),
resources.getDeliveryName(),resources.getDeliveryType());
@ -143,7 +147,9 @@ public class StoreOrderController {
@PutMapping(value = "/yxStoreOrder/check")
@PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')")
public ResponseEntity check(@Validated @RequestBody YxStoreOrder resources) {
if (StrUtil.isBlank(resources.getVerifyCode())) throw new BadRequestException("核销码不能为空");
if (StrUtil.isBlank(resources.getVerifyCode())) {
throw new BadRequestException("核销码不能为空");
}
YxStoreOrderDto storeOrderDTO = generator.convert(yxStoreOrderService.getById(resources.getId()),YxStoreOrderDto.class);
if(!resources.getVerifyCode().equals(storeOrderDTO.getVerifyCode())){
throw new BadRequestException("核销码不对");
@ -185,8 +191,12 @@ public class StoreOrderController {
@PostMapping(value = "/yxStoreOrder/edit")
@PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')")
public ResponseEntity editOrder(@RequestBody YxStoreOrder resources) {
if (ObjectUtil.isNull(resources.getPayPrice())) throw new BadRequestException("请输入支付金额");
if (resources.getPayPrice().doubleValue() < 0) throw new BadRequestException("金额不能低于0");
if (ObjectUtil.isNull(resources.getPayPrice())) {
throw new BadRequestException("请输入支付金额");
}
if (resources.getPayPrice().doubleValue() < 0) {
throw new BadRequestException("金额不能低于0");
}
YxStoreOrderDto storeOrder = generator.convert(yxStoreOrderService.getById(resources.getId()),YxStoreOrderDto.class);
//判断金额是否有变动,生成一个额外订单号去支付
int res = NumberUtil.compare(storeOrder.getPayPrice().doubleValue(), resources.getPayPrice().doubleValue());
@ -208,7 +218,9 @@ public class StoreOrderController {
@PostMapping(value = "/yxStoreOrder/remark")
@PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')")
public ResponseEntity editOrderRemark(@RequestBody YxStoreOrder resources) {
if (StrUtil.isBlank(resources.getRemark())) throw new BadRequestException("请输入备注");
if (StrUtil.isBlank(resources.getRemark())) {
throw new BadRequestException("请输入备注");
}
yxStoreOrderService.saveOrUpdate(resources);
return new ResponseEntity(HttpStatus.OK);
}
@ -223,7 +235,9 @@ public class StoreOrderController {
ExpressService expressService = ExpressAutoConfiguration.expressService();
ExpressInfo expressInfo = expressService.getExpressInfo(expressInfoDo.getOrderCode(),
expressInfoDo.getShipperCode(), expressInfoDo.getLogisticCode());
if(!expressInfo.isSuccess()) throw new BadRequestException(expressInfo.getReason());
if(!expressInfo.isSuccess()) {
throw new BadRequestException(expressInfo.getReason());
}
return new ResponseEntity<>(expressInfo, HttpStatus.OK);
}

View File

@ -84,7 +84,7 @@ public class WechatArticleService {
WxMpMassSendResult massResult = wxMpService.getMassMessageService()
.massGroupMessageSend(massMessage);
if(!massResult.getErrorCode().equals("0")) {
if(!"0".equals(massResult.getErrorCode())) {
log.info("error:"+massResult.getErrorMsg());
throw new ErrorRequestException("发送失败");
}

View File

@ -88,7 +88,9 @@ public class SystemStoreController {
@PreAuthorize("@el.check('yxSystemStore:getl')")
public ResponseEntity<Object> create(@Validated @RequestBody String jsonStr){
String key = RedisUtil.get(ShopKeyUtils.getTengXunMapKey());
if(StrUtil.isBlank(key)) throw new BadRequestException("请先配置腾讯地图key");
if(StrUtil.isBlank(key)) {
throw new BadRequestException("请先配置腾讯地图key");
}
JSONObject jsonObject = JSON.parseObject(jsonStr);
String addr = jsonObject.getString("addr");
String url = StrUtil.format("?address={}&key={}",addr,key);

View File

@ -97,7 +97,7 @@ public class ShippingTemplatesController {
List<YxStoreProduct> productList = yxStoreProductService.list();
Arrays.asList(ids).forEach(id->{
for (YxStoreProduct yxStoreProduct : productList) {
if(id==yxStoreProduct.getTempId()){
if(id.equals(yxStoreProduct.getTempId())){
throw new BadRequestException("运费模板存在商品关联,请删除对应商品");
}
}