修复sql模糊查询中含有特殊符号时查询不准备的BUG

This commit is contained in:
648540858
2024-11-14 14:08:05 +08:00
parent 86879aa58d
commit 6e8a3f6adf
13 changed files with 51 additions and 11 deletions

View File

@@ -48,8 +48,8 @@ public interface StreamPushMapper {
" on st.id = wdc.stream_push_id " +
" WHERE " +
" 1=1 " +
" <if test='query != null'> AND (st.app LIKE concat('%',#{query},'%') OR st.stream LIKE concat('%',#{query},'%') " +
" OR wdc.gb_device_id LIKE concat('%',#{query},'%') OR wdc.gb_name LIKE concat('%',#{query},'%'))</if> " +
" <if test='query != null'> AND (st.app LIKE concat('%',#{query},'%') escape '/' OR st.stream LIKE concat('%',#{query},'%') escape '/' " +
" OR wdc.gb_device_id LIKE concat('%',#{query},'%') escape '/' OR wdc.gb_name LIKE concat('%',#{query},'%') escape '/')</if> " +
" <if test='pushing == true' > AND st.pushing=1</if>" +
" <if test='pushing == false' > AND st.pushing=0 </if>" +
" <if test='mediaServerId != null' > AND st.media_server_id=#{mediaServerId} </if>" +

View File

@@ -175,6 +175,11 @@ public class StreamPushServiceImpl implements IStreamPushService {
@Override
public PageInfo<StreamPush> getPushList(Integer page, Integer count, String query, Boolean pushing, String mediaServerId) {
PageHelper.startPage(page, count);
if (query != null) {
query = query.replaceAll("/", "//")
.replaceAll("%", "/%")
.replaceAll("_", "/_");
}
List<StreamPush> all = streamPushMapper.selectAll(query, pushing, mediaServerId);
return new PageInfo<>(all);
}