mirror of
https://github.com/luoye663/e5.git
synced 2024-12-26 03:38:53 +00:00
备份
This commit is contained in:
parent
8d6df46e2d
commit
8aced448b4
@ -13,11 +13,14 @@ import io.qyi.e5.outlook.service.IOutlookService;
|
||||
import io.qyi.e5.outlook_log.service.IOutlookLogService;
|
||||
import io.qyi.e5.util.netRequest.OkHttpClientUtil;
|
||||
import io.qyi.e5.util.netRequest.OkHttpRequestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -37,6 +40,9 @@ public class OutlookServiceImpl extends ServiceImpl<OutlookMapper, Outlook> impl
|
||||
@Autowired
|
||||
IOutlookLogService outlookLogService;
|
||||
|
||||
@Value("${outlook.errorMsg}")
|
||||
private String[] errorMsg;
|
||||
|
||||
|
||||
// 2020-03-2 10:38 这里需要进行查询判断数据库是否有内容再进行插入。
|
||||
@Override
|
||||
@ -79,7 +85,7 @@ public class OutlookServiceImpl extends ServiceImpl<OutlookMapper, Outlook> impl
|
||||
}
|
||||
QueryWrapper<Outlook> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("github_id", github_id)
|
||||
.or().eq("client_id",client_id);
|
||||
.or().eq("client_id", client_id);
|
||||
Outlook outlook1 = baseMapper.selectOne(queryWrapper);
|
||||
// 有数据
|
||||
if (outlook1 != null) {
|
||||
@ -118,10 +124,11 @@ public class OutlookServiceImpl extends ServiceImpl<OutlookMapper, Outlook> impl
|
||||
if (json.containsKey("error")) {
|
||||
String code = json.getJSONObject("error").getString("code");
|
||||
String message = json.getJSONObject("error").getString("message");
|
||||
if (!("Access token has expired.".equals(message) || "Access token validation failure.".equals(message))) {
|
||||
outlookLogService.addLog(outlook.getGithubId(), "无法刷新令牌!code:3", "0", json.getJSONObject("error").getString("message"));
|
||||
if (!errorCheck(message)) {
|
||||
outlookLogService.addLog(outlook.getGithubId(), "无法刷新令牌!code:3", "0", message);
|
||||
return false;
|
||||
}
|
||||
// CompactToken validation failed with reason code: 80049228
|
||||
|
||||
logger.info("令牌过期!");
|
||||
String token = refresh_token(outlook);
|
||||
@ -192,4 +199,23 @@ public class OutlookServiceImpl extends ServiceImpl<OutlookMapper, Outlook> impl
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查出现的错误是否能够刷新令牌
|
||||
*
|
||||
* @throws
|
||||
* @title errorCheck
|
||||
* @description
|
||||
* @author 落叶随风
|
||||
* @updateTime 2020/3/5 14:47
|
||||
*/
|
||||
public boolean errorCheck(String msg) {
|
||||
System.out.println(Arrays.toString(errorMsg));
|
||||
for (String s : errorMsg) {
|
||||
if (msg.indexOf(s) != -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
20
src/test/java/io/qyi/e5/string/dome01.java
Normal file
20
src/test/java/io/qyi/e5/string/dome01.java
Normal file
@ -0,0 +1,20 @@
|
||||
package io.qyi.e5.string;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @program: e5
|
||||
* @description:
|
||||
* @author: 落叶随风
|
||||
* @create: 2020-03-05 17:09
|
||||
**/
|
||||
public class dome01 {
|
||||
@Test
|
||||
public void test01(){
|
||||
String[] s = new String[]{"CompactToken validation", "Access token has expired.", "Access token validation failure"};
|
||||
String msg = "Access token has expired.";
|
||||
|
||||
System.out.println(s[1]);
|
||||
System.out.println(msg.indexOf(s[1]));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user