Commit 9bf32317 authored by 耿迪迪's avatar 耿迪迪

创蓝接口错误日志添加

parent 044a81df
...@@ -9,7 +9,10 @@ import org.slf4j.Logger; ...@@ -9,7 +9,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
...@@ -36,11 +39,12 @@ public class VoiceNotifyController { ...@@ -36,11 +39,12 @@ public class VoiceNotifyController {
public Result sendVoiceNotify(@Valid @RequestBody SendVoiceNotify sendVoiceNotify, BindingResult result){ public Result sendVoiceNotify(@Valid @RequestBody SendVoiceNotify sendVoiceNotify, BindingResult result){
try { try {
if(result.hasErrors()){ if(result.hasErrors()){
logger.error("语音发送失败,params:{},message:{}",sendVoiceNotify.toString(),result.getFieldError().getDefaultMessage());
return new Result(ResultEnum.VALIDATA_ERROR.getCode(),result.getFieldError().getDefaultMessage()); return new Result(ResultEnum.VALIDATA_ERROR.getCode(),result.getFieldError().getDefaultMessage());
} }
return voiceNotifyService.sendVoiceNotify(sendVoiceNotify); return voiceNotifyService.sendVoiceNotify(sendVoiceNotify);
} catch (IOException | URISyntaxException e) { } catch (IOException | URISyntaxException e) {
logger.info("语音发送失败!phoneNumber:%",sendVoiceNotify.getPhoneNumber(),e); logger.error("语音发送失败,phoneNumbers:{},message:{}",sendVoiceNotify.getPhoneNumber(),e);
return new Result(ResultEnum.SYSTEM_EXCEPTION); return new Result(ResultEnum.SYSTEM_EXCEPTION);
} }
} }
...@@ -54,11 +58,12 @@ public class VoiceNotifyController { ...@@ -54,11 +58,12 @@ public class VoiceNotifyController {
public Result sendBatchVoiceNotify(@Valid @RequestBody SendBatchVoiceNotify sendBatchVoiceNotify, BindingResult result){ public Result sendBatchVoiceNotify(@Valid @RequestBody SendBatchVoiceNotify sendBatchVoiceNotify, BindingResult result){
try { try {
if(result.hasErrors()){ if(result.hasErrors()){
logger.error("群发语音失败,params:{},message:{}",sendBatchVoiceNotify.toString(),result.getFieldError().getDefaultMessage());
return new Result(ResultEnum.VALIDATA_ERROR.getCode(),result.getFieldError().getDefaultMessage()); return new Result(ResultEnum.VALIDATA_ERROR.getCode(),result.getFieldError().getDefaultMessage());
} }
return voiceNotifyService.sendBatchVoiceNotify(sendBatchVoiceNotify); return voiceNotifyService.sendBatchVoiceNotify(sendBatchVoiceNotify);
} catch (IOException | URISyntaxException e) { } catch (IOException | URISyntaxException e) {
logger.info("群发语音失败!phoneNumbers:%",sendBatchVoiceNotify.getPhoneNumberJson(),e); logger.error("群发语音失败,params:{},message:{}",sendBatchVoiceNotify.getPhoneNumberJson(),e);
return new Result(ResultEnum.SYSTEM_EXCEPTION); return new Result(ResultEnum.SYSTEM_EXCEPTION);
} }
} }
......
...@@ -2,6 +2,7 @@ package com.zehong.communication.util; ...@@ -2,6 +2,7 @@ package com.zehong.communication.util;
import com.zehong.communication.common.result.Result; import com.zehong.communication.common.result.Result;
import com.zehong.communication.common.result.ResultEnum; import com.zehong.communication.common.result.ResultEnum;
import com.zehong.communication.service.impl.AliVoiceNotifyServiceImpl;
import org.apache.http.*; import org.apache.http.*;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.entity.UrlEncodedFormEntity;
...@@ -15,6 +16,8 @@ import org.apache.http.impl.client.HttpClients; ...@@ -15,6 +16,8 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair; import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
...@@ -28,6 +31,8 @@ import java.util.Map; ...@@ -28,6 +31,8 @@ import java.util.Map;
public class HttpUtil { public class HttpUtil {
private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
/** /**
* get请求 * get请求
* @return * @return
...@@ -85,6 +90,7 @@ public class HttpUtil { ...@@ -85,6 +90,7 @@ public class HttpUtil {
if(code == 200){ if(code == 200){
return new Result(ResultEnum.SUCCESS.getCode(),sb.toString()); return new Result(ResultEnum.SUCCESS.getCode(),sb.toString());
} }
logger.error("请求失败,params:{},message:{}",params.toString(),sb.toString());
return new Result(ResultEnum.FAIL.getCode(),sb.toString()); return new Result(ResultEnum.FAIL.getCode(),sb.toString());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment