| | |
| | | import com.ard.work.domain.receiver.TyHttpCommonReceiver; |
| | | import com.ard.work.mapper.ArdServerInfoMapper; |
| | | import com.ard.work.service.IArdServerInfoService; |
| | | import com.dtflys.forest.exceptions.ForestRuntimeException; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.DigestUtils; |
| | |
| | | @Override |
| | | public AccessTokenReceiver getAccessToken(String id) { |
| | | long timeStamp = getTimeStamp(); |
| | | AccessTokenReceiver accessToken = null; |
| | | |
| | | ArdServerInfo serverInfo = selectArdServerInfoById(id); |
| | | // 准备请求的json |
| | | TokenDTO gtd = TokenDTO.builder() |
| | |
| | | .encryptStr(getEncryptStr(serverInfo, timeStamp)) |
| | | .timeStamp(timeStamp) |
| | | .build(); |
| | | try { |
| | | // try { |
| | | TyHttpCommonReceiver<AccessTokenReceiver> getTokenRes = tyClient.getToken(id, gtd); |
| | | accessToken = getTokenRes.getContent(); |
| | | } catch (Exception e) { |
| | | log.error("获取token失败:{}", e.getMessage()); |
| | | } |
| | | return getTokenRes.getContent(); |
| | | // } catch (Exception e) { |
| | | // log.error("获取 Token 失败 serverId={}, 异常: {}", id, e.getMessage()); |
| | | // return null; // 请求失败返回 null |
| | | // } |
| | | //{"state":0,"content":{"companyId":4127,"accessToken":"sOONT0MMVdoKcMBibb40xxgrUrq0Hw9RFiajic3KOzoNtk"}} |
| | | return accessToken; |
| | | } |
| | | |
| | | /** |
| | | * 修改服务器状态 |
| | | */ |
| | | @Override |
| | | public int updateServerStatus(String id,String status) { |
| | | return ardServerInfoMapper.updateServerStatus(id,status); |
| | | public int updateServerStatus(String id, String status) { |
| | | return ardServerInfoMapper.updateServerStatus(id, status); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getServerIdsList() { |
| | | return ardServerInfoMapper.getServerIdsList(); |
| | | } |
| | | |
| | | private String getEncryptStr(ArdServerInfo serverInfo, long timeStamp) { |