From 1b7278416649e8dcd60ffaa6144d2558b942526b Mon Sep 17 00:00:00 2001 From: jay <75509151@qq.com> Date: Mon, 29 May 2023 11:47:32 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cc/iotkit/common/api/PageRequest.java | 3 + .../data/dao/ProtocolComponentRepository.java | 3 +- .../data/service/AlertConfigDataImpl.java | 28 ++++++++- .../data/service/AlertRecordDataImpl.java | 27 ++++++++- .../iotkit/data/service/CategoryDataImpl.java | 36 ++++++++--- .../data/service/ChannelConfigDataImpl.java | 34 +++++++++-- .../iotkit/data/service/ChannelDataImpl.java | 34 +++++++++-- .../data/service/ChannelTemplateDataImpl.java | 35 +++++++++-- .../data/service/DeviceConfigDataImpl.java | 34 +++++++++-- .../data/service/DeviceGroupDataImpl.java | 32 ++++++++-- .../data/service/DeviceInfoDataImpl.java | 32 ++++++++-- .../cc/iotkit/data/service/HomeDataImpl.java | 32 +++++++++- .../data/service/OauthClientDataImpl.java | 31 +++++++++- .../iotkit/data/service/ProductDataImpl.java | 35 +++++++++-- .../service/ProtocolComponentDataImpl.java | 45 ++++++++++++-- .../service/ProtocolConverterDataImpl.java | 34 +++++++++-- .../iotkit/data/service/RuleInfoDataImpl.java | 35 +++++++++-- .../cc/iotkit/data/service/SpaceDataImpl.java | 32 +++++++++- .../data/service/SpaceDeviceDataImpl.java | 31 +++++++++- .../data/service/SysConfigDataImpl.java | 30 ++++------ .../iotkit/data/service/SysMenuDataImpl.java | 28 +-------- .../iotkit/data/service/TaskInfoDataImpl.java | 34 +++++++++-- .../data/service/ThingModelDataImpl.java | 29 ++++++++- .../iotkit/data/service/UserInfoDataImpl.java | 11 +--- .../data/service/VirtualDeviceDataImpl.java | 32 ++++++++-- .../java/cc/iotkit/data/util/PageBuilder.java | 25 ++++++++ .../tenant/exception/TenantException.java | 2 +- .../cc/iotkit/comp/utils/SpringUtils.java | 2 +- .../iotkit/comp/emqx/EmqxDeviceComponent.java | 3 +- .../comp/emqx/TransparentConverter.java | 3 +- .../comp/mqtt/TransparentConverter.java | 3 +- .../controller/ProtocolController.java | 14 ++--- .../ProtocolComponentBo.java | 22 +++++++ .../ProtocolConverterBo.java | 20 +++++++ .../ProtocolComponentVo.java | 59 +++++++++++++++++++ .../manager/service/ExampleDataInit.java | 4 +- .../manager/service/IProtocolService.java | 20 +++++++ .../handler/RuleDeviceConsumer.java | 3 +- .../iotkit/ruleengine/rule/RuleManager.java | 8 +-- .../iotkit/ruleengine/task/TaskManager.java | 9 ++- .../system/controller/SysOssController.java | 2 +- .../system/controller/SysPostController.java | 3 +- .../cc/iotkit/system/dto/bo/SysRoleBo.java | 2 +- .../cc/iotkit/system/dto/vo/SysRoleVo.java | 2 +- .../system/service/ISysRoleService.java | 2 +- .../service/impl/SysRoleServiceImpl.java | 10 +++- pom.xml | 29 +++++++++ 47 files changed, 805 insertions(+), 179 deletions(-) create mode 100644 iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/protocolcomponent/ProtocolComponentBo.java create mode 100644 iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/protocolconverter/ProtocolConverterBo.java create mode 100644 iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/vo/protocolcomponent/ProtocolComponentVo.java create mode 100644 iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/IProtocolService.java diff --git a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/api/PageRequest.java b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/api/PageRequest.java index fd22e32b..702cbd55 100644 --- a/iot-common/iot-common-core/src/main/java/cc/iotkit/common/api/PageRequest.java +++ b/iot-common/iot-common-core/src/main/java/cc/iotkit/common/api/PageRequest.java @@ -2,6 +2,7 @@ package cc.iotkit.common.api; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.SnowflakeIdGeneratorUtil; +import cn.hutool.core.collection.CollUtil; import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; @@ -87,4 +88,6 @@ public class PageRequest extends Request implements Serializable { } + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/ProtocolComponentRepository.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/ProtocolComponentRepository.java index 166cb0dd..8c309f18 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/ProtocolComponentRepository.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/ProtocolComponentRepository.java @@ -13,10 +13,11 @@ import cc.iotkit.data.model.TbProtocolComponent; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.querydsl.QuerydslPredicateExecutor; import java.util.List; -public interface ProtocolComponentRepository extends JpaRepository { +public interface ProtocolComponentRepository extends JpaRepository, QuerydslPredicateExecutor{ List findByState(String state); diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/AlertConfigDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/AlertConfigDataImpl.java index 870c36c4..5c86d1bc 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/AlertConfigDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/AlertConfigDataImpl.java @@ -14,6 +14,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -30,12 +31,22 @@ public class AlertConfigDataImpl implements IAlertConfigData { return null; } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public AlertConfig save(AlertConfig data) { alertConfigRepository.save(MapstructUtils.convert(data, TbAlertConfig.class)); return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String s) { @@ -43,10 +54,12 @@ public class AlertConfigDataImpl implements IAlertConfigData { } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + + @Override public long count() { return 0; @@ -58,10 +71,21 @@ public class AlertConfigDataImpl implements IAlertConfigData { } @Override - public Paging findAll(int page, int size) { + public Paging findAll(PageRequest pageRequest) { return null; } + @Override + public List findAllByCondition(AlertConfig data) { + return null; + } + + @Override + public AlertConfig findOneByCondition(AlertConfig data) { + return null; + } + + @Override public Paging selectAlertConfigPage(PageRequest request) { Page alertConfigPage = alertConfigRepository.findAll(Pageable.ofSize(request.getPageSize()).withPage(request.getPageNum() - 1)); diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/AlertRecordDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/AlertRecordDataImpl.java index 64d80ca9..9499e045 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/AlertRecordDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/AlertRecordDataImpl.java @@ -8,6 +8,7 @@ import cc.iotkit.data.model.TbAlertRecord; import cc.iotkit.common.api.Paging; import cc.iotkit.model.alert.AlertRecord; +import java.util.Collection; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -29,11 +30,21 @@ public class AlertRecordDataImpl implements IAlertRecordData { return null; } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public AlertRecord save(AlertRecord data) { return null; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String s) { @@ -41,10 +52,11 @@ public class AlertRecordDataImpl implements IAlertRecordData { } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + @Override public long count() { return 0; @@ -56,10 +68,21 @@ public class AlertRecordDataImpl implements IAlertRecordData { } @Override - public Paging findAll(int page, int size) { + public Paging findAll(PageRequest pageRequest) { return null; } + @Override + public List findAllByCondition(AlertRecord data) { + return null; + } + + @Override + public AlertRecord findOneByCondition(AlertRecord data) { + return null; + } + + @Override public Paging selectAlertConfigPage(PageRequest request) { diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/CategoryDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/CategoryDataImpl.java index 91695038..421f88de 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/CategoryDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/CategoryDataImpl.java @@ -9,6 +9,7 @@ */ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.manager.ICategoryData; import cc.iotkit.data.dao.CategoryRepository; @@ -20,6 +21,7 @@ import org.springframework.context.annotation.Primary; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @@ -35,6 +37,11 @@ public class CategoryDataImpl implements ICategoryData { return MapstructUtils.convert(categoryRepository.findById(s).orElse(null), Category.class); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public Category save(Category data) { TbCategory tb = categoryRepository.save(MapstructUtils.convert(data, TbCategory.class)); @@ -42,16 +49,23 @@ public class CategoryDataImpl implements ICategoryData { return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String s) { categoryRepository.deleteById(s); } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + + @Override public long count() { return categoryRepository.count(); @@ -65,12 +79,20 @@ public class CategoryDataImpl implements ICategoryData { } @Override - public Paging findAll(int page, int size) { - return new Paging<>( - categoryRepository.count(), - MapstructUtils.convert(categoryRepository.findAll( - Pageable.ofSize(size).withPage(page - 1)).getContent(), - Category.class)); + public Paging findAll(PageRequest pageRequest) { + return null; } + @Override + public List findAllByCondition(Category data) { + return null; + } + + @Override + public Category findOneByCondition(Category data) { + return null; + } + + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ChannelConfigDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ChannelConfigDataImpl.java index 08fd4b45..90926ec2 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ChannelConfigDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ChannelConfigDataImpl.java @@ -1,5 +1,6 @@ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.manager.IChannelConfigData; import cc.iotkit.data.dao.ChannelConfigRepository; @@ -13,6 +14,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -33,6 +35,11 @@ public class ChannelConfigDataImpl implements IChannelConfigData { return MapstructUtils.convert(channelConfigRepository.findById(id).orElse(null), ChannelConfig.class); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public ChannelConfig save(ChannelConfig data) { if (StringUtils.isBlank(data.getId())) { @@ -42,16 +49,22 @@ public class ChannelConfigDataImpl implements IChannelConfigData { return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String id) { channelConfigRepository.deleteById(id); } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + @Override public long count() { return channelConfigRepository.count(); @@ -63,10 +76,19 @@ public class ChannelConfigDataImpl implements IChannelConfigData { } @Override - public Paging findAll(int page, int size) { - Page tbDeviceConfigs = channelConfigRepository.findAll(Pageable.ofSize(size).withPage(page - 1)); - return new Paging<>( - tbDeviceConfigs.getTotalElements(), - MapstructUtils.convert(tbDeviceConfigs.getContent(), ChannelConfig.class)); + public Paging findAll(PageRequest pageRequest) { + return null; } + + @Override + public List findAllByCondition(ChannelConfig data) { + return null; + } + + @Override + public ChannelConfig findOneByCondition(ChannelConfig data) { + return null; + } + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ChannelDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ChannelDataImpl.java index fb86fb02..375886b9 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ChannelDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ChannelDataImpl.java @@ -1,5 +1,6 @@ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.manager.IChannelData; import cc.iotkit.data.dao.ChannelRepository; @@ -13,6 +14,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -33,6 +35,11 @@ public class ChannelDataImpl implements IChannelData { return MapstructUtils.convert(channelRepository.findById(id).orElse(null), Channel.class); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public Channel save(Channel data) { if (StringUtils.isBlank(data.getId())) { @@ -44,6 +51,11 @@ public class ChannelDataImpl implements IChannelData { return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String id) { @@ -51,10 +63,11 @@ public class ChannelDataImpl implements IChannelData { } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + @Override public long count() { return channelRepository.count(); @@ -66,10 +79,19 @@ public class ChannelDataImpl implements IChannelData { } @Override - public Paging findAll(int page, int size) { - Page tbDeviceConfigs = channelRepository.findAll(Pageable.ofSize(size).withPage(page - 1)); - return new Paging<>( - tbDeviceConfigs.getTotalElements(), - MapstructUtils.convert(tbDeviceConfigs.getContent(), Channel.class)); + public Paging findAll(PageRequest pageRequest) { + return null; } + + @Override + public List findAllByCondition(Channel data) { + return null; + } + + @Override + public Channel findOneByCondition(Channel data) { + return null; + } + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ChannelTemplateDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ChannelTemplateDataImpl.java index cd1f0dac..cfbbdd4a 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ChannelTemplateDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ChannelTemplateDataImpl.java @@ -1,5 +1,6 @@ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.manager.IChannelTemplateData; import cc.iotkit.data.dao.ChannelTemplateRepository; @@ -13,6 +14,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Collection; import java.util.List; import java.util.UUID; import java.util.stream.Collectors; @@ -34,6 +36,11 @@ public class ChannelTemplateDataImpl implements IChannelTemplateData { return MapstructUtils.convert(channelTemplateRepository.findById(id).orElse(null), ChannelTemplate.class); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public ChannelTemplate save(ChannelTemplate data) { if (StringUtils.isBlank(data.getId())) { @@ -43,6 +50,11 @@ public class ChannelTemplateDataImpl implements IChannelTemplateData { return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String id) { @@ -50,10 +62,12 @@ public class ChannelTemplateDataImpl implements IChannelTemplateData { } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + + @Override public long count() { return channelTemplateRepository.count(); @@ -67,10 +81,19 @@ public class ChannelTemplateDataImpl implements IChannelTemplateData { } @Override - public Paging findAll(int page, int size) { - Page tbDeviceConfigs = channelTemplateRepository.findAll(Pageable.ofSize(size).withPage(page - 1)); - return new Paging<>( - tbDeviceConfigs.getTotalElements(), - MapstructUtils.convert(tbDeviceConfigs.getContent(), ChannelTemplate.class)); + public Paging findAll(PageRequest pageRequest) { + return null; } + + @Override + public List findAllByCondition(ChannelTemplate data) { + return null; + } + + @Override + public ChannelTemplate findOneByCondition(ChannelTemplate data) { + return null; + } + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceConfigDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceConfigDataImpl.java index b3a693e7..3d48531b 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceConfigDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceConfigDataImpl.java @@ -9,6 +9,7 @@ */ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.manager.IDeviceConfigData; import cc.iotkit.data.dao.DeviceConfigRepository; @@ -22,6 +23,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -47,6 +49,11 @@ public class DeviceConfigDataImpl implements IDeviceConfigData { return MapstructUtils.convert(deviceConfigRepository.findById(s).orElse(null), DeviceConfig.class); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public DeviceConfig save(DeviceConfig data) { if (StringUtils.isBlank(data.getId())) { @@ -56,6 +63,11 @@ public class DeviceConfigDataImpl implements IDeviceConfigData { return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String s) { @@ -63,10 +75,11 @@ public class DeviceConfigDataImpl implements IDeviceConfigData { } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + @Override public long count() { return deviceConfigRepository.count(); @@ -78,10 +91,19 @@ public class DeviceConfigDataImpl implements IDeviceConfigData { } @Override - public Paging findAll(int page, int size) { - Page tbDeviceConfigs = deviceConfigRepository.findAll(Pageable.ofSize(size).withPage(page - 1)); - return new Paging<>( - tbDeviceConfigs.getTotalElements(), - MapstructUtils.convert(tbDeviceConfigs.getContent(), DeviceConfig.class)); + public Paging findAll(PageRequest pageRequest) { + return null; } + + @Override + public List findAllByCondition(DeviceConfig data) { + return null; + } + + @Override + public DeviceConfig findOneByCondition(DeviceConfig data) { + return null; + } + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceGroupDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceGroupDataImpl.java index 9c06303e..33d9f337 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceGroupDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceGroupDataImpl.java @@ -1,5 +1,6 @@ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.manager.IDeviceGroupData; import cc.iotkit.data.dao.DeviceGroupRepository; @@ -13,6 +14,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -36,6 +38,11 @@ public class DeviceGroupDataImpl implements IDeviceGroupData { return MapstructUtils.convert(deviceGroupRepository.findById(s).orElse(null), DeviceGroup.class); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public DeviceGroup save(DeviceGroup data) { if (StringUtils.isBlank(data.getId())) { @@ -45,6 +52,11 @@ public class DeviceGroupDataImpl implements IDeviceGroupData { return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String s) { @@ -52,10 +64,11 @@ public class DeviceGroupDataImpl implements IDeviceGroupData { } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + @Override public long count() { return deviceGroupRepository.count(); @@ -67,8 +80,19 @@ public class DeviceGroupDataImpl implements IDeviceGroupData { } @Override - public Paging findAll(int page, int size) { - Page groups = deviceGroupRepository.findAll(Pageable.ofSize(size).withPage(page - 1)); - return new Paging<>(groups.getTotalElements(), MapstructUtils.convert(groups.getContent(), DeviceGroup.class)); + public Paging findAll(PageRequest pageRequest) { + return null; } + + @Override + public List findAllByCondition(DeviceGroup data) { + return null; + } + + @Override + public DeviceGroup findOneByCondition(DeviceGroup data) { + return null; + } + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceInfoDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceInfoDataImpl.java index 7c4d87d1..33a71cb7 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceInfoDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceInfoDataImpl.java @@ -1,5 +1,6 @@ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.ReflectUtil; import cc.iotkit.data.manager.ICategoryData; import cc.iotkit.data.manager.IDeviceInfoData; @@ -429,6 +430,11 @@ public class DeviceInfoDataImpl implements IDeviceInfoData { deviceInfoRepository.findById(s).orElse(null)); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override @Transactional public DeviceInfo save(DeviceInfo data) { @@ -463,16 +469,23 @@ public class DeviceInfoDataImpl implements IDeviceInfoData { return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String s) { deviceInfoRepository.deleteById(s); } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + + @Override public long count() { return deviceInfoRepository.count(); @@ -484,9 +497,20 @@ public class DeviceInfoDataImpl implements IDeviceInfoData { } @Override - public Paging findAll(int page, int size) { - Page paged = deviceInfoRepository.findAll(Pageable.ofSize(size).withPage(page - 1)); - return new Paging<>(paged.getTotalElements(), parseVoToDto(paged.getContent())); + public Paging findAll(PageRequest pageRequest) { + return null; } + @Override + public List findAllByCondition(DeviceInfo data) { + return null; + } + + @Override + public DeviceInfo findOneByCondition(DeviceInfo data) { + return null; + } + + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/HomeDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/HomeDataImpl.java index c6cd3dfc..6bf8a1dd 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/HomeDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/HomeDataImpl.java @@ -1,5 +1,6 @@ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.manager.IHomeData; import cc.iotkit.data.dao.HomeRepository; @@ -11,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -51,6 +53,11 @@ public class HomeDataImpl implements IHomeData { return MapstructUtils.convert(homeRepository.findById(s).orElse(null), Home.class); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public Home save(Home data) { if (StringUtils.isBlank(data.getId())) { @@ -60,6 +67,11 @@ public class HomeDataImpl implements IHomeData { return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String s) { @@ -67,10 +79,12 @@ public class HomeDataImpl implements IHomeData { } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + + @Override public long count() { return homeRepository.count(); @@ -82,7 +96,19 @@ public class HomeDataImpl implements IHomeData { } @Override - public Paging findAll(int page, int size) { - return new Paging<>(); + public Paging findAll(PageRequest pageRequest) { + return null; } + + @Override + public List findAllByCondition(Home data) { + return null; + } + + @Override + public Home findOneByCondition(Home data) { + return null; + } + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/OauthClientDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/OauthClientDataImpl.java index f44b6701..83f237e5 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/OauthClientDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/OauthClientDataImpl.java @@ -9,6 +9,7 @@ */ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.manager.IOauthClientData; import cc.iotkit.data.dao.OauthClientRepository; @@ -21,6 +22,7 @@ import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -41,6 +43,11 @@ public class OauthClientDataImpl implements IOauthClientData { return MapstructUtils.convert(oauthClientRepository.findById(s).orElse(null), OauthClient.class); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public OauthClient save(OauthClient data) { if (StringUtils.isBlank(data.getId())) { @@ -51,16 +58,22 @@ public class OauthClientDataImpl implements IOauthClientData { return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String s) { oauthClientRepository.deleteById(s); } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + @Override public long count() { return oauthClientRepository.count(); @@ -72,7 +85,19 @@ public class OauthClientDataImpl implements IOauthClientData { } @Override - public Paging findAll(int page, int size) { - return new Paging<>(); + public Paging findAll(PageRequest pageRequest) { + return null; } + + @Override + public List findAllByCondition(OauthClient data) { + return null; + } + + @Override + public OauthClient findOneByCondition(OauthClient data) { + return null; + } + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProductDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProductDataImpl.java index 6a1536f5..a43a7b22 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProductDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProductDataImpl.java @@ -1,5 +1,6 @@ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.manager.IProductData; import cc.iotkit.data.dao.ProductRepository; @@ -12,6 +13,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.List; @Primary @@ -50,12 +52,22 @@ public class ProductDataImpl implements IProductData { return MapstructUtils.convert(productRepository.findById(s).orElse(null), Product.class); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public Product save(Product data) { productRepository.save(MapstructUtils.convert(data, TbProduct.class)); return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String s) { @@ -63,10 +75,12 @@ public class ProductDataImpl implements IProductData { } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + + @Override public long count() { return productRepository.count(); @@ -78,10 +92,19 @@ public class ProductDataImpl implements IProductData { } @Override - public Paging findAll(int page, int size) { - Page productPage = productRepository.findAll( - Pageable.ofSize(size).withPage(page - 1)); - return new Paging<>(productPage.getTotalElements(), - MapstructUtils.convert(productPage.getContent(), Product.class)); + public Paging findAll(PageRequest pageRequest) { + return null; } + + @Override + public List findAllByCondition(Product data) { + return null; + } + + @Override + public Product findOneByCondition(Product data) { + return null; + } + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProtocolComponentDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProtocolComponentDataImpl.java index 47708f7f..339f4b46 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProtocolComponentDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProtocolComponentDataImpl.java @@ -1,21 +1,29 @@ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.manager.IProtocolComponentData; import cc.iotkit.data.dao.ProtocolComponentRepository; import cc.iotkit.data.model.TbProtocolComponent; import cc.iotkit.common.api.Paging; +import cc.iotkit.data.util.PageBuilder; +import cc.iotkit.data.util.PredicateBuilder; import cc.iotkit.model.protocol.ProtocolComponent; +import com.querydsl.core.types.Predicate; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.List; import java.util.UUID; +import static cc.iotkit.data.model.QTbSysConfig.tbSysConfig; + @Primary @Service public class ProtocolComponentDataImpl implements IProtocolComponentData { @@ -56,6 +64,11 @@ public class ProtocolComponentDataImpl implements IProtocolComponentData { return MapstructUtils.convert(protocolComponentRepository.findById(s).orElse(null), ProtocolComponent.class); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public ProtocolComponent save(ProtocolComponent data) { if (StringUtils.isBlank(data.getId())) { @@ -66,6 +79,11 @@ public class ProtocolComponentDataImpl implements IProtocolComponentData { return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String s) { @@ -73,10 +91,12 @@ public class ProtocolComponentDataImpl implements IProtocolComponentData { } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + + @Override public long count() { return protocolComponentRepository.count(); @@ -88,10 +108,23 @@ public class ProtocolComponentDataImpl implements IProtocolComponentData { } @Override - public Paging findAll(int page, int size) { - Page paged = protocolComponentRepository - .findAll(Pageable.ofSize(size).withPage(page - 1)); - return new Paging<>(paged.getTotalElements(), - MapstructUtils.convert(paged.getContent(), ProtocolComponent.class)); + public Paging findAll(PageRequest pageRequest) { + ProtocolComponent query = pageRequest.getData(); + Predicate predicate = PredicateBuilder.instance() + .build(); + Page all = protocolComponentRepository.findAll(predicate, PageBuilder.toPageable(pageRequest)); + return new Paging<>(all.getTotalElements(), MapstructUtils.convert(all.getContent(), ProtocolComponent.class)); } + + @Override + public List findAllByCondition(ProtocolComponent data) { + return null; + } + + @Override + public ProtocolComponent findOneByCondition(ProtocolComponent data) { + return null; + } + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProtocolConverterDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProtocolConverterDataImpl.java index 1805b737..65142715 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProtocolConverterDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProtocolConverterDataImpl.java @@ -9,6 +9,7 @@ */ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.manager.IProtocolConverterData; import cc.iotkit.data.dao.ProtocolConverterRepository; @@ -22,6 +23,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -56,6 +58,11 @@ public class ProtocolConverterDataImpl implements IProtocolConverterData { protocolConverterRepository.findById(s).orElse(null), ProtocolConverter.class); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public ProtocolConverter save(ProtocolConverter data) { if (StringUtils.isBlank(data.getId())) { @@ -66,6 +73,11 @@ public class ProtocolConverterDataImpl implements IProtocolConverterData { return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String s) { @@ -73,10 +85,11 @@ public class ProtocolConverterDataImpl implements IProtocolConverterData { } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + @Override public long count() { return protocolConverterRepository.count(); @@ -88,10 +101,19 @@ public class ProtocolConverterDataImpl implements IProtocolConverterData { } @Override - public Paging findAll(int page, int size) { - Page paged = protocolConverterRepository - .findAll(Pageable.ofSize(size).withPage(page - 1)); - return new Paging<>(paged.getTotalElements(), - MapstructUtils.convert(paged.getContent(), ProtocolConverter.class)); + public Paging findAll(PageRequest pageRequest) { + return null; } + + + @Override + public List findAllByCondition(ProtocolConverter data) { + return null; + } + + @Override + public ProtocolConverter findOneByCondition(ProtocolConverter data) { + return null; + } + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/RuleInfoDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/RuleInfoDataImpl.java index a99e899e..cc3ce974 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/RuleInfoDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/RuleInfoDataImpl.java @@ -9,6 +9,7 @@ */ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.data.manager.IRuleInfoData; import cc.iotkit.data.dao.RuleInfoRepository; import cc.iotkit.data.model.TbRuleInfo; @@ -22,6 +23,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -76,6 +78,11 @@ public class RuleInfoDataImpl implements IRuleInfoData { return RuleInfoMapper.toDtoFix(ruleInfoRepository.findById(s).orElse(null)); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public RuleInfo save(RuleInfo data) { if (StringUtils.isBlank(data.getId())) { @@ -86,16 +93,23 @@ public class RuleInfoDataImpl implements IRuleInfoData { return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String s) { ruleInfoRepository.deleteById(s); } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + + @Override public long count() { return ruleInfoRepository.count(); @@ -107,10 +121,19 @@ public class RuleInfoDataImpl implements IRuleInfoData { } @Override - public Paging findAll(int page, int size) { - Page paged = ruleInfoRepository. - findAll(Pageable.ofSize(size).withPage(page - 1)); - return new Paging<>(paged.getTotalElements(), - RuleInfoMapper.toDto(paged.getContent())); + public Paging findAll(PageRequest pageRequest) { + return null; } + + @Override + public List findAllByCondition(RuleInfo data) { + return null; + } + + @Override + public RuleInfo findOneByCondition(RuleInfo data) { + return null; + } + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SpaceDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SpaceDataImpl.java index b157cc92..7dd491ac 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SpaceDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SpaceDataImpl.java @@ -1,5 +1,6 @@ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.manager.ISpaceData; import cc.iotkit.data.dao.SpaceRepository; @@ -13,6 +14,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -61,6 +63,11 @@ public class SpaceDataImpl implements ISpaceData { return MapstructUtils.convert(spaceRepository.findById(s).orElse(null), Space.class); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public Space save(Space data) { if (StringUtils.isBlank(data.getId())) { @@ -70,16 +77,23 @@ public class SpaceDataImpl implements ISpaceData { return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String s) { spaceRepository.deleteById(s); } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + + @Override public long count() { return spaceRepository.count(); @@ -91,7 +105,19 @@ public class SpaceDataImpl implements ISpaceData { } @Override - public Paging findAll(int page, int size) { - return new Paging<>(); + public Paging findAll(PageRequest pageRequest) { + return null; } + + @Override + public List findAllByCondition(Space data) { + return null; + } + + @Override + public Space findOneByCondition(Space data) { + return null; + } + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SpaceDeviceDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SpaceDeviceDataImpl.java index 9b98bb95..32819016 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SpaceDeviceDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SpaceDeviceDataImpl.java @@ -9,6 +9,7 @@ */ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.data.manager.ISpaceDeviceData; import cc.iotkit.data.dao.SpaceDeviceRepository; @@ -20,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -85,6 +87,11 @@ public class SpaceDeviceDataImpl implements ISpaceDeviceData { return MapstructUtils.convert(spaceDeviceRepository.findById(s).orElse(null), SpaceDevice.class); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public SpaceDevice save(SpaceDevice data) { if (StringUtils.isBlank(data.getId())) { @@ -95,16 +102,22 @@ public class SpaceDeviceDataImpl implements ISpaceDeviceData { return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String s) { spaceDeviceRepository.deleteById(s); } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + @Override public long count() { return spaceDeviceRepository.count(); @@ -116,7 +129,19 @@ public class SpaceDeviceDataImpl implements ISpaceDeviceData { } @Override - public Paging findAll(int page, int size) { - return new Paging<>(); + public Paging findAll(PageRequest pageRequest) { + return null; } + + @Override + public List findAllByCondition(SpaceDevice data) { + return null; + } + + @Override + public SpaceDevice findOneByCondition(SpaceDevice data) { + return null; + } + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysConfigDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysConfigDataImpl.java index dc2f7298..e7b4a41a 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysConfigDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysConfigDataImpl.java @@ -15,6 +15,7 @@ import cc.iotkit.data.util.PredicateBuilder; import cc.iotkit.model.system.SysConfig; import cn.hutool.core.collection.CollUtil; import com.querydsl.core.types.Predicate; + import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -22,9 +23,7 @@ import java.util.Map; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Primary; -import org.springframework.data.domain.Sort; -import org.springframework.data.domain.Sort.Direction; -import org.springframework.data.domain.Sort.Order; + import org.springframework.stereotype.Service; import static cc.iotkit.data.model.QTbSysConfig.tbSysConfig; @@ -39,14 +38,14 @@ public class SysConfigDataImpl implements ISysConfigData { @Override public SysConfig findById(Long id) { - TbSysConfig tbSysConfig = alertConfigRepository.findById(id).orElseThrow(() -> - new BizException(ErrCode.DATA_NOT_EXIST)); - return MapstructUtils.convert(tbSysConfig,SysConfig.class); + TbSysConfig tbSysConfig = alertConfigRepository.findById(id).orElseThrow(() -> + new BizException(ErrCode.DATA_NOT_EXIST)); + return MapstructUtils.convert(tbSysConfig, SysConfig.class); } @Override public SysConfig save(SysConfig data) { - alertConfigRepository.save(MapstructUtils.convert(data,TbSysConfig.class)); + alertConfigRepository.save(MapstructUtils.convert(data, TbSysConfig.class)); return data; } @@ -84,27 +83,18 @@ public class SysConfigDataImpl implements ISysConfigData { public Paging findAll(PageRequest pageRequest) { SysConfig query = pageRequest.getData(); Predicate predicate = PredicateBuilder.instance(tbSysConfig.configId.isNotNull()) - .and(StringUtils.isNotEmpty(query.getConfigKey()),() -> tbSysConfig.configKey.eq(query.getConfigKey())) + .and(StringUtils.isNotEmpty(query.getConfigKey()), () -> tbSysConfig.configKey.eq(query.getConfigKey())) - .build(); + .build(); - List orders = new ArrayList<>(); - Map sortMap = pageRequest.getSortMap(); - if (CollUtil.isNotEmpty(sortMap)){ - sortMap.forEach((k,v) -> { - orders.add(new Order(Direction.ASC, k)); - }); - } // TODO: 2023/5/26 抽成通用工具类方法 - - alertConfigRepository.findAll(predicate,PageBuilder.toPageable(pageRequest, Sort.by(orders))); - - + alertConfigRepository.findAll(predicate, PageBuilder.toPageable(pageRequest)); throw new BizException(ErrCode.UNSUPPORTED_OPERATION_EXCEPTION); } + @Override public List findAllByCondition(SysConfig data) { throw new BizException(ErrCode.UNSUPPORTED_OPERATION_EXCEPTION); diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysMenuDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysMenuDataImpl.java index 71e81c19..6dd02e2e 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysMenuDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/SysMenuDataImpl.java @@ -110,35 +110,9 @@ public class SysMenuDataImpl implements ISysMenuData { PredicateBuilder predicateBuilder = PredicateBuilder.instance(tbSysMenu.menuId.isNotNull()); - - // 管理员显示所有菜单信息 - if (isSuperAdmin) { - predicateBuilder - .and(StringUtils.isNotBlank(menu.getMenuName()), () -> tbSysMenu.menuName.like(menu.getMenuName())) - .and(StringUtils.isNotBlank(menu.getVisible()), () -> tbSysMenu.visible.eq(menu.getVisible())) - .and(StringUtils.isNotBlank(menu.getStatus()), () -> tbSysMenu.status.eq(menu.getStatus())); - - menuList = baseMapper.selectVoList(new LambdaQueryWrapper() - .like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName()) - .eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible()) - .eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus()) - .orderByAsc(SysMenu::getParentId) - .orderByAsc(SysMenu::getOrderNum)); - } else { - predicateBuilder.and(tbSysMenu.menuId.eq(userId)); - BooleanBuilder builder = new BooleanBuilder(); - QueryWrapper wrapper = Wrappers.query(); - wrapper.eq("sur.user_id", userId) - .like(StringUtils.isNotBlank(menu.getMenuName()), "m.menu_name", menu.getMenuName()) - .eq(StringUtils.isNotBlank(menu.getVisible()), "m.visible", menu.getVisible()) - .eq(StringUtils.isNotBlank(menu.getStatus()), "m.status", menu.getStatus()) - .orderByAsc("m.parent_id") - .orderByAsc("m.order_num"); - menuList = baseMapper.selectMenuListByUserId(wrapper); - } Predicate predicate = predicateBuilder.build(); sysMenuRepository.findAll(predicate); - return menuList; + return null; } } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/TaskInfoDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/TaskInfoDataImpl.java index c9a81684..bd2d37a2 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/TaskInfoDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/TaskInfoDataImpl.java @@ -9,6 +9,7 @@ */ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.data.manager.ITaskInfoData; import cc.iotkit.data.dao.TaskInfoRepository; import cc.iotkit.data.model.TbTaskInfo; @@ -22,6 +23,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -55,6 +57,11 @@ public class TaskInfoDataImpl implements ITaskInfoData { return TaskInfoMapper.toDtoFix(taskInfoRepository.findById(s).orElse(null)); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public TaskInfo save(TaskInfo data) { if (StringUtils.isBlank(data.getId())) { @@ -65,16 +72,23 @@ public class TaskInfoDataImpl implements ITaskInfoData { return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String s) { taskInfoRepository.deleteById(s); } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + + @Override public long count() { return taskInfoRepository.count(); @@ -86,8 +100,20 @@ public class TaskInfoDataImpl implements ITaskInfoData { } @Override - public Paging findAll(int page, int size) { - Page paged = taskInfoRepository.findAll(Pageable.ofSize(size).withPage(page - 1)); - return new Paging<>(paged.getTotalElements(), TaskInfoMapper.toDto(paged.getContent())); + public Paging findAll(PageRequest pageRequest) { + return null; } + + @Override + public List findAllByCondition(TaskInfo data) { + return null; + } + + @Override + public TaskInfo findOneByCondition(TaskInfo data) { + return null; + } + + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ThingModelDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ThingModelDataImpl.java index db5965a5..a950e466 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ThingModelDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ThingModelDataImpl.java @@ -9,6 +9,7 @@ */ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.data.manager.IThingModelData; import cc.iotkit.data.dao.ThingModelRepository; import cc.iotkit.data.service.convert.ThingModelMapper; @@ -19,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Service; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -34,6 +36,11 @@ public class ThingModelDataImpl implements IThingModelData { return ThingModelMapper.toDtoFix(thingModelRepository.findById(s).orElse(null)); } + @Override + public List findByIds(Collection id) { + return null; + } + @Override public ThingModel save(ThingModel data) { if (StringUtils.isBlank(data.getId())) { @@ -43,16 +50,22 @@ public class ThingModelDataImpl implements IThingModelData { return data; } + @Override + public void batchSave(List data) { + + } + @Override public void deleteById(String s) { thingModelRepository.deleteById(s); } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + @Override public long count() { return 0; @@ -64,7 +77,19 @@ public class ThingModelDataImpl implements IThingModelData { } @Override - public Paging findAll(int page, int size) { + public Paging findAll(PageRequest pageRequest) { return null; } + + @Override + public List findAllByCondition(ThingModel data) { + return null; + } + + @Override + public ThingModel findOneByCondition(ThingModel data) { + return null; + } + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/UserInfoDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/UserInfoDataImpl.java index 1f8388f2..cc6d2ba0 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/UserInfoDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/UserInfoDataImpl.java @@ -84,10 +84,6 @@ public class UserInfoDataImpl implements IUserInfoData { } - @Override - public void deleteByIds(String[] strings) { - - } @Override public long count() { @@ -114,10 +110,5 @@ public class UserInfoDataImpl implements IUserInfoData { return null; } - @Override - public Paging findAll(int page, int size) { - Page paged = userInfoRepository.findAll(Pageable.ofSize(size).withPage(page - 1)); - return new Paging<>(paged.getTotalElements(), - UserInfoMapper.toDto(paged.getContent())); - } + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/VirtualDeviceDataImpl.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/VirtualDeviceDataImpl.java index 5cc89dd1..cd8b327b 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/VirtualDeviceDataImpl.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/VirtualDeviceDataImpl.java @@ -9,6 +9,7 @@ */ package cc.iotkit.data.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.data.manager.IVirtualDeviceData; import cc.iotkit.data.dao.VirtualDeviceMappingRepository; import cc.iotkit.data.dao.VirtualDeviceRepository; @@ -26,6 +27,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @@ -79,6 +81,11 @@ public class VirtualDeviceDataImpl implements IVirtualDeviceData { return dto; } + @Override + public List findByIds(Collection id) { + return null; + } + private List getVirtualDeviceIds(String virtualId) { List deviceMappings = virtualDeviceMappingRepository.findByVirtualId(virtualId); return deviceMappings.stream().map(TbVirtualDeviceMapping::getDeviceId).collect(Collectors.toList()); @@ -105,6 +112,11 @@ public class VirtualDeviceDataImpl implements IVirtualDeviceData { return data; } + @Override + public void batchSave(List data) { + + } + @Override @Transactional public void deleteById(String s) { @@ -113,10 +125,11 @@ public class VirtualDeviceDataImpl implements IVirtualDeviceData { } @Override - public void deleteByIds(String[] strings) { + public void deleteByIds(Collection strings) { } + @Override public long count() { return virtualDeviceRepository.count(); @@ -128,8 +141,19 @@ public class VirtualDeviceDataImpl implements IVirtualDeviceData { } @Override - public Paging findAll(int page, int size) { - Page paged = virtualDeviceRepository.findAll(Pageable.ofSize(size).withPage(page - 1)); - return new Paging<>(paged.getTotalElements(), VirtualDeviceMapper.toDto(paged.getContent())); + public Paging findAll(PageRequest pageRequest) { + return null; } + + @Override + public List findAllByCondition(VirtualDevice data) { + return null; + } + + @Override + public VirtualDevice findOneByCondition(VirtualDevice data) { + return null; + } + + } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/util/PageBuilder.java b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/util/PageBuilder.java index 1c5f2988..a311881c 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/util/PageBuilder.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/util/PageBuilder.java @@ -3,9 +3,18 @@ package cc.iotkit.data.util; import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.PageRequestEmpty; import cc.iotkit.model.system.SysConfig; +import cn.hutool.core.collection.CollUtil; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.springframework.data.domain.Sort; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.data.domain.Sort.Order; + /** * @author: Longjun.Tu * @description: @@ -19,7 +28,12 @@ public class PageBuilder { } public static Pageable toPageable(PageRequest request) { + List orders = getOrders(request); + if(CollUtil.isNotEmpty(orders)){ + return toPageable(request, Sort.by(orders)); + } return (Pageable)(request.getPageSize() <= 0 ? Pageable.unpaged() : org.springframework.data.domain.PageRequest.of(request.getPageNum() - 1, request.getPageSize())); + } public static Pageable toPageable(PageRequestEmpty request) { @@ -34,4 +48,15 @@ public class PageBuilder { return (Pageable)(request.getPageSize() <= 0 ? Pageable.unpaged() : org.springframework.data.domain.PageRequest.of(request.getPageNum() - 1, request.getPageSize(), sort)); } + private static List getOrders(PageRequest pageRequest) { + List orders = new ArrayList<>(); + Map sortMap = pageRequest.getSortMap(); + if (CollUtil.isNotEmpty(sortMap)){ + sortMap.forEach((k,v) -> { + orders.add(new Order(Direction.ASC, k)); + }); + } + return orders; + } + } diff --git a/iot-common/iot-common-tenant/src/main/java/cc/iotkit/common/tenant/exception/TenantException.java b/iot-common/iot-common-tenant/src/main/java/cc/iotkit/common/tenant/exception/TenantException.java index 45a5af4b..d2bebc99 100644 --- a/iot-common/iot-common-tenant/src/main/java/cc/iotkit/common/tenant/exception/TenantException.java +++ b/iot-common/iot-common-tenant/src/main/java/cc/iotkit/common/tenant/exception/TenantException.java @@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode; @Data public class TenantException extends BizException { - public TenantException(String code, String message) { + public TenantException(Integer code, String message) { super("tenant", code, message); } } 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 14d99ae4..cb96ab24 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 @@ -21,7 +21,7 @@ import org.springframework.stereotype.Component; /** * spring工具类 方便在非spring管理环境中获取bean */ -@Component +//@Component public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware { /** Spring应用上下文环境 */ 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 a2b50993..82dbd6d5 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 @@ -13,12 +13,13 @@ import cc.iotkit.common.enums.ErrCode; import cc.iotkit.common.exception.BizException; import cc.iotkit.common.thing.ThingService; import cc.iotkit.common.utils.JsonUtils; +import cc.iotkit.common.utils.SpringUtils; import cc.iotkit.common.utils.ThreadUtil; import cc.iotkit.comp.AbstractDeviceComponent; import cc.iotkit.comp.CompConfig; import cc.iotkit.comp.IMessageHandler; import cc.iotkit.comp.model.DeviceState; -import cc.iotkit.comp.utils.SpringUtils; + import cc.iotkit.converter.DeviceMessage; import cc.iotkit.data.manager.IDeviceInfoData; import cc.iotkit.model.device.DeviceInfo; 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 9e986f77..c4b039b7 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,8 @@ 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.comp.utils.SpringUtils; + +import cc.iotkit.common.utils.SpringUtils; import cc.iotkit.converter.Device; import cc.iotkit.converter.DeviceMessage; import cc.iotkit.data.manager.IDeviceInfoData; 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 67675758..5bdc998d 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,8 @@ 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.comp.utils.SpringUtils; + +import cc.iotkit.common.utils.SpringUtils; import cc.iotkit.converter.Device; import cc.iotkit.converter.DeviceMessage; import cc.iotkit.data.manager.IDeviceInfoData; diff --git a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/ProtocolController.java b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/ProtocolController.java index d1d9580f..21ec3b3e 100644 --- a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/ProtocolController.java +++ b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/ProtocolController.java @@ -9,6 +9,7 @@ */ package cc.iotkit.manager.controller; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.enums.ErrCode; import cc.iotkit.common.exception.BizException; import cc.iotkit.common.satoken.utils.AuthUtil; @@ -214,9 +215,8 @@ public class ProtocolController { @PostMapping("/components/{size}/{page}") public Paging getComponents( - @PathVariable("size") int size, - @PathVariable("page") int page) { - Paging components = protocolComponentData.findAll(page, size); + PageRequest query ) { + Paging components = protocolComponentData.findAll(query); components.getData().forEach(c -> c.setState( componentManager.isRunning(c.getId()) ? ProtocolComponent.STATE_RUNNING : ProtocolComponent.STATE_STOPPED @@ -224,11 +224,9 @@ public class ProtocolController { return components; } - @PostMapping("/converters/{size}/{page}") - public Paging getConverters( - @PathVariable("size") int size, - @PathVariable("page") int page) { - return protocolConverterData.findAll(page, size); + @PostMapping("/converters/list") + public Paging getConverters(PageRequest query) { + return protocolConverterData.findAll(query); } @PostMapping("/addConverter") diff --git a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/protocolcomponent/ProtocolComponentBo.java b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/protocolcomponent/ProtocolComponentBo.java new file mode 100644 index 00000000..79bc9e48 --- /dev/null +++ b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/protocolcomponent/ProtocolComponentBo.java @@ -0,0 +1,22 @@ +package cc.iotkit.manager.dto.bo.protocolcomponent; + + +import cc.iotkit.common.api.PageRequest; +import cc.iotkit.model.protocol.ProtocolComponent; + +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @Author: jay + * @Date: 2023/5/29 10:43 + * @Version: V1.0 + * @Description: 组件查询 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@AutoMapper(target = ProtocolComponent.class, reverseConvertGenerate = false) +public class ProtocolComponentBo extends PageRequest { + +} diff --git a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/protocolconverter/ProtocolConverterBo.java b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/protocolconverter/ProtocolConverterBo.java new file mode 100644 index 00000000..8ea247fd --- /dev/null +++ b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/protocolconverter/ProtocolConverterBo.java @@ -0,0 +1,20 @@ +package cc.iotkit.manager.dto.bo.protocolconverter; + + +import cc.iotkit.common.api.PageRequest; +import cc.iotkit.model.protocol.ProtocolConverter; +import io.github.linpeilie.annotations.AutoMapper; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @Author: jay + * @Date: 2023/5/29 10:48 + * @Version: V1.0 + * @Description: 转换脚本查询参数 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@AutoMapper(target = ProtocolConverter.class, reverseConvertGenerate = false) +public class ProtocolConverterBo extends PageRequest { +} diff --git a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/vo/protocolcomponent/ProtocolComponentVo.java b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/vo/protocolcomponent/ProtocolComponentVo.java new file mode 100644 index 00000000..6b2a2329 --- /dev/null +++ b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/vo/protocolcomponent/ProtocolComponentVo.java @@ -0,0 +1,59 @@ +package cc.iotkit.manager.dto.vo.protocolcomponent; + +import cc.iotkit.model.protocol.ProtocolComponent; + +import io.github.linpeilie.annotations.AutoMapper; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: jay + * @Date: 2023/5/29 10:54 + * @Version: V1.0 + * @Description: 组件Vo + */ +@Data + +@AutoMapper(target = ProtocolComponent.class) +public class ProtocolComponentVo implements Serializable { + private static final long serialVersionUID = 1L; + + + /** + * 所属性用户id + */ + @ApiModelProperty(value = "用户id") + private String uid; + + @ApiModelProperty(value = "名称") + private String name; + + + @ApiModelProperty(value = "协议类型") + + private String protocol; + + @ApiModelProperty(value = "jar包") + private String jarFile; + + @ApiModelProperty(value = "配置") + private String config; + + @ApiModelProperty(value = "转换器") + private String converter; + + + + @ApiModelProperty(value = "运行状态") + private String state; + + private Long createAt; + + @ApiModelProperty(value = "脚本类型") + private String scriptTyp; + + @ApiModelProperty(value = "脚本内容") + private String script; +} diff --git a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/ExampleDataInit.java b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/ExampleDataInit.java index 9dd8a06e..3442c7f9 100644 --- a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/ExampleDataInit.java +++ b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/ExampleDataInit.java @@ -10,6 +10,8 @@ package cc.iotkit.manager.service; import cc.iotkit.common.utils.JsonUtils; +import cc.iotkit.data.ICommonData; +import cc.iotkit.data.manager.*; import cc.iotkit.model.Id; import cc.iotkit.model.OauthClient; import cc.iotkit.model.UserInfo; @@ -156,7 +158,7 @@ public class ExampleDataInit implements SmartInitializingSingleton { String json = FileUtils.readFileToString(new File("./data/init/" + name + ".json"), Charsets.UTF_8); List list = (List) JsonUtils.parseObject(json, type); for (Object obj : list) { - service.add((Id) obj); + service.save((Id) obj); } return (T) list; } diff --git a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/IProtocolService.java b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/IProtocolService.java new file mode 100644 index 00000000..3688fc99 --- /dev/null +++ b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/IProtocolService.java @@ -0,0 +1,20 @@ +package cc.iotkit.manager.service; + +import cc.iotkit.model.protocol.ProtocolComponent; + +/** + * @Author: jay + * @Date: 2023/5/29 11:28 + * @Version: V1.0 + * @Description: 协议组件接口 + */ +public interface IProtocolService { + + // 上传jar包 + String uploadJar(String jarFile, String id); + + // 添加组件 + boolean addComponent(ProtocolComponent component); + + +} diff --git a/iot-module/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/handler/RuleDeviceConsumer.java b/iot-module/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/handler/RuleDeviceConsumer.java index 1c0b4d05..e893593f 100644 --- a/iot-module/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/handler/RuleDeviceConsumer.java +++ b/iot-module/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/handler/RuleDeviceConsumer.java @@ -9,7 +9,8 @@ */ package cc.iotkit.ruleengine.handler; -import cc.iotkit.common.Constants; + +import cc.iotkit.common.constant.Constants; import cc.iotkit.common.utils.JsonUtils; import cc.iotkit.model.device.message.ThingModelMessage; import cc.iotkit.mq.ConsumerHandler; diff --git a/iot-module/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleManager.java b/iot-module/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleManager.java index 8943d1db..cbc82ecc 100644 --- a/iot-module/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleManager.java +++ b/iot-module/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleManager.java @@ -73,12 +73,8 @@ public class RuleManager { public void initRules() { int idx = 1; while (true) { - Paging rules = ruleInfoData.findAll(idx, 1000); - // 如果记录为空,直接跳出循环 - if (rules.getData() == null || rules.getData().isEmpty()) { - break; - } - rules.getData().forEach(rule -> { + List rules = ruleInfoData.findAll(); + rules.forEach(rule -> { try { //不添加停止的规则 if (RuleInfo.STATE_STOPPED.equals(rule.getState())) { diff --git a/iot-module/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/TaskManager.java b/iot-module/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/TaskManager.java index 0fc6e520..bd4d8521 100644 --- a/iot-module/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/TaskManager.java +++ b/iot-module/iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/TaskManager.java @@ -16,6 +16,7 @@ import cc.iotkit.common.api.Paging; import cc.iotkit.model.rule.TaskInfo; import cc.iotkit.model.rule.TaskLog; import cc.iotkit.temporal.ITaskLogData; +import cn.hutool.core.collection.CollectionUtil; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.quartz.*; @@ -25,7 +26,9 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.annotation.Lazy; +import java.util.Collections; import java.util.Date; +import java.util.List; import java.util.UUID; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -51,12 +54,12 @@ public class TaskManager implements ApplicationContextAware { public void initTask() { int idx = 1; while (true) { - Paging tasks = taskInfoData.findAll(idx, 1000); + List tasks = taskInfoData.findAll(); // 如果记录为空,直接跳出循环 - if (tasks.getData() == null || tasks.getData().isEmpty()) { + if (CollectionUtil.isEmpty(tasks)) { break; } - tasks.getData().forEach(task -> { + tasks.forEach(task -> { try { if (!TaskInfo.STATE_RUNNING.equals(task.getState())) { return; diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysOssController.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysOssController.java index f9fb0a18..d606de08 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysOssController.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysOssController.java @@ -87,7 +87,7 @@ public class SysOssController extends BaseController { @SaCheckPermission("system:oss:download") @GetMapping("/download/{ossId}") public void download(@PathVariable Long ossId, HttpServletResponse response) throws IOException { - ossService.download(ossId, response); + ossService.download(ossId); } /** diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysPostController.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysPostController.java index 047ead9f..861e7445 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysPostController.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/controller/SysPostController.java @@ -15,6 +15,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import java.util.Collection; import java.util.List; /** @@ -99,7 +100,7 @@ public class SysPostController extends BaseController { @SaCheckPermission("system:post:remove") @Log(title = "岗位管理", businessType = BusinessType.DELETE) @DeleteMapping("/{postIds}") - public void remove(@PathVariable Long[] postIds) { + public void remove(@PathVariable Collection postIds) { postService.deletePostByIds(postIds); } diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/dto/bo/SysRoleBo.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/dto/bo/SysRoleBo.java index 47510248..2d7fb03f 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/dto/bo/SysRoleBo.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/dto/bo/SysRoleBo.java @@ -29,7 +29,7 @@ public class SysRoleBo extends BaseDto { * 角色ID */ @NotNull(message = "角色ID不能为空", groups = { EditGroup.class }) - private Long id; + private Long roleId; /** * 角色名称 diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/dto/vo/SysRoleVo.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/dto/vo/SysRoleVo.java index 445e87be..ca5d87ee 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/dto/vo/SysRoleVo.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/dto/vo/SysRoleVo.java @@ -27,7 +27,7 @@ public class SysRoleVo implements Serializable { * 角色ID */ @ExcelProperty(value = "角色序号") - private Long id; + private Long roleId; /** * 角色名称 diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/ISysRoleService.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/ISysRoleService.java index ae7c9905..b312b9c2 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/ISysRoleService.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/ISysRoleService.java @@ -118,7 +118,7 @@ public interface ISysRoleService { * @param bo 角色信息 * @return 结果 */ - void updateRole(SysRoleBo bo); + int updateRole(SysRoleBo bo); /** * 修改角色状态 diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java index 9d2384d3..0d16c131 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java @@ -177,7 +177,7 @@ public class SysRoleServiceImpl implements ISysRoleService { @Transactional(rollbackFor = Exception.class) public void insertRole(SysRoleBo bo) { SysRole role = sysRoleData.save(bo.to(SysRole.class)); - bo.setId(role.getId()); + bo.setRoleId(role.getId()); insertRoleMenu(bo); } @@ -189,8 +189,12 @@ public class SysRoleServiceImpl implements ISysRoleService { */ @Override @Transactional(rollbackFor = Exception.class) - public void updateRole(SysRoleBo bo) { - sysRoleData.save(bo.to(SysRole.class)); + public int updateRole(SysRoleBo bo) { + SysRole role = sysRoleData.save(bo.to(SysRole.class)); + if(ObjectUtil.isNull(role)){ + return 0; + } + return 1; } /** diff --git a/pom.xml b/pom.xml index 3bbd85ad..7f6c3ac7 100755 --- a/pom.xml +++ b/pom.xml @@ -508,5 +508,34 @@ + + + + org.codehaus.mojo + flatten-maven-plugin + 1.3.0 + + true + resolveCiFriendliesOnly + + + + flatten + process-resources + + flatten + + + + flatten.clean + clean + + clean + + + + + +