1
0
mirror of https://github.com/haiwen/ccnet-server.git synced 2025-04-27 18:25:06 +00:00

Get group members add LIMIT

This commit is contained in:
杨赫然 2020-10-14 14:33:57 +08:00
parent e603dfdecd
commit c0ffad358a
7 changed files with 39 additions and 15 deletions

View File

@ -30,7 +30,7 @@
GList *ccnet_get_groups_by_user (SearpcClient *client, const char *user, int return_ancestors);
GList *ccnet_get_org_groups_by_user (SearpcClient *client, const char *user, int org_id);
GList *
ccnet_get_group_members (SearpcClient *client, int group_id);
ccnet_get_group_members (SearpcClient *client, int group_id, int start, int limit);
int
ccnet_org_user_exists (SearpcClient *client, int org_id, const char *user);

View File

@ -29,11 +29,11 @@ ccnet_get_org_groups_by_user (SearpcClient *client, const char *user, int org_id
}
GList *
ccnet_get_group_members (SearpcClient *client, int group_id)
ccnet_get_group_members (SearpcClient *client, int group_id, int start, int limit)
{
return searpc_client_call__objlist (
client, "get_group_members", CCNET_TYPE_GROUP_USER, NULL,
1, "int", group_id);
3, "int", group_id, "int", start, "int", limit);
}
int

View File

@ -172,7 +172,7 @@ ccnet_start_rpc(CcnetSession *session)
searpc_server_register_function ("ccnet-threaded-rpcserver",
ccnet_rpc_get_group_members,
"get_group_members",
searpc_signature_objlist__int());
searpc_signature_objlist__int_int_int());
searpc_server_register_function ("ccnet-threaded-rpcserver",
ccnet_rpc_get_members_with_prefix,
"get_members_with_prefix",
@ -838,13 +838,17 @@ ccnet_rpc_get_group (int group_id, GError **error)
GList *
ccnet_rpc_get_group_members (int group_id, GError **error)
ccnet_rpc_get_group_members (int group_id, int start, int limit, GError **error)
{
CcnetGroupManager *group_mgr =
((CcnetServerSession *)session)->group_mgr;
GList *ret = NULL;
ret = ccnet_group_manager_get_group_members (group_mgr, group_id, error);
if (start < 0 ) {
start = 0;
}
ret = ccnet_group_manager_get_group_members (group_mgr, group_id, start, limit, error);
if (ret == NULL)
return NULL;

View File

@ -171,7 +171,7 @@ GObject *
ccnet_rpc_get_group (int group_id, GError **error);
GList *
ccnet_rpc_get_group_members (int group_id, GError **error);
ccnet_rpc_get_group_members (int group_id, int start, int limit, GError **error);
GList *
ccnet_rpc_get_members_with_prefix(int group_id, const char *prefix, GError **error);

View File

@ -1020,18 +1020,35 @@ get_ccnet_groupuser_cb (CcnetDBRow *row, void *data)
}
GList *
ccnet_group_manager_get_group_members (CcnetGroupManager *mgr, int group_id,
ccnet_group_manager_get_group_members (CcnetGroupManager *mgr,
int group_id,
int start,
int limit,
GError **error)
{
CcnetDB *db = mgr->priv->db;
char *sql;
GList *group_users = NULL;
int rc;
if (limit == -1) {
sql = "SELECT group_id, user_name, is_staff FROM GroupUser WHERE group_id = ?";
rc = ccnet_db_statement_foreach_row (db, sql,
get_ccnet_groupuser_cb, &group_users,
1, "int", group_id);
} else {
sql = "SELECT group_id, user_name, is_staff FROM GroupUser WHERE group_id = ? LIMIT ? OFFSET ?";
rc = ccnet_db_statement_foreach_row (db, sql,
get_ccnet_groupuser_cb, &group_users,
3, "int", group_id,
"int", limit,
"int", start);
sql = "SELECT group_id, user_name, is_staff FROM GroupUser WHERE group_id = ?";
if (ccnet_db_statement_foreach_row (db, sql,
get_ccnet_groupuser_cb, &group_users,
1, "int", group_id) < 0)
}
if (rc < 0) {
return NULL;
}
return g_list_reverse (group_users);
}

View File

@ -85,7 +85,10 @@ ccnet_group_manager_get_group (CcnetGroupManager *mgr, int group_id,
GError **error);
GList *
ccnet_group_manager_get_group_members (CcnetGroupManager *mgr, int group_id,
ccnet_group_manager_get_group_members (CcnetGroupManager *mgr,
int group_id,
int start,
int limit,
GError **error);
GList *

View File

@ -157,8 +157,8 @@ class CcnetThreadedRpcClient(NamedPipeClient):
def get_group(self, group_id):
pass
@searpc_func("objlist", ["int"])
def get_group_members(self, group_id):
@searpc_func("objlist", ["int", "int", "int"])
def get_group_members(self, group_id, start, limit):
pass
@searpc_func("objlist", ["int", "string"])