Bladeren bron

字典从integer 修改为string
设备分页查询,增加反参节点类型

xucaiqin 1 jaar geleden
bovenliggende
commit
7ece440a2a
18 gewijzigde bestanden met toevoegingen van 169 en 60 verwijderingen
  1. 2 2
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/constant/UrlCategory.java
  2. 7 7
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/constant/UrlInit.java
  3. 3 3
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/constant/UrlTypeEnum.java
  4. 1 1
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/controller/IotDeviceController.java
  5. 10 6
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/domain/req/IotProductPara.java
  6. 74 0
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/domain/req/IotProductUpdate.java
  7. 4 4
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/domain/req/IotUrlPara.java
  8. 6 2
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/domain/vo/IotDeviceVo.java
  9. 6 6
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/domain/vo/IotProductDetailVo.java
  10. 1 1
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/domain/vo/IotProductVo.java
  11. 6 6
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/entity/IotProduct.java
  12. 4 4
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/entity/IotUrl.java
  13. 1 1
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/mapper/IotProductMapper.java
  14. 2 1
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/service/IotDeviceService.java
  15. 35 9
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/service/IotProductService.java
  16. 2 2
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/service/IotUrlService.java
  17. 4 4
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/resources/mapper/IotDeviceMapper.xml
  18. 1 1
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/resources/mapper/IotProductMapper.xml

+ 2 - 2
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/constant/UrlCategory.java

@@ -5,6 +5,6 @@ package com.middle.platform.manage.biz.constant;
  * @date 2023-12-21 09:23:36
  */
 public interface UrlCategory {
-    Integer init = 1;
-    Integer custom = 2;
+    String init = "1";
+    String custom = "2";
 }

+ 7 - 7
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/constant/UrlInit.java

