| | |
| | | import com.ard.tianyu.http.TyClient; |
| | | import com.ard.tianyu.model.dto.TokenDTO; |
| | | import com.ard.tianyu.model.receiver.AccessTokenReceiver; |
| | | import com.ard.tianyu.model.receiver.BoxReceiver; |
| | | import com.ard.tianyu.model.receiver.TyHttpCommonReceiver; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.util.DigestUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * TianyuConfiguration |
| | |
| | | private String encryptstr; |
| | | |
| | | public String getEncryptStr() { |
| | | String sb = new StringBuilder() |
| | | .append(accesskeyid) |
| | | .append(accesskeysecret) |
| | | .append(getTimeStamp()) |
| | | .toString(); |
| | | String sb = accesskeyid + |
| | | accesskeysecret + |
| | | getTimeStamp(); |
| | | encryptstr = DigestUtils.md5DigestAsHex(sb.getBytes()); |
| | | return encryptstr; |
| | | } |
| | | |
| | | public String getIpPort() { |
| | | return tcpserver + "/" + tcpport; |
| | | return tcpserver + ":" + tcpport; |
| | | } |
| | | |
| | | @Resource |
| | |
| | | .encryptStr(getEncryptStr()) |
| | | .timeStamp(timestamp) |
| | | .build(); |
| | | TyHttpCommonReceiver<AccessTokenReceiver> getTokenRes = tyClient.getToken(gtd); |
| | | try { |
| | | TyHttpCommonReceiver<AccessTokenReceiver> getTokenRes = tyClient.getToken(gtd); |
| | | accessToken = getTokenRes.getContent(); |
| | | } catch (Exception e) { |
| | | log.error("获取token失败:{}", e.getMessage()); |
| | | } |
| | | //{"state":0,"content":{"companyId":4127,"accessToken":"sOONT0MMVdoKcMBibb40xxgrUrq0Hw9RFiajic3KOzoNtk"}} |
| | | accessToken = getTokenRes.getContent(); |
| | | return accessToken; |
| | | } |
| | | |
| | | } |