兴安优化

This commit is contained in:
zc
2025-09-08 15:15:31 +08:00
parent c7a2bc5276
commit 4fb615c695
3 changed files with 28 additions and 4 deletions

View File

@@ -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("人脸检测失败,请重新上传");
}
}
}