|
@@ -30,22 +30,28 @@ import com.ym.mec.util.string.ValueUtil;
|
|
|
@RestController
|
|
|
public class WechatController extends BaseController {
|
|
|
|
|
|
- private String appId = "wx80f175c0eb6836e9";
|
|
|
-
|
|
|
- private String secret = "a9d779747dba9f4e82f19882debe3e93";
|
|
|
+// private String appId = "wx80f175c0eb6836e9";
|
|
|
+//
|
|
|
+// private String secret = "a9d779747dba9f4e82f19882debe3e93";
|
|
|
|
|
|
private final static String WX_ACCESS_TOKEN = "WX_ACCESS_TOKEN";
|
|
|
|
|
|
@Autowired
|
|
|
private RedisCache<String, Object> redisCache;
|
|
|
|
|
|
+ private static final Map<String,Map<String,String>> appidMap = createAppidMap();
|
|
|
+
|
|
|
@ApiOperation("获取签名")
|
|
|
@GetMapping(value = "/getSignature")
|
|
|
- public Object getSignature(String url) throws Exception {
|
|
|
-
|
|
|
- url = URLDecoder.decode(url);
|
|
|
+ public Object getSignature(String url,String platForm) throws Exception {
|
|
|
+ if(StringUtils.isEmpty(platForm)){
|
|
|
+ platForm = "gym";
|
|
|
+ }
|
|
|
+ Map<String, String> appIdMap = appidMap.get(platForm);
|
|
|
|
|
|
- String accessToken = getAccessToken(appId, secret);
|
|
|
+ url = URLDecoder.decode(url);
|
|
|
+ String appId = appIdMap.get("appId");
|
|
|
+ String accessToken = getAccessToken(appId, appIdMap.get("secret"));
|
|
|
|
|
|
String ticket = getTicket(accessToken);
|
|
|
|
|
@@ -71,6 +77,19 @@ public class WechatController extends BaseController {
|
|
|
return succeed(result);
|
|
|
}
|
|
|
|
|
|
+ private static Map<String,Map<String,String>> createAppidMap(){
|
|
|
+ Map<String,Map<String,String>> resultMap = new HashMap<>();
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ map.put("appId", "wx80f175c0eb6836e9");
|
|
|
+ map.put("secret", "a9d779747dba9f4e82f19882debe3e93");
|
|
|
+ Map<String,String> map1 = new HashMap<>();
|
|
|
+ map.put("appId", "wx751141096e75a4ee");
|
|
|
+ map.put("secret", "e882d76c95d1613607a85338b1bed3ff");
|
|
|
+ resultMap.put("gym",map);
|
|
|
+ resultMap.put("daya",map1);
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
private String getAccessToken(String appid, String secret) throws IOException {
|
|
|
|
|
|
if (redisCache.exists(WX_ACCESS_TOKEN)) {
|