兴安优化
This commit is contained in:
@@ -362,6 +362,7 @@ public class SysFileController {
|
||||
*/
|
||||
private void checkPhoto(String imgBase64) {
|
||||
String token = redisService.getCacheObject("yf-Token");
|
||||
log.info("redis-token:{}", token);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
try {
|
||||
long l = System.currentTimeMillis();
|
||||
@@ -375,10 +376,13 @@ public class SysFileController {
|
||||
.header("sign", sign)
|
||||
.form(map)
|
||||
.timeout(5000).execute().body();
|
||||
log.info("请求宇泛token-result:{}", result);
|
||||
JSONObject jsonObject1 = JSONObject.parseObject(result);
|
||||
if (jsonObject1.getInteger("result") == 1 && StringUtils.isNotBlank(jsonObject1.getString("data"))) {
|
||||
token = jsonObject1.getString("data");
|
||||
redisService.setCacheObject("yf-Token", token, 20 * 60 * 60L, TimeUnit.SECONDS);
|
||||
} else {
|
||||
throw new ServiceException("宇泛鉴权失败!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("宇泛鉴权失败!");
|
||||
@@ -404,7 +408,13 @@ public class SysFileController {
|
||||
log.info("请求宇泛人脸返回:{}", result);
|
||||
JSONObject jsonObject1 = JSONObject.parseObject(result);
|
||||
if (jsonObject1.getInteger("result") != 1 || !jsonObject1.getBoolean("success")) {
|
||||
throw new ServiceException("人脸检测失败,请重新上传");
|
||||
//token失效
|
||||
if (StringUtils.equals("WO_EXP-1203", jsonObject1.getString("code"))) {
|
||||
redisService.deleteObject("yf-Token");
|
||||
this.checkPhoto(imgBase64);
|
||||
} else {
|
||||
throw new ServiceException("人脸检测失败,请重新上传");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user