forked from Qortal/qortal
Added isAdmin field to output of API call GET /groups/member/{address}
This commit is contained in:
parent
33010f82d8
commit
5011a2be22
@ -35,6 +35,9 @@ public class GroupData {
|
|||||||
)
|
)
|
||||||
private int creationGroupId;
|
private int creationGroupId;
|
||||||
|
|
||||||
|
// We abuse this class for API purposes by adding this unrelated field. Not always present.
|
||||||
|
private Boolean isAdmin;
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
// necessary for JAX-RS serialization
|
// necessary for JAX-RS serialization
|
||||||
@ -140,4 +143,14 @@ public class GroupData {
|
|||||||
return this.creationGroupId;
|
return this.creationGroupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is for API call GET /groups/member/{address}
|
||||||
|
|
||||||
|
public Boolean isAdmin() {
|
||||||
|
return this.isAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsAdmin(boolean isAdmin) {
|
||||||
|
this.isAdmin = isAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -206,8 +206,10 @@ public class HSQLDBGroupRepository implements GroupRepository {
|
|||||||
public List<GroupData> getGroupsWithMember(String member, Integer limit, Integer offset, Boolean reverse) throws DataException {
|
public List<GroupData> getGroupsWithMember(String member, Integer limit, Integer offset, Boolean reverse) throws DataException {
|
||||||
StringBuilder sql = new StringBuilder(512);
|
StringBuilder sql = new StringBuilder(512);
|
||||||
sql.append("SELECT group_id, owner, group_name, description, created, updated, reference, is_open, "
|
sql.append("SELECT group_id, owner, group_name, description, created, updated, reference, is_open, "
|
||||||
+ "approval_threshold, min_block_delay, max_block_delay, creation_group_id FROM Groups "
|
+ "approval_threshold, min_block_delay, max_block_delay, creation_group_id, admin FROM Groups "
|
||||||
+ "JOIN GroupMembers USING (group_id) WHERE address = ? ORDER BY group_name");
|
+ "JOIN GroupMembers USING (group_id) "
|
||||||
|
+ "LEFT OUTER JOIN GroupAdmins ON GroupAdmins.group_id = GroupMembers.group_id AND GroupAdmins.admin = GroupMembers.address "
|
||||||
|
+ "WHERE address = ? ORDER BY group_name");
|
||||||
if (reverse != null && reverse)
|
if (reverse != null && reverse)
|
||||||
sql.append(" DESC");
|
sql.append(" DESC");
|
||||||
|
|
||||||
@ -239,8 +241,13 @@ public class HSQLDBGroupRepository implements GroupRepository {
|
|||||||
int maxBlockDelay = resultSet.getInt(11);
|
int maxBlockDelay = resultSet.getInt(11);
|
||||||
|
|
||||||
int creationGroupId = resultSet.getInt(12);
|
int creationGroupId = resultSet.getInt(12);
|
||||||
|
resultSet.getString(13);
|
||||||
|
boolean isAdmin = !resultSet.wasNull();
|
||||||
|
|
||||||
groups.add(new GroupData(groupId, owner, groupName, description, created, updated, isOpen, approvalThreshold, minBlockDelay, maxBlockDelay, reference, creationGroupId));
|
GroupData groupData = new GroupData(groupId, owner, groupName, description, created, updated, isOpen, approvalThreshold, minBlockDelay, maxBlockDelay, reference, creationGroupId);
|
||||||
|
groupData.setIsAdmin(isAdmin);
|
||||||
|
|
||||||
|
groups.add(groupData);
|
||||||
} while (resultSet.next());
|
} while (resultSet.next());
|
||||||
|
|
||||||
return groups;
|
return groups;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user