| | |
| | | RateLimiter rateLimiter = RateLimiter.create(10.0); |
| | | |
| | | |
| | | @RequestMapping(value = "/getToken",method = RequestMethod.POST) |
| | | @RequestMapping(value = "/list",method = RequestMethod.POST) |
| | | public Msg listWithNotStatus(@RequestBody ReqParams reqParams){ |
| | | rateLimiter.acquire(1); |
| | | |
| | | if (reqParams.getLimit()>200){ |
| | | return Msg.error("limit exception!!!"); |
| | | } |
| | | Long userId = accessService.getUserId(reqParams.getAccessToken()); |
| | | |
| | | |
| | |
| | | return Msg.error("accessToken exception!!!"); |
| | | } |
| | | |
| | | reqParams.setApiKey(reqParams.getApiKey()); |
| | | reqParams.setUserId(userId); |
| | | |
| | | String result = HttpUtil.Post( |
| | | "http://47.106.172.9:8888/machine-fast/serv/api/camera/cameraList", |
| | | new Gson().toJson(reqParams) |
| | | ); |
| | | |
| | | Map msg = JSON.parseObject(result, HashMap.class); |
| | | |
| | | if (msg.get("msg").equals("success")){ |
| | | |
| | | return Msg.ok().put("data",msg.get("data")); |
| | | } |
| | | else { |
| | | return Msg.error(msg.get("msg").toString()); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "/getToken", method = RequestMethod.POST) |
| | | public Msg getToken(@RequestBody ReqParams reqParams) { |
| | | rateLimiter.acquire(1); |
| | | |
| | | Long userId = accessService.getUserId(reqParams.getAccessToken()); |
| | | |
| | | |
| | | if (userId == null) { |
| | | return Msg.error("accessToken exception!!!"); |
| | | } |
| | | |
| | | //父accesstoken |
| | | |
| | | Map<String, String> parms =new HashMap<>(2); |
| | | Map<String, String> parms = new HashMap<>(2); |
| | | |
| | | parms.put("appKey","51a534ebadf54c31a0848dc575dfa206"); |
| | | parms.put("appSecret","8c32c67a73c87b9e461b2e3bdf58967a"); |
| | | String post = HttpUtil.httpRequestToString("https://open.ys7.com/api/lapp/token/get","post",parms); |
| | | String accessToken= JSON.parseObject(JSON.parseObject(post).getString("data")).getString("accessToken"); |
| | | parms.put("appKey", "51a534ebadf54c31a0848dc575dfa206"); |
| | | parms.put("appSecret", "8c32c67a73c87b9e461b2e3bdf58967a"); |
| | | String post = HttpUtil.httpRequestToString("https://open.ys7.com/api/lapp/token/get", "post", parms); |
| | | String accessToken = JSON.parseObject(JSON.parseObject(post).getString("data")).getString("accessToken"); |
| | | |
| | | |
| | | //子accesstoken |
| | | |
| | | String ys7AccountId = accessService.getYs7AccountId(reqParams.getAccessToken()); |
| | | |
| | | Map<String, String> parms02 =new HashMap<>(2); |
| | | Map<String, String> parms02 = new HashMap<>(2); |
| | | |
| | | parms02.put("accessToken",accessToken); |
| | | parms02.put("accountId",ys7AccountId); |
| | | String post02 = HttpUtil.httpRequestToString("https://open.ys7.com/api/lapp/ram/token/get","post",parms02); |
| | | parms02.put("accessToken", accessToken); |
| | | parms02.put("accountId", ys7AccountId); |
| | | String post02 = HttpUtil.httpRequestToString("https://open.ys7.com/api/lapp/ram/token/get", "post", parms02); |
| | | System.out.println(post02); |
| | | JSONObject data = JSON.parseObject(JSON.parseObject(post02).getString("data")); |
| | | |
| | | // System.out.println(data); |
| | | |
| | | // System.out.println(data.get("accessToken")); |
| | | // accessService.setYs7Token((String) data.get("accessToken"), reqParams.getAccessToken()); |
| | | |
| | | return Msg.ok(data); |
| | | } |
| | | |
| | | |
| | | @RequestMapping("/getLiveAddress") |
| | | public Msg getUrl(@RequestBody ReqParams reqParams){ |
| | | System.out.println(reqParams.toString()); |
| | | rateLimiter.acquire(1); |
| | | |
| | | Long userId = accessService.getUserId(reqParams.getAccessToken()); |
| | | |
| | | |
| | | if (userId == null) { |
| | | return Msg.error("accessToken exception!!!"); |
| | | } |
| | | |
| | | Map<String, String> parms = new HashMap<>(2); |
| | | |
| | | parms.put("appKey", "51a534ebadf54c31a0848dc575dfa206"); |
| | | parms.put("appSecret", "8c32c67a73c87b9e461b2e3bdf58967a"); |
| | | String post = HttpUtil.httpRequestToString("https://open.ys7.com/api/lapp/token/get", "post", parms); |
| | | String accessToken = JSON.parseObject(JSON.parseObject(post).getString("data")).getString("accessToken"); |
| | | |
| | | |
| | | //子accesstoken |
| | | |
| | | String ys7AccountId = accessService.getYs7AccountId(reqParams.getAccessToken()); |
| | | |
| | | Map<String, String> parms02 = new HashMap<>(2); |
| | | |
| | | parms02.put("accessToken", accessToken); |
| | | parms02.put("accountId", ys7AccountId); |
| | | String post02 = HttpUtil.httpRequestToString("https://open.ys7.com/api/lapp/ram/token/get", "post", parms02); |
| | | System.out.println(post02); |
| | | JSONObject data = JSON.parseObject(JSON.parseObject(post02).getString("data")); |
| | | |
| | | //可以单独传入http参数,这样参数会自动做URL编码,拼接在URL中 |
| | | HashMap<String, Object> paramMap = new HashMap<>(); |
| | | paramMap.put("accessToken", data.get("accessToken")); |
| | | paramMap.put("deviceSerial", reqParams.getDeviceSerial()); |
| | | paramMap.put("protocol", 2); |
| | | paramMap.put("expireTime", 720 * 60 * 60 * 24); |
| | | paramMap.put("quality", 1); |
| | | |
| | | |
| | | try { |
| | | String result = |
| | | cn.hutool.http.HttpUtil.post |
| | | ("https://open.ys7.com/api/lapp/v2/live/address/get", paramMap); |
| | | |
| | | System.out.println(result); |
| | | JSONObject url = JSON.parseObject(JSON.parseObject(result).getString("data")); |
| | | |
| | | return Msg.ok(url); |
| | | } catch (Exception e) { |
| | | return Msg.error(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |