提交 6969b173 编写于 作者: zhouweidong's avatar zhouweidong

异常处理

上级 cafda352
...@@ -7,12 +7,14 @@ import com.dingtalk.api.request.OapiGettokenRequest; ...@@ -7,12 +7,14 @@ import com.dingtalk.api.request.OapiGettokenRequest;
import com.dingtalk.api.response.OapiGetJsapiTicketResponse; import com.dingtalk.api.response.OapiGetJsapiTicketResponse;
import com.dingtalk.api.response.OapiGettokenResponse; import com.dingtalk.api.response.OapiGettokenResponse;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Formatter; import java.util.Formatter;
@Slf4j
public class DingTalkHelper { public class DingTalkHelper {
/** /**
* 获取jsapi_ticket * 获取jsapi_ticket
...@@ -24,8 +26,12 @@ public class DingTalkHelper { ...@@ -24,8 +26,12 @@ public class DingTalkHelper {
DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/get_jsapi_ticket"); DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/get_jsapi_ticket");
OapiGetJsapiTicketRequest req = new OapiGetJsapiTicketRequest(); OapiGetJsapiTicketRequest req = new OapiGetJsapiTicketRequest();
req.setTopHttpMethod("GET"); req.setTopHttpMethod("GET");
OapiGetJsapiTicketResponse execute = client.execute(req, accessToken); OapiGetJsapiTicketResponse rs = client.execute(req, accessToken);
return execute.getTicket(); if(!rs.isSuccess()){
log.error("获取ticket失败,{},错误代码:{}",rs.getErrmsg(),rs.getErrcode());
throw new BadRequestAlertException(String.format("获取ticket失败,%s,错误代码:[%s]",rs.getErrmsg(),rs.getErrcode()),"DingTalkHelper","getJsapiTicket");
}
return rs.getTicket();
} }
/** /**
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册