Quellcode durchsuchen

【功能完善】IoT:设备分页筛选去除多余字段

YunaiV vor 8 Monaten
Ursprung
Commit
9041de2da5

+ 2 - 50
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDevicePageReqVO.java

@@ -8,11 +8,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.ToString;
-import org.springframework.format.annotation.DateTimeFormat;
-
-import java.time.LocalDateTime;
-
-import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
 
 @Schema(description = "管理后台 - IoT 设备分页 Request VO")
 @Data
@@ -20,11 +15,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
 @ToString(callSuper = true)
 public class IotDevicePageReqVO extends PageParam {
 
-    // TODO @芋艿:需要去掉一些多余的字段;
-
-    @Schema(description = "设备唯一标识符", example = "24602")
-    private String deviceKey;
-
     @Schema(description = "设备名称", example = "王五")
     private String deviceName;
 
@@ -34,53 +24,15 @@ public class IotDevicePageReqVO extends PageParam {
     @Schema(description = "产品编号", example = "26202")
     private Long productId;
 
-    @Schema(description = "产品标识")
-    private String productKey;
-
     @Schema(description = "设备类型", example = "1")
     @InEnum(IotProductDeviceTypeEnum.class)
     private Integer deviceType;
 
-    @Schema(description = "网关设备 ID", example = "16380")
-    private Long gatewayId;
-
     @Schema(description = "设备状态", example = "1")
     @InEnum(IotDeviceStatusEnum.class)
     private Integer status;
 
-    @Schema(description = "设备状态最后更新时间")
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    private LocalDateTime[] statusLastUpdateTime;
-
-    @Schema(description = "最后上线时间")
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    private LocalDateTime[] lastOnlineTime;
-
-    @Schema(description = "最后离线时间")
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    private LocalDateTime[] lastOfflineTime;
-
-    @Schema(description = "设备激活时间")
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    private LocalDateTime[] activeTime;
-
-    @Schema(description = "设备密钥,用于设备认证,需安全存储")
-    private String deviceSecret;
-
-    @Schema(description = "MQTT 客户端 ID", example = "24602")
-    private String mqttClientId;
-
-    @Schema(description = "MQTT 用户名", example = "芋艿")
-    private String mqttUsername;
-
-    @Schema(description = "MQTT 密码")
-    private String mqttPassword;
-
-    @Schema(description = "认证类型(如一机一密、动态注册)", example = "2")
-    private String authType;
-
-    @Schema(description = "创建时间")
-    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
-    private LocalDateTime[] createTime;
+    @Schema(description = "设备分组编号", example = "1024")
+    private Long groupId;
 
 }

+ 2 - 14
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/device/IotDeviceMapper.java

@@ -1,5 +1,6 @@
 package cn.iocoder.yudao.module.iot.dal.mysql.device;
 
+import cn.hutool.core.util.ObjectUtil;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
@@ -17,27 +18,14 @@ import java.util.List;
 @Mapper
 public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
 
-    // TODO @haohao:可能多余的查询条件,要去掉哈
     default PageResult<IotDeviceDO> selectPage(IotDevicePageReqVO reqVO) {
         return selectPage(reqVO, new LambdaQueryWrapperX<IotDeviceDO>()
-                .eqIfPresent(IotDeviceDO::getDeviceKey, reqVO.getDeviceKey())
                 .likeIfPresent(IotDeviceDO::getDeviceName, reqVO.getDeviceName())
                 .eqIfPresent(IotDeviceDO::getProductId, reqVO.getProductId())
-                .eqIfPresent(IotDeviceDO::getProductKey, reqVO.getProductKey())
                 .eqIfPresent(IotDeviceDO::getDeviceType, reqVO.getDeviceType())
                 .likeIfPresent(IotDeviceDO::getNickname, reqVO.getNickname())
-                .eqIfPresent(IotDeviceDO::getGatewayId, reqVO.getGatewayId())
                 .eqIfPresent(IotDeviceDO::getStatus, reqVO.getStatus())
-                .betweenIfPresent(IotDeviceDO::getStatusLastUpdateTime, reqVO.getStatusLastUpdateTime())
-                .betweenIfPresent(IotDeviceDO::getLastOnlineTime, reqVO.getLastOnlineTime())
-                .betweenIfPresent(IotDeviceDO::getLastOfflineTime, reqVO.getLastOfflineTime())
-                .betweenIfPresent(IotDeviceDO::getActiveTime, reqVO.getActiveTime())
-                .eqIfPresent(IotDeviceDO::getDeviceSecret, reqVO.getDeviceSecret())
-                .eqIfPresent(IotDeviceDO::getMqttClientId, reqVO.getMqttClientId())
-                .likeIfPresent(IotDeviceDO::getMqttUsername, reqVO.getMqttUsername())
-                .eqIfPresent(IotDeviceDO::getMqttPassword, reqVO.getMqttPassword())
-                .eqIfPresent(IotDeviceDO::getAuthType, reqVO.getAuthType())
-                .betweenIfPresent(IotDeviceDO::getCreateTime, reqVO.getCreateTime())
+                .apply(ObjectUtil.isNotNull(reqVO.getGroupId()), "FIND_IN_SET(" + reqVO.getGroupId() + ",group_ids) > 0")
                 .orderByDesc(IotDeviceDO::getId));
     }