diff --git a/pom.xml b/pom.xml index 077b0de..7ecb31f 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,8 @@ 1.8 2.6 - + 3.4.1 + 3.21.0.1 @@ -71,6 +72,19 @@ ${commons.version} + + diff --git a/src/main/java/com/example/zxweb/KafkaApplication.java b/src/main/java/com/example/zxweb/KafkaApplication.java index fda12b2..34c05f5 100644 --- a/src/main/java/com/example/zxweb/KafkaApplication.java +++ b/src/main/java/com/example/zxweb/KafkaApplication.java @@ -2,12 +2,16 @@ package com.example.zxweb; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.core.env.Environment; @SpringBootApplication public class KafkaApplication { public static void main(String[] args) { - SpringApplication.run(KafkaApplication.class, args); + ConfigurableApplicationContext context = SpringApplication.run(KafkaApplication.class, args); + Environment bean = context.getBean(Environment.class); + System.out.println("---启动完成,当前使用端口:[" + bean.getProperty("local.server.port") + "]---"); } } diff --git a/src/main/java/com/example/zxweb/controller/GatewayController.java b/src/main/java/com/example/zxweb/controller/GatewayController.java new file mode 100644 index 0000000..cc0254f --- /dev/null +++ b/src/main/java/com/example/zxweb/controller/GatewayController.java @@ -0,0 +1,38 @@ +package com.example.zxweb.controller; + +import com.alibaba.fastjson.JSONObject; +import com.example.zxweb.common.api.vo.Result; +import com.example.zxweb.common.constant.enums.IotApiEnum; +import com.example.zxweb.utils.AssertUtils; +import com.example.zxweb.utils.IotUtils; +import io.swagger.annotations.Api; +import lombok.extern.slf4j.Slf4j; +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; + +/** + * @Description + * @Author ZhouWenTao + * @Date 2023/9/12 10:28 + */ +@RestController +@RequestMapping("/gateway") +@Slf4j +@Api(tags = "网关设备管理") +public class GatewayController { + /** + * 获取网关策略列表 + * @param devid 网关设备id + * @return 结果 + */ + @GetMapping(value = "/celueListQuery") + public Result celueListQuery(@RequestParam(value = "devid")String devid){ + AssertUtils.notEmpty(devid,"请输入-[devid]"); + String format = String.format("{\"serial\":\"%s\",\"productId\":\"\",\"methodName\":\"celueListQuery\",\"inputData\":{\"devid\":\"%s\"}}", devid,devid); + JSONObject requestBody = JSONObject.parseObject(format); + JSONObject responseBody = IotUtils.postApi(IotApiEnum.getPathByText("向设备发送方法"), requestBody); + return Result.OK(responseBody); + } +} diff --git a/src/main/java/com/example/zxweb/vo/IotRquestBodyPVO.java b/src/main/java/com/example/zxweb/vo/IotRquestBodyPVO.java new file mode 100644 index 0000000..c42a247 --- /dev/null +++ b/src/main/java/com/example/zxweb/vo/IotRquestBodyPVO.java @@ -0,0 +1,33 @@ +package com.example.zxweb.vo; + +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description + * @Author ZhouWenTao + * @Date 2023/9/12 11:28 + */ +@Data +public class IotRquestBodyPVO implements Serializable { + @ApiModelProperty(value = "serial") + private String serial; + @ApiModelProperty(value = "productId") + private String productId; + @ApiModelProperty(value = "方法名") + private String methodName; + @ApiModelProperty(value = "方法执行参数") + private JSONObject inputData; + + public IotRquestBodyPVO() {} + + public IotRquestBodyPVO(String serial, String productId, String methodName, JSONObject inputData) { + this.serial = serial; + this.productId = productId; + this.methodName = methodName; + this.inputData = inputData; + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 408d6c4..759ef24 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -21,7 +21,16 @@ spring: send.buffer.bytes: 131072 #??128KB???socket???????????-1?????????? request.timeout.ms: 10000 #??30000ms?????????????? transaction.timeout.ms: 5000 - +# #数据库配置 +# datasource: +# driver-class-name: org.sqlite.JDBC +# url: jdbc:sqlite:E:\\demo.db +# #username: +# #password: +##控制台打印SQL语句 +#mybatis-plus: +# configuration: +# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl key: dwVendor secret: fEVcb^QFB;IN$K5 -appCode: 42142fd0jkbf4515853b7fcec64748f6 \ No newline at end of file +appCode: 42142fd0jkbf4515853b7fcec64748f6