diff --git a/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/handler/ResponseResultHandler.java b/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/handler/ResponseResultHandler.java index 84ab1697..d0bd31b8 100644 --- a/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/handler/ResponseResultHandler.java +++ b/iot-common/iot-common-web/src/main/java/cc/iotkit/common/web/handler/ResponseResultHandler.java @@ -10,11 +10,13 @@ package cc.iotkit.common.web.handler; import cc.iotkit.common.api.Response; +import cc.iotkit.common.utils.JsonUtils; import cn.dev33.satoken.util.SaResult; import cn.hutool.core.util.IdUtil; import org.springframework.core.MethodParameter; import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.http.server.ServerHttpRequest; import org.springframework.http.server.ServerHttpResponse; import org.springframework.web.bind.annotation.ControllerAdvice; @@ -26,7 +28,7 @@ import java.util.Map; public class ResponseResultHandler implements ResponseBodyAdvice { @Override public boolean supports(MethodParameter returnType, Class> converterType) { - return true; + return !converterType.equals(StringHttpMessageConverter.class); } @Override @@ -48,6 +50,8 @@ public class ResponseResultHandler implements ResponseBodyAdvice { return new Response((Integer) map.get("status"), (String) map.get("error"), "", IdUtil.simpleUUID()); } + } else if (body instanceof Response) { + return body; } return new Response(200, "", body, IdUtil.simpleUUID()); diff --git a/iot-components/iot-DLT645-component/dependency-reduced-pom.xml b/iot-components/iot-DLT645-component/dependency-reduced-pom.xml index 7172d851..06f8e6a3 100644 --- a/iot-components/iot-DLT645-component/dependency-reduced-pom.xml +++ b/iot-components/iot-DLT645-component/dependency-reduced-pom.xml @@ -3,12 +3,10 @@ iot-components cc.iotkit - 0.4.5-SNAPSHOT + ${revision} 4.0.0 - cc.iotkit iot-DLT645-component - 0.4.5-SNAPSHOT diff --git a/iot-components/iot-component-tcp/dependency-reduced-pom.xml b/iot-components/iot-component-tcp/dependency-reduced-pom.xml index 5bc831dc..4036f835 100644 --- a/iot-components/iot-component-tcp/dependency-reduced-pom.xml +++ b/iot-components/iot-component-tcp/dependency-reduced-pom.xml @@ -3,12 +3,10 @@ iot-components cc.iotkit - 0.4.5-SNAPSHOT + ${revision} 4.0.0 - cc.iotkit iot-component-tcp - 0.4.5-SNAPSHOT diff --git a/iot-components/iot-emqx-component/dependency-reduced-pom.xml b/iot-components/iot-emqx-component/dependency-reduced-pom.xml index ce15a1da..83f08d38 100644 --- a/iot-components/iot-emqx-component/dependency-reduced-pom.xml +++ b/iot-components/iot-emqx-component/dependency-reduced-pom.xml @@ -3,12 +3,10 @@ iot-components cc.iotkit - 0.4.5-SNAPSHOT + ${revision} 4.0.0 - cc.iotkit iot-emqx-component - 0.4.5-SNAPSHOT diff --git a/iot-components/iot-http-biz-component/dependency-reduced-pom.xml b/iot-components/iot-http-biz-component/dependency-reduced-pom.xml index 91363138..f15be121 100644 --- a/iot-components/iot-http-biz-component/dependency-reduced-pom.xml +++ b/iot-components/iot-http-biz-component/dependency-reduced-pom.xml @@ -3,12 +3,10 @@ iot-components cc.iotkit - 0.4.5-SNAPSHOT + ${revision} 4.0.0 - cc.iotkit iot-http-biz-component - 0.4.5-SNAPSHOT diff --git a/iot-components/iot-mqtt-component/dependency-reduced-pom.xml b/iot-components/iot-mqtt-component/dependency-reduced-pom.xml index 6a2a5b12..1c659172 100644 --- a/iot-components/iot-mqtt-component/dependency-reduced-pom.xml +++ b/iot-components/iot-mqtt-component/dependency-reduced-pom.xml @@ -3,12 +3,10 @@ iot-components cc.iotkit - 0.4.5-SNAPSHOT + ${revision} 4.0.0 - cc.iotkit iot-mqtt-component - 0.4.5-SNAPSHOT diff --git a/iot-components/iot-websocket-component/dependency-reduced-pom.xml b/iot-components/iot-websocket-component/dependency-reduced-pom.xml index fde37299..e336169d 100644 --- a/iot-components/iot-websocket-component/dependency-reduced-pom.xml +++ b/iot-components/iot-websocket-component/dependency-reduced-pom.xml @@ -3,12 +3,10 @@ iot-components cc.iotkit - 0.4.5-SNAPSHOT + ${revision} 4.0.0 - cc.iotkit iot-websocket-component - 0.4.5-SNAPSHOT diff --git a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/IBaetylService.java b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/IBaetylService.java index 97103279..1effb46f 100644 --- a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/IBaetylService.java +++ b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/IBaetylService.java @@ -25,4 +25,10 @@ public interface IBaetylService { GetNodeCoreVersionVo getNodeCoreVersion(String data); GetNodesVo getNodes(GetNodesBo data); + + GetCoreConfigVo getCoreConfig(String data); + + String getInstallCommand(GetInstallCommandBo data); + + GetNodePropertiesVo getNodeProperties(String data); } diff --git a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/controller/BartylController.java b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/controller/BartylNodeController.java similarity index 80% rename from iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/controller/BartylController.java rename to iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/controller/BartylNodeController.java index 02ea93c0..322a8bc0 100644 --- a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/controller/BartylController.java +++ b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/controller/BartylNodeController.java @@ -23,9 +23,9 @@ import org.springframework.web.bind.annotation.RestController; @Validated @RequiredArgsConstructor @RestController -@RequestMapping("/baetyl") -@Api(tags = "边缘计算管理") -public class BartylController extends BaseController { +@RequestMapping("/baetyl/node") +@Api(tags = "边缘计算节点管理") +public class BartylNodeController extends BaseController { @Autowired private IBaetylService configService; @@ -96,4 +96,23 @@ public class BartylController extends BaseController { return configService.getNodes(request.getData()); } + @ApiOperation("获取 core 配置") + @PostMapping("/getCoreConfig") + public GetCoreConfigVo getCoreConfig(@Validated @RequestBody Request request) { + return configService.getCoreConfig(request.getData()); + } + + @ApiOperation("获取安装命令") + @PostMapping("/getInstallCommand") + public String getInstallCommand(@Validated @RequestBody Request request) { + return configService.getInstallCommand(request.getData()); + } + + @ApiOperation("获取节点属性") + @PostMapping("/getNodeProperties") + public GetNodePropertiesVo getNodeProperties(@Validated @RequestBody Request request) { + return configService.getNodeProperties(request.getData()); + } + + } diff --git a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/bo/GetInstallCommandBo.java b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/bo/GetInstallCommandBo.java new file mode 100644 index 00000000..447a21a9 --- /dev/null +++ b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/bo/GetInstallCommandBo.java @@ -0,0 +1,26 @@ +package cc.iotkit.baetyl.dto.bo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author: regan + * @description: + * @date:created in 2023/6/18 16:22 + * @modificed by: + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class GetInstallCommandBo { + + @ApiModelProperty(value = "节点名称") + private String name; + + @ApiModelProperty(value = "缺省或kube为kube安装命令") + private String mode; + + +} diff --git a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/vo/GetCoreConfigVo.java b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/vo/GetCoreConfigVo.java new file mode 100644 index 00000000..006dd868 --- /dev/null +++ b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/vo/GetCoreConfigVo.java @@ -0,0 +1,27 @@ +package cc.iotkit.baetyl.dto.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author: regan + * @description: + * @date:created in 2023/6/18 15:58 + * @modificed by: + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class GetCoreConfigVo { + + @ApiModelProperty(value = "core 版本") + private String version; + + @ApiModelProperty(value = "core 上报频率") + private Integer frequency; + + @ApiModelProperty(value = "core 边缘 API 端口") + private Integer apiport; +} diff --git a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/vo/GetNodePropertiesVo.java b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/vo/GetNodePropertiesVo.java new file mode 100644 index 00000000..2d9a11f0 --- /dev/null +++ b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/vo/GetNodePropertiesVo.java @@ -0,0 +1,45 @@ +package cc.iotkit.baetyl.dto.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author: regan + * @description: + * @date:created in 2023/6/18 18:08 + * @modificed by: + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class GetNodePropertiesVo { + + @ApiModelProperty(value = "map[string]string, value必须为 string") + private GetNodePropertiesVoBodyState state; + + @ApiModelProperty(value = "map[string]string, value必须为 string") + private GetNodePropertiesVoBodyMetadata metadata; + + @Data + @AllArgsConstructor + @NoArgsConstructor + public static class GetNodePropertiesVoBodyState { + @ApiModelProperty(value = "map[string]string, value必须为 string") + private String report; + @ApiModelProperty(value = "map[string]string, value必须为 string") + private String desire; + } + + @Data + @AllArgsConstructor + @NoArgsConstructor + public static class GetNodePropertiesVoBodyMetadata { + + @ApiModelProperty(value = "map[string]string, value必须为 string") + private String report; + @ApiModelProperty(value = "map[string]string, value必须为 string") + private String desire; + } +} diff --git a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/feign/BaetylServiceFeignClient.java b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/feign/BaetylServiceFeignClient.java index d32296ab..cd7977f1 100644 --- a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/feign/BaetylServiceFeignClient.java +++ b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/feign/BaetylServiceFeignClient.java @@ -45,4 +45,10 @@ public interface BaetylServiceFeignClient { GetNodesVo getNodes(@RequestParam(value = "selector") String selector, @RequestParam(value = "fieldSelector") String fieldSelector, @RequestParam(value = "limit") Integer limit, @RequestParam(value = "continue") String isContinue, @RequestParam(value = "pageNo") Integer pageNo, @RequestParam(value = "pageSize") Integer pageSize, @RequestParam(value = "name") String name, @RequestParam(value = "nodeSelector") String nodeSelector); + @GetMapping(value = BaetylConstant.Url.NodeManagement.GetCoreConfig) + GetCoreConfigVo getCoreConfig(@PathVariable(value = "name") String name); + @GetMapping(value = BaetylConstant.Url.NodeManagement.GetInstallCommand) + String getInstallCommand(@PathVariable(value = "name") String name, @RequestParam(value = "mode") String mode); + @GetMapping(value = BaetylConstant.Url.NodeManagement.GetNodeProperties) + GetNodePropertiesVo getNodeProperties(@PathVariable(value = "name") String data); } diff --git a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/service/BaetylServiceFeignImpl.java b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/service/BaetylServiceFeignImpl.java index 898e21a8..33e249d5 100644 --- a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/service/BaetylServiceFeignImpl.java +++ b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/service/BaetylServiceFeignImpl.java @@ -74,4 +74,19 @@ public class BaetylServiceFeignImpl implements IBaetylService { return client.getNodes(data.getSelector(),data.getFieldSelector(),data.getLimit(),data.getIsContinue(),data.getPageNo(),data.getPageSize(), data.getName(),data.getNodeSelector()); } + + @Override + public GetCoreConfigVo getCoreConfig(String data) { + return client.getCoreConfig(data); + } + + @Override + public String getInstallCommand(GetInstallCommandBo data) { + return client.getInstallCommand(data.getName(),data.getMode()); + } + + @Override + public GetNodePropertiesVo getNodeProperties(String data) { + return client.getNodeProperties(data); + } } diff --git a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/service/BaetylServiceWebclientImpl.java b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/service/BaetylServiceWebclientImpl.java index 613556e7..111aab33 100644 --- a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/service/BaetylServiceWebclientImpl.java +++ b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/service/BaetylServiceWebclientImpl.java @@ -84,4 +84,19 @@ public class BaetylServiceWebclientImpl implements IBaetylService { public GetNodesVo getNodes(GetNodesBo data) { return null; } + + @Override + public GetCoreConfigVo getCoreConfig(String data) { + return null; + } + + @Override + public String getInstallCommand(GetInstallCommandBo data) { + return null; + } + + @Override + public GetNodePropertiesVo getNodeProperties(String data) { + return null; + } } diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java index 11c3520d..d830a7e3 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java @@ -237,6 +237,7 @@ public class SysRoleServiceImpl implements ISysRoleService { * @param status 角色状态 */ @Override + @Transactional(rollbackFor = Exception.class) public void updateRoleStatus(Long roleId, String status) { SysRole sysRole = new SysRole(); sysRole.setId(roleId);