1. if else if 容易产生空
try{
String applyedServiceId = "";
String applyType = applyList.getApplyType();
if (applyType.equals(ApplyList.ApplyType.CHANGE.name())) {
IaasChangeDTO iaasChangeDTO = OBJECT_MAPPER.readValue(applyList.getResourceContent(), IaasChangeDTO.class);
applyedServiceId = iaasChangeDTO.getApplyedServiceId();
}else if(applyType.equals(ApplyList.ApplyType.UNSUBSCRIBE.name())){
IaasDeleteDTO iaasDeleteDTO = OBJECT_MAPPER.readValue(applyList.getResourceContent(), IaasDeleteDTO.class);
applyedServiceId = iaasDeleteDTO.getApplyedServiceId();
}
if(applyedServiceId.length() >0){ //这里需要加上非空判断,因为用了if else if存在产生空的可能
MyServiceIaas myServiceIaas = myServiceIaasMapper.selectById(applyedServiceId);
myServiceIaas.setApplyStatus(applyStatusEnum);
myServiceIaasMapper.updateById(myServiceIaas);
}
}catch (Exception e){
logger.error("更改我的服务Iaas信息失败", e);
throw new BaseServiceException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "更改我的服务Iaas信息失败");
}
2. list.get(0)要进行非空判断