feat(iot): 优化设备名称搜索功能
- 在 DeviceMapper.xml 中添加新的 SQL 查询语句,用于按名称搜索设备 - 在 DeviceRepository 接口中添加 selectListByName 方法 - 修改 DeviceServiceImpl 中的 findByName 方法,使用新的搜索逻辑 - 新增 WebSocketServer 类(暂无实现)
This commit is contained in:
parent
0644faf262
commit
4a1abef98a
@ -0,0 +1,4 @@
|
||||
package com.zsc.edu.gateway.framework.message.websocket;
|
||||
|
||||
public class WebSocketServer {
|
||||
}
|
@ -11,6 +11,8 @@ import com.zsc.edu.gateway.modules.iot.device.vo.DeviceVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author zhuang
|
||||
@ -28,4 +30,6 @@ public interface DeviceRepository extends BaseMapper<Device> {
|
||||
|
||||
@Select("select * from iot_device where client_id=#{clientId}")
|
||||
Device findByClientId(@Param("clientId") String clientId);
|
||||
|
||||
List<Device> selectListByName(@Param("name") String name);
|
||||
}
|
||||
|
@ -227,9 +227,10 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceRepository, Device> imp
|
||||
*/
|
||||
@Override
|
||||
public List<Device> findByName(String name) {
|
||||
LambdaQueryWrapper<Device> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.like(Device::getName, name);
|
||||
return baseMapper.selectList(queryWrapper);
|
||||
if (name == null) {
|
||||
return baseMapper.selectList(new QueryWrapper<>());
|
||||
}
|
||||
return baseMapper.selectListByName(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,4 +87,26 @@
|
||||
FROM iot_device d
|
||||
LEFT JOIN iot_product p ON d.product_id = p.id
|
||||
</select>
|
||||
|
||||
<select id="selectListByName" resultMap="BaseResultMap">
|
||||
select d.*,
|
||||
p.*,
|
||||
ip.id as param_id,
|
||||
ip.data_type as param_data_type,
|
||||
ip.uint as param_uint,
|
||||
ip.type as param_type,
|
||||
ip.identifier as param_identifier,
|
||||
ip.name as param_name,
|
||||
ip.remark as param_remark,
|
||||
ai.id as icon_id,
|
||||
ai.file_name as icon_file_name,
|
||||
ap.file_name as preview_file_name,
|
||||
ap.id as preview_id
|
||||
from iot_device d
|
||||
left join iot_product p on d.product_id = p.id
|
||||
left join iot_param ip on p.id = ip.foreign_id and ip.foreign_type = 3
|
||||
left join attachment ai on d.icon_id = ai.id
|
||||
left join attachment ap on d.preview_id = ap.id
|
||||
WHERE d.name LIKE concat('%', #{name}, '%')
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user