mirror of
https://github.com/HangarMC/Hangar.git
synced 2024-11-21 01:21:54 +08:00
move query param name to method
This commit is contained in:
parent
af775ee613
commit
1e97e576ca
@ -4,9 +4,11 @@ import io.papermc.hangar.controller.extras.pagination.Filter.FilterInstance;
|
|||||||
import org.jdbi.v3.core.statement.SqlStatement;
|
import org.jdbi.v3.core.statement.SqlStatement;
|
||||||
import org.springframework.web.context.request.NativeWebRequest;
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
|
|
||||||
public interface Filter<F extends FilterInstance> {
|
public interface Filter<F extends FilterInstance> extends QueryIdentified {
|
||||||
|
|
||||||
boolean supports(NativeWebRequest webRequest);
|
default boolean supports(NativeWebRequest webRequest) {
|
||||||
|
return webRequest.getParameterMap().containsKey(getQueryParamName());
|
||||||
|
}
|
||||||
|
|
||||||
F create(NativeWebRequest webRequest);
|
F create(NativeWebRequest webRequest);
|
||||||
|
|
||||||
|
@ -10,13 +10,13 @@ public class ProjectCategoryFilter implements Filter<ProjectCategoryFilterInstan
|
|||||||
private static final String QUERY_PARAM = "projectCategory";
|
private static final String QUERY_PARAM = "projectCategory";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supports(NativeWebRequest webRequest) {
|
public ProjectCategoryFilterInstance create(NativeWebRequest webRequest) {
|
||||||
return webRequest.getParameterMap().containsKey(QUERY_PARAM);
|
return new ProjectCategoryFilterInstance(webRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProjectCategoryFilterInstance create(NativeWebRequest webRequest) {
|
public String getQueryParamName() {
|
||||||
return new ProjectCategoryFilterInstance(webRequest);
|
return QUERY_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ProjectCategoryFilterInstance implements FilterInstance {
|
static class ProjectCategoryFilterInstance implements FilterInstance {
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
package io.papermc.hangar.controller.extras.pagination;
|
||||||
|
|
||||||
|
public interface QueryIdentified {
|
||||||
|
|
||||||
|
String getQueryParamName();
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package io.papermc.hangar.controller.extras.pagination;
|
package io.papermc.hangar.controller.extras.pagination;
|
||||||
|
|
||||||
public interface SortBy {
|
public interface SortBy extends QueryIdentified {
|
||||||
|
|
||||||
void createSql(StringBuilder sb);
|
void createSql(StringBuilder sb);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user