Mod aaa-12 修改显示用户列表接口,输出json串中增加total字段
RCA: SOL: 修改人:zhouzian 检视人:zhouzian
This commit is contained in:
parent
3ce0a38ce5
commit
e32783b49b
|
@ -64,7 +64,7 @@ ret_code user_config_chk(uint source, uint *config_type,
|
|||
}
|
||||
|
||||
/*
|
||||
* 根据用户uuid查询用户详情-处理
|
||||
* get-根据用户uuid查询用户详情
|
||||
* iuput格式:
|
||||
{
|
||||
"type": 3, //3:表示根据用户id查询用户详情
|
||||
|
@ -195,7 +195,7 @@ static ret_code user_config_get_detail_proc(uint source,
|
|||
}
|
||||
|
||||
/*
|
||||
* 根据用户名查询用户uuid-处理
|
||||
* get-根据用户名查询用户uuid
|
||||
* iuput格式:
|
||||
{
|
||||
"type": 7, //7:表示查询用户名重名
|
||||
|
@ -270,7 +270,7 @@ static ret_code user_config_get_uuid_proc(uint source,
|
|||
}
|
||||
|
||||
/*
|
||||
* 查询用户列表-处理
|
||||
* get-查询用户列表
|
||||
* iuput格式:
|
||||
{
|
||||
"type": 4, //4表示查询用户列表
|
||||
|
@ -285,6 +285,7 @@ static ret_code user_config_get_uuid_proc(uint source,
|
|||
{
|
||||
"retcode": 0,
|
||||
"message": "查询成功",
|
||||
"total":1, //data中查询到的数据个数
|
||||
"data": [{
|
||||
"ID": 2,
|
||||
"GID": 3,
|
||||
|
@ -307,7 +308,7 @@ static ret_code user_config_get_list_proc(uint source,
|
|||
ret_code ret = RET_OK;
|
||||
char * data_list = NULL;
|
||||
char * ret_char = NULL;
|
||||
int group_uuid, temp_output_len;
|
||||
int group_uuid, temp_output_len, total;
|
||||
|
||||
/* 解析json串 */
|
||||
cJSON * root = cJSON_Parse(input);
|
||||
|
@ -351,7 +352,7 @@ static ret_code user_config_get_list_proc(uint source,
|
|||
}
|
||||
|
||||
/* 执行查询函数 */
|
||||
bool ret_get = useraccount_showlist(group_uuid, user_name->valuestring, page_start->valueint, page_counts->valueint, &data_list);
|
||||
bool ret_get = useraccount_showlist(group_uuid, user_name->valuestring, page_start->valueint, page_counts->valueint, &data_list, &total);
|
||||
cJSON_Delete(root);
|
||||
|
||||
cJSON * ret_root = cJSON_CreateObject();
|
||||
|
@ -370,6 +371,7 @@ static ret_code user_config_get_list_proc(uint source,
|
|||
{
|
||||
cJSON_AddNumberToObject(ret_root, "retcode", 1);
|
||||
cJSON_AddStringToObject(ret_root, "message", "查询失败");
|
||||
cJSON_AddNumberToObject(ret_root, "total", 0);
|
||||
cJSON_AddStringToObject(ret_root, "data", "");
|
||||
|
||||
ret_char = cJSON_PrintUnformatted(ret_root);
|
||||
|
@ -404,6 +406,7 @@ static ret_code user_config_get_list_proc(uint source,
|
|||
}
|
||||
|
||||
cJSON_AddItemToObject(ret_root, "data", list_data);
|
||||
cJSON_AddNumberToObject(ret_root, "total", total);
|
||||
cJSON_AddNumberToObject(ret_root, "retcode", 0);
|
||||
cJSON_AddStringToObject(ret_root, "message", "查询成功");
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ void offline_force_by_userid(char *userid);
|
|||
void offline_force_one_user(unsigned short user_id);
|
||||
|
||||
/* 查询用户列表 */
|
||||
bool useraccount_showlist(int group_id, char * user_name, int page_start, int page_counts, char ** user_list);
|
||||
bool useraccount_showlist(int group_id, char * user_name, int page_start, int page_counts, char ** user_list, int * total);
|
||||
|
||||
/* 查询 user_account 内存恢复 */
|
||||
void um_getuser_db(char ** user_db);
|
||||
|
|
|
@ -827,12 +827,12 @@ int usermanager_del_user(int uuid)
|
|||
}
|
||||
|
||||
/* 查询用户列表 */
|
||||
bool useraccount_showlist(int uugroup_id, char * user_name, int page_start, int page_counts, char ** user_list)
|
||||
bool useraccount_showlist(int uugroup_id, char * user_name, int page_start, int page_counts, char ** user_list, int * total)
|
||||
{
|
||||
int num, arrlen, page_s;
|
||||
char * ulist, *point, *select_sql;
|
||||
int num1, num2, arrlen, page_s;
|
||||
char * ulist, *point, *select_sql, * select_total, * ret_total;
|
||||
|
||||
if(NULL == user_list)
|
||||
if(NULL == user_list || NULL == total)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -874,22 +874,32 @@ bool useraccount_showlist(int uugroup_id, char * user_name, int page_start, int
|
|||
select_sql = "SELECT U.uuid ID, G.uuid GID, U.user_name uname, G.gname gname, U.udescription udescription,\
|
||||
U.multi_player multi, U.valid_always valid, U.valid_begin_time, U.valid_end_time \
|
||||
FROM user_account U, user_group G WHERE U.group_id = G.id AND U.user_name LIKE ? LIMIT ?, ?";
|
||||
ulist = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_GROUP_TABLE, select_sql, 1, 0, &num, 3,
|
||||
select_total = "SELECT U.uuid FROM user_account U, user_group G WHERE U.group_id = G.id AND U.user_name LIKE ?";
|
||||
|
||||
ulist = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_TABLE, select_sql, 1, 0, &num1, 3,
|
||||
DB_DATA_STRING_TYPE, arrlen+1, temp_uname,
|
||||
DB_DATA_INT_TYPE, sizeof(page_s_templong), page_s_templong,
|
||||
DB_DATA_INT_TYPE, sizeof(page_counts_templong), page_counts_templong);
|
||||
ret_total = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_TABLE, select_total, 1, 0, &num2, 1,
|
||||
DB_DATA_STRING_TYPE, arrlen+1, temp_uname);
|
||||
}else
|
||||
{
|
||||
select_sql = "SELECT U.uuid ID, G.uuid GID, U.user_name uname, G.gname gname, U.udescription udescription,\
|
||||
U.multi_player multi, U.valid_always valid, U.valid_begin_time, U.valid_end_time \
|
||||
FROM user_account U, user_group G WHERE G.uuid = ? AND U.group_id = G.id AND U.user_name LIKE ? LIMIT ?, ?";
|
||||
ulist = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_GROUP_TABLE, select_sql, 1, 0, &num, 4,
|
||||
select_total = "SELECT U.uuid FROM user_account U, user_group G WHERE G.uuid = ? AND U.group_id = G.id AND U.user_name LIKE ?";
|
||||
|
||||
ulist = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_TABLE, select_sql, 1, 0, &num1, 4,
|
||||
DB_DATA_INT_TYPE, sizeof(uugroup_id_templong), uugroup_id_templong,
|
||||
DB_DATA_STRING_TYPE, arrlen+1, temp_uname,
|
||||
DB_DATA_INT_TYPE, sizeof(page_s_templong), page_s_templong,
|
||||
DB_DATA_INT_TYPE, sizeof(page_counts_templong), page_counts_templong);
|
||||
ret_total = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_TABLE, select_total, 1, 0, &num2, 2,
|
||||
DB_DATA_INT_TYPE, sizeof(uugroup_id_templong), uugroup_id_templong,
|
||||
DB_DATA_STRING_TYPE, arrlen+1, temp_uname);
|
||||
}
|
||||
if (0 == num || NULL == ulist) //查询结果为空
|
||||
|
||||
if (0 == num1 || 0 == num2 || NULL == ulist || NULL == ret_total) //查询结果为空
|
||||
{
|
||||
cJSON * root = cJSON_CreateObject();
|
||||
cJSON * array;
|
||||
|
@ -901,10 +911,12 @@ bool useraccount_showlist(int uugroup_id, char * user_name, int page_start, int
|
|||
cJSON_AddItemToObject(root, "data", array = cJSON_CreateArray());
|
||||
/*{"data":[]}*/
|
||||
*user_list = cJSON_Print(root); //在函数外面释放
|
||||
|
||||
*total = num2;
|
||||
return true;
|
||||
}
|
||||
|
||||
*total = num2;
|
||||
|
||||
point = (char*)malloc(strlen(ulist)+1);
|
||||
if(NULL == point)
|
||||
{
|
||||
|
@ -952,7 +964,7 @@ void um_getuser_db(char ** user_db)
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
char * select_sql = "SELECT id ID, group_id GID, multi_player multi, valid_always valid, user_name uname, udescription, \
|
||||
valid_begin_time,valid_end_time FROM user_account";
|
||||
char * ret_user = select_datebase_by_number(USER_MANAGER_DBID, um_hdbc, USER_TABLE, select_sql, 1, 0, &num, 0);
|
||||
|
|
|
@ -27,7 +27,7 @@ void test(int a, int b, int c, int d)
|
|||
return;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
int main6(void)
|
||||
{
|
||||
char * testin; //input
|
||||
char testout[2000]; //output
|
||||
|
@ -79,7 +79,7 @@ int main(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int main5(void)
|
||||
int main(void)
|
||||
{
|
||||
char * testrec;
|
||||
int testnum;
|
||||
|
@ -96,16 +96,15 @@ int main5(void)
|
|||
ret_pro = usergroup_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
||||
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
test(1,2,3,4);
|
||||
printf("\n************************************查询 user list*******************************************\n");
|
||||
testin = "{\"type\": 4,\"data\":{\"group_id\": 0, \"user_name\": \"3\",\"page_start\": 1,\"page_counts\": 20}}";
|
||||
testin = "{\"type\": 4,\"data\":{\"group_id\": 1014, \"user_name\": \"0\",\"page_start\": 1,\"page_counts\": 5}}";
|
||||
ret_pro = user_config_get(1, testin, strlen(testin)+1, testout, &outlen);
|
||||
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
printf("************************************新增 group*******************************************\n");
|
||||
testin = "{\"type\": 0,\"data\": {\"gname\": \"group011\",\"gdescription\": \"描述group011\"}}";
|
||||
ret_pro = usergroup_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
||||
|
|
Loading…
Reference in New Issue