!1462 fix featuredQueries json deserialization bug

Merge pull request !1462 from tianyi.tu/master
This commit is contained in:
i-robot 2022-05-10 12:07:50 +00:00 committed by Gitee
commit 6b005c02f0
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 79 additions and 10 deletions

View File

@ -38,9 +38,7 @@ public interface SavedQuery
class Position
{
@JsonProperty
private int row;
@JsonProperty
private int column;
public Position(@JsonProperty("row") int row,
@ -61,6 +59,18 @@ public interface SavedQuery
{
return column;
}
@JsonProperty
public void setRow(int row)
{
this.row = row;
}
@JsonProperty
public void setColumn(int column)
{
this.column = column;
}
}
class QueryPlaceholder
@ -98,13 +108,29 @@ public interface SavedQuery
{
return name;
}
@JsonProperty
public void setLength(int length)
{
this.length = length;
}
@JsonProperty
public void setPosition(Position position)
{
this.position = position;
}
@JsonProperty
public void setName(String name)
{
this.name = name;
}
}
class QueryWithPlaceholders
{
@JsonProperty
private String query;
@JsonProperty
private List<QueryPlaceholder> placeholders;
public QueryWithPlaceholders()
@ -130,6 +156,18 @@ public interface SavedQuery
return placeholders;
}
@JsonProperty
public void setQuery(String query)
{
this.query = query;
}
@JsonProperty
public void setPlaceholders(List<QueryPlaceholder> placeholders)
{
this.placeholders = placeholders;
}
public static QueryWithPlaceholders fromQuery(String query)
{
ImmutableList.Builder<QueryPlaceholder> builder = ImmutableList.builder();

View File

@ -21,24 +21,18 @@ import java.util.UUID;
public class UserSavedQuery
implements SavedQuery
{
@JsonProperty
private QueryWithPlaceholders queryWithPlaceholders;
@JsonProperty
private String user;
@JsonProperty
private String name;
@JsonProperty
private String description;
private DateTime createdAt;
@JsonProperty
private UUID uuid;
@JsonProperty
private boolean featured;
public UserSavedQuery()
@ -97,6 +91,7 @@ public class UserSavedQuery
return uuid;
}
@JsonProperty
public void setFeatured(boolean featured)
{
this.featured = featured;
@ -118,4 +113,40 @@ public class UserSavedQuery
return null;
}
}
@JsonProperty
public void setQueryWithPlaceholders(QueryWithPlaceholders queryWithPlaceholders)
{
this.queryWithPlaceholders = queryWithPlaceholders;
}
@JsonProperty
public void setUser(String user)
{
this.user = user;
}
@JsonProperty
public void setName(String name)
{
this.name = name;
}
@JsonProperty
public void setDescription(String description)
{
this.description = description;
}
@JsonProperty
public void setCreatedAt(DateTime createdAt)
{
this.createdAt = createdAt;
}
@JsonProperty
public void setUuid(UUID uuid)
{
this.uuid = uuid;
}
}