打開nacos

This commit is contained in:
wulin 2023-09-21 19:40:05 +08:00
parent 71d9895192
commit 9d4c0030fe
3 changed files with 33 additions and 124 deletions

View File

@ -33,36 +33,35 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis-reactive</artifactId>
</dependency>
<!-- 基礎通用功能 -->
<dependency>
<groupId>org.hswebframework.web</groupId>
<artifactId>hsweb-commons-crud</artifactId>
<version>${hswebframework.version}</version>
</dependency>
<!-- 權限控制 -->
<dependency>
<groupId>org.hswebframework.web</groupId>
<artifactId>hsweb-system-authorization-default</artifactId>
<version>${hswebframework.version}</version>
</dependency>
<dependency>
<groupId>org.hswebframework</groupId>
<artifactId>hsweb-easy-orm-rdb</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis-reactive</artifactId>
</dependency>
<!-- 模塊啓動器 -->
<dependency>
<groupId>org.hswebframework.web</groupId>
<artifactId>hsweb-starter</artifactId>
<version>${hswebframework.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
@ -84,13 +83,20 @@
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- 下面都是響應式數據庫相關-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-r2dbc</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<!-- ORM工具數據 -->
<dependency>
<groupId>org.hswebframework</groupId>
<artifactId>hsweb-easy-orm-rdb</artifactId>
<version>4.1.1</version>
</dependency>
<!-- MySQL數據 -->
<dependency>
<groupId>dev.miku</groupId>
<artifactId>r2dbc-mysql</artifactId>
@ -104,6 +110,7 @@
<type>pom</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>

View File

@ -1,110 +0,0 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.qiuguo.iot.user.api.IotBoxUserApiApplication;
import com.qiuguo.iot.user.api.service.TuyaDeviceConnector;
import java.util.Arrays;
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;
/**
* XXX
*
* @author weiyachao
* @since 2023/9/5 16:03
*/
@SpringBootTest(classes = IotBoxUserApiApplication.class)
@Slf4j
public class UserTest {
public String deviceId = "6cae26f5512eee7c12aqd9";
public String spaceId = "163257138";
@Autowired
private TuyaDeviceConnector tuyaDeviceConnector;
@Test
public void 查询所有分类() {
JSONArray aa = tuyaDeviceConnector.categories();
aa.forEach(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(jsonObject));
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);
}
}

View File

@ -21,7 +21,19 @@
</properties>
<dependencies>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>2021.0.1.0</version>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2021.0.1.0</version>
</dependency>
<!--下面两个bootstrap.yml启动-->
<dependency>