From 031dc16345fed35a4fd58fccf5e191dd9b1284c5 Mon Sep 17 00:00:00 2001 From: chenhui <1204351172@qq.com> Date: Sat, 8 Jul 2023 11:42:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?style:=20SonarLint=E6=89=AB=E6=8F=8F?= =?UTF-8?q?=E4=BB=A5=E5=8F=8Aclean=20code=E4=BB=A3=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit iot-module,iot-test-tool,iot-starter,iot-components模块SonarLint扫描以及clean code代码规范修改 --- .../java/cc/iotkit/common/enums/ErrCode.java | 3 +- .../iotkit/comp/DLT645/DLT645Component.java | 3 +- .../cc/iotkit/comp/DLT645/DLT645Verticle.java | 4 +- .../comp/DLT645/analysis/DLT645Analysis.java | 7 ++- .../DLT645/analysis/DLT645DataFormat.java | 20 +++---- .../DLT645/analysis/DLT645v1997CsvLoader.java | 2 +- .../comp/DLT645/utils/ContainerUtils.java | 55 +++++------------- .../java/cc/iotkit/comp/IMessageHandler.java | 1 - .../cc/iotkit/comp/utils/SpringUtils.java | 4 +- .../cc/iotkit/comps/BizComponentManager.java | 2 +- .../iotkit/comps/DeviceComponentManager.java | 2 +- .../cc/iotkit/comps/DeviceMessageHandler.java | 9 ++- .../comps/service/DeviceBehaviourService.java | 6 +- .../comp/tcp/cilent/VertxTcpClient.java | 5 +- .../comp/tcp/server/TcpServerVerticle.java | 10 +--- .../iotkit/comp/emqx/EmqxDeviceComponent.java | 3 +- .../java/cc/iotkit/comp/emqx/LuaScripter.java | 2 + .../comp/emqx/TransparentConverter.java | 1 - .../cc/iotkit/comp/biz/HttpBizComponent.java | 2 +- .../cc/iotkit/comp/mqtt/MqttVerticle.java | 8 +-- .../comp/mqtt/TransparentConverter.java | 1 - .../client/WebSocketClientVerticle.java | 18 +++--- .../baetyl/dto/bo/UpdateNodePropertiesBo.java | 2 - .../baetyl/dto/vo/UpdateNodePropertiesVo.java | 2 - .../cc/iotkit/baetyl/dto/vo/UpdateNodeVo.java | 2 - .../controller/IotContributorController.java | 31 +++++----- .../data/IIotContributorData.java | 3 +- .../data/impl/IotContributorDataImpl.java | 42 ++++++-------- .../data/model/TbIotContributor.java | 5 +- .../contribution/dto/bo/IotContributorBo.java | 7 +-- .../contribution/dto/vo/IotContributorVo.java | 5 +- .../contribution/model/IotContributor.java | 2 +- .../service/IIotContributorService.java | 7 +-- .../impl/IotContributorServiceImpl.java | 23 +++----- .../generator/config/MybatisPlusConfig.java | 8 --- .../generator/controller/GenController.java | 19 ++----- .../cc/iotkit/generator/core/BaseEntity.java | 1 - .../iotkit/generator/core/BaseMapperPlus.java | 1 - .../iotkit/generator/core/DataBaseHelper.java | 1 - .../iotkit/generator/core/DbIdGenerator.java | 8 --- .../cc/iotkit/generator/core/PageBuilder.java | 18 ++---- .../cc/iotkit/generator/core/PageQuery.java | 5 +- .../cc/iotkit/generator/domain/GenTable.java | 3 +- .../generator/domain/GenTableColumn.java | 4 +- .../mapper/GenTableColumnMapper.java | 3 +- .../generator/mapper/GenTableMapper.java | 3 +- .../service/GenTableServiceImpl.java | 21 +++---- .../generator/service/IGenTableService.java | 2 - .../cc/iotkit/generator/util/GenUtils.java | 9 +-- .../iotkit/generator/util/VelocityUtils.java | 9 ++- .../src/main/resources/vm/ts/api.ts.vm | 56 +++++++++---------- .../main/resources/vm/vue/index-tree.vue.vm | 9 ++- .../src/main/resources/vm/vue/index.vue.vm | 9 ++- .../manager/config/AutoMapperConfig2.java | 1 - .../manager/controller/AlertController.java | 2 +- .../manager/controller/OtaController.java | 2 +- .../manager/controller/ProductController.java | 3 +- .../manager/controller/ScreenController.java | 4 +- .../manager/controller/SpaceController.java | 5 +- .../iotkit/manager/dto/bo/ChangeStateBo.java | 6 +- .../manager/dto/bo/category/CategoryBo.java | 18 +----- .../dto/bo/device/DeviceLogQueryBo.java | 3 - .../manager/dto/bo/device/DeviceQueryBo.java | 1 - .../dto/bo/device/DeviceQueryByPkDnBo.java | 3 - .../dto/bo/deviceconfig/DeviceConfigBo.java | 19 +------ .../dto/bo/devicegroup/DeviceAddGroupBo.java | 6 -- .../dto/bo/devicegroup/DeviceGroupBo.java | 21 ++----- .../manager/dto/bo/ota/DeviceUpgradeBo.java | 1 - .../dto/bo/productmodel/ProductModelBo.java | 18 +----- .../ProtocolComponentBo.java | 18 +----- .../ProtocolConverterBo.java | 23 ++------ .../manager/dto/bo/ruleinfo/RuleLogBo.java | 3 - .../manager/dto/bo/taskinfo/TaskLogBo.java | 4 +- .../dto/bo/thingmodel/ThingModelBo.java | 18 +----- .../bo/thingmodel/ThingModelMessageBo.java | 1 - .../manager/dto/vo/category/CategoryVo.java | 13 ++--- .../dto/vo/deviceconfig/DeviceConfigVo.java | 15 ++--- .../dto/vo/devicegroup/DeviceGroupVo.java | 15 ++--- .../dto/vo/productmodel/ProductModelVo.java | 13 ++--- .../ProtocolComponentVo.java | 13 ++--- .../ProtocolConverterVo.java | 15 ++--- .../manager/dto/vo/ruleinfo/RuleInfoVo.java | 19 ++----- .../manager/dto/vo/taskinfo/TaskInfoVo.java | 19 ++----- .../iotkit/manager/service/AlertService.java | 2 +- .../manager/service/DeferredDataConsumer.java | 7 ++- .../iotkit/manager/service/DeviceService.java | 2 - .../manager/service/ExampleDataInit.java | 6 +- .../manager/service/IProtocolService.java | 2 - .../cc/iotkit/manager/service/OtaService.java | 4 +- .../service/impl/DeviceServiceImpl.java | 4 +- .../service/impl/ProductServiceImpl.java | 6 +- .../service/impl/ProtocolServiceImpl.java | 9 +-- .../action/device/DeviceActionService.java | 2 +- .../ruleengine/link/impl/KafkaLink.java | 1 + .../iotkit/ruleengine/rule/RuleManager.java | 4 +- .../ruleengine/rule/RuleMessageHandler.java | 2 +- .../ruleengine/task/DeviceActionExecutor.java | 6 +- .../iotkit/ruleengine/task/TaskManager.java | 3 +- .../screen/staticres/ScreenComponent.java | 8 +-- .../system/controller/SysDeptController.java | 5 +- .../controller/SysDictDataController.java | 2 +- .../controller/SysLogininforController.java | 5 +- .../system/controller/SysMenuController.java | 7 ++- .../controller/SysOperlogController.java | 5 +- .../system/controller/SysRoleController.java | 5 +- .../SysTenantPackageController.java | 4 +- .../controller/SysUserOnlineController.java | 6 +- .../cc/iotkit/system/dto/bo/SysConfigBo.java | 4 +- .../cc/iotkit/system/dto/bo/SysRoleBo.java | 2 +- .../cc/iotkit/system/dto/bo/SysTenantBo.java | 3 +- .../system/dto/bo/SysTenantPackageBo.java | 3 +- .../cc/iotkit/system/dto/vo/SysTenantVo.java | 3 +- .../system/service/ISysNoticeService.java | 1 - .../service/impl/SysDataScopeServiceImpl.java | 2 - .../service/impl/SysDictDataServiceImpl.java | 1 - .../service/impl/SysOssConfigServiceImpl.java | 6 +- .../impl/SysPermissionServiceImpl.java | 2 +- .../impl/SysTenantPackageServiceImpl.java | 1 - .../src/main/java/cc/iotkit/Application.java | 2 +- .../iotkit/web/controller/AuthController.java | 7 ++- .../iotkit/web/service/SysLoginService.java | 26 ++++----- .../web/service/SysRegisterService.java | 11 ++-- .../test/mqtt/example/TransparentTest.java | 5 +- .../cc/iotkit/test/mqtt/service/Gateway.java | 1 - .../iotkit/virtualdevice/VirtualManager.java | 1 - 125 files changed, 354 insertions(+), 624 deletions(-) diff --git a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/enums/ErrCode.java b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/enums/ErrCode.java index d603dd53..b467cce2 100644 --- a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/enums/ErrCode.java +++ b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/enums/ErrCode.java @@ -95,7 +95,8 @@ public enum ErrCode implements IEnum { STATE_ERROR(00000000, "状态错误"), RECORD_NOT_FOUND(00000000, "记录不存在"), ADD_PLATFORM_USER_ERROR(00000000, "添加平台用户失败"), - UPLOAD_FILE_ERROR(00000000, "上传文件失败"); + UPLOAD_FILE_ERROR(00000000, "上传文件失败"), + FILE_NAME_IS_NULL(00000000, "文件名为空,获取文件名失败"); private int code; diff --git a/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/DLT645Component.java b/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/DLT645Component.java index 20817a2c..d9045caf 100644 --- a/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/DLT645Component.java +++ b/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/DLT645Component.java @@ -57,7 +57,7 @@ public class DLT645Component extends AbstractDeviceComponent { deployedId = s; countDownLatch.countDown(); })); - future.onFailure((e) -> { + future.onFailure(e -> { countDownLatch.countDown(); log.error("start GLT645 component failed", e); }); @@ -68,6 +68,7 @@ public class DLT645Component extends AbstractDeviceComponent { } } + @Override @SneakyThrows public void stop() { DLT645Verticle.stop(); diff --git a/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/DLT645Verticle.java b/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/DLT645Verticle.java index cbc833e0..90f81dc2 100644 --- a/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/DLT645Verticle.java +++ b/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/DLT645Verticle.java @@ -155,10 +155,10 @@ public class DLT645Verticle extends AbstractVerticle { dataMap.put("mac",clientKey.split("_")[1]); executor.onReceive(dataMap, "offline", ""); } - if(entityList.size()>0){ + if (!entityList.isEmpty()) { entityList.clear(); } - if(!dinMap.isEmpty()){ + if (!dinMap.isEmpty()) { dinMap.clear(); } clientMap.clear(); diff --git a/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/analysis/DLT645Analysis.java b/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/analysis/DLT645Analysis.java index 32ad4195..c70db45e 100644 --- a/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/analysis/DLT645Analysis.java +++ b/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/analysis/DLT645Analysis.java @@ -4,6 +4,7 @@ import cc.iotkit.comp.DLT645.utils.ByteRef; import cc.iotkit.comp.DLT645.utils.BytesRef; import cc.iotkit.comp.DLT645.utils.ContainerUtils; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -79,10 +80,10 @@ public class DLT645Analysis { // 检查:数据块的大小 int iDataSize = arrData.length; if (iDataSize > 255) { - return null; + return new byte[0]; } if (arrAddr.length != 6) { - return null; + return new byte[0]; } // 初始化数组大小 @@ -268,7 +269,7 @@ public class DLT645Analysis { BytesRef byAddr = new BytesRef(); BytesRef arrData = new BytesRef(); if (!unPackCmd2Map(arrCmd, byAddr, byFun, arrData)) { - return null; + return Collections.emptyMap(); } Map value = new HashMap<>(); diff --git a/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/analysis/DLT645DataFormat.java b/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/analysis/DLT645DataFormat.java index 1a888c69..02df7cd0 100644 --- a/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/analysis/DLT645DataFormat.java +++ b/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/analysis/DLT645DataFormat.java @@ -290,11 +290,11 @@ public class DLT645DataFormat { // 拆解成个位数列表 List list = new ArrayList<>(); for (int i = 0; i < length; i++) { - Integer l = data[start + i] & 0x0f; - Integer h = (data[start + i] & 0xf0) >> 4; + int l = data[start + i] & 0x0f; + int h = (data[start + i] & 0xf0) >> 4; - list.add(l.toString()); - list.add(h.toString()); + list.add(Integer.toString(l)); + list.add(Integer.toString(h)); } // 格式1 @@ -310,12 +310,10 @@ public class DLT645DataFormat { return result; } if (format.equals(FORMAT_hhmmss)) { - String result = list.get(5) + list.get(4) + "点" + list.get(3) + list.get(2) + "分" + list.get(1) + list.get(0) + "秒"; - return result; + return list.get(5) + list.get(4) + "点" + list.get(3) + list.get(2) + "分" + list.get(1) + list.get(0) + "秒"; } if (format.equals(FORMAT_mmmm)) { - String result = list.get(3) + list.get(2) + list.get(1) + list.get(0) + "分"; - return result; + return list.get(3) + list.get(2) + list.get(1) + list.get(0) + "分"; } @@ -325,12 +323,10 @@ public class DLT645DataFormat { return result; } if (format.equals(FORMAT_DDhh)) { - String result = list.get(3) + list.get(2) + "号 " + list.get(1) + list.get(0) + "点"; - return result; + return list.get(3) + list.get(2) + "号 " + list.get(1) + list.get(0) + "点"; } if (format.equals(FORMAT_hhmm)) { - String result = list.get(3) + list.get(2) + "点 " + list.get(1) + list.get(0) + "分"; - return result; + return list.get(3) + list.get(2) + "点 " + list.get(1) + list.get(0) + "分"; } diff --git a/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/analysis/DLT645v1997CsvLoader.java b/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/analysis/DLT645v1997CsvLoader.java index 3f2599b0..01a2b7b1 100644 --- a/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/analysis/DLT645v1997CsvLoader.java +++ b/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/analysis/DLT645v1997CsvLoader.java @@ -53,7 +53,7 @@ public class DLT645v1997CsvLoader { @Data - static public class JDecoderValueParam implements Serializable { + public static class JDecoderValueParam implements Serializable { private String di1h; private String di1l; private String di0h; diff --git a/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/utils/ContainerUtils.java b/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/utils/ContainerUtils.java index ccf9c073..6ec6c534 100644 --- a/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/utils/ContainerUtils.java +++ b/iot-components/iot-DLT645-component/src/main/java/cc/iotkit/comp/DLT645/utils/ContainerUtils.java @@ -153,9 +153,9 @@ public class ContainerUtils { return uid2deviceMap; } catch (IllegalAccessException e) { - return null; + return Collections.emptyMap(); } catch (InvocationTargetException e) { - return null; + return Collections.emptyMap(); } } @@ -171,15 +171,8 @@ public class ContainerUtils { // 使用方法返回对应的数组 return ContainerUtils.buildMapByKey(objList, method); - } catch (NoSuchMethodException e) { - return new HashMap(); - } catch (SecurityException e) { - return new HashMap(); - } catch (IllegalAccessException e) { - return new HashMap(); - } catch (IllegalArgumentException e) { - return new HashMap(); - } catch (InvocationTargetException e) { + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | IllegalArgumentException | + SecurityException e) { return new HashMap(); } } @@ -194,10 +187,8 @@ public class ContainerUtils { } return uid2deviceMap; - } catch (IllegalAccessException e) { - return null; - } catch (InvocationTargetException e) { - return null; + } catch (IllegalAccessException | InvocationTargetException e) { + return Collections.emptyMap(); } } @@ -219,22 +210,13 @@ public class ContainerUtils { Object keyObject = method.invoke(obj); if (clazz.isInstance(keyObject)) { K key = clazz.cast(keyObject); - - List list = uid2deviceMap.get(key); - if (list == null) { - list = new ArrayList<>(); - uid2deviceMap.put(key, list); - } - + List list = uid2deviceMap.computeIfAbsent(key, k -> new ArrayList<>()); list.add(obj); } } - return uid2deviceMap; - } catch (IllegalAccessException e) { - return null; - } catch (InvocationTargetException e) { - return null; + } catch (IllegalAccessException | InvocationTargetException e) { + return Collections.emptyMap(); } } @@ -285,16 +267,9 @@ public class ContainerUtils { // 使用方法返回对应的数组 return ContainerUtils.buildMapByTypeAndFinalMethod(objList, clazz, method); - } catch (NoSuchMethodException e) { - return new HashMap>(); - } catch (SecurityException e) { - return new HashMap>(); - } catch (IllegalAccessException e) { - return new HashMap>(); - } catch (IllegalArgumentException e) { - return new HashMap>(); - } catch (InvocationTargetException e) { - return new HashMap>(); + } catch (NoSuchMethodException | InvocationTargetException | IllegalArgumentException | IllegalAccessException | + SecurityException e) { + return new HashMap<>(); } } @@ -360,11 +335,7 @@ public class ContainerUtils { } return null; - } catch (NoSuchMethodException e) { - return null; - } catch (IllegalAccessException e) { - return null; - } catch (InvocationTargetException e) { + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { return null; } } diff --git a/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/IMessageHandler.java b/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/IMessageHandler.java index 8af6043f..5e277e0d 100755 --- a/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/IMessageHandler.java +++ b/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/IMessageHandler.java @@ -12,7 +12,6 @@ package cc.iotkit.comp; import cc.iotkit.comp.model.ReceiveResult; import java.util.Map; -import java.util.concurrent.Callable; import java.util.function.Consumer; public interface IMessageHandler { diff --git a/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/utils/SpringUtils.java b/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/utils/SpringUtils.java index cb96ab24..9cffd106 100755 --- a/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/utils/SpringUtils.java +++ b/iot-components/iot-component-base/src/main/java/cc/iotkit/comp/utils/SpringUtils.java @@ -16,7 +16,6 @@ import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Component; /** * spring工具类 方便在非spring管理环境中获取bean @@ -65,8 +64,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC */ public static T getBean(Class clz) throws BeansException { - T result = (T) beanFactory.getBean(clz); - return result; + return (T) beanFactory.getBean(clz); } /** diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/BizComponentManager.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/BizComponentManager.java index 57ecfcb6..73be5465 100755 --- a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/BizComponentManager.java +++ b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/BizComponentManager.java @@ -10,9 +10,9 @@ package cc.iotkit.comps; -import cc.iotkit.common.utils.ComponentClassLoader; import cc.iotkit.common.enums.ErrCode; import cc.iotkit.common.exception.BizException; +import cc.iotkit.common.utils.ComponentClassLoader; import cc.iotkit.comp.CompConfig; import cc.iotkit.comp.IComponent; import cc.iotkit.comps.config.ComponentConfig; diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceComponentManager.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceComponentManager.java index 828f03b8..d088c94e 100755 --- a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceComponentManager.java +++ b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceComponentManager.java @@ -10,10 +10,10 @@ package cc.iotkit.comps; -import cc.iotkit.common.utils.ComponentClassLoader; import cc.iotkit.common.enums.ErrCode; import cc.iotkit.common.exception.BizException; import cc.iotkit.common.thing.ThingService; +import cc.iotkit.common.utils.ComponentClassLoader; import cc.iotkit.common.utils.JsonUtils; import cc.iotkit.comp.CompConfig; import cc.iotkit.comp.IComponent; diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceMessageHandler.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceMessageHandler.java index 3f651510..3a1d9b2a 100755 --- a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceMessageHandler.java +++ b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceMessageHandler.java @@ -14,11 +14,11 @@ import cc.iotkit.common.utils.UniqueIdUtil; import cc.iotkit.comp.IDeviceComponent; import cc.iotkit.comp.IMessageHandler; import cc.iotkit.comp.model.AuthInfo; +import cc.iotkit.comp.model.DeviceState; import cc.iotkit.comp.model.ReceiveResult; import cc.iotkit.comp.model.RegisterInfo; -import cc.iotkit.converter.DeviceMessage; -import cc.iotkit.comp.model.DeviceState; import cc.iotkit.comps.service.DeviceBehaviourService; +import cc.iotkit.converter.DeviceMessage; import cc.iotkit.converter.IConverter; import cc.iotkit.model.device.message.ThingModelMessage; import cc.iotkit.script.IScriptEngine; @@ -28,7 +28,10 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import java.util.Map; -import java.util.concurrent.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import java.util.function.Consumer; @Slf4j diff --git a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceBehaviourService.java b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceBehaviourService.java index 4f2b197e..64ac5d02 100755 --- a/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceBehaviourService.java +++ b/iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceBehaviourService.java @@ -14,7 +14,6 @@ import cc.iotkit.common.enums.ErrCode; import cc.iotkit.common.exception.BizException; import cc.iotkit.common.utils.DeviceUtil; import cc.iotkit.common.utils.JsonUtils; -import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.UniqueIdUtil; import cc.iotkit.comp.model.DeviceState; import cc.iotkit.comp.model.RegisterInfo; @@ -34,7 +33,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Objects; +import java.util.UUID; @Slf4j @Service diff --git a/iot-components/iot-component-tcp/src/main/java/cc/iotkit/comp/tcp/cilent/VertxTcpClient.java b/iot-components/iot-component-tcp/src/main/java/cc/iotkit/comp/tcp/cilent/VertxTcpClient.java index 11e8fe66..4205a306 100644 --- a/iot-components/iot-component-tcp/src/main/java/cc/iotkit/comp/tcp/cilent/VertxTcpClient.java +++ b/iot-components/iot-component-tcp/src/main/java/cc/iotkit/comp/tcp/cilent/VertxTcpClient.java @@ -3,7 +3,6 @@ package cc.iotkit.comp.tcp.cilent; import cc.iotkit.comp.IMessageHandler; import cc.iotkit.comp.tcp.parser.PayloadParser; import io.vertx.core.buffer.Buffer; -import io.vertx.core.net.NetClient; import io.vertx.core.net.NetSocket; import lombok.Getter; import lombok.Setter; @@ -100,10 +99,9 @@ public class VertxTcpClient { .handlePayload() .onErrorContinue((err, res) -> { log.error(err.getMessage(), err); - System.out.println(err.getMessage()); }) .subscribe(buffer -> { - System.out.println(buffer.toString()); + log.info(buffer.toString()); receiveHandler.accept(buffer); }); } @@ -158,6 +156,7 @@ public class VertxTcpClient { log.warn("close tcp client error", e); } } + /** * 是否有父设备 */ diff --git a/iot-components/iot-component-tcp/src/main/java/cc/iotkit/comp/tcp/server/TcpServerVerticle.java b/iot-components/iot-component-tcp/src/main/java/cc/iotkit/comp/tcp/server/TcpServerVerticle.java index 12121a8b..1ea21e36 100644 --- a/iot-components/iot-component-tcp/src/main/java/cc/iotkit/comp/tcp/server/TcpServerVerticle.java +++ b/iot-components/iot-component-tcp/src/main/java/cc/iotkit/comp/tcp/server/TcpServerVerticle.java @@ -180,9 +180,7 @@ public class TcpServerVerticle extends AbstractVerticle { client.setKeepAliveTimeoutMs(keepAliveTimeout); try { // TCP异常和关闭处理 - socket.exceptionHandler(err -> { - log.error("tcp server client [{}] error", socket.remoteAddress(), err); - }).closeHandler((nil) -> { + socket.exceptionHandler(err -> log.error("tcp server client [{}] error", socket.remoteAddress(), err)).closeHandler(nil -> { log.debug("tcp server client [{}] closed", socket.remoteAddress()); client.shutdown(); }); @@ -190,12 +188,10 @@ public class TcpServerVerticle extends AbstractVerticle { client.setKeepAliveTimeoutMs(keepAliveTimeout); client.setRecordParser(parserSupplier.get()); client.setSocket(socket); - client.onDisconnect(() -> { - clientDisconnect(client.getDeviceName()); - }); + client.onDisconnect(() -> clientDisconnect(client.getDeviceName())); // 设置收到消息处理 client.setReceiveHandler(buffer -> { - System.out.println(buffer.toString()); + log.info(buffer.toString()); try { executor.onReceive(null, "", buffer.toString(), result -> { diff --git a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/EmqxDeviceComponent.java b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/EmqxDeviceComponent.java index 82dbd6d5..1087e6fc 100755 --- a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/EmqxDeviceComponent.java +++ b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/EmqxDeviceComponent.java @@ -19,7 +19,6 @@ import cc.iotkit.comp.AbstractDeviceComponent; import cc.iotkit.comp.CompConfig; import cc.iotkit.comp.IMessageHandler; import cc.iotkit.comp.model.DeviceState; - import cc.iotkit.converter.DeviceMessage; import cc.iotkit.data.manager.IDeviceInfoData; import cc.iotkit.model.device.DeviceInfo; @@ -82,7 +81,7 @@ public class EmqxDeviceComponent extends AbstractDeviceComponent implements Runn countDownLatch.countDown(); log.info("start emqx auth component success"); })); - future.onFailure((e) -> { + future.onFailure(e -> { countDownLatch.countDown(); log.error("start emqx auth component failed", e); }); diff --git a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/LuaScripter.java b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/LuaScripter.java index ba7e5297..73472b09 100755 --- a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/LuaScripter.java +++ b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/LuaScripter.java @@ -57,6 +57,7 @@ public class LuaScripter implements IScripter { } } + @Override public ThingModelMessage decode(TransparentMsg msg) { try { LuaTable table = new LuaTable(); @@ -76,6 +77,7 @@ public class LuaScripter implements IScripter { return null; } + @Override public TransparentMsg encode(ThingService service) { try { LuaTable table = new LuaTable(); diff --git a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/TransparentConverter.java b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/TransparentConverter.java index c4b039b7..8d3c48de 100755 --- a/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/TransparentConverter.java +++ b/iot-components/iot-emqx-component/src/main/java/cc/iotkit/comp/emqx/TransparentConverter.java @@ -13,7 +13,6 @@ package cc.iotkit.comp.emqx; import cc.iotkit.common.enums.ErrCode; import cc.iotkit.common.exception.BizException; import cc.iotkit.common.thing.ThingService; - import cc.iotkit.common.utils.SpringUtils; import cc.iotkit.converter.Device; import cc.iotkit.converter.DeviceMessage; diff --git a/iot-components/iot-http-biz-component/src/main/java/cc/iotkit/comp/biz/HttpBizComponent.java b/iot-components/iot-http-biz-component/src/main/java/cc/iotkit/comp/biz/HttpBizComponent.java index 0884891b..80958674 100755 --- a/iot-components/iot-http-biz-component/src/main/java/cc/iotkit/comp/biz/HttpBizComponent.java +++ b/iot-components/iot-http-biz-component/src/main/java/cc/iotkit/comp/biz/HttpBizComponent.java @@ -116,7 +116,7 @@ public class HttpBizComponent implements IComponent { }); backendServer.requestHandler(backendRouter) - .listen(httpConfig.getPort(), (http) -> { + .listen(httpConfig.getPort(), http -> { if (http.succeeded()) { log.info("http server create succeed,port:{}", httpConfig.getPort()); } else { diff --git a/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/MqttVerticle.java b/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/MqttVerticle.java index a18dd006..b1db2ded 100755 --- a/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/MqttVerticle.java +++ b/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/MqttVerticle.java @@ -55,7 +55,7 @@ public class MqttVerticle extends AbstractVerticle { } @Override - public void start() throws Exception { + public void start() { MqttServerOptions options = new MqttServerOptions() .setPort(config.getPort()); if (config.isSsl()) { @@ -103,7 +103,7 @@ public class MqttVerticle extends AbstractVerticle { endpoint.accept(false); endpoint.closeHandler((v) -> { log.warn("client connection closed,clientId:{}", clientId); - if (!mqttConnectPool.get(clientId)) { + if (Boolean.FALSE.equals(mqttConnectPool.get(clientId))) { return; } executor.onReceive(new HashMap<>(), "disconnect", clientId, (r) -> { @@ -213,8 +213,6 @@ public class MqttVerticle extends AbstractVerticle { Future result = endpoint.publish(topic, Buffer.buffer(msg), MqttQoS.AT_LEAST_ONCE, false, false); result.onFailure(e -> log.error("public topic failed", e)); - result.onSuccess(integer -> { - log.info("publish success,topic:{},payload:{}", topic, msg); - }); + result.onSuccess(integer -> log.info("publish success,topic:{},payload:{}", topic, msg)); } } diff --git a/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/TransparentConverter.java b/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/TransparentConverter.java index 5bdc998d..5254d3b8 100755 --- a/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/TransparentConverter.java +++ b/iot-components/iot-mqtt-component/src/main/java/cc/iotkit/comp/mqtt/TransparentConverter.java @@ -13,7 +13,6 @@ package cc.iotkit.comp.mqtt; import cc.iotkit.common.enums.ErrCode; import cc.iotkit.common.exception.BizException; import cc.iotkit.common.thing.ThingService; - import cc.iotkit.common.utils.SpringUtils; import cc.iotkit.converter.Device; import cc.iotkit.converter.DeviceMessage; diff --git a/iot-components/iot-websocket-component/src/main/java/cc/iotkit/comp/websocket/client/WebSocketClientVerticle.java b/iot-components/iot-websocket-component/src/main/java/cc/iotkit/comp/websocket/client/WebSocketClientVerticle.java index b124472a..e5c50a9b 100644 --- a/iot-components/iot-websocket-component/src/main/java/cc/iotkit/comp/websocket/client/WebSocketClientVerticle.java +++ b/iot-components/iot-websocket-component/src/main/java/cc/iotkit/comp/websocket/client/WebSocketClientVerticle.java @@ -22,6 +22,8 @@ import java.util.concurrent.ConcurrentHashMap; @Slf4j public class WebSocketClientVerticle extends AbstractDeviceVerticle { + public static final String DISCONNECT = "disconnect"; + private HttpClient httpClient; private WebSocket webSocketClient; @@ -40,6 +42,7 @@ public class WebSocketClientVerticle extends AbstractDeviceVerticle { this.webSocketConfig = JsonUtils.parseObject(config, WebSocketClientConfig.class); } + @Override public void start() { WebSocketConnectOptions options = new WebSocketConnectOptions().setPort(webSocketConfig.getPort()) .setHost(webSocketConfig.getIp()).setURI(webSocketConfig.getUrl()).setSsl(webSocketConfig.isSsl()); @@ -49,9 +52,9 @@ public class WebSocketClientVerticle extends AbstractDeviceVerticle { log.info("webSocket client connect success!"); ws.textMessageHandler(data -> { log.info("webSocket client receive msg:" + data); - executor.onReceive(new HashMap<>(), null, data, (ret) -> { + executor.onReceive(new HashMap<>(), null, data, ret -> { if (ret != null && ret.getData() instanceof RegisterInfo) { - executor.onReceive(null, "connected", data, (r) -> { + executor.onReceive(null, "connected", data, r -> { if (!devices.containsKey(getDeviceKey(r))) { devices.put(getDeviceKey(r), new Device(r.getDeviceName(), r.getProductKey())); } @@ -61,13 +64,13 @@ public class WebSocketClientVerticle extends AbstractDeviceVerticle { }); ws.closeHandler(e -> { for (String deviceKey : devices.keySet()) { - executor.onReceive(null, "disconnect", deviceKey); + executor.onReceive(null, DISCONNECT, deviceKey); } log.warn("client connection closed!"); }); ws.exceptionHandler(e -> { for (String deviceKey : devices.keySet()) { - executor.onReceive(null, "disconnect", deviceKey); + executor.onReceive(null, DISCONNECT, deviceKey); } log.error("webSocket client connect exception!"); }); @@ -79,16 +82,15 @@ public class WebSocketClientVerticle extends AbstractDeviceVerticle { executor.onReceive(new HashMap<>(), "ping", JsonUtils.toJsonString(webSocketConfig)); }); } - }).onFailure(e -> { - log.info("webSocket client connect failed!"); - }); + }).onFailure(e -> log.info("webSocket client connect failed!")); } @SneakyThrows + @Override public void stop() { vertx.cancelTimer(timerID); for (String deviceKey : devices.keySet()) { - executor.onReceive(null, "disconnect", deviceKey); + executor.onReceive(null, DISCONNECT, deviceKey); } httpClient.close(); } diff --git a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/bo/UpdateNodePropertiesBo.java b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/bo/UpdateNodePropertiesBo.java index ff83918f..e0a9b4fa 100644 --- a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/bo/UpdateNodePropertiesBo.java +++ b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/bo/UpdateNodePropertiesBo.java @@ -5,8 +5,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import java.util.Map; - /** * @author: regan * @description: diff --git a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/vo/UpdateNodePropertiesVo.java b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/vo/UpdateNodePropertiesVo.java index 8b2e71f6..3cbac0b3 100644 --- a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/vo/UpdateNodePropertiesVo.java +++ b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/vo/UpdateNodePropertiesVo.java @@ -5,8 +5,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import java.util.Map; - /** * @author: regan * @description: diff --git a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/vo/UpdateNodeVo.java b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/vo/UpdateNodeVo.java index 292177e3..ce018c25 100644 --- a/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/vo/UpdateNodeVo.java +++ b/iot-module/iot-baetyl/src/main/java/cc/iotkit/baetyl/dto/vo/UpdateNodeVo.java @@ -5,8 +5,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import java.util.Map; - /** * @author: regan * @description: diff --git a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/controller/IotContributorController.java b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/controller/IotContributorController.java index f81af2a6..69bc69a9 100644 --- a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/controller/IotContributorController.java +++ b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/controller/IotContributorController.java @@ -1,27 +1,28 @@ package cc.iotkit.contribution.controller; -import java.util.List; - - -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import javax.servlet.http.HttpServletResponse; -import jakarta.validation.constraints.*; -import cn.dev33.satoken.annotation.SaCheckPermission; -import org.springframework.web.bind.annotation.*; -import org.springframework.validation.annotation.Validated; -import cc.iotkit.common.log.annotation.Log; -import cc.iotkit.common.web.core.BaseController; import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.Paging; import cc.iotkit.common.api.Request; +import cc.iotkit.common.excel.utils.ExcelUtil; +import cc.iotkit.common.log.annotation.Log; +import cc.iotkit.common.log.enums.BusinessType; import cc.iotkit.common.validate.AddGroup; import cc.iotkit.common.validate.EditGroup; -import cc.iotkit.common.log.enums.BusinessType; -import cc.iotkit.common.excel.utils.ExcelUtil; -import cc.iotkit.contribution.dto.vo.IotContributorVo; +import cc.iotkit.common.web.core.BaseController; import cc.iotkit.contribution.dto.bo.IotContributorBo; +import cc.iotkit.contribution.dto.vo.IotContributorVo; import cc.iotkit.contribution.service.IIotContributorService; +import cn.dev33.satoken.annotation.SaCheckPermission; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** diff --git a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/data/IIotContributorData.java b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/data/IIotContributorData.java index 76bd21ab..d8b3ba37 100644 --- a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/data/IIotContributorData.java +++ b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/data/IIotContributorData.java @@ -1,8 +1,7 @@ package cc.iotkit.contribution.data; -import cc.iotkit.data.ICommonData; import cc.iotkit.contribution.model.IotContributor; -import java.util.List; +import cc.iotkit.data.ICommonData; /** * 数据接口 diff --git a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/data/impl/IotContributorDataImpl.java b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/data/impl/IotContributorDataImpl.java index db819953..51999653 100644 --- a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/data/impl/IotContributorDataImpl.java +++ b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/data/impl/IotContributorDataImpl.java @@ -1,32 +1,25 @@ package cc.iotkit.contribution.data.impl; -import cc.iotkit.contribution.repository.IotContributorRepository; -import cc.iotkit.data.ICommonData; -import cc.iotkit.contribution.data.IIotContributorData; -import cc.iotkit.contribution.data.model.TbIotContributor; -import cc.iotkit.contribution.model.IotContributor; -import java.util.List; - -import cc.iotkit.data.util.PageBuilder; -import com.google.common.collect.Lists; -import com.querydsl.core.QueryResults; -import com.querydsl.core.types.Predicate; -import com.querydsl.core.types.Projections; -import com.querydsl.jpa.impl.JPAQueryFactory; -import lombok.RequiredArgsConstructor; -import org.springframework.context.annotation.Primary; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Service; -import cc.iotkit.data.util.PredicateBuilder; - import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.Paging; -import cc.iotkit.common.utils.StringUtils; -import java.util.Collection; -import java.util.Optional; - import cc.iotkit.common.utils.MapstructUtils; +import cc.iotkit.common.utils.StringUtils; +import cc.iotkit.contribution.data.IIotContributorData; +import cc.iotkit.contribution.data.model.TbIotContributor; +import cc.iotkit.contribution.model.IotContributor; +import cc.iotkit.contribution.repository.IotContributorRepository; +import cc.iotkit.data.util.PageBuilder; +import cc.iotkit.data.util.PredicateBuilder; +import com.google.common.collect.Lists; +import com.querydsl.core.types.Predicate; +import com.querydsl.jpa.impl.JPAQueryFactory; +import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; +import java.util.Collection; +import java.util.List; +import java.util.Optional; import static cc.iotkit.contribution.data.model.QTbIotContributor.tbIotContributor; /** @@ -113,7 +106,6 @@ public class IotContributorDataImpl implements IIotContributorData { @Override public IotContributor findById(Long id) { TbIotContributor ret = jpaQueryFactory.select(tbIotContributor).from(tbIotContributor).where(tbIotContributor.id.eq(id)).fetchOne(); - IotContributor convert = MapstructUtils.convert(ret, IotContributor.class); - return convert; + return MapstructUtils.convert(ret, IotContributor.class); } } diff --git a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/data/model/TbIotContributor.java b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/data/model/TbIotContributor.java index 6682c07e..193bfae7 100644 --- a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/data/model/TbIotContributor.java +++ b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/data/model/TbIotContributor.java @@ -1,6 +1,7 @@ package cc.iotkit.contribution.data.model; import cc.iotkit.contribution.model.IotContributor; +import cc.iotkit.data.model.BaseEntity; import io.github.linpeilie.annotations.AutoMapper; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -13,10 +14,6 @@ import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; -import cc.iotkit.data.model.BaseEntity; -import lombok.Data; -import lombok.EqualsAndHashCode; - /** * 贡献者对象 iot_contributor diff --git a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/dto/bo/IotContributorBo.java b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/dto/bo/IotContributorBo.java index 108f8f56..030d0cbd 100644 --- a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/dto/bo/IotContributorBo.java +++ b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/dto/bo/IotContributorBo.java @@ -1,17 +1,14 @@ package cc.iotkit.contribution.dto.bo; -import cc.iotkit.contribution.model.IotContributor; import cc.iotkit.common.api.BaseDto; -import cc.iotkit.common.api.PageRequest; -import cc.iotkit.common.api.Paging; -import cc.iotkit.common.api.Request; import cc.iotkit.common.validate.AddGroup; import cc.iotkit.common.validate.EditGroup; +import cc.iotkit.contribution.model.IotContributor; import io.github.linpeilie.annotations.AutoMapper; import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.constraints.NotBlank; import lombok.Data; import lombok.EqualsAndHashCode; -import jakarta.validation.constraints.*; /** * 贡献者业务对象 iot_contributor diff --git a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/dto/vo/IotContributorVo.java b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/dto/vo/IotContributorVo.java index 0ead8698..022630ad 100644 --- a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/dto/vo/IotContributorVo.java +++ b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/dto/vo/IotContributorVo.java @@ -1,15 +1,14 @@ package cc.iotkit.contribution.dto.vo; +import cc.iotkit.common.excel.annotation.ExcelDictFormat; +import cc.iotkit.common.excel.convert.ExcelDictConvert; import cc.iotkit.contribution.model.IotContributor; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelProperty; -import cc.iotkit.common.excel.annotation.ExcelDictFormat; -import cc.iotkit.common.excel.convert.ExcelDictConvert; import io.github.linpeilie.annotations.AutoMapper; import lombok.Data; import java.io.Serializable; -import java.util.Date; diff --git a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/model/IotContributor.java b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/model/IotContributor.java index a2659e4a..e9b5ca15 100644 --- a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/model/IotContributor.java +++ b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/model/IotContributor.java @@ -1,7 +1,7 @@ package cc.iotkit.contribution.model; -import cc.iotkit.model.Id; import cc.iotkit.model.BaseModel; +import cc.iotkit.model.Id; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/service/IIotContributorService.java b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/service/IIotContributorService.java index b36d4b9e..81e89a3d 100644 --- a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/service/IIotContributorService.java +++ b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/service/IIotContributorService.java @@ -1,10 +1,9 @@ package cc.iotkit.contribution.service; -import cc.iotkit.contribution.dto.vo.IotContributorVo; -import cc.iotkit.contribution.dto.bo.IotContributorBo; - -import cc.iotkit.common.api.Paging; import cc.iotkit.common.api.PageRequest; +import cc.iotkit.common.api.Paging; +import cc.iotkit.contribution.dto.bo.IotContributorBo; +import cc.iotkit.contribution.dto.vo.IotContributorVo; import java.util.Collection; import java.util.List; diff --git a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/service/impl/IotContributorServiceImpl.java b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/service/impl/IotContributorServiceImpl.java index d48cfa14..403586e5 100644 --- a/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/service/impl/IotContributorServiceImpl.java +++ b/iot-module/iot-contribution/src/main/java/cc/iotkit/contribution/service/impl/IotContributorServiceImpl.java @@ -1,22 +1,19 @@ package cc.iotkit.contribution.service.impl; -import cc.iotkit.common.utils.MapstructUtils; -import cc.iotkit.common.utils.StringUtils; import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.Paging; -import cc.iotkit.common.api.Request; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; +import cc.iotkit.common.exception.BizException; +import cc.iotkit.common.utils.MapstructUtils; +import cc.iotkit.contribution.data.IIotContributorData; import cc.iotkit.contribution.dto.bo.IotContributorBo; import cc.iotkit.contribution.dto.vo.IotContributorVo; import cc.iotkit.contribution.model.IotContributor; import cc.iotkit.contribution.service.IIotContributorService; -import cc.iotkit.contribution.data.IIotContributorData; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; -import java.util.List; -import java.util.Map; import java.util.Collection; -import cc.iotkit.common.exception.BizException; +import java.util.List; /** @@ -44,8 +41,7 @@ public class IotContributorServiceImpl implements IIotContributorService { */ @Override public Paging queryPageList(PageRequest pageQuery) { - Paging result = baseData.findAll(pageQuery.to(IotContributor.class)).to(IotContributorVo.class); - return result; + return baseData.findAll(pageQuery.to(IotContributor.class)).to(IotContributorVo.class); } /** @@ -79,10 +75,7 @@ public class IotContributorServiceImpl implements IIotContributorService { IotContributor update = MapstructUtils.convert(bo, IotContributor.class); validEntityBeforeSave(update); IotContributor ret = baseData.save(update); - if(ret == null){ - return false; - } - return true; + return ret != null; } /** diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/config/MybatisPlusConfig.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/config/MybatisPlusConfig.java index 957a7c92..c7e96a90 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/config/MybatisPlusConfig.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/config/MybatisPlusConfig.java @@ -1,21 +1,13 @@ package cc.iotkit.generator.config; import cc.iotkit.generator.core.DbIdGenerator; -import cc.iotkit.generator.factory.YmlPropertySourceFactory; -import cn.hutool.core.net.NetUtil; -import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; -import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator; import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; -//import org.dromara.common.core.factory.YmlPropertySourceFactory; -//import org.dromara.common.mybatis.handler.InjectionMetaObjectHandler; -//import org.dromara.common.mybatis.interceptor.PlusDataPermissionInterceptor; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.PropertySource; import org.springframework.transaction.annotation.EnableTransactionManagement; /** diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/controller/GenController.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/controller/GenController.java index 53b2aaca..984baf12 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/controller/GenController.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/controller/GenController.java @@ -3,25 +3,21 @@ package cc.iotkit.generator.controller; import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.Paging; import cc.iotkit.common.api.Request; -import cc.iotkit.generator.dto.bo.ImportTableBo; -import cn.hutool.core.convert.Convert; -import cn.hutool.core.io.IoUtil; - -import cc.iotkit.common.web.core.BaseController; - import cc.iotkit.common.log.annotation.Log; import cc.iotkit.common.log.enums.BusinessType; +import cc.iotkit.common.web.core.BaseController; import cc.iotkit.generator.domain.GenTable; import cc.iotkit.generator.domain.GenTableColumn; +import cc.iotkit.generator.dto.bo.ImportTableBo; import cc.iotkit.generator.service.IGenTableService; -import io.swagger.annotations.ApiOperation; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.io.IoUtil; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; - import java.io.IOException; import java.util.HashMap; import java.util.List; @@ -62,7 +58,7 @@ public class GenController extends BaseController { GenTable table = genTableService.selectGenTableById(tableId); List tables = genTableService.selectGenTableAll(); List list = genTableService.selectGenTableColumnListByTableId(tableId); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("info", table); map.put("rows", list); map.put("tables", tables); @@ -108,7 +104,6 @@ public class GenController extends BaseController { // 查询表信息 List tableList = genTableService.selectDbTableListByNames(tables); genTableService.importGenTable(tableList); - return; } /** @@ -122,7 +117,6 @@ public class GenController extends BaseController { GenTable genTable = bo.getData(); genTableService.validateEdit(genTable); genTableService.updateGenTable(genTable); - return; } /** @@ -136,7 +130,6 @@ public class GenController extends BaseController { @ApiOperation(value = "删除代码生成", notes = "删除代码生成") public void remove(@Validated @RequestBody Request> bo) { genTableService.deleteGenTableByIds(bo.getData()); - return; } /** @@ -175,7 +168,6 @@ public class GenController extends BaseController { @PostMapping("/genCode/{tableName}") public void genCode(@PathVariable("tableName") String tableName) { genTableService.generatorCode(tableName); - return ; } /** @@ -188,7 +180,6 @@ public class GenController extends BaseController { @PostMapping("/synchDb") public void synchDb(@Validated @RequestBody Request bo) { genTableService.synchDb(bo.getData()); - return ; } /** diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/BaseEntity.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/BaseEntity.java index dcc1daa5..8e2109c0 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/BaseEntity.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/BaseEntity.java @@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; - import java.io.Serializable; import java.util.Date; import java.util.HashMap; diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/BaseMapperPlus.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/BaseMapperPlus.java index cb2d67ec..378813e7 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/BaseMapperPlus.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/BaseMapperPlus.java @@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.ReflectionKit; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.toolkit.Db; - import org.apache.ibatis.logging.Log; import org.apache.ibatis.logging.LogFactory; diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/DataBaseHelper.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/DataBaseHelper.java index 1ee0d49c..22243391 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/DataBaseHelper.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/DataBaseHelper.java @@ -7,7 +7,6 @@ import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; import lombok.AccessLevel; import lombok.NoArgsConstructor; - import javax.sql.DataSource; import java.sql.Connection; import java.sql.DatabaseMetaData; diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/DbIdGenerator.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/DbIdGenerator.java index df8dea2c..f1c748e8 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/DbIdGenerator.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/DbIdGenerator.java @@ -1,17 +1,9 @@ package cc.iotkit.generator.core; -import cn.hutool.core.net.NetUtil; import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; import com.github.yitter.contract.IdGeneratorOptions; import com.github.yitter.idgen.YitIdHelper; -import org.springframework.stereotype.Component; - -import javax.annotation.PostConstruct; -import java.io.Serializable; -import java.lang.reflect.Field; -import java.util.Objects; - /** * @author: Jay * @description: diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/PageBuilder.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/PageBuilder.java index ac4a3ffe..0d5d7510 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/PageBuilder.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/PageBuilder.java @@ -1,18 +1,10 @@ package cc.iotkit.generator.core; import cc.iotkit.common.api.PageRequest; -import cc.iotkit.common.exception.BizException; -import cc.iotkit.common.utils.StringUtils; -import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; -import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import lombok.Data; import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; /** * 分页查询实体类 @@ -24,12 +16,10 @@ import java.util.Map; public class PageBuilder implements Serializable { - static public Page build(PageRequest pageRequest) { - Integer pageNum = ObjectUtil.defaultIfNull(pageRequest.getPageNum(), PageQuery.DEFAULT_PAGE_NUM); - Integer pageSize = ObjectUtil.defaultIfNull(pageRequest.getPageSize(), PageQuery.DEFAULT_PAGE_SIZE); - Page page = new Page(pageNum, pageSize); - - return page; + public static Page build(PageRequest pageRequest) { + Integer pageNum = ObjectUtil.defaultIfNull(pageRequest.getPageNum(), PageQuery.DEFAULT_PAGE_NUM); + Integer pageSize = ObjectUtil.defaultIfNull(pageRequest.getPageSize(), PageQuery.DEFAULT_PAGE_SIZE); + return new Page(pageNum, pageSize); } } diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/PageQuery.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/PageQuery.java index e4a17d47..efab0216 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/PageQuery.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/PageQuery.java @@ -8,10 +8,9 @@ import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.Data; - - import java.io.Serializable; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -81,7 +80,7 @@ public class PageQuery implements Serializable { */ private List buildOrderItem() { if (StringUtils.isBlank(orderByColumn) || StringUtils.isBlank(isAsc)) { - return null; + return Collections.emptyList(); } String orderBy = SqlUtil.escapeOrderBySql(orderByColumn); orderBy = StringUtils.toUnderScoreCase(orderBy); diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/domain/GenTable.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/domain/GenTable.java index be58149b..16c1a903 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/domain/GenTable.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/domain/GenTable.java @@ -1,13 +1,12 @@ package cc.iotkit.generator.domain; import cc.iotkit.common.utils.StringUtils; +import cc.iotkit.generator.constant.GenConstants; import cc.iotkit.generator.core.BaseEntity; import com.baomidou.mybatisplus.annotation.FieldStrategy; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; - -import cc.iotkit.generator.constant.GenConstants; import jakarta.validation.Valid; import jakarta.validation.constraints.NotBlank; import lombok.Data; diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/domain/GenTableColumn.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/domain/GenTableColumn.java index 2d07c9dc..6535f28f 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/domain/GenTableColumn.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/domain/GenTableColumn.java @@ -6,13 +6,11 @@ import com.baomidou.mybatisplus.annotation.FieldStrategy; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; - +import jakarta.validation.constraints.NotBlank; import lombok.Data; import lombok.EqualsAndHashCode; import org.apache.ibatis.type.JdbcType; -import jakarta.validation.constraints.NotBlank; - /** * 代码生成业务字段表 gen_table_column * diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/mapper/GenTableColumnMapper.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/mapper/GenTableColumnMapper.java index 3b0ebcd6..ad5a4a53 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/mapper/GenTableColumnMapper.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/mapper/GenTableColumnMapper.java @@ -1,9 +1,8 @@ package cc.iotkit.generator.mapper; import cc.iotkit.generator.core.BaseMapperPlus; -import com.baomidou.mybatisplus.annotation.InterceptorIgnore; - import cc.iotkit.generator.domain.GenTableColumn; +import com.baomidou.mybatisplus.annotation.InterceptorIgnore; import java.util.List; diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/mapper/GenTableMapper.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/mapper/GenTableMapper.java index a6948a20..42f8f9bd 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/mapper/GenTableMapper.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/mapper/GenTableMapper.java @@ -1,10 +1,9 @@ package cc.iotkit.generator.mapper; import cc.iotkit.generator.core.BaseMapperPlus; +import cc.iotkit.generator.domain.GenTable; import com.baomidou.mybatisplus.annotation.InterceptorIgnore; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; - -import cc.iotkit.generator.domain.GenTable; import org.apache.ibatis.annotations.Param; import java.util.Collection; diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/service/GenTableServiceImpl.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/service/GenTableServiceImpl.java index fa02269a..7887ca3e 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/service/GenTableServiceImpl.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/service/GenTableServiceImpl.java @@ -4,13 +4,21 @@ import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.Paging; import cc.iotkit.common.constant.Constants; import cc.iotkit.common.exception.BizException; +import cc.iotkit.common.satoken.utils.LoginHelper; import cc.iotkit.common.utils.JsonUtils; import cc.iotkit.common.utils.StreamUtils; import cc.iotkit.common.utils.StringUtils; import cc.iotkit.common.utils.file.FileUtils; +import cc.iotkit.generator.constant.GenConstants; import cc.iotkit.generator.core.DbIdGenerator; import cc.iotkit.generator.core.PageBuilder; -import cc.iotkit.generator.core.PageQuery; +import cc.iotkit.generator.domain.GenTable; +import cc.iotkit.generator.domain.GenTableColumn; +import cc.iotkit.generator.mapper.GenTableColumnMapper; +import cc.iotkit.generator.mapper.GenTableMapper; +import cc.iotkit.generator.util.GenUtils; +import cc.iotkit.generator.util.VelocityInitializer; +import cc.iotkit.generator.util.VelocityUtils; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.lang.Dict; @@ -20,17 +28,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; - -import cc.iotkit.generator.constant.GenConstants; - -import cc.iotkit.common.satoken.utils.LoginHelper; -import cc.iotkit.generator.domain.GenTable; -import cc.iotkit.generator.domain.GenTableColumn; -import cc.iotkit.generator.mapper.GenTableColumnMapper; -import cc.iotkit.generator.mapper.GenTableMapper; -import cc.iotkit.generator.util.GenUtils; -import cc.iotkit.generator.util.VelocityInitializer; -import cc.iotkit.generator.util.VelocityUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.velocity.Template; diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/service/IGenTableService.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/service/IGenTableService.java index adbd40a6..7b53f199 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/service/IGenTableService.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/service/IGenTableService.java @@ -1,10 +1,8 @@ package cc.iotkit.generator.service; - import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.Paging; -import cc.iotkit.generator.core.PageQuery; import cc.iotkit.generator.domain.GenTable; import cc.iotkit.generator.domain.GenTableColumn; diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/util/GenUtils.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/util/GenUtils.java index a409474b..4659c5e7 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/util/GenUtils.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/util/GenUtils.java @@ -1,17 +1,14 @@ package cc.iotkit.generator.util; -import cc.iotkit.common.utils.StringUtils; -import cc.iotkit.generator.constant.GenConstants; - import cc.iotkit.common.satoken.utils.LoginHelper; +import cc.iotkit.common.utils.StringUtils; import cc.iotkit.generator.config.GenConfig; +import cc.iotkit.generator.constant.GenConstants; import cc.iotkit.generator.domain.GenTable; import cc.iotkit.generator.domain.GenTableColumn; +import cn.hutool.core.util.ReUtil; import lombok.AccessLevel; import lombok.NoArgsConstructor; -import cn.hutool.core.util.ReUtil; - - import java.util.Arrays; diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/util/VelocityUtils.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/util/VelocityUtils.java index 47cdc631..88b2768d 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/util/VelocityUtils.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/util/VelocityUtils.java @@ -3,14 +3,13 @@ package cc.iotkit.generator.util; import cc.iotkit.common.utils.DateUtils; import cc.iotkit.common.utils.JsonUtils; import cc.iotkit.common.utils.StringUtils; +import cc.iotkit.generator.constant.GenConstants; import cc.iotkit.generator.core.DataBaseHelper; +import cc.iotkit.generator.domain.GenTable; +import cc.iotkit.generator.domain.GenTableColumn; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.lang.Dict; -import cc.iotkit.generator.constant.GenConstants; - -import cc.iotkit.generator.domain.GenTable; -import cc.iotkit.generator.domain.GenTableColumn; import lombok.AccessLevel; import lombok.NoArgsConstructor; import org.apache.velocity.VelocityContext; @@ -225,7 +224,7 @@ public class VelocityUtils { */ public static HashSet getImportList(GenTable genTable) { List columns = genTable.getColumns(); - HashSet importList = new HashSet(); + HashSet importList = new HashSet<>(); for (GenTableColumn column : columns) { if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType())) { importList.add("java.util.Date"); diff --git a/iot-module/iot-generator/src/main/resources/vm/ts/api.ts.vm b/iot-module/iot-generator/src/main/resources/vm/ts/api.ts.vm index 4341db23..ee309bc7 100644 --- a/iot-module/iot-generator/src/main/resources/vm/ts/api.ts.vm +++ b/iot-module/iot-generator/src/main/resources/vm/ts/api.ts.vm @@ -1,48 +1,48 @@ import request from '@/utils/request'; -import { AxiosPromise } from 'axios'; -import { ${BusinessName}VO, ${BusinessName}Form, ${BusinessName}Query } from './types'; +import {AxiosPromise} from 'axios'; +import {${BusinessName}Form, ${BusinessName}Query, ${BusinessName}VO} from './types'; // 查询${functionName}列表 export const list${BusinessName}(query: ${BusinessName}Query): AxiosPromise<${BusinessName}VO[]> { - return request({ - url: '/${moduleName}/${businessName}/list', - method: 'post', - params: query - }) + return request({ + url: '/${moduleName}/${businessName}/list', + method: 'post', + params: query + }) } // 查询${functionName}详细 -export const get${BusinessName}(${pkColumn.javaField}: string | number) : AxiosPromise<${BusinessName}VO> { - return request({ - url: '/${moduleName}/${businessName}/getDetail', - method: 'post', - data: ${pkColumn.javaField} - }) +export const get${BusinessName}(${pkColumn.javaField}: string | number): AxiosPromise<${BusinessName}VO> { + return request({ + url: '/${moduleName}/${businessName}/getDetail', + method: 'post', + data: ${pkColumn.javaField} + }) } // 新增${functionName} export const add${BusinessName}(data: ${BusinessName}Form) { - return request({ - url: '/${moduleName}/${businessName}/add', - method: 'post', - data - }) + return request({ + url: '/${moduleName}/${businessName}/add', + method: 'post', + data + }) } // 修改${functionName} export const update${BusinessName}(data: ${BusinessName}Form) { - return request({ - url: '/${moduleName}/${businessName}/edit', - method: 'post', - data: data - }) + return request({ + url: '/${moduleName}/${businessName}/edit', + method: 'post', + data: data + }) } // 删除${functionName} export const del${BusinessName}(${pkColumn.javaField}: Array) { - return request({ - url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, - method: 'post', - data: ${pkColumn.javaField} - }) + return request({ + url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, + method: 'post', + data: ${pkColumn.javaField} + }) } diff --git a/iot-module/iot-generator/src/main/resources/vm/vue/index-tree.vue.vm b/iot-module/iot-generator/src/main/resources/vm/vue/index-tree.vue.vm index dda1b467..dbfa4b98 100644 --- a/iot-module/iot-generator/src/main/resources/vm/vue/index-tree.vue.vm +++ b/iot-module/iot-generator/src/main/resources/vm/vue/index-tree.vue.vm @@ -266,13 +266,12 @@