Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
<bind name="excluded" value="('%' + condition.excluded + '%')"/>
AND (
p.name NOT LIKE #{excluded, jdbcType=VARCHAR}
OR p.role NOT LIKE #{excluded, jdbcType=VARCHAR}
AND p.role NOT LIKE #{excluded, jdbcType=VARCHAR}
)
</if>
<if test="condition.switchStatus != null">
Expand Down
2 changes: 1 addition & 1 deletion shenyu-admin/src/main/resources/mappers/plugin-sqlmap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
<bind name="excluded" value="('%' + condition.excluded + '%')"/>
AND (
name NOT LIKE #{excluded, jdbcType=VARCHAR}
OR role NOT LIKE #{excluded, jdbcType=VARCHAR}
AND role NOT LIKE #{excluded, jdbcType=VARCHAR}
)
</if>
<if test="condition.switchStatus != null">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@ void testSelectByIds() {
Assertions.assertEquals(id, queryResults.get(0).getId());
}

@Test
@Transactional
void excludedSearchDropsRelPluginWhenAnySearchableFieldMatches() {
pluginMapper.insert(PluginDO.builder().id("excluded-rel-divide").name("mockRelExcluded").role("Proxy").sort(0).enabled(true)
.dateCreated(new Timestamp(0)).dateUpdated(new Timestamp(0)).build());
pluginMapper.insert(PluginDO.builder().id("excluded-rel-other").name("mockRelRetained").role("HttpProcess").sort(1).enabled(true)
.dateCreated(new Timestamp(0)).dateUpdated(new Timestamp(0)).build());
namespacePluginRelMapper.insertSelective(NamespacePluginRelDO.builder().id("rel-excluded-0").pluginId("excluded-rel-divide")
.namespaceId("excluded-search").enabled(true).sort(0).build());
namespacePluginRelMapper.insertSelective(NamespacePluginRelDO.builder().id("rel-excluded-1").pluginId("excluded-rel-other")
.namespaceId("excluded-search").enabled(true).sort(1).build());
NamespacePluginQueryCondition condition = new NamespacePluginQueryCondition();
condition.setKeyword("!mockRelExcluded");
condition.init();
List<NamespacePluginVO> searched = namespacePluginRelMapper.searchByCondition(condition);
Assertions.assertTrue(searched.stream().noneMatch(item -> "mockRelExcluded".equals(item.getName())));
Assertions.assertTrue(searched.stream().anyMatch(item -> "mockRelRetained".equals(item.getName())));
}

@Test
void testSelectByQueryWithStringNamespaceId() {
String namespaceId = "namespace-text";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Test cases for PluginMapper.
Expand Down Expand Up @@ -245,6 +246,24 @@ public void delete() {
assertThat(deleteResult, equalTo(1));
}

@Test
@org.springframework.transaction.annotation.Transactional
public void excludedSearchDropsPluginWhenAnySearchableFieldMatches() {
final PluginDO excluded = PluginDO.builder().id("excluded-search-divide").name("mockExcludedPlugin").role("Proxy")
.sort(0).enabled(true).dateCreated(new java.sql.Timestamp(0)).dateUpdated(new java.sql.Timestamp(0)).build();
final PluginDO retained = PluginDO.builder().id("excluded-search-other").name("mockRetainedPlugin").role("HttpProcess")
.sort(1).enabled(true).dateCreated(new java.sql.Timestamp(0)).dateUpdated(new java.sql.Timestamp(0)).build();
assertEquals(1, pluginMapper.insert(excluded));
assertEquals(1, pluginMapper.insert(retained));
final org.apache.shenyu.admin.model.query.PluginQueryCondition condition =
new org.apache.shenyu.admin.model.query.PluginQueryCondition();
condition.setKeyword("!mockExcludedPlugin");
condition.init();
final List<PluginListVO> searched = pluginService.searchByCondition(condition);
assertTrue(searched.stream().noneMatch(item -> "mockExcludedPlugin".equals(item.getName())));
assertTrue(searched.stream().anyMatch(item -> "mockRetainedPlugin".equals(item.getName())));
}

@Test
public void pagedListOmitsJarWhileDetailAndExportPreserveIt() {
final PluginDO plugin = PluginDO.buildPluginDO(buildPluginDTO());
Expand Down
Loading