fix(设备中心):获取IOT平台token接口优化
This commit is contained in:
+10
-3
@@ -1,6 +1,7 @@
|
||||
package com.central.device.controller.token;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.util.Utils;
|
||||
import com.central.device.util.http.HeaderUtils;
|
||||
@@ -11,6 +12,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
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.RestController;
|
||||
@@ -36,10 +38,10 @@ public class ApiTokenController {
|
||||
private HeaderUtils headerUtils;
|
||||
|
||||
@Operation(summary = "客户端获取通信平台token")
|
||||
@GetMapping("_query")
|
||||
@GetMapping("/query")
|
||||
public Result token() throws IOException {
|
||||
|
||||
String url = jetlinksServiceUrl+"/api/v1/token";
|
||||
String url = jetlinksServiceUrl+"/token";
|
||||
|
||||
HttpRequest request = new SimpleHttpRequest(url);
|
||||
|
||||
@@ -51,6 +53,11 @@ public class ApiTokenController {
|
||||
|
||||
Response response = request.post();
|
||||
Map<String, String> result = Utils.queryStringToMap(new String(response.asBytes(), "utf8"), "utf8");
|
||||
return Result.succeed("data",result.get(""));
|
||||
JSONObject jsonObject = JSON.parseObject(result.get(""));
|
||||
Assert.notNull(jsonObject,"获取IOT数据异常");
|
||||
if (jsonObject.getString("message").equals("success")) {
|
||||
return Result.succeed(jsonObject,"获取成功");
|
||||
}
|
||||
return Result.failed("请重试");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user