Commit 9041de2da57bd7fac4af894d5f44f82e20e58cf3

Authored by YunaiV
1 parent afaf98c4

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

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; @@ -8,11 +8,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
8 import lombok.Data; 8 import lombok.Data;
9 import lombok.EqualsAndHashCode; 9 import lombok.EqualsAndHashCode;
10 import lombok.ToString; 10 import lombok.ToString;
11 -import org.springframework.format.annotation.DateTimeFormat;  
12 -  
13 -import java.time.LocalDateTime;  
14 -  
15 -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;  
16 11
17 @Schema(description = "管理后台 - IoT 设备分页 Request VO") 12 @Schema(description = "管理后台 - IoT 设备分页 Request VO")
18 @Data 13 @Data
@@ -20,11 +15,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @@ -20,11 +15,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
20 @ToString(callSuper = true) 15 @ToString(callSuper = true)
21 public class IotDevicePageReqVO extends PageParam { 16 public class IotDevicePageReqVO extends PageParam {
22 17
23 - // TODO @芋艿:需要去掉一些多余的字段;  
24 -  
25 - @Schema(description = "设备唯一标识符", example = "24602")  
26 - private String deviceKey;  
27 -  
28 @Schema(description = "设备名称", example = "王五") 18 @Schema(description = "设备名称", example = "王五")
29 private String deviceName; 19 private String deviceName;
30 20
@@ -34,53 +24,15 @@ public class IotDevicePageReqVO extends PageParam { @@ -34,53 +24,15 @@ public class IotDevicePageReqVO extends PageParam {
34 @Schema(description = "产品编号", example = "26202") 24 @Schema(description = "产品编号", example = "26202")
35 private Long productId; 25 private Long productId;
36 26
37 - @Schema(description = "产品标识")  
38 - private String productKey;  
39 -  
40 @Schema(description = "设备类型", example = "1") 27 @Schema(description = "设备类型", example = "1")
41 @InEnum(IotProductDeviceTypeEnum.class) 28 @InEnum(IotProductDeviceTypeEnum.class)
42 private Integer deviceType; 29 private Integer deviceType;
43 30
44 - @Schema(description = "网关设备 ID", example = "16380")  
45 - private Long gatewayId;  
46 -  
47 @Schema(description = "设备状态", example = "1") 31 @Schema(description = "设备状态", example = "1")
48 @InEnum(IotDeviceStatusEnum.class) 32 @InEnum(IotDeviceStatusEnum.class)
49 private Integer status; 33 private Integer status;
50 34
51 - @Schema(description = "设备状态最后更新时间")  
52 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
53 - private LocalDateTime[] statusLastUpdateTime;  
54 -  
55 - @Schema(description = "最后上线时间")  
56 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
57 - private LocalDateTime[] lastOnlineTime;  
58 -  
59 - @Schema(description = "最后离线时间")  
60 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
61 - private LocalDateTime[] lastOfflineTime;  
62 -  
63 - @Schema(description = "设备激活时间")  
64 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
65 - private LocalDateTime[] activeTime;  
66 -  
67 - @Schema(description = "设备密钥,用于设备认证,需安全存储")  
68 - private String deviceSecret;  
69 -  
70 - @Schema(description = "MQTT 客户端 ID", example = "24602")  
71 - private String mqttClientId;  
72 -  
73 - @Schema(description = "MQTT 用户名", example = "芋艿")  
74 - private String mqttUsername;  
75 -  
76 - @Schema(description = "MQTT 密码")  
77 - private String mqttPassword;  
78 -  
79 - @Schema(description = "认证类型(如一机一密、动态注册)", example = "2")  
80 - private String authType;  
81 -  
82 - @Schema(description = "创建时间")  
83 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
84 - private LocalDateTime[] createTime; 35 + @Schema(description = "设备分组编号", example = "1024")
  36 + private Long groupId;
85 37
86 } 38 }
87 \ No newline at end of file 39 \ No newline at end of file
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/device/IotDeviceMapper.java
1 package cn.iocoder.yudao.module.iot.dal.mysql.device; 1 package cn.iocoder.yudao.module.iot.dal.mysql.device;
2 2
  3 +import cn.hutool.core.util.ObjectUtil;
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 5 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 6 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
@@ -17,27 +18,14 @@ import java.util.List; @@ -17,27 +18,14 @@ import java.util.List;
17 @Mapper 18 @Mapper
18 public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> { 19 public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
19 20
20 - // TODO @haohao:可能多余的查询条件,要去掉哈  
21 default PageResult<IotDeviceDO> selectPage(IotDevicePageReqVO reqVO) { 21 default PageResult<IotDeviceDO> selectPage(IotDevicePageReqVO reqVO) {
22 return selectPage(reqVO, new LambdaQueryWrapperX<IotDeviceDO>() 22 return selectPage(reqVO, new LambdaQueryWrapperX<IotDeviceDO>()
23 - .eqIfPresent(IotDeviceDO::getDeviceKey, reqVO.getDeviceKey())  
24 .likeIfPresent(IotDeviceDO::getDeviceName, reqVO.getDeviceName()) 23 .likeIfPresent(IotDeviceDO::getDeviceName, reqVO.getDeviceName())
25 .eqIfPresent(IotDeviceDO::getProductId, reqVO.getProductId()) 24 .eqIfPresent(IotDeviceDO::getProductId, reqVO.getProductId())
26 - .eqIfPresent(IotDeviceDO::getProductKey, reqVO.getProductKey())  
27 .eqIfPresent(IotDeviceDO::getDeviceType, reqVO.getDeviceType()) 25 .eqIfPresent(IotDeviceDO::getDeviceType, reqVO.getDeviceType())
28 .likeIfPresent(IotDeviceDO::getNickname, reqVO.getNickname()) 26 .likeIfPresent(IotDeviceDO::getNickname, reqVO.getNickname())
29 - .eqIfPresent(IotDeviceDO::getGatewayId, reqVO.getGatewayId())  
30 .eqIfPresent(IotDeviceDO::getStatus, reqVO.getStatus()) 27 .eqIfPresent(IotDeviceDO::getStatus, reqVO.getStatus())
31 - .betweenIfPresent(IotDeviceDO::getStatusLastUpdateTime, reqVO.getStatusLastUpdateTime())  
32 - .betweenIfPresent(IotDeviceDO::getLastOnlineTime, reqVO.getLastOnlineTime())  
33 - .betweenIfPresent(IotDeviceDO::getLastOfflineTime, reqVO.getLastOfflineTime())  
34 - .betweenIfPresent(IotDeviceDO::getActiveTime, reqVO.getActiveTime())  
35 - .eqIfPresent(IotDeviceDO::getDeviceSecret, reqVO.getDeviceSecret())  
36 - .eqIfPresent(IotDeviceDO::getMqttClientId, reqVO.getMqttClientId())  
37 - .likeIfPresent(IotDeviceDO::getMqttUsername, reqVO.getMqttUsername())  
38 - .eqIfPresent(IotDeviceDO::getMqttPassword, reqVO.getMqttPassword())  
39 - .eqIfPresent(IotDeviceDO::getAuthType, reqVO.getAuthType())  
40 - .betweenIfPresent(IotDeviceDO::getCreateTime, reqVO.getCreateTime()) 28 + .apply(ObjectUtil.isNotNull(reqVO.getGroupId()), "FIND_IN_SET(" + reqVO.getGroupId() + ",group_ids) > 0")
41 .orderByDesc(IotDeviceDO::getId)); 29 .orderByDesc(IotDeviceDO::getId));
42 } 30 }
43 31