*
This commit is contained in:
parent
3d94bb3a31
commit
9eeeeea273
@ -202,7 +202,7 @@ public class UserController {
|
||||
*/
|
||||
@PostMapping("/login/pwd")
|
||||
public Mono<JSONObject> loginByPwd(@RequestBody JSONObject jsonObject) {
|
||||
log.info("UserController[]loginByPwd[]jsonObject:{}", jsonObject);
|
||||
//log.info("UserController[]loginByPwd[]jsonObject:{}", jsonObject);
|
||||
return webClient.post().uri(baseUrl + pwdUrl).bodyValue(getMultiValueMap(jsonObject)).retrieve()
|
||||
.bodyToMono(JSONObject.class)
|
||||
.doOnNext(res -> {
|
||||
|
||||
@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
/**
|
||||
* XXX
|
||||
@ -17,94 +18,24 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
@SpringBootTest(classes = IotBoxUserApiApplication.class)
|
||||
@Slf4j
|
||||
public class UserTest {
|
||||
|
||||
public String deviceId = "6c4a153095be2b7f8baofp";
|
||||
|
||||
public String spaceId = "163257138";
|
||||
|
||||
@Autowired
|
||||
private TuyaDeviceConnector tuyaDeviceConnector;
|
||||
|
||||
@Test
|
||||
public void 查询所有分类() {
|
||||
JSONArray aa = tuyaDeviceConnector.categories();
|
||||
aa.forEach(System.out::println);
|
||||
public static void main(String[] args) {
|
||||
// WebClient client = WebClient.builder().build();
|
||||
// Mono<String> jsonObjectMono = client.get().uri("http://www.baidu.com").retrieve()
|
||||
// .bodyToMono(String.class);
|
||||
// return jsonObjectMono;
|
||||
// Flux.just(1, 2).zipWith(Flux.just(3, 4), (s1, s2) ->
|
||||
// String.format("%s+%s=%s", s1, s2, s1 + s2))
|
||||
// .subscribe(System.out::println);
|
||||
|
||||
// Flux.range(1,7).window(2).toIterable().forEach( w -> {
|
||||
// w.subscribe(System.out::println);
|
||||
// System.out.println("----------");
|
||||
// });
|
||||
|
||||
Flux.concat(
|
||||
Flux.range(4,2),
|
||||
Flux.range(1,3),
|
||||
Flux.range(6,5)
|
||||
).subscribe(System.out::println);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 转移设备() {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("space_id", "163257138");
|
||||
Boolean aBoolean = tuyaDeviceConnector.transferDevice(deviceId, jsonObject);
|
||||
System.out.println(aBoolean);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 获取设备支持的指令集() {
|
||||
Object functions = tuyaDeviceConnector.getFunctions(deviceId);
|
||||
System.out.println(functions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 修改空间() {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name", "testname");
|
||||
Boolean jsonObject1 = tuyaDeviceConnector.updateSpace(spaceId, jsonObject);
|
||||
System.out.println(jsonObject1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 查询空间() {
|
||||
//40001900
|
||||
JSONObject spaceInfo = tuyaDeviceConnector.getSpaceInfo("163257138");
|
||||
System.out.println(spaceInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 删除空间() {
|
||||
//40001900
|
||||
Boolean jsonObject = tuyaDeviceConnector.deleteSpace("163258893");
|
||||
System.out.println(jsonObject);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 创建空间() {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("name", "space1_2");
|
||||
jsonObject.put("description", "space1_2的空间描述");
|
||||
Long jsonObject1 = tuyaDeviceConnector.creatSpace(jsonObject);
|
||||
System.out.println(jsonObject1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 控制设备动作() {
|
||||
JSONObject commands = new JSONObject();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("code", "switch_led");
|
||||
jsonObject.put("value", true);
|
||||
JSONObject js2 = new JSONObject();
|
||||
js2.put("code", "work_mode");
|
||||
js2.put("value", "colour");
|
||||
JSONObject js3 = new JSONObject();
|
||||
js3.put("code", "bright_value_v2");
|
||||
js3.put("value", 10);
|
||||
commands.put("commands", Arrays.asList( js3));
|
||||
|
||||
Object controlDevice = tuyaDeviceConnector.controlDevice(deviceId,commands);
|
||||
System.out.println(controlDevice);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 查询空间下设备列表() {
|
||||
JSONArray devicesBySpaceIds = tuyaDeviceConnector.getDevicesBySpaceIds("163257138", 20);
|
||||
System.out.println(devicesBySpaceIds);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void 查询设备信息() {
|
||||
JSONArray byid = tuyaDeviceConnector.getByid(deviceId);
|
||||
System.out.println(byid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user