|
@@ -2,6 +2,8 @@ package com.dragoninfo.dcuc.auth.business.impl;
|
|
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.vo.AuthNoticeReqVO;
|
|
|
+import com.dragoninfo.dcuc.auth.auth.vo.AuthNoticeRespVO;
|
|
|
import com.dragoninfo.dcuc.auth.auth.vo.bim.BimAppPermissionUpdateContentRespVO;
|
|
|
import com.dragoninfo.dcuc.auth.auth.vo.bim.BimAppPermissionUpdateReqVO;
|
|
|
import com.dragoninfo.dcuc.auth.auth.vo.bim.BimAppPermissionUpdateRespVo;
|
|
@@ -10,6 +12,8 @@ import com.dragoninfo.dcuc.auth.business.INotifyBusiness;
|
|
|
import com.dragoninfo.dcuc.auth.config.DcucAuthConfig;
|
|
|
import com.dragonsoft.duceap.commons.util.UUIDUtils;
|
|
|
import com.dragonsoft.duceap.commons.util.json.JsonUtils;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.remoting.RemoteAccessException;
|
|
@@ -34,6 +38,7 @@ public class NotifyBusinessImpl implements INotifyBusiness {
|
|
|
@Autowired
|
|
|
private IBimBusiness bimBusiness;
|
|
|
|
|
|
+
|
|
|
@Retryable(value = RemoteAccessException.class,
|
|
|
maxAttempts = 5,
|
|
|
backoff = @Backoff(delay = 1000)
|
|
@@ -41,7 +46,7 @@ public class NotifyBusinessImpl implements INotifyBusiness {
|
|
|
@Override
|
|
|
public void sendAppPermissionUpdateNotify(List<String> tokenList) {
|
|
|
if (tokenList.isEmpty()) {
|
|
|
- log.info("Is't have userToken notify.");
|
|
|
+ log.info("Isn't have userToken notify.");
|
|
|
return;
|
|
|
}
|
|
|
String notifyUrl = dcucAuthConfig.getBimUrl() + "/api/rest/customization/ExpApiCustomDragonitService/appPermissionUpdate";
|
|
@@ -84,6 +89,54 @@ public class NotifyBusinessImpl implements INotifyBusiness {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void sendPermissionUpdateNotify(List<String> userToken) {
|
|
|
+ List<String> notifyAppUrlList = dcucAuthConfig.getNotifyAppUrlList();
|
|
|
+ for (String notifyAppUrl : notifyAppUrlList) {
|
|
|
+ sendNotify(notifyAppUrl, userToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Retryable(value = RemoteAccessException.class,
|
|
|
+ maxAttempts = 5,
|
|
|
+ backoff = @Backoff(delay = 1000)
|
|
|
+ )
|
|
|
+ public void sendNotify(String notifyUrl, List<String> userTokenList) {
|
|
|
+ AuthNoticeReqVO authNoticeReqVO = new AuthNoticeReqVO();
|
|
|
+ authNoticeReqVO.setUserTokenId(userTokenList);
|
|
|
+
|
|
|
+ String postJson = JSONUtil.toJsonStr(authNoticeReqVO);
|
|
|
+ log.info("App permission notify URL:{}", notifyUrl);
|
|
|
+ log.info("App permission notify post content:{}", postJson);
|
|
|
+ String postResp;
|
|
|
+ try {
|
|
|
+ postResp = HttpRequest.post(notifyUrl)
|
|
|
+ .header("Message-Type", "tokencheck")
|
|
|
+ .header("Content-Type", "application/json")
|
|
|
+ .body(postJson)
|
|
|
+ .execute()
|
|
|
+ .body();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("Post error", e);
|
|
|
+ throw new RemoteAccessException(e.getMessage());
|
|
|
+ }
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+
|
|
|
+ try {
|
|
|
+ AuthNoticeRespVO authNoticeRespVO = objectMapper.readValue(postResp, AuthNoticeRespVO.class);
|
|
|
+ String statusCode = authNoticeRespVO.getStatusCode();
|
|
|
+ if (!"0000".equals(statusCode)) {
|
|
|
+ log.error("notify error:{}", authNoticeRespVO.getMessage());
|
|
|
+ throw new RemoteAccessException(authNoticeRespVO.getMessage());
|
|
|
+ }
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ log.error("parse json error", e);
|
|
|
+ throw new RemoteAccessException(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Recover
|
|
|
public void recover(RemoteAccessException e) {
|
|
|
log.error("Remote error", e);
|