feat:设备运维ops管理模块功能新增
This commit is contained in:
+12
-7
@@ -10,11 +10,13 @@ import com.central.device.util.http.Response;
|
||||
import com.central.device.util.http.SimpleHttpRequest;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -39,24 +41,27 @@ public class ApiTokenController {
|
||||
|
||||
@Operation(summary = "客户端获取通信平台token")
|
||||
@GetMapping("/query")
|
||||
public Result token() throws IOException {
|
||||
public Result token(@RequestParam(required = false) String expires) throws IOException {
|
||||
|
||||
String url = jetlinksServiceUrl+"/token";
|
||||
if (StringUtils.isBlank(expires)) {
|
||||
expires = String.valueOf(7200);
|
||||
}
|
||||
|
||||
String url = jetlinksServiceUrl + "/token";
|
||||
|
||||
HttpRequest request = new SimpleHttpRequest(url);
|
||||
|
||||
Map<String,Object> param = new HashMap<>(2);
|
||||
param.put("expires",7200*24);
|
||||
Map<String, Object> param = new HashMap<>(2);
|
||||
param.put("expires", expires);
|
||||
request.headers(headerUtils.createHeadersOfJsonString(JSON.toJSONString(param)));
|
||||
request.requestBody(JSON.toJSONString(param));
|
||||
|
||||
|
||||
Response response = request.post();
|
||||
Map<String, String> result = Utils.queryStringToMap(new String(response.asBytes(), "utf8"), "utf8");
|
||||
JSONObject jsonObject = JSON.parseObject(result.get(""));
|
||||
Assert.notNull(jsonObject,"获取IOT数据异常");
|
||||
Assert.notNull(jsonObject, "获取IOT数据异常");
|
||||
if (jsonObject.getString("message").equals("success")) {
|
||||
return Result.succeed(jsonObject,"获取成功");
|
||||
return Result.succeed(jsonObject, "获取成功");
|
||||
}
|
||||
return Result.failed("请重试");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user