diff --git a/iot-common/iot-common-core/pom.xml b/iot-common/iot-common-core/pom.xml index 23d00fa5..7007d989 100644 --- a/iot-common/iot-common-core/pom.xml +++ b/iot-common/iot-common-core/pom.xml @@ -90,6 +90,11 @@ jakarta.validation-api + + javax.validation + validation-api + + org.slf4j slf4j-api 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 702cbd55..d095127c 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 @@ -87,7 +87,11 @@ public class PageRequest extends Request implements Serializable { return pageRequest; } + public Integer getPageSize() { + return pageSize == null ? DEFAULT_PAGE_SIZE : pageSize; + } - - + public Integer getPageNum() { + return pageNum == null ? DEFAULT_PAGE_NUM : pageNum; + } } diff --git a/iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/DeviceInfoDataCache.java b/iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/DeviceInfoDataCache.java index 43a777df..cfed6778 100644 --- a/iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/DeviceInfoDataCache.java +++ b/iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/DeviceInfoDataCache.java @@ -63,6 +63,7 @@ public class DeviceInfoDataCache implements IDeviceInfoData, SmartInitializingSi List parentIds = new ArrayList<>(); PageRequest pageRequest = new PageRequest<>(); pageRequest.setPageSize(1000); + pageRequest.setPageNum(page); while ((paged = deviceInfoData.findAll(pageRequest)).getData().size() > 0) { pageRequest.setPageNum(page++); 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 33a71cb7..162903bc 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,6 +1,7 @@ package cc.iotkit.data.service; import cc.iotkit.common.api.PageRequest; +import cc.iotkit.common.utils.MapstructUtils; import cc.iotkit.common.utils.ReflectUtil; import cc.iotkit.data.manager.ICategoryData; import cc.iotkit.data.manager.IDeviceInfoData; @@ -9,6 +10,7 @@ import cc.iotkit.data.dao.*; import cc.iotkit.data.model.*; import cc.iotkit.data.service.convert.DeviceInfoMapper; import cc.iotkit.common.api.Paging; +import cc.iotkit.data.util.PageBuilder; import cc.iotkit.model.device.DeviceInfo; import cc.iotkit.model.product.Category; import cc.iotkit.model.product.Product; @@ -498,7 +500,8 @@ public class DeviceInfoDataImpl implements IDeviceInfoData { @Override public Paging findAll(PageRequest pageRequest) { - return null; + Page ret = deviceInfoRepository.findAll(PageBuilder.toPageable(pageRequest)); + return new Paging<>(ret.getTotalElements(), MapstructUtils.convert(ret.getContent(), DeviceInfo.class)); } @Override diff --git a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/AlertController.java b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/AlertController.java index acc14ebe..5c4f967c 100644 --- a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/AlertController.java +++ b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/AlertController.java @@ -19,12 +19,13 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +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.validation.Valid; + @Api(tags = {"告警中心"}) @Slf4j @@ -38,32 +39,32 @@ public class AlertController { @ApiOperation("新增告警中心配置") @PostMapping("/createAlertConfig") - public AlertConfig createAlertConfig(@RequestBody @Valid Request request) { + public AlertConfig createAlertConfig(@RequestBody @Validated Request request) { return alertService.createAlertConfig(request); } @ApiOperation("编辑告警中心配置") @PostMapping("/updateAlertConfig") - public AlertConfig updateAlertConfig(@RequestBody @Valid Request request) { + public AlertConfig updateAlertConfig(@RequestBody @Validated Request request) { return alertService.updateAlertConfig(request); } @ApiOperation("删除告警中心配置") @PostMapping("/deleteAlertConfigById") - public Boolean deleteAlertConfigById(@RequestBody @Valid Request request) { + public Boolean deleteAlertConfigById(@RequestBody @Validated Request request) { return alertService.deleteAlertConfigById(request); } @ApiOperation("查询告警中心配置分页") @PostMapping("/selectAlertConfigPage") - public Paging selectAlertConfigPage(@RequestBody @Valid PageRequest request) { + public Paging selectAlertConfigPage(@RequestBody @Validated PageRequest request) { return alertService.selectAlertConfigPage(request); } @ApiOperation("查询告警消息分页") @PostMapping("/selectAlertRecordPage") - public Paging selectAlertRecordPage(@RequestBody @Valid PageRequest request) { + public Paging selectAlertRecordPage(@RequestBody @Validated PageRequest request) { return alertService.selectAlertRecordPage(request); } diff --git a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/ChangeStateBo.java b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/ChangeStateBo.java index f60ae9a0..4393176c 100644 --- a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/ChangeStateBo.java +++ b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/ChangeStateBo.java @@ -5,11 +5,12 @@ import cc.iotkit.model.protocol.ProtocolComponent; import io.github.linpeilie.annotations.AutoMapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.constraints.NotBlank; import lombok.Data; import lombok.EqualsAndHashCode; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; + +import jakarta.validation.constraints.Size; @ApiModel(value = "ProtocolComponentBo") diff --git a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/category/CategoryBo.java b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/category/CategoryBo.java index 3831f3bc..28843c3a 100644 --- a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/category/CategoryBo.java +++ b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/category/CategoryBo.java @@ -8,9 +8,9 @@ import org.springframework.format.annotation.DateTimeFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import javax.validation.constraints.Size; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + + import java.io.Serializable; import java.util.Date; import java.math.BigDecimal; diff --git a/iot-starter/pom.xml b/iot-starter/pom.xml index 444ffb6d..9ec53c8c 100644 --- a/iot-starter/pom.xml +++ b/iot-starter/pom.xml @@ -176,31 +176,8 @@ iot-data-serviceImpl-cache - - - io.springfox - springfox-boot-starter - 3.0.0 - - - io.swagger - swagger-models - - - - - io.swagger - swagger-models - 1.6.8 - - - com.github.xiaoymin - knife4j-spring-boot-starter - 3.0.3 - - diff --git a/pom.xml b/pom.xml index f37c1412..e198d0d5 100755 --- a/pom.xml +++ b/pom.xml @@ -42,6 +42,8 @@ 2.3 2.7.0 1.0.0 + 2.0.5 + 1.1.0.Final @@ -518,6 +520,16 @@ jpa-comment-spring-boot-starter ${jap-comment.version} + + com.github.xiaoymin + knife4j-spring-boot-starter + ${knife4j.version} + + + javax.validation + validation-api + ${validateion.version} +