| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.common.util.concurrent.RateLimiter; |
| | | import com.google.gson.Gson; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | RateLimiter rateLimiter = RateLimiter.create(10.0); |
| | | |
| | | |
| | | @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()); |
| | | |
| | | |
| | | if(userId == null){ |
| | | 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); |