Commit 61840059fcfcb704c336146a2a61e59f00a480a9
1 parent
b00de0dd
Exists in
master
新增萤石model以及代码优化
Showing
3 changed files
with
24 additions
and
32 deletions
Show diff stats
springboot/src/main/java/com/sincre/springboot/ApiModel/YinShiResResult.java
| @@ -33,29 +33,31 @@ public class YinShiResResult { | @@ -33,29 +33,31 @@ public class YinShiResResult { | ||
| 33 | 33 | ||
| 34 | private String code; | 34 | private String code; |
| 35 | private String msg; | 35 | private String msg; |
| 36 | -} | ||
| 37 | 36 | ||
| 38 | -class YinShiToken{ | 37 | + public class YinShiToken{ |
| 39 | 38 | ||
| 40 | - private String accessToken; | 39 | + private String accessToken; |
| 40 | + /** | ||
| 41 | + * 精确到毫秒的时间戳 | ||
| 42 | + */ | ||
| 43 | + private Long expireTime; | ||
| 41 | 44 | ||
| 42 | - private Long expireTime; | 45 | + public String getAccessToken() { |
| 46 | + return accessToken; | ||
| 47 | + } | ||
| 43 | 48 | ||
| 44 | - public String getAccessToken() { | ||
| 45 | - return accessToken; | ||
| 46 | - } | 49 | + public void setAccessToken(String accessToken) { |
| 50 | + this.accessToken = accessToken; | ||
| 51 | + } | ||
| 47 | 52 | ||
| 48 | - public void setAccessToken(String accessToken) { | ||
| 49 | - this.accessToken = accessToken; | ||
| 50 | - } | 53 | + public Long getExpireTime() { |
| 54 | + return expireTime; | ||
| 55 | + } | ||
| 51 | 56 | ||
| 52 | - public Long getExpireTime() { | ||
| 53 | - return expireTime; | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - public void setExpireTime(Long expireTime) { | ||
| 57 | - this.expireTime = expireTime; | 57 | + public void setExpireTime(Long expireTime) { |
| 58 | + this.expireTime = expireTime; | ||
| 59 | + } | ||
| 58 | } | 60 | } |
| 61 | +} | ||
| 59 | 62 | ||
| 60 | 63 | ||
| 61 | -} |
springboot/src/main/java/com/sincre/springboot/controller/YinShiController.java
| @@ -3,6 +3,7 @@ package com.sincre.springboot.controller; | @@ -3,6 +3,7 @@ package com.sincre.springboot.controller; | ||
| 3 | 3 | ||
| 4 | import com.sincre.springboot.common.MD5; | 4 | import com.sincre.springboot.common.MD5; |
| 5 | import com.sincre.springboot.utils.ApiHelper; | 5 | import com.sincre.springboot.utils.ApiHelper; |
| 6 | +import com.sincre.springboot.utils.CacheHelper; | ||
| 6 | import io.swagger.annotations.Api; | 7 | import io.swagger.annotations.Api; |
| 7 | import io.swagger.annotations.ApiOperation; | 8 | import io.swagger.annotations.ApiOperation; |
| 8 | import org.springframework.web.bind.annotation.GetMapping; | 9 | import org.springframework.web.bind.annotation.GetMapping; |
| @@ -21,21 +22,6 @@ import com.sincre.springboot.ApiPlatform.YinShiServiceConfig; | @@ -21,21 +22,6 @@ import com.sincre.springboot.ApiPlatform.YinShiServiceConfig; | ||
| 21 | public class YinShiController { | 22 | public class YinShiController { |
| 22 | 23 | ||
| 23 | private static String AccessToken = "at.2scte32926nu6q7j6adhlabg28emicz6-58f6w0596w-1ppubtz-uxh6dnv5x"; | 24 | private static String AccessToken = "at.2scte32926nu6q7j6adhlabg28emicz6-58f6w0596w-1ppubtz-uxh6dnv5x"; |
| 24 | - @ApiOperation(value = "用于管理员获取accessToken") | ||
| 25 | - @GetMapping("/token") | ||
| 26 | - public String GetYinShiToken(){ | ||
| 27 | - String appKey = YinShiServiceConfig.appKey; | ||
| 28 | - String appSecret = YinShiServiceConfig.appSecret; | ||
| 29 | - | ||
| 30 | - String url = YinShiServiceConfig.HostUrl + "lapp/token/get"; | ||
| 31 | - Map<String,Object> map = new HashMap<>(); | ||
| 32 | - | ||
| 33 | - map.put("appKey",appKey); | ||
| 34 | - map.put("appSecret",appSecret); | ||
| 35 | - String result = ApiHelper.doPost(url,new HashMap<String, String>(),map); | ||
| 36 | - | ||
| 37 | - return result; | ||
| 38 | - } | ||
| 39 | 25 | ||
| 40 | @ApiOperation(value = "增加子账号") | 26 | @ApiOperation(value = "增加子账号") |
| 41 | @GetMapping("/addChildAccount") | 27 | @GetMapping("/addChildAccount") |
springboot/src/main/java/com/sincre/springboot/utils/CacheHelper.java
| @@ -4,7 +4,9 @@ import com.fasterxml.jackson.core.type.TypeReference; | @@ -4,7 +4,9 @@ import com.fasterxml.jackson.core.type.TypeReference; | ||
| 4 | import com.fasterxml.jackson.databind.ObjectMapper; | 4 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 5 | import com.sincre.springboot.ApiModel.TuYaResResult; | 5 | import com.sincre.springboot.ApiModel.TuYaResResult; |
| 6 | import com.sincre.springboot.ApiModel.TuYaResTokenObj; | 6 | import com.sincre.springboot.ApiModel.TuYaResTokenObj; |
| 7 | +import com.sincre.springboot.ApiModel.YinShiResResult; | ||
| 7 | import com.sincre.springboot.ApiPlatform.TuYaCloudService; | 8 | import com.sincre.springboot.ApiPlatform.TuYaCloudService; |
| 9 | +import com.sincre.springboot.ApiPlatform.YinShiServiceConfig; | ||
| 8 | import com.sincre.springboot.common.EhcacheUtil; | 10 | import com.sincre.springboot.common.EhcacheUtil; |
| 9 | import org.apache.commons.lang3.StringUtils; | 11 | import org.apache.commons.lang3.StringUtils; |
| 10 | 12 | ||
| @@ -16,6 +18,7 @@ public class CacheHelper { | @@ -16,6 +18,7 @@ public class CacheHelper { | ||
| 16 | static EhcacheUtil ehcacheUtil = new EhcacheUtil(); | 18 | static EhcacheUtil ehcacheUtil = new EhcacheUtil(); |
| 17 | static String TuYaTokenKey = "TuYa_Token"; | 19 | static String TuYaTokenKey = "TuYa_Token"; |
| 18 | static String TuYaRefreshTokenKey = "TuYa_Re_Token"; | 20 | static String TuYaRefreshTokenKey = "TuYa_Re_Token"; |
| 21 | + | ||
| 19 | private static void setTuYaToken(){ | 22 | private static void setTuYaToken(){ |
| 20 | 23 | ||
| 21 | String apiUrl = "/v1.0/token?grant_type=1"; | 24 | String apiUrl = "/v1.0/token?grant_type=1"; |
| @@ -91,4 +94,5 @@ public class CacheHelper { | @@ -91,4 +94,5 @@ public class CacheHelper { | ||
| 91 | System.out.println(ex.getMessage()); | 94 | System.out.println(ex.getMessage()); |
| 92 | } | 95 | } |
| 93 | } | 96 | } |
| 97 | + | ||
| 94 | } | 98 | } |