Commit cbfbc55cd8612296978b56a122972a35e0e4c5da
1 parent
8ca9bebf
【功能完善】IoT: 添加插件和插件实例管理功能,包括插件信息的增删改查接口,支持文件上传和状态更新,同时优化了枚举类型的处理逻辑。
Showing
23 changed files
with
99 additions
and
284 deletions
plugins/yudao-module-iot-http-plugin-2.2.0-snapshot.jar
No preview for this file type
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/plugin/IotPluginDeployTypeEnum.java
| @@ -34,12 +34,10 @@ public enum IotPluginDeployTypeEnum implements IntArrayValuable { | @@ -34,12 +34,10 @@ public enum IotPluginDeployTypeEnum implements IntArrayValuable { | ||
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | public static IotPluginDeployTypeEnum fromDeployType(Integer deployType) { | 36 | public static IotPluginDeployTypeEnum fromDeployType(Integer deployType) { |
| 37 | - for (IotPluginDeployTypeEnum value : values()) { | ||
| 38 | - if (value.getDeployType().equals(deployType)) { | ||
| 39 | - return value; | ||
| 40 | - } | ||
| 41 | - } | ||
| 42 | - return null; | 37 | + return Arrays.stream(values()) |
| 38 | + .filter(value -> value.getDeployType().equals(deployType)) | ||
| 39 | + .findFirst() | ||
| 40 | + .orElse(null); | ||
| 43 | } | 41 | } |
| 44 | 42 | ||
| 45 | public static boolean isValidDeployType(Integer deployType) { | 43 | public static boolean isValidDeployType(Integer deployType) { |
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/plugin/IotPluginStatusEnum.java
| @@ -34,12 +34,10 @@ public enum IotPluginStatusEnum implements IntArrayValuable { | @@ -34,12 +34,10 @@ public enum IotPluginStatusEnum implements IntArrayValuable { | ||
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | public static IotPluginStatusEnum fromState(Integer state) { | 36 | public static IotPluginStatusEnum fromState(Integer state) { |
| 37 | - for (IotPluginStatusEnum value : values()) { | ||
| 38 | - if (value.getStatus().equals(state)) { | ||
| 39 | - return value; | ||
| 40 | - } | ||
| 41 | - } | ||
| 42 | - return null; | 37 | + return Arrays.stream(values()) |
| 38 | + .filter(value -> value.getStatus().equals(state)) | ||
| 39 | + .findFirst() | ||
| 40 | + .orElse(null); | ||
| 43 | } | 41 | } |
| 44 | 42 | ||
| 45 | @Override | 43 | @Override |
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/plugin/IotPluginTypeEnum.java
| @@ -35,14 +35,11 @@ public enum IotPluginTypeEnum implements IntArrayValuable { | @@ -35,14 +35,11 @@ public enum IotPluginTypeEnum implements IntArrayValuable { | ||
| 35 | return ARRAYS; | 35 | return ARRAYS; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | - // TODO @haohao:可以使用 hutool 简化 | ||
| 39 | public static IotPluginTypeEnum fromType(Integer type) { | 38 | public static IotPluginTypeEnum fromType(Integer type) { |
| 40 | - for (IotPluginTypeEnum value : values()) { | ||
| 41 | - if (value.getType().equals(type)) { | ||
| 42 | - return value; | ||
| 43 | - } | ||
| 44 | - } | ||
| 45 | - return null; | 39 | + return Arrays.stream(values()) |
| 40 | + .filter(value -> value.getType().equals(type)) | ||
| 41 | + .findFirst() | ||
| 42 | + .orElse(null); | ||
| 46 | } | 43 | } |
| 47 | 44 | ||
| 48 | public static boolean isValidType(Integer type) { | 45 | public static boolean isValidType(Integer type) { |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugininfo/PluginInfoController.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/PluginInfoController.java
| 1 | -package cn.iocoder.yudao.module.iot.controller.admin.plugininfo; | 1 | +package cn.iocoder.yudao.module.iot.controller.admin.plugin; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | -import cn.iocoder.yudao.module.iot.controller.admin.plugininfo.vo.PluginInfoImportReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.iot.controller.admin.plugininfo.vo.PluginInfoPageReqVO; | ||
| 8 | -import cn.iocoder.yudao.module.iot.controller.admin.plugininfo.vo.PluginInfoRespVO; | ||
| 9 | -import cn.iocoder.yudao.module.iot.controller.admin.plugininfo.vo.PluginInfoSaveReqVO; | 6 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.PluginInfoImportReqVO; |
| 7 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.PluginInfoPageReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.PluginInfoRespVO; | ||
| 9 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.PluginInfoSaveReqVO; | ||
| 10 | import cn.iocoder.yudao.module.iot.dal.dataobject.plugininfo.PluginInfoDO; | 10 | import cn.iocoder.yudao.module.iot.dal.dataobject.plugininfo.PluginInfoDO; |
| 11 | -import cn.iocoder.yudao.module.iot.service.plugininfo.PluginInfoService; | 11 | +import cn.iocoder.yudao.module.iot.service.plugin.PluginInfoService; |
| 12 | import io.swagger.v3.oas.annotations.Operation; | 12 | import io.swagger.v3.oas.annotations.Operation; |
| 13 | import io.swagger.v3.oas.annotations.Parameter; | 13 | import io.swagger.v3.oas.annotations.Parameter; |
| 14 | import io.swagger.v3.oas.annotations.tags.Tag; | 14 | import io.swagger.v3.oas.annotations.tags.Tag; |
| @@ -72,6 +72,7 @@ public class PluginInfoController { | @@ -72,6 +72,7 @@ public class PluginInfoController { | ||
| 72 | 72 | ||
| 73 | @PostMapping("/upload-file") | 73 | @PostMapping("/upload-file") |
| 74 | @Operation(summary = "上传插件文件") | 74 | @Operation(summary = "上传插件文件") |
| 75 | + @PreAuthorize("@ss.hasPermission('iot:plugin-info:update')") | ||
| 75 | public CommonResult<Boolean> uploadFile(@Valid PluginInfoImportReqVO reqVO) { | 76 | public CommonResult<Boolean> uploadFile(@Valid PluginInfoImportReqVO reqVO) { |
| 76 | pluginInfoService.uploadFile(reqVO.getId(), reqVO.getFile()); | 77 | pluginInfoService.uploadFile(reqVO.getId(), reqVO.getFile()); |
| 77 | return success(true); | 78 | return success(true); |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugininstance/PluginInstanceController.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/PluginInstanceController.java
| 1 | -package cn.iocoder.yudao.module.iot.controller.admin.plugininstance; | ||
| 2 | - | ||
| 3 | -import org.springframework.web.bind.annotation.*; | ||
| 4 | -import jakarta.annotation.Resource; | ||
| 5 | -import org.springframework.validation.annotation.Validated; | ||
| 6 | -import org.springframework.security.access.prepost.PreAuthorize; | ||
| 7 | -import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 8 | -import io.swagger.v3.oas.annotations.Parameter; | ||
| 9 | -import io.swagger.v3.oas.annotations.Operation; | ||
| 10 | - | ||
| 11 | -import jakarta.validation.*; | ||
| 12 | -import jakarta.servlet.http.*; | ||
| 13 | -import java.util.*; | ||
| 14 | -import java.io.IOException; | 1 | +package cn.iocoder.yudao.module.iot.controller.admin.plugin; |
| 15 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 16 | import cn.iocoder.yudao.framework.common.pojo.PageParam; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 17 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 18 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 19 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 20 | -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 21 | - | ||
| 22 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | 8 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 9 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.PluginInstancePageReqVO; | ||
| 10 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.PluginInstanceRespVO; | ||
| 11 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.PluginInstanceSaveReqVO; | ||
| 12 | +import cn.iocoder.yudao.module.iot.dal.dataobject.plugininstance.PluginInstanceDO; | ||
| 13 | +import cn.iocoder.yudao.module.iot.service.plugin.PluginInstanceService; | ||
| 14 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 15 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 16 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 17 | +import jakarta.annotation.Resource; | ||
| 18 | +import jakarta.servlet.http.HttpServletResponse; | ||
| 19 | +import jakarta.validation.Valid; | ||
| 20 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 21 | +import org.springframework.validation.annotation.Validated; | ||
| 22 | +import org.springframework.web.bind.annotation.*; | ||
| 23 | 23 | ||
| 24 | -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | ||
| 25 | -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; | 24 | +import java.io.IOException; |
| 25 | +import java.util.List; | ||
| 26 | 26 | ||
| 27 | -import cn.iocoder.yudao.module.iot.controller.admin.plugininstance.vo.*; | ||
| 28 | -import cn.iocoder.yudao.module.iot.dal.dataobject.plugininstance.PluginInstanceDO; | ||
| 29 | -import cn.iocoder.yudao.module.iot.service.plugininstance.PluginInstanceService; | 27 | +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| 28 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 30 | 29 | ||
| 31 | @Tag(name = "管理后台 - IoT 插件实例") | 30 | @Tag(name = "管理后台 - IoT 插件实例") |
| 32 | @RestController | 31 | @RestController |
| @@ -78,17 +77,4 @@ public class PluginInstanceController { | @@ -78,17 +77,4 @@ public class PluginInstanceController { | ||
| 78 | return success(BeanUtils.toBean(pageResult, PluginInstanceRespVO.class)); | 77 | return success(BeanUtils.toBean(pageResult, PluginInstanceRespVO.class)); |
| 79 | } | 78 | } |
| 80 | 79 | ||
| 81 | - @GetMapping("/export-excel") | ||
| 82 | - @Operation(summary = "导出IoT 插件实例 Excel") | ||
| 83 | - @PreAuthorize("@ss.hasPermission('iot:plugin-instance:export')") | ||
| 84 | - @ApiAccessLog(operateType = EXPORT) | ||
| 85 | - public void exportPluginInstanceExcel(@Valid PluginInstancePageReqVO pageReqVO, | ||
| 86 | - HttpServletResponse response) throws IOException { | ||
| 87 | - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 88 | - List<PluginInstanceDO> list = pluginInstanceService.getPluginInstancePage(pageReqVO).getList(); | ||
| 89 | - // 导出 Excel | ||
| 90 | - ExcelUtils.write(response, "IoT 插件实例.xls", "数据", PluginInstanceRespVO.class, | ||
| 91 | - BeanUtils.toBean(list, PluginInstanceRespVO.class)); | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | } | 80 | } |
| 95 | \ No newline at end of file | 81 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugininfo/vo/PluginInfoImportReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/PluginInfoImportReqVO.java
| 1 | -package cn.iocoder.yudao.module.iot.controller.admin.plugininfo.vo; | 1 | +package cn.iocoder.yudao.module.iot.controller.admin.plugin.vo; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import jakarta.validation.constraints.NotNull; | 4 | import jakarta.validation.constraints.NotNull; |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/PluginInfoPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.controller.admin.plugin.vo; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +@Schema(description = "管理后台 - IoT 插件信息分页 Request VO") | ||
| 8 | +@Data | ||
| 9 | +public class PluginInfoPageReqVO extends PageParam { | ||
| 10 | + | ||
| 11 | + @Schema(description = "插件名称", example = "http") | ||
| 12 | + private String name; | ||
| 13 | + | ||
| 14 | + @Schema(description = "状态") | ||
| 15 | + private Integer status; | ||
| 16 | + | ||
| 17 | +} | ||
| 0 | \ No newline at end of file | 18 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugininfo/vo/PluginInfoRespVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/PluginInfoRespVO.java
| 1 | -package cn.iocoder.yudao.module.iot.controller.admin.plugininfo.vo; | 1 | +package cn.iocoder.yudao.module.iot.controller.admin.plugin.vo; |
| 2 | 2 | ||
| 3 | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | 3 | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| 4 | import com.alibaba.excel.annotation.ExcelProperty; | 4 | import com.alibaba.excel.annotation.ExcelProperty; |
| @@ -34,7 +34,7 @@ public class PluginInfoRespVO { | @@ -34,7 +34,7 @@ public class PluginInfoRespVO { | ||
| 34 | 34 | ||
| 35 | @Schema(description = "插件包文件名", requiredMode = Schema.RequiredMode.REQUIRED) | 35 | @Schema(description = "插件包文件名", requiredMode = Schema.RequiredMode.REQUIRED) |
| 36 | @ExcelProperty("插件包文件名") | 36 | @ExcelProperty("插件包文件名") |
| 37 | - private String file; | 37 | + private String fileName; |
| 38 | 38 | ||
| 39 | @Schema(description = "插件版本", requiredMode = Schema.RequiredMode.REQUIRED) | 39 | @Schema(description = "插件版本", requiredMode = Schema.RequiredMode.REQUIRED) |
| 40 | @ExcelProperty("插件版本") | 40 | @ExcelProperty("插件版本") |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugininfo/vo/PluginInfoSaveReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/PluginInfoSaveReqVO.java
| 1 | -package cn.iocoder.yudao.module.iot.controller.admin.plugininfo.vo; | 1 | +package cn.iocoder.yudao.module.iot.controller.admin.plugin.vo; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.*; | 4 | import lombok.*; |
| @@ -23,7 +23,7 @@ public class PluginInfoSaveReqVO { | @@ -23,7 +23,7 @@ public class PluginInfoSaveReqVO { | ||
| 23 | private Integer deployType; | 23 | private Integer deployType; |
| 24 | 24 | ||
| 25 | @Schema(description = "插件包文件名", requiredMode = Schema.RequiredMode.REQUIRED) | 25 | @Schema(description = "插件包文件名", requiredMode = Schema.RequiredMode.REQUIRED) |
| 26 | - private String file; | 26 | + private String fileName; |
| 27 | 27 | ||
| 28 | @Schema(description = "插件版本", requiredMode = Schema.RequiredMode.REQUIRED) | 28 | @Schema(description = "插件版本", requiredMode = Schema.RequiredMode.REQUIRED) |
| 29 | private String version; | 29 | private String version; |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugininstance/vo/PluginInstancePageReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/PluginInstancePageReqVO.java
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugininstance/vo/PluginInstanceRespVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/PluginInstanceRespVO.java
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugininstance/vo/PluginInstanceSaveReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugin/vo/PluginInstanceSaveReqVO.java
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugininfo/PluginController.java deleted
| 1 | -package cn.iocoder.yudao.module.iot.controller.admin.plugininfo; | ||
| 2 | - | ||
| 3 | -import jakarta.annotation.Resource; | ||
| 4 | -import org.pf4j.spring.SpringPluginManager; | ||
| 5 | -import org.springframework.beans.factory.annotation.Value; | ||
| 6 | -import org.springframework.http.HttpStatus; | ||
| 7 | -import org.springframework.http.ResponseEntity; | ||
| 8 | -import org.springframework.web.bind.annotation.*; | ||
| 9 | -import org.springframework.web.multipart.MultipartFile; | ||
| 10 | - | ||
| 11 | -import javax.annotation.security.PermitAll; | ||
| 12 | -import java.io.IOException; | ||
| 13 | -import java.nio.file.Files; | ||
| 14 | -import java.nio.file.Path; | ||
| 15 | -import java.nio.file.Paths; | ||
| 16 | -import java.nio.file.StandardCopyOption; | ||
| 17 | -import java.util.List; | ||
| 18 | -import java.util.stream.Collectors; | ||
| 19 | - | ||
| 20 | -/** | ||
| 21 | - * 插件 Controller 测试用例 | ||
| 22 | - */ | ||
| 23 | -@RestController | ||
| 24 | -@RequestMapping("/iot/plugins") | ||
| 25 | -public class PluginController { | ||
| 26 | - | ||
| 27 | - @Resource | ||
| 28 | - private SpringPluginManager springPluginManager; | ||
| 29 | - | ||
| 30 | - @Value("${pf4j.pluginsDir}") | ||
| 31 | - private String pluginsDir; | ||
| 32 | - | ||
| 33 | - /** | ||
| 34 | - * 上传插件 JAR 文件并加载插件 | ||
| 35 | - * | ||
| 36 | - * @param file 上传的 JAR 文件 | ||
| 37 | - * @return 上传结果 | ||
| 38 | - */ | ||
| 39 | - @PermitAll | ||
| 40 | - @PostMapping("/upload") | ||
| 41 | - public ResponseEntity<String> uploadPlugin(@RequestParam("file") MultipartFile file) { | ||
| 42 | - if (file.isEmpty()) { | ||
| 43 | - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("上传的文件为空"); | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - // 确保插件目录存在 | ||
| 47 | - Path pluginsPath = Paths.get(pluginsDir); | ||
| 48 | - try { | ||
| 49 | - if (!Files.exists(pluginsPath)) { | ||
| 50 | - Files.createDirectories(pluginsPath); | ||
| 51 | - } | ||
| 52 | - | ||
| 53 | - // 保存上传的 JAR 文件到插件目录 | ||
| 54 | - String filename = file.getOriginalFilename(); | ||
| 55 | - if (filename == null || (!filename.endsWith(".jar") && !filename.endsWith(".zip"))) { | ||
| 56 | - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("上传的文件不是 JAR 或 ZIP 文件"); | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - Path jarPath = pluginsPath.resolve(filename); | ||
| 60 | - | ||
| 61 | - Files.copy(file.getInputStream(), jarPath, StandardCopyOption.REPLACE_EXISTING); | ||
| 62 | - | ||
| 63 | - // 加载插件 | ||
| 64 | - String pluginId = springPluginManager.loadPlugin(jarPath.toAbsolutePath()); | ||
| 65 | - | ||
| 66 | - // 启动插件 | ||
| 67 | - springPluginManager.startPlugin(pluginId); | ||
| 68 | - | ||
| 69 | - return ResponseEntity.ok("插件上传并加载成功"); | ||
| 70 | - } catch (IOException e) { | ||
| 71 | - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("上传插件时发生错误: " + e.getMessage()); | ||
| 72 | - } catch (Exception e) { | ||
| 73 | - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("加载插件时发生错误: " + e.getMessage()); | ||
| 74 | - } | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - /** | ||
| 78 | - * 卸载指定插件 | ||
| 79 | - * | ||
| 80 | - * @param pluginId 插件 ID | ||
| 81 | - * @return 卸载结果 | ||
| 82 | - */ | ||
| 83 | - @PermitAll | ||
| 84 | - @DeleteMapping("/unload/{pluginId}") | ||
| 85 | - public ResponseEntity<String> unloadPlugin(@PathVariable String pluginId) { | ||
| 86 | - if (springPluginManager.getPlugins().stream().noneMatch(plugin -> plugin.getDescriptor().getPluginId().equals(pluginId))) { | ||
| 87 | - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("插件未加载: " + pluginId); | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - springPluginManager.stopPlugin(pluginId); | ||
| 91 | - springPluginManager.unloadPlugin(pluginId); | ||
| 92 | - | ||
| 93 | - // 删除插件 JAR 文件(可选) | ||
| 94 | -// PluginWrapper plugin = pluginManager.getPlugin(pluginId); | ||
| 95 | -// PluginDescriptor descriptor = plugin.getDescriptor(); | ||
| 96 | -// Path jarPath = Paths.get(pluginsDir).resolve(descriptor.getPluginId() + ".jar"); | ||
| 97 | -// Files.deleteIfExists(jarPath); | ||
| 98 | - | ||
| 99 | - return ResponseEntity.ok("插件卸载成功: " + pluginId); | ||
| 100 | - } | ||
| 101 | - | ||
| 102 | - /** | ||
| 103 | - * 列出所有已加载的插件 | ||
| 104 | - * | ||
| 105 | - * @return 插件列表 | ||
| 106 | - */ | ||
| 107 | - @PermitAll | ||
| 108 | - @GetMapping("/list") | ||
| 109 | - public ResponseEntity<List<String>> listPlugins() { | ||
| 110 | - List<String> plugins = springPluginManager.getPlugins().stream() | ||
| 111 | - .map(plugin -> plugin.getDescriptor().getPluginId()) | ||
| 112 | - .collect(Collectors.toList()); | ||
| 113 | - return ResponseEntity.ok(plugins); | ||
| 114 | - } | ||
| 115 | - | ||
| 116 | -} | ||
| 117 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/plugininfo/vo/PluginInfoPageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.iot.controller.admin.plugininfo.vo; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 4 | -import cn.iocoder.yudao.module.iot.enums.plugin.IotPluginTypeEnum; | ||
| 5 | -import lombok.*; | ||
| 6 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 7 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | -import java.time.LocalDateTime; | ||
| 10 | - | ||
| 11 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 12 | - | ||
| 13 | -// TODO @haohao:只查询必要字段哈 | ||
| 14 | -@Schema(description = "管理后台 - IoT 插件信息分页 Request VO") | ||
| 15 | -@Data | ||
| 16 | -public class PluginInfoPageReqVO extends PageParam { | ||
| 17 | - | ||
| 18 | - @Schema(description = "插件包 ID ", example = "24627") | ||
| 19 | - private String pluginId; | ||
| 20 | - | ||
| 21 | - @Schema(description = "插件名称", example = "赵六") | ||
| 22 | - private String name; | ||
| 23 | - | ||
| 24 | - @Schema(description = "描述", example = "你猜") | ||
| 25 | - private String description; | ||
| 26 | - | ||
| 27 | - @Schema(description = "部署方式", example = "2") | ||
| 28 | - private Integer deployType; | ||
| 29 | - | ||
| 30 | - @Schema(description = "插件包文件名") | ||
| 31 | - private String file; | ||
| 32 | - | ||
| 33 | - @Schema(description = "插件版本") | ||
| 34 | - private String version; | ||
| 35 | - | ||
| 36 | - @Schema(description = "插件类型", example = "2") | ||
| 37 | - @InEnum(IotPluginTypeEnum.class) | ||
| 38 | - private Integer type; | ||
| 39 | - | ||
| 40 | - @Schema(description = "设备插件协议类型") | ||
| 41 | - private String protocol; | ||
| 42 | - | ||
| 43 | - @Schema(description = "状态") | ||
| 44 | - private Integer status; | ||
| 45 | - | ||
| 46 | - @Schema(description = "插件配置项描述信息") | ||
| 47 | - private String configSchema; | ||
| 48 | - | ||
| 49 | - @Schema(description = "插件配置信息") | ||
| 50 | - private String config; | ||
| 51 | - | ||
| 52 | - @Schema(description = "插件脚本") | ||
| 53 | - private String script; | ||
| 54 | - | ||
| 55 | - @Schema(description = "创建时间") | ||
| 56 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 57 | - private LocalDateTime[] createTime; | ||
| 58 | - | ||
| 59 | -} | ||
| 60 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/plugininfo/PluginInfoDO.java
| 1 | package cn.iocoder.yudao.module.iot.dal.dataobject.plugininfo; | 1 | package cn.iocoder.yudao.module.iot.dal.dataobject.plugininfo; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | +import cn.iocoder.yudao.module.iot.enums.plugin.IotPluginDeployTypeEnum; | ||
| 5 | +import cn.iocoder.yudao.module.iot.enums.plugin.IotPluginStatusEnum; | ||
| 6 | +import cn.iocoder.yudao.module.iot.enums.plugin.IotPluginTypeEnum; | ||
| 4 | import com.baomidou.mybatisplus.annotation.KeySequence; | 7 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 5 | import com.baomidou.mybatisplus.annotation.TableId; | 8 | import com.baomidou.mybatisplus.annotation.TableId; |
| 6 | import com.baomidou.mybatisplus.annotation.TableName; | 9 | import com.baomidou.mybatisplus.annotation.TableName; |
| @@ -27,6 +30,7 @@ public class PluginInfoDO extends BaseDO { | @@ -27,6 +30,7 @@ public class PluginInfoDO extends BaseDO { | ||
| 27 | @TableId | 30 | @TableId |
| 28 | private Long id; | 31 | private Long id; |
| 29 | // TODO @haohao:这个是不是改成类似 key 之类的字段哈? | 32 | // TODO @haohao:这个是不是改成类似 key 之类的字段哈? |
| 33 | + // 回复:默认是 pluginId,可以不用改 | ||
| 30 | /** | 34 | /** |
| 31 | * 插件包 ID | 35 | * 插件包 ID |
| 32 | */ | 36 | */ |
| @@ -41,22 +45,23 @@ public class PluginInfoDO extends BaseDO { | @@ -41,22 +45,23 @@ public class PluginInfoDO extends BaseDO { | ||
| 41 | private String description; | 45 | private String description; |
| 42 | /** | 46 | /** |
| 43 | * 部署方式 | 47 | * 部署方式 |
| 48 | + * <p> | ||
| 49 | + * 枚举 {@link IotPluginDeployTypeEnum} | ||
| 44 | */ | 50 | */ |
| 45 | - // TODO @haohao:枚举 | ||
| 46 | private Integer deployType; | 51 | private Integer deployType; |
| 47 | /** | 52 | /** |
| 48 | * 插件包文件名 | 53 | * 插件包文件名 |
| 49 | */ | 54 | */ |
| 50 | - // TODO @haohao:是不是叫 fileName 哈?避免后续有别的字段,类似 fileUrl? | ||
| 51 | - private String file; | 55 | + private String fileName; |
| 52 | /** | 56 | /** |
| 53 | * 插件版本 | 57 | * 插件版本 |
| 54 | */ | 58 | */ |
| 55 | private String version; | 59 | private String version; |
| 56 | /** | 60 | /** |
| 57 | * 插件类型 | 61 | * 插件类型 |
| 62 | + * <p> | ||
| 63 | + * 枚举 {@link IotPluginTypeEnum} | ||
| 58 | */ | 64 | */ |
| 59 | - // TODO @haohao:枚举 | ||
| 60 | private Integer type; | 65 | private Integer type; |
| 61 | /** | 66 | /** |
| 62 | * 设备插件协议类型 | 67 | * 设备插件协议类型 |
| @@ -64,8 +69,9 @@ public class PluginInfoDO extends BaseDO { | @@ -64,8 +69,9 @@ public class PluginInfoDO extends BaseDO { | ||
| 64 | private String protocol; | 69 | private String protocol; |
| 65 | /** | 70 | /** |
| 66 | * 状态 | 71 | * 状态 |
| 72 | + * <p> | ||
| 73 | + * 枚举 {@link IotPluginStatusEnum} | ||
| 67 | */ | 74 | */ |
| 68 | - // TODO @haohao:枚举 | ||
| 69 | private Integer status; | 75 | private Integer status; |
| 70 | /** | 76 | /** |
| 71 | * 插件配置项描述信息 | 77 | * 插件配置项描述信息 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/plugininfo/PluginInfoMapper.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/plugin/PluginInfoMapper.java
| 1 | -package cn.iocoder.yudao.module.iot.dal.mysql.plugininfo; | 1 | +package cn.iocoder.yudao.module.iot.dal.mysql.plugin; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.plugininfo.PluginInfoDO; | 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.plugininfo.PluginInfoDO; |
| 7 | import org.apache.ibatis.annotations.Mapper; | 7 | import org.apache.ibatis.annotations.Mapper; |
| 8 | -import cn.iocoder.yudao.module.iot.controller.admin.plugininfo.vo.*; | 8 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.*; |
| 9 | 9 | ||
| 10 | /** | 10 | /** |
| 11 | * IoT 插件信息 Mapper | 11 | * IoT 插件信息 Mapper |
| @@ -17,19 +17,8 @@ public interface PluginInfoMapper extends BaseMapperX<PluginInfoDO> { | @@ -17,19 +17,8 @@ public interface PluginInfoMapper extends BaseMapperX<PluginInfoDO> { | ||
| 17 | 17 | ||
| 18 | default PageResult<PluginInfoDO> selectPage(PluginInfoPageReqVO reqVO) { | 18 | default PageResult<PluginInfoDO> selectPage(PluginInfoPageReqVO reqVO) { |
| 19 | return selectPage(reqVO, new LambdaQueryWrapperX<PluginInfoDO>() | 19 | return selectPage(reqVO, new LambdaQueryWrapperX<PluginInfoDO>() |
| 20 | - .eqIfPresent(PluginInfoDO::getPluginId, reqVO.getPluginId()) | ||
| 21 | .likeIfPresent(PluginInfoDO::getName, reqVO.getName()) | 20 | .likeIfPresent(PluginInfoDO::getName, reqVO.getName()) |
| 22 | - .eqIfPresent(PluginInfoDO::getDescription, reqVO.getDescription()) | ||
| 23 | - .eqIfPresent(PluginInfoDO::getDeployType, reqVO.getDeployType()) | ||
| 24 | - .eqIfPresent(PluginInfoDO::getFile, reqVO.getFile()) | ||
| 25 | - .eqIfPresent(PluginInfoDO::getVersion, reqVO.getVersion()) | ||
| 26 | - .eqIfPresent(PluginInfoDO::getType, reqVO.getType()) | ||
| 27 | - .eqIfPresent(PluginInfoDO::getProtocol, reqVO.getProtocol()) | ||
| 28 | .eqIfPresent(PluginInfoDO::getStatus, reqVO.getStatus()) | 21 | .eqIfPresent(PluginInfoDO::getStatus, reqVO.getStatus()) |
| 29 | - .eqIfPresent(PluginInfoDO::getConfigSchema, reqVO.getConfigSchema()) | ||
| 30 | - .eqIfPresent(PluginInfoDO::getConfig, reqVO.getConfig()) | ||
| 31 | - .eqIfPresent(PluginInfoDO::getScript, reqVO.getScript()) | ||
| 32 | - .betweenIfPresent(PluginInfoDO::getCreateTime, reqVO.getCreateTime()) | ||
| 33 | .orderByDesc(PluginInfoDO::getId)); | 22 | .orderByDesc(PluginInfoDO::getId)); |
| 34 | } | 23 | } |
| 35 | 24 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/plugininstance/PluginInstanceMapper.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/plugin/PluginInstanceMapper.java
| 1 | -package cn.iocoder.yudao.module.iot.dal.mysql.plugininstance; | 1 | +package cn.iocoder.yudao.module.iot.dal.mysql.plugin; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 6 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.PluginInstancePageReqVO; | ||
| 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.plugininstance.PluginInstanceDO; | 7 | import cn.iocoder.yudao.module.iot.dal.dataobject.plugininstance.PluginInstanceDO; |
| 7 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 8 | -import cn.iocoder.yudao.module.iot.controller.admin.plugininstance.vo.*; | ||
| 9 | 9 | ||
| 10 | /** | 10 | /** |
| 11 | * IoT 插件实例 Mapper | 11 | * IoT 插件实例 Mapper |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/plugininfo/PluginInfoService.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/plugin/PluginInfoService.java
| 1 | -package cn.iocoder.yudao.module.iot.service.plugininfo; | 1 | +package cn.iocoder.yudao.module.iot.service.plugin; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.iot.controller.admin.plugininfo.vo.PluginInfoPageReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.iot.controller.admin.plugininfo.vo.PluginInfoSaveReqVO; | 4 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.PluginInfoPageReqVO; |
| 5 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.PluginInfoSaveReqVO; | ||
| 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.plugininfo.PluginInfoDO; | 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.plugininfo.PluginInfoDO; |
| 7 | import jakarta.validation.Valid; | 7 | import jakarta.validation.Valid; |
| 8 | import org.springframework.web.multipart.MultipartFile; | 8 | import org.springframework.web.multipart.MultipartFile; |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/plugininfo/PluginInfoServiceImpl.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/plugin/PluginInfoServiceImpl.java
| 1 | -package cn.iocoder.yudao.module.iot.service.plugininfo; | 1 | +package cn.iocoder.yudao.module.iot.service.plugin; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | -import cn.iocoder.yudao.module.iot.controller.admin.plugininfo.vo.PluginInfoPageReqVO; | ||
| 6 | -import cn.iocoder.yudao.module.iot.controller.admin.plugininfo.vo.PluginInfoSaveReqVO; | 5 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.PluginInfoPageReqVO; |
| 6 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.PluginInfoSaveReqVO; | ||
| 7 | import cn.iocoder.yudao.module.iot.dal.dataobject.plugininfo.PluginInfoDO; | 7 | import cn.iocoder.yudao.module.iot.dal.dataobject.plugininfo.PluginInfoDO; |
| 8 | -import cn.iocoder.yudao.module.iot.dal.mysql.plugininfo.PluginInfoMapper; | 8 | +import cn.iocoder.yudao.module.iot.dal.mysql.plugin.PluginInfoMapper; |
| 9 | import cn.iocoder.yudao.module.iot.enums.plugin.IotPluginStatusEnum; | 9 | import cn.iocoder.yudao.module.iot.enums.plugin.IotPluginStatusEnum; |
| 10 | import jakarta.annotation.Resource; | 10 | import jakarta.annotation.Resource; |
| 11 | import lombok.extern.slf4j.Slf4j; | 11 | import lombok.extern.slf4j.Slf4j; |
| @@ -41,7 +41,6 @@ public class PluginInfoServiceImpl implements PluginInfoService { | @@ -41,7 +41,6 @@ public class PluginInfoServiceImpl implements PluginInfoService { | ||
| 41 | 41 | ||
| 42 | @Resource | 42 | @Resource |
| 43 | private PluginInfoMapper pluginInfoMapper; | 43 | private PluginInfoMapper pluginInfoMapper; |
| 44 | - | ||
| 45 | @Resource | 44 | @Resource |
| 46 | private SpringPluginManager pluginManager; | 45 | private SpringPluginManager pluginManager; |
| 47 | 46 | ||
| @@ -94,12 +93,12 @@ public class PluginInfoServiceImpl implements PluginInfoService { | @@ -94,12 +93,12 @@ public class PluginInfoServiceImpl implements PluginInfoService { | ||
| 94 | Executors.newSingleThreadExecutor().submit(() -> { | 93 | Executors.newSingleThreadExecutor().submit(() -> { |
| 95 | try { | 94 | try { |
| 96 | TimeUnit.SECONDS.sleep(1); // 等待 1 秒,避免插件未卸载完毕 | 95 | TimeUnit.SECONDS.sleep(1); // 等待 1 秒,避免插件未卸载完毕 |
| 97 | - File file = new File(pluginsDir, pluginInfoDO.getFile()); | 96 | + File file = new File(pluginsDir, pluginInfoDO.getFileName()); |
| 98 | if (file.exists() && !file.delete()) { | 97 | if (file.exists() && !file.delete()) { |
| 99 | - log.error("[deletePluginInfo][删除插件文件({}) 失败]", pluginInfoDO.getFile()); | 98 | + log.error("[deletePluginInfo][删除插件文件({}) 失败]", pluginInfoDO.getFileName()); |
| 100 | } | 99 | } |
| 101 | } catch (InterruptedException e) { | 100 | } catch (InterruptedException e) { |
| 102 | - log.error("[deletePluginInfo][删除插件文件({}) 失败]", pluginInfoDO.getFile(), e); | 101 | + log.error("[deletePluginInfo][删除插件文件({}) 失败]", pluginInfoDO.getFileName(), e); |
| 103 | } | 102 | } |
| 104 | }); | 103 | }); |
| 105 | 104 | ||
| @@ -213,7 +212,7 @@ public class PluginInfoServiceImpl implements PluginInfoService { | @@ -213,7 +212,7 @@ public class PluginInfoServiceImpl implements PluginInfoService { | ||
| 213 | private void updatePluginInfo(PluginInfoDO pluginInfoDo, String pluginIdNew, MultipartFile file) { | 212 | private void updatePluginInfo(PluginInfoDO pluginInfoDo, String pluginIdNew, MultipartFile file) { |
| 214 | pluginInfoDo.setPluginId(pluginIdNew); | 213 | pluginInfoDo.setPluginId(pluginIdNew); |
| 215 | pluginInfoDo.setStatus(IotPluginStatusEnum.STOPPED.getStatus()); | 214 | pluginInfoDo.setStatus(IotPluginStatusEnum.STOPPED.getStatus()); |
| 216 | - pluginInfoDo.setFile(file.getOriginalFilename()); | 215 | + pluginInfoDo.setFileName(file.getOriginalFilename()); |
| 217 | pluginInfoDo.setScript(""); | 216 | pluginInfoDo.setScript(""); |
| 218 | 217 | ||
| 219 | PluginDescriptor pluginDescriptor = pluginManager.getPlugin(pluginIdNew).getDescriptor(); | 218 | PluginDescriptor pluginDescriptor = pluginManager.getPlugin(pluginIdNew).getDescriptor(); |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/plugininstance/PluginInstanceService.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/plugin/PluginInstanceService.java
| 1 | -package cn.iocoder.yudao.module.iot.service.plugininstance; | 1 | +package cn.iocoder.yudao.module.iot.service.plugin; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.iot.controller.admin.plugininstance.vo.PluginInstancePageReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.iot.controller.admin.plugininstance.vo.PluginInstanceSaveReqVO; | 4 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.PluginInstancePageReqVO; |
| 5 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.PluginInstanceSaveReqVO; | ||
| 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.plugininstance.PluginInstanceDO; | 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.plugininstance.PluginInstanceDO; |
| 7 | import jakarta.validation.Valid; | 7 | import jakarta.validation.Valid; |
| 8 | 8 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/plugininstance/PluginInstanceServiceImpl.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/plugin/PluginInstanceServiceImpl.java
| 1 | -package cn.iocoder.yudao.module.iot.service.plugininstance; | 1 | +package cn.iocoder.yudao.module.iot.service.plugin; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | -import cn.iocoder.yudao.module.iot.controller.admin.plugininstance.vo.PluginInstancePageReqVO; | ||
| 6 | -import cn.iocoder.yudao.module.iot.controller.admin.plugininstance.vo.PluginInstanceSaveReqVO; | 5 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.PluginInstancePageReqVO; |
| 6 | +import cn.iocoder.yudao.module.iot.controller.admin.plugin.vo.PluginInstanceSaveReqVO; | ||
| 7 | import cn.iocoder.yudao.module.iot.dal.dataobject.plugininstance.PluginInstanceDO; | 7 | import cn.iocoder.yudao.module.iot.dal.dataobject.plugininstance.PluginInstanceDO; |
| 8 | -import cn.iocoder.yudao.module.iot.dal.mysql.plugininstance.PluginInstanceMapper; | 8 | +import cn.iocoder.yudao.module.iot.dal.mysql.plugin.PluginInstanceMapper; |
| 9 | import jakarta.annotation.Resource; | 9 | import jakarta.annotation.Resource; |
| 10 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
| 11 | import org.springframework.validation.annotation.Validated; | 11 | import org.springframework.validation.annotation.Validated; |
| @@ -13,7 +13,6 @@ import org.springframework.validation.annotation.Validated; | @@ -13,7 +13,6 @@ import org.springframework.validation.annotation.Validated; | ||
| 13 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 13 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 14 | import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.PLUGIN_INSTANCE_NOT_EXISTS; | 14 | import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.PLUGIN_INSTANCE_NOT_EXISTS; |
| 15 | 15 | ||
| 16 | -// TODO @haohao:可以搞个 plugin 包,然后把 plugininfo、plugininstance | ||
| 17 | /** | 16 | /** |
| 18 | * IoT 插件实例 Service 实现类 | 17 | * IoT 插件实例 Service 实现类 |
| 19 | * | 18 | * |
yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/plugininstance/PluginInstanceMapper.xml
| 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | -<mapper namespace="cn.iocoder.yudao.module.iot.dal.mysql.plugininstance.PluginInstanceMapper"> | 3 | +<mapper namespace="cn.iocoder.yudao.module.iot.dal.mysql.plugin.PluginInstanceMapper"> |
| 4 | 4 | ||
| 5 | <!-- | 5 | <!-- |
| 6 | 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | 6 | 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 |