@@ -5,16 +5,16 @@ package com.middle.platform.manage.biz.constant;
  * @date 2023-12-21 09:25:19
  */
 public enum UrlInit {
-    ATTR_UP("/iot/%s/+/property/post", "设备属性上报", 1, 1),
-    ATTR_DOWN("/iot/%s/+/property/post_reply", "云端响应属性上报", 2, 2),
+    ATTR_UP("/iot/%s/+/property/post", "设备属性上报", "1", "1"),
+    ATTR_DOWN("/iot/%s/+/property/post_reply", "云端响应属性上报", "2", "2"),
     ;
     private final String prefix;
     private final String desc;
-    private final Integer permission;
-    private final Integer func;
+    private final String permission;
+    private final String func;
 
 
-    UrlInit(String prefix, String desc, Integer permission, Integer func) {
+    UrlInit(String prefix, String desc, String permission, String func) {
         this.prefix = prefix;
         this.desc = desc;
         this.permission = permission;
@@ -25,7 +25,7 @@ public enum UrlInit {
         return prefix;
     }
 
-    public Integer getPermission() {
+    public String getPermission() {
         return permission;
     }
 
@@ -33,7 +33,7 @@ public enum UrlInit {
         return desc;
     }
 
-    public Integer getFunc() {
+    public String getFunc() {
         return func;
     }
 }

+ 3 - 3
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/constant/UrlTypeEnum.java

@@ -10,9 +10,9 @@ import lombok.Getter;
 @Getter
 @AllArgsConstructor
 public enum UrlTypeEnum {
-    MQTT("MQTT", 1),
-    HTTP("HTTP", 2),
+    MQTT("MQTT", "1"),
+    HTTP("HTTP", "2"),
     ;
     private final String label;
-    private final Integer val;
+    private final String val;
 }

+ 1 - 1
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/controller/IotDeviceController.java

@@ -122,7 +122,7 @@ public class IotDeviceController {
      * @return 设备总数、当前在线
      */
     @GetMapping("/count")
-    public Result<Object> count(@NotNull(message = "产品id不能为空") Long productId) {
+    public Result<Object> count(/*@NotNull(message = "产品id不能为空")*/ Long productId) {
         return Result.ok(iotDeviceService.count(productId), "查询成功");
     }
 }

+ 10 - 6
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/domain/req/IotProductPara.java

@@ -12,6 +12,10 @@ import lombok.Setter;
 @Getter
 @Setter
 public class IotProductPara {
+    /**
+     * id
+     */
+    private Long id;
 
     /**
      * 产品名称
@@ -25,36 +29,36 @@ public class IotProductPara {
      * 节点类型:1网关、2子设备
      */
     @NotNull(message = "节点类型不能为空")
-    private Integer nodeType;
+    private String nodeType;
 
     /**
      * 联网类型 network_type
      */
     @NotNull(message = "联网类型不能为空")
-    private Integer networkType;
+    private String networkType;
 
     /**
      * 上报协议 1-mqtt 2-http 3-coap 4-tcp 5-udp
      */
     @NotNull(message = "上报协议不能为空")
-    private Integer reportProtocol;
+    private String reportProtocol;
 
     /**
      * 数据格式
      */
     @NotNull(message = "数据格式不能为空")
-    private Integer dataFormat;
+    private String dataFormat;
 
     /**
      * 认证方式
      */
     @NotNull(message = "数据格式不能为空")
-    private Integer authType;
+    private String authType;
     /**
      * 设备厂商
      */
     @NotNull(message = "设备厂商不能为空")
-    private Integer vendors;
+    private String vendors;
 
     /**
      * 产品标签

+ 74 - 0
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/domain/req/IotProductUpdate.java

@@ -0,0 +1,74 @@
+package com.middle.platform.manage.biz.domain.req;
+
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Size;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 产品
+ */
+@Getter
+@Setter
+public class IotProductUpdate {
+    /**
+     * id
+     */
+    private Long id;
+
+    /**
+     * 产品名称
+     */
+    @NotBlank(message = "产品名称不能为空")
+    @Size(max = 50, message = "产品名称需介于0-50")
+    private String name;
+
+
+    /**
+     * 节点类型:1网关、2子设备
+     */
+    @NotNull(message = "节点类型不能为空")
+    private String nodeType;
+
+    /**
+     * 联网类型 network_type
+     */
+    @NotNull(message = "联网类型不能为空")
+    private String networkType;
+
+    /**
+     * 上报协议 1-mqtt 2-http 3-coap 4-tcp 5-udp
+     */
+    @NotNull(message = "上报协议不能为空")
+    private String reportProtocol;
+
+    /**
+     * 数据格式
+     */
+    @NotNull(message = "数据格式不能为空")
+    private String dataFormat;
+
+    /**
+     * 认证方式
+     */
+    @NotNull(message = "数据格式不能为空")
+    private String authType;
+    /**
+     * 设备厂商
+     */
+    @NotNull(message = "设备厂商不能为空")
+    private String vendors;
+
+    /**
+     * 产品标签
+     */
+//    @NotBlank(message = "产品标签不能为空")
+    private String tag;
+
+    /**
+     * 备注
+     */
+    @Size(max = 100, message = "备注需介于0-100")
+    private String remark;
+}

+ 4 - 4
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/domain/req/IotUrlPara.java

@@ -25,13 +25,13 @@ public class IotUrlPara {
      * 类别 1-默认 2-自定义
      */
     @NotNull(message = "类别不能为空")
-    private Integer category;
+    private String category;
 
     /**
      * 功能 1-属性上报
      */
     @NotNull(message = "功能不能为空")
-    private Integer func;
+    private String func;
 
     /**
      * 地址
@@ -44,13 +44,13 @@ public class IotUrlPara {
      * 设备权限:1发布 2订阅 3发布和订阅
      */
     @NotNull(message = "设备权限不能为空")
-    private Integer permission;
+    private String permission;
 
     /**
      * 地址类型 1-mqtt 2-http 3-Coap
      */
     @NotNull(message = "地址类型不能为空")
-    private Integer type;
+    private String type;
 
     /**
      * 备注

+ 6 - 2
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/domain/vo/IotDeviceVo.java

@@ -6,7 +6,6 @@ import lombok.Getter;
 import lombok.Setter;
 
 import java.math.BigDecimal;
-import java.time.LocalDateTime;
 
 /**
  * 设备表
@@ -67,7 +66,12 @@ public class IotDeviceVo extends BaseVO {
      * 最后在线时间
      */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    private LocalDateTime onlineTime;
+    private Object onlineTime;
+    /**
+     * 节点类型
+     */
+    private Integer nodeType;
+    private String nodeTypeLabel;
 
     /**
      * 设备状态 1-在线 0-离线

+ 6 - 6
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/domain/vo/IotProductDetailVo.java

@@ -33,36 +33,36 @@ public class IotProductDetailVo extends BaseVO {
     /**
      * 节点类型:1网关、2子设备
      */
-    private Integer nodeType;
+    private String nodeType;
     private String nodeTypeLabel;
 
     /**
      * 联网类型
      */
-    private Integer networkType;
+    private String networkType;
     private String networkTypeLabel;
 
     /**
      * 上报协议
      */
-    private Integer reportProtocol;
+    private String reportProtocol;
     private String reportProtocolLabel;
     /**
      * 设备厂商
      */
-    private Integer vendors;
+    private String vendors;
     private String vendorsLabel;
 
     /**
      * 数据格式
      */
-    private Integer dataFormat;
+    private String dataFormat;
     private String dataFormatLabel;
 
     /**
      * 认证方式
      */
-    private Integer authType;
+    private String authType;
     private String authTypeLabel;
 
     /**

+ 1 - 1
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/domain/vo/IotProductVo.java

@@ -28,7 +28,7 @@ public class IotProductVo extends BaseVO {
     /**
      * 节点类型:1网关、2子设备
      */
-    private Integer nodeType;
+    private String nodeType;
     private String nodeTypeLabel;
 
 

+ 6 - 6
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/entity/IotProduct.java

@@ -43,36 +43,36 @@ public class IotProduct extends BaseDO {
      * 节点类型:1网关、2子设备
      */
     @TableField(value = "node_type")
-    private Integer nodeType;
+    private String nodeType;
 
     /**
      * 联网类型
      */
     @TableField(value = "network_type")
-    private Integer networkType;
+    private String networkType;
 
     /**
      * 上报协议
      */
     @TableField(value = "report_protocol")
-    private Integer reportProtocol;
+    private String reportProtocol;
     /**
      * 设备厂商
      */
     @TableField(value = "vendors")
-    private Integer vendors;
+    private String vendors;
 
     /**
      * 数据格式
      */
     @TableField(value = "data_format")
-    private Integer dataFormat;
+    private String dataFormat;
 
     /**
      * 认证方式
      */
     @TableField(value = "auth_type")
-    private Integer authType;
+    private String authType;
 
     /**
      * 产品标签

+ 4 - 4
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/entity/IotUrl.java

@@ -30,13 +30,13 @@ public class IotUrl extends BaseDO {
      * 类别 1-默认 2-自定义
      */
     @TableField(value = "category")
-    private Integer category;
+    private String category;
 
     /**
      * 功能 1-属性上报
      */
     @TableField(value = "func")
-    private Integer func;
+    private String func;
 
     /**
      * 地址
@@ -48,13 +48,13 @@ public class IotUrl extends BaseDO {
      * 设备权限:1发布 2订阅 3发布和订阅
      */
     @TableField(value = "permission")
-    private Integer permission;
+    private String permission;
 
     /**
      * 地址类型 1-mqtt 2-http 3-Coap
      */
     @TableField(value = "`type`")
-    private Integer type;
+    private String type;
 
     /**
      * 备注

+ 1 - 1
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/mapper/IotProductMapper.java

@@ -46,7 +46,7 @@ public interface IotProductMapper extends BaseMapper<IotProduct> {
      * @param type 地址类型 1-mqtt 2-http 3-coap
      * @return
      */
-    List<TopicVo> queryProductTopic(@Param("type") Integer type);
+    List<TopicVo> queryProductTopic(@Param("type") String type);
 
     void updateSize(@Param("productId") Long productId,@Param("size") Integer size);
 }

+ 2 - 1
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/service/IotDeviceService.java

@@ -69,8 +69,9 @@ public class IotDeviceService {
         iotProductVos.forEach(a -> {
             Optional.ofNullable(userApi.queryUser(a.getCreateBy())).ifPresent(userCache -> a.setCreateByLabel(userCache.getName()));
             Optional.ofNullable(userApi.queryUser(a.getUpdateBy())).ifPresent(userCache -> a.setUpdateByLabel(userCache.getName()));
+            Optional.ofNullable(dictApi.query(DictType.NODE_TYPE, String.valueOf(a.getNodeType()))).ifPresent(dictCache -> a.setNodeTypeLabel(dictCache.getLabel()));
             Optional.ofNullable(cacheService.getKey(String.format(CacheConstant.ONLINE_CACHE, a.getGuid()))).ifPresent(t -> {
-                a.setOnlineTime((LocalDateTime) t);
+                a.setOnlineTime(t);
                 a.setStatus(1);
             });
         });

+ 35 - 9
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/service/IotProductService.java

@@ -13,6 +13,7 @@ import com.middle.platform.manage.api.pojo.TopicVo;
 import com.middle.platform.manage.biz.constant.Constant;
 import com.middle.platform.manage.biz.constant.UrlTypeEnum;
 import com.middle.platform.manage.biz.domain.req.IotProductPara;
+import com.middle.platform.manage.biz.domain.req.IotProductUpdate;
 import com.middle.platform.manage.biz.domain.req.ProductPage;
 import com.middle.platform.manage.biz.domain.vo.IotProductDetailVo;
 import com.middle.platform.manage.biz.domain.vo.IotProductVo;
@@ -70,7 +71,7 @@ public class IotProductService {
         iotProductVos.forEach(u -> {
             Optional.ofNullable(userApi.queryUser(u.getCreateBy())).ifPresent(userCache -> u.setCreateByLabel(userCache.getName()));
             Optional.ofNullable(userApi.queryUser(u.getUpdateBy())).ifPresent(userCache -> u.setUpdateByLabel(userCache.getName()));
-            Optional.ofNullable(dictApi.query(DictType.NODE_TYPE, String.valueOf(u.getNodeType()))).ifPresent(cache -> u.setNodeTypeLabel(cache.getLabel()));
+            Optional.ofNullable(dictApi.query(DictType.NODE_TYPE, u.getNodeType())).ifPresent(cache -> u.setNodeTypeLabel(cache.getLabel()));
         });
         return new PageRes<>(pageInfo, iotProductVos);
     }
@@ -84,7 +85,7 @@ public class IotProductService {
     @Transactional(rollbackFor = Exception.class)
     public Object save(IotProductPara iotProductPara) {
         IotProduct iotProduct = new IotProduct();
-        iotProduct.setCode(OrderUtil.get(Constant.PRODUCT_PREFIX + String.format("%02d", iotProductPara.getNodeType())));
+        iotProduct.setCode(OrderUtil.get(Constant.PRODUCT_PREFIX + String.format("%02d", Integer.valueOf(iotProductPara.getNodeType()))));
         iotProduct.setName(iotProductPara.getName());
         iotProduct.setSecret(IdUtil.nanoId());
         iotProduct.setNodeType(iotProductPara.getNodeType());
@@ -101,7 +102,32 @@ public class IotProductService {
         iotUrlService.save(iotProduct);
         /*创建产品*/
         tdApi.createProduct(iotProduct.getCode());
-        return null;
+        return true;
+    }
+
+    /**
+     * 新增产品
+     *
+     * @param iotProductPara
+     * @return
+     */
+    public Object update(IotProductUpdate iotProductPara) {
+        if (Objects.isNull(iotProductPara.getId())) {
+            throw new BusinessException("id不能为空");
+        }
+        IotProduct iotProduct = new IotProduct();
+        iotProduct.setId(iotProductPara.getId());
+        iotProduct.setName(iotProductPara.getName());
+        iotProduct.setNodeType(iotProductPara.getNodeType());
+        iotProduct.setNetworkType(iotProductPara.getNetworkType());
+        iotProduct.setVendors(iotProductPara.getVendors());
+        iotProduct.setAuthType(iotProductPara.getAuthType());
+        iotProduct.setTag(iotProductPara.getTag());
+        iotProduct.setSize(0);
+        iotProduct.setRemark(iotProductPara.getRemark());
+        iotProductMapper.updateById(iotProduct);
+
+        return true;
     }
 
     /**
@@ -146,12 +172,12 @@ public class IotProductService {
         }
         IotProductDetailVo iotProductDetailVo = new IotProductDetailVo();
         BeanUtils.copyProperties(iotProduct, iotProductDetailVo);
-        Optional.ofNullable(dictApi.query(DictType.AUTH_TYPE, String.valueOf(iotProductDetailVo.getAuthType()))).ifPresent(cache -> iotProductDetailVo.setAuthTypeLabel(cache.getLabel()));
-        Optional.ofNullable(dictApi.query(DictType.NODE_TYPE, String.valueOf(iotProductDetailVo.getNodeType()))).ifPresent(cache -> iotProductDetailVo.setNodeTypeLabel(cache.getLabel()));
-        Optional.ofNullable(dictApi.query(DictType.NETWORK_TYPE, String.valueOf(iotProductDetailVo.getNetworkType()))).ifPresent(cache -> iotProductDetailVo.setNetworkTypeLabel(cache.getLabel()));
-        Optional.ofNullable(dictApi.query(DictType.REPORT_PROTOCOL_TYPE, String.valueOf(iotProductDetailVo.getReportProtocol()))).ifPresent(cache -> iotProductDetailVo.setReportProtocolLabel(cache.getLabel()));
-        Optional.ofNullable(dictApi.query(DictType.VENDORS_TYPE, String.valueOf(iotProductDetailVo.getVendors()))).ifPresent(cache -> iotProductDetailVo.setVendorsLabel(cache.getLabel()));
-        Optional.ofNullable(dictApi.query(DictType.DATA_FORMAT_TYPE, String.valueOf(iotProductDetailVo.getDataFormat()))).ifPresent(cache -> iotProductDetailVo.setDataFormatLabel(cache.getLabel()));
+        Optional.ofNullable(dictApi.query(DictType.AUTH_TYPE, iotProductDetailVo.getAuthType())).ifPresent(cache -> iotProductDetailVo.setAuthTypeLabel(cache.getLabel()));
+        Optional.ofNullable(dictApi.query(DictType.NODE_TYPE, iotProductDetailVo.getNodeType())).ifPresent(cache -> iotProductDetailVo.setNodeTypeLabel(cache.getLabel()));
+        Optional.ofNullable(dictApi.query(DictType.NETWORK_TYPE, iotProductDetailVo.getNetworkType())).ifPresent(cache -> iotProductDetailVo.setNetworkTypeLabel(cache.getLabel()));
+        Optional.ofNullable(dictApi.query(DictType.REPORT_PROTOCOL_TYPE, iotProductDetailVo.getReportProtocol())).ifPresent(cache -> iotProductDetailVo.setReportProtocolLabel(cache.getLabel()));
+        Optional.ofNullable(dictApi.query(DictType.VENDORS_TYPE, iotProductDetailVo.getVendors())).ifPresent(cache -> iotProductDetailVo.setVendorsLabel(cache.getLabel()));
+        Optional.ofNullable(dictApi.query(DictType.DATA_FORMAT_TYPE, iotProductDetailVo.getDataFormat())).ifPresent(cache -> iotProductDetailVo.setDataFormatLabel(cache.getLabel()));
         Optional.ofNullable(userApi.queryUser(iotProductDetailVo.getCreateBy())).ifPresent(userCache -> iotProductDetailVo.setCreateByLabel(userCache.getName()));
         Optional.ofNullable(userApi.queryUser(iotProductDetailVo.getUpdateBy())).ifPresent(userCache -> iotProductDetailVo.setUpdateByLabel(userCache.getName()));
         return iotProductDetailVo;

+ 2 - 2
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/service/IotUrlService.java

@@ -125,9 +125,9 @@ public class IotUrlService {
         return true;
     }
 
-    private void checkType(Integer type) {
+    private void checkType(String type) {
         for (UrlTypeEnum value : UrlTypeEnum.values()) {
-            if (Objects.equals(value.getVal(), type)) {
+            if (StringUtils.equals(value.getVal(), type)) {
                 return;
             }
         }

+ 4 - 4
iot-module/iot-module-manage/iot-module-manage-biz/src/main/resources/mapper/IotDeviceMapper.xml

@@ -102,16 +102,16 @@
         </where>
     </select>
   <select id="pageQuery" resultType="com.middle.platform.manage.biz.domain.vo.IotDeviceVo">
-      select id.*, ip.name as productName
+      select id.*, ip.name as productName, ip.node_type
       from iot_device id
                inner join iot_product ip on id.product_id = ip.id and ip.del_flag = 0
       <where>
           <if test="keywords != null and keywords != ''">
               and id.name like concat('%', #{keywords,jdbcType=VARCHAR}, '%')
           </if>
-        <if test="productId != null">
-            and id.product_id = #{productId,jdbcType=BIGINT}
-        </if>
+          <if test="productId != null">
+              and id.product_id = #{productId,jdbcType=BIGINT}
+          </if>
           and id.del_flag = 0
       </where>
   </select>

+ 1 - 1
iot-module/iot-module-manage/iot-module-manage-biz/src/main/resources/mapper/IotProductMapper.xml

@@ -98,7 +98,7 @@
         from iot_product ip
                  inner join iot_url iu on ip.id = iu.product_id and iu.del_flag = 0
         <where>
-            <if test="type != null">
+            <if test="type != null and type != ''">
                 and iu.type = #{type,jdbcType=INTEGER}
             </if>
             and iu.permission in (1, 3)