Commit b68eea6186a746e633eafac00697d494ffa9a2f9
1 parent
10cb26e0
Exists in
master
1
Showing
1 changed file
with
6 additions
and
3 deletions
Show diff stats
src/main/java/com/sincere/wechatbusiness/controller/TokenController.java
@@ -6,6 +6,7 @@ import com.sincere.wechatbusiness.model.AccessToken; | @@ -6,6 +6,7 @@ import com.sincere.wechatbusiness.model.AccessToken; | ||
6 | import com.sincere.wechatbusiness.model.Channel; | 6 | import com.sincere.wechatbusiness.model.Channel; |
7 | import com.sincere.wechatbusiness.model.Token; | 7 | import com.sincere.wechatbusiness.model.Token; |
8 | import com.sincere.wechatbusiness.service.ChannelService; | 8 | import com.sincere.wechatbusiness.service.ChannelService; |
9 | +import com.sincere.wechatbusiness.utils.HttpClientUtils; | ||
9 | import io.swagger.annotations.ApiOperation; | 10 | import io.swagger.annotations.ApiOperation; |
10 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.web.bind.annotation.RequestMapping; | 12 | import org.springframework.web.bind.annotation.RequestMapping; |
@@ -29,8 +30,10 @@ public class TokenController { | @@ -29,8 +30,10 @@ public class TokenController { | ||
29 | ChannelService channelService ; | 30 | ChannelService channelService ; |
30 | 31 | ||
31 | @Autowired | 32 | @Autowired |
32 | - ChannelMapper channelMapper ; | 33 | + ChannelMapper channelMapper; |
33 | 34 | ||
35 | + private static String appId = "wx6078ff3f67524996" ; | ||
36 | + private static String secret = "8a0465b8ad0f000f568f48853e2818c8" ; | ||
34 | 37 | ||
35 | @ApiOperation(value = "获取分享token") | 38 | @ApiOperation(value = "获取分享token") |
36 | @RequestMapping(value = "getToken",method = RequestMethod.GET) | 39 | @RequestMapping(value = "getToken",method = RequestMethod.GET) |
@@ -48,13 +51,13 @@ public class TokenController { | @@ -48,13 +51,13 @@ public class TokenController { | ||
48 | 51 | ||
49 | if(minute<60) token.setAccess_token(accessToken.getAccessToken()); | 52 | if(minute<60) token.setAccess_token(accessToken.getAccessToken()); |
50 | else{ | 53 | else{ |
51 | - token=getAccessToken("wx6078ff3f67524996","8a0465b8ad0f000f568f48853e2818c8"); | 54 | + token=getAccessToken(appId,secret); |
52 | accessToken.setAccessToken(token.getAccess_token()); | 55 | accessToken.setAccessToken(token.getAccess_token()); |
53 | channelService.insertAccessToken(accessToken); | 56 | channelService.insertAccessToken(accessToken); |
54 | } | 57 | } |
55 | } | 58 | } |
56 | else { | 59 | else { |
57 | - token=getAccessToken("wx6078ff3f67524996","8a0465b8ad0f000f568f48853e2818c8"); | 60 | + token=getAccessToken(appId,secret); |
58 | accessToken=new AccessToken(); | 61 | accessToken=new AccessToken(); |
59 | accessToken.setAccessToken(token.getAccess_token()); | 62 | accessToken.setAccessToken(token.getAccess_token()); |
60 | channelService.insertAccessToken(accessToken); | 63 | channelService.insertAccessToken(accessToken); |