Mod aaa-12 修改用户/用户组删除逻辑,并发布相应的删除消息
RCA: SOL: 修改人:zhouzian 检视人:zhouzian
This commit is contained in:
parent
4d828bef69
commit
88c837ba68
4
Makefile
4
Makefile
|
@ -28,9 +28,9 @@ MAKE_FLAGS += -j$(shell cat /proc/cpuinfo | grep processor | wc -l)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY : demo conntrack netlink trace openrpc usermanager configm redismq ulog database
|
.PHONY : demo conntrack netlink trace openrpc redismq usermanager configm ulog database
|
||||||
|
|
||||||
all: demo conntrack netlink trace openrpc usermanager configm redismq ulog database
|
all: demo conntrack netlink trace openrpc redismq usermanager configm ulog database
|
||||||
|
|
||||||
ifeq ($(OPT), install)
|
ifeq ($(OPT), install)
|
||||||
#$(shell `find ../release -name "*.zip" -delete`)
|
#$(shell `find ../release -name "*.zip" -delete`)
|
||||||
|
|
|
@ -34,26 +34,29 @@ COMMON_SRCS = configserver.c ipconfig/ipconfig.c ipconfig/parsefile.c \
|
||||||
PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
||||||
PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
||||||
|
|
||||||
|
COMMOM_CFLAGS = -I../user/configm/config-server/include -I../../Common -I../common/redismq -I../common/configm -I../common/rpc -I../common/rpc/hashtable
|
||||||
# gcc CFLAGS
|
# gcc CFLAGS
|
||||||
PLAT_ARM64_CFLAGS := -I../user/configm/config-server/include -I../../Common -I../common/configm -I../common/rpc -I../common/rpc/hashtable
|
PLAT_ARM64_CFLAGS := $(COMMOM_CFLAGS) -I../thirdparty/arm64/usr/local/include
|
||||||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
PLAT_LINUX_CFLAGS := $(COMMOM_CFLAGS) -I../thirdparty/x86_64/usr/local/include
|
||||||
|
|
||||||
|
|
||||||
PLAT_ARM64_LDFLAGS :=
|
PLAT_ARM64_LDFLAGS :=
|
||||||
PLAT_LINUX_LDFLAGS :=
|
PLAT_LINUX_LDFLAGS :=
|
||||||
|
|
||||||
#gcc libs
|
#gcc libs
|
||||||
ARM64_LIBS := -lcjson ../thirdparty/arm64/libev-arm64.so ./libopenrpc-arm64.so ./libnetlinku-arm64.so -lpthread -lm
|
ARM64_LIBS := ../thirdparty/arm64/libev-arm64.so ./libopenrpc-arm64.so ./libnetlinku-arm64.so ./libredismq-arm64.so
|
||||||
LINUX_LIBS := -lcjson ../thirdparty/x86_64/libev-linux.so ./libopenrpc-linux.so ./libnetlinku-linux.so -lpthread -lm
|
ARM64_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis
|
||||||
|
|
||||||
|
LINUX_LIBS := ../thirdparty/x86_64/libev-linux.so ./libopenrpc-linux.so ./libnetlinku-linux.so ./libredismq-linux.so
|
||||||
|
LINUX_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis
|
||||||
|
|
||||||
ifeq ($(PLAT_ARM64), TRUE)
|
ifeq ($(PLAT_ARM64), TRUE)
|
||||||
DEPEND_LIB += ../thirdparty/arm64/libev-arm64.so ./debug/libopenrpc-arm64.so ./debug/libnetlinku-arm64.so
|
DEPEND_LIB += ../thirdparty/arm64/libev-arm64.so ./debug/libopenrpc-arm64.so ./debug/libnetlinku-arm64.so ./debug/libredismq-arm64.so
|
||||||
USER_CLEAN_ITEMS += ./libopenrpc-arm64.so ./libnetlinku-arm64.so
|
USER_CLEAN_ITEMS += ./libopenrpc-arm64.so ./libnetlinku-arm64.so ./libredismq-arm64.so
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(PLAT_LINUX), TRUE)
|
ifeq ($(PLAT_LINUX), TRUE)
|
||||||
DEPEND_LIB += ../thirdparty/x86_64/libev-linux.so ./debug/libopenrpc-linux.so ./libnetlinku-linux.so
|
DEPEND_LIB += ../thirdparty/x86_64/libev-linux.so ./debug/libopenrpc-linux.so ./libnetlinku-linux.so ./debug/libredismq-linux.so
|
||||||
USER_CLEAN_ITEMS += ./libopenrpc-linux.so ./libnetlinku-linux.so
|
USER_CLEAN_ITEMS += ./libopenrpc-linux.so ./libnetlinku-linux.so ./libredismq-linux.so
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,16 +43,16 @@ PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
#gcc libs
|
#gcc libs
|
||||||
ARM64_LIBS := ../thirdparty/arm64/usr/local/lib/libhiredis.so ../thirdparty/arm64/usr/local/lib/libjemalloc.so ../thirdparty/arm64/usr/local/lib/libjson-c.so ../thirdparty/arm64/usr/local/lib/libevent.so
|
ARM64_LIBS := -lhiredis -ljson-c -levent
|
||||||
LINUX_LIBS := ../thirdparty/x86_64/usr/local/lib/libhiredis.so ../thirdparty/x86_64/usr/local/lib/libjemalloc.so ../thirdparty/x86_64/usr/local/lib/libjson-c.so ../thirdparty/x86_64/usr/local/lib/libevent.so
|
LINUX_LIBS := -lhiredis -ljson-c -levent
|
||||||
|
|
||||||
ifeq ($(PLAT_ARM64), TRUE)
|
ifeq ($(PLAT_ARM64), TRUE)
|
||||||
DEPEND_LIB += ../thirdparty/arm64/usr/local/lib/libhiredis.so ../thirdparty/arm64/usr/local/lib/libjemalloc.so ../thirdparty/arm64/usr/local/lib/libjson-c.so ../thirdparty/arm64/usr/local/lib/libevent.so
|
DEPEND_LIB += ../thirdparty/arm64/usr/local/lib/libjemalloc.so
|
||||||
USER_CLEAN_ITEMS +=
|
USER_CLEAN_ITEMS +=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(PLAT_LINUX), TRUE)
|
ifeq ($(PLAT_LINUX), TRUE)
|
||||||
DEPEND_LIB += ../thirdparty/x86_64/usr/local/lib/libhiredis.so ../thirdparty/x86_64/usr/local/lib/libjemalloc.so ../thirdparty/x86_64/usr/local/lib/libjson-c.so ../thirdparty/x86_64/usr/local/lib/libevent.so
|
DEPEND_LIB += ../thirdparty/x86_64/usr/local/lib/libjemalloc.so
|
||||||
USER_CLEAN_ITEMS +=
|
USER_CLEAN_ITEMS +=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,9 @@
|
||||||
#include "usermanager-server/include/common_user.h"
|
#include "usermanager-server/include/common_user.h"
|
||||||
#include "usermanager-server/include/user.h"
|
#include "usermanager-server/include/user.h"
|
||||||
#include "usermanager-server/include/user_mod.h"
|
#include "usermanager-server/include/user_mod.h"
|
||||||
|
#include "usermanager-server/include/array_index.h"
|
||||||
#include "s2j/s2j.h"
|
#include "s2j/s2j.h"
|
||||||
|
#include "s2j/s2jdef.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,12 +128,12 @@ static ret_code user_config_del_proc(uint source, uint config_type,
|
||||||
{
|
{
|
||||||
ret_code ret = RET_OK;
|
ret_code ret = RET_OK;
|
||||||
int array_size;
|
int array_size;
|
||||||
cJSON *root, *data, *username_json, *ret_json, *ret_body_json;
|
cJSON *root, *data, *username_json, *ret_json, *ret_body_json, *user_id_del_success_json;
|
||||||
USER_DEL *username;
|
USER_DEL *username;
|
||||||
char *ret_char = NULL;
|
char *ret_char = NULL;
|
||||||
|
|
||||||
/* 解析json串 */
|
/* 解析json串 */
|
||||||
root = cJSON_Parse(input);
|
root = cJSON_Parse(input); //需要释放
|
||||||
data = cJSON_GetObjectItem(root, "data");
|
data = cJSON_GetObjectItem(root, "data");
|
||||||
if(!data)
|
if(!data)
|
||||||
{
|
{
|
||||||
|
@ -142,8 +144,9 @@ static ret_code user_config_del_proc(uint source, uint config_type,
|
||||||
}
|
}
|
||||||
|
|
||||||
array_size = cJSON_GetArraySize(data);
|
array_size = cJSON_GetArraySize(data);
|
||||||
|
//unsigned short user_id_del_success[array_size]; //存储删除成功的用户id
|
||||||
|
|
||||||
username = (USER_DEL *)malloc(sizeof(USER_DEL));
|
username = (USER_DEL *)malloc(sizeof(USER_DEL)); //需要释放
|
||||||
if(NULL == username)
|
if(NULL == username)
|
||||||
{
|
{
|
||||||
ret = RET_INPUTERR;
|
ret = RET_INPUTERR;
|
||||||
|
@ -152,14 +155,18 @@ static ret_code user_config_del_proc(uint source, uint config_type,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret_json = cJSON_CreateArray();
|
ret_json = cJSON_CreateArray(); //需要释放
|
||||||
if(!ret_json)
|
if(!ret_json)
|
||||||
{
|
{
|
||||||
ret = RET_ERR;
|
ret = RET_ERR;
|
||||||
|
cJSON_Delete(root);
|
||||||
|
UCHAR_FREE(username);
|
||||||
//ASSERT_RET(ret);
|
//ASSERT_RET(ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//memset(user_id_del_success, 0, sizeof(user_id_del_success));
|
||||||
|
user_id_del_success_json = cJSON_CreateArray();
|
||||||
|
|
||||||
for(int i = 0; i < array_size; i++)
|
for(int i = 0; i < array_size; i++)
|
||||||
{
|
{
|
||||||
|
@ -171,25 +178,36 @@ static ret_code user_config_del_proc(uint source, uint config_type,
|
||||||
username->type = DELUSER_BY_USERNAME;
|
username->type = DELUSER_BY_USERNAME;
|
||||||
strcpy(username->id_name.uname, ret_username);
|
strcpy(username->id_name.uname, ret_username);
|
||||||
ret_del_user = usermanager_del_user(username); //执行操作-删除用户
|
ret_del_user = usermanager_del_user(username); //执行操作-删除用户
|
||||||
|
|
||||||
ret_body_json = cJSON_CreateObject();
|
ret_body_json = cJSON_CreateObject();
|
||||||
// if(!ret_result_json)
|
// if(!ret_result_json)
|
||||||
// {
|
/* 返回结果封json */
|
||||||
// ret = RET_ERR;
|
cJSON_AddNumberToObject(ret_body_json, ret_username, ret_del_user); //ret_body_json {"用户01": 0}
|
||||||
// return ret;
|
|
||||||
// }
|
|
||||||
cJSON_AddNumberToObject(ret_body_json, ret_username, ret_del_user);
|
|
||||||
cJSON_AddItemToArray(ret_json, ret_body_json);
|
cJSON_AddItemToArray(ret_json, ret_body_json);
|
||||||
}
|
|
||||||
|
|
||||||
|
//保存删除成功的用户id
|
||||||
|
if(DELUSER_SUCCESS == ret_del_user)
|
||||||
|
{
|
||||||
|
cJSON_AddItemToArray(user_id_del_success_json, cJSON_CreateNumber(username->id_name.id));
|
||||||
|
// user_id_del_success[i] = username->id_name.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* 处理返回结果 */
|
/* 处理返回结果 */
|
||||||
ret_char = cJSON_PrintUnformatted(ret_json);
|
ret_char = cJSON_PrintUnformatted(ret_json);
|
||||||
memcpy(output, ret_char, strlen(ret_char)+1);
|
memcpy(output, ret_char, strlen(ret_char)+1);
|
||||||
|
|
||||||
|
/* 强制下线删除成功的用户 */
|
||||||
|
// for(int j = 0; j < GROUP_INDEX_MAX; j++)
|
||||||
|
// {
|
||||||
|
// cJSON_AddItemToArray(user_id_del_success_json, cJSON_CreateNumber(user_id_del_success[j]));
|
||||||
|
// }
|
||||||
|
printf("需要下线的用户id:%s \n", cJSON_PrintUnformatted(user_id_del_success_json));
|
||||||
|
offline_force_by_userid(cJSON_PrintUnformatted(user_id_del_success_json));
|
||||||
|
|
||||||
/* 释放内存 */
|
/* 释放内存 */
|
||||||
cJSON_Delete(root);
|
cJSON_Delete(root);
|
||||||
cJSON_Delete(ret_json);
|
cJSON_Delete(ret_json);
|
||||||
|
cJSON_Delete(user_id_del_success_json);
|
||||||
UCHAR_FREE(ret_char);
|
UCHAR_FREE(ret_char);
|
||||||
UCHAR_FREE(username);
|
UCHAR_FREE(username);
|
||||||
|
|
||||||
|
@ -244,14 +262,14 @@ static ret_code user_config_mod_web_proc(uint source, uint config_type,
|
||||||
s2j_create_struct_obj(input_data, USERLIST);
|
s2j_create_struct_obj(input_data, USERLIST);
|
||||||
s2j_struct_get_basic_element(input_data, data, int, ID);
|
s2j_struct_get_basic_element(input_data, data, int, ID);
|
||||||
s2j_struct_get_basic_element(input_data, data, int, GID);
|
s2j_struct_get_basic_element(input_data, data, int, GID);
|
||||||
s2j_struct_get_basic_element(input_data, data, string, uname);
|
S2J_STRUCT_GET_STRING_ELEMENT_N(input_data, data, uname,UNAMESIZE);
|
||||||
s2j_struct_get_basic_element(input_data, data, string, gname);
|
S2J_STRUCT_GET_STRING_ELEMENT_N(input_data, data, gname, GNAMESIZE);
|
||||||
s2j_struct_get_basic_element(input_data, data, string, passwd);
|
S2J_STRUCT_GET_STRING_ELEMENT_N(input_data, data, passwd, UPWDSIZE);
|
||||||
s2j_struct_get_basic_element(input_data, data, string, udescription);
|
S2J_STRUCT_GET_STRING_ELEMENT_N(input_data, data, udescription, UDESIZE);
|
||||||
s2j_struct_get_basic_element(input_data, data, int, multi);
|
s2j_struct_get_basic_element(input_data, data, int, multi);
|
||||||
s2j_struct_get_basic_element(input_data, data, int, valid);
|
s2j_struct_get_basic_element(input_data, data, int, valid);
|
||||||
s2j_struct_get_basic_element(input_data, data, string, valid_begin_time);
|
S2J_STRUCT_GET_STRING_ELEMENT_N(input_data, data, valid_begin_time, UTIME);
|
||||||
s2j_struct_get_basic_element(input_data, data, string, valid_end_time);
|
S2J_STRUCT_GET_STRING_ELEMENT_N(input_data, data, valid_end_time, UTIME);
|
||||||
|
|
||||||
/* 执行操作 */
|
/* 执行操作 */
|
||||||
ret_mod_web = mod_user_web(input_data);
|
ret_mod_web = mod_user_web(input_data);
|
||||||
|
@ -271,7 +289,7 @@ static ret_code user_config_mod_web_proc(uint source, uint config_type,
|
||||||
/* 释放内存 */
|
/* 释放内存 */
|
||||||
cJSON_Delete(root);
|
cJSON_Delete(root);
|
||||||
cJSON_Delete(ret_json);
|
cJSON_Delete(ret_json);
|
||||||
UCHAR_FREE(input_data);
|
s2j_delete_struct_obj(input_data);
|
||||||
UCHAR_FREE(ret_char);
|
UCHAR_FREE(ret_char);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -361,7 +379,6 @@ static ret_code user_config_mod_line_proc(uint source, uint config_type,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 修改用户-移动分组
|
* 修改用户-移动分组
|
||||||
* iuput格式:
|
* iuput格式:
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "user_group_config.h"
|
#include "user_group_config.h"
|
||||||
#include "usermanager-server/include/user_group.h"
|
#include "usermanager-server/include/user_group.h"
|
||||||
#include "usermanager-server/include/common_user.h"
|
#include "usermanager-server/include/common_user.h"
|
||||||
|
#include "usermanager-server/include/array_index.h"
|
||||||
#include "rpc.h"
|
#include "rpc.h"
|
||||||
#include "parsefile.h"
|
#include "parsefile.h"
|
||||||
|
|
||||||
|
@ -107,8 +108,11 @@ static ret_code usergroup_config_del_proc(uint source, uint config_type,
|
||||||
{
|
{
|
||||||
ret_code ret = RET_OK;
|
ret_code ret = RET_OK;
|
||||||
int array_size;
|
int array_size;
|
||||||
cJSON *root, *data, *ret_json, *ret_body_json;
|
GROUP_DEL *groupname;
|
||||||
|
cJSON *root, *data, *ret_json, *ret_body_json, *group_id_del_success_json;
|
||||||
char *ret_char = NULL;
|
char *ret_char = NULL;
|
||||||
|
//unsigned short *group_id_del_success; //存储删除成功的用户组id
|
||||||
|
unsigned short group_id_del_success[GROUP_INDEX_MAX];
|
||||||
|
|
||||||
/* 解析json串 */
|
/* 解析json串 */
|
||||||
root = cJSON_Parse(input);
|
root = cJSON_Parse(input);
|
||||||
|
@ -123,30 +127,52 @@ static ret_code usergroup_config_del_proc(uint source, uint config_type,
|
||||||
|
|
||||||
array_size = cJSON_GetArraySize(data);
|
array_size = cJSON_GetArraySize(data);
|
||||||
|
|
||||||
|
groupname = (GROUP_DEL *)malloc(sizeof(GROUP_DEL));
|
||||||
|
if(NULL == groupname)
|
||||||
|
{
|
||||||
|
ret = RET_ERR;
|
||||||
|
//ASSERT_RET(ret);
|
||||||
|
cJSON_Delete(root);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ret_json = cJSON_CreateArray();
|
ret_json = cJSON_CreateArray();
|
||||||
if(!ret_json)
|
if(!ret_json)
|
||||||
{
|
{
|
||||||
ret = RET_ERR;
|
ret = RET_ERR;
|
||||||
//ASSERT_RET(ret);
|
//ASSERT_RET(ret);
|
||||||
|
cJSON_Delete(root);
|
||||||
|
UCHAR_FREE(groupname);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(group_id_del_success, 0, sizeof(group_id_del_success));
|
||||||
for(int i = 0; i < array_size; i++)
|
for(int i = 0; i < array_size; i++)
|
||||||
{
|
{
|
||||||
int ret_del_group;
|
int ret_del_group;
|
||||||
char *ret_groupname = NULL;
|
char *ret_groupname = NULL;
|
||||||
ret_groupname = cJSON_GetArrayItem(data, i)->valuestring;
|
ret_groupname = cJSON_GetArrayItem(data, i)->valuestring;
|
||||||
ret_del_group = del_group_by_name(ret_groupname); //执行操作-删除用户组
|
groupname->type = DELGROUP_BY_GROUPNAME;
|
||||||
|
strcpy(groupname->id_name.gname, ret_groupname);
|
||||||
|
ret_del_group = del_group_by_name(groupname); //执行操作-删除用户组
|
||||||
ret_body_json = cJSON_CreateObject();
|
ret_body_json = cJSON_CreateObject();
|
||||||
// if(!ret_result_json)
|
// if(!ret_result_json)
|
||||||
// {
|
|
||||||
// ret = RET_ERR;
|
|
||||||
// return ret;
|
|
||||||
// }
|
|
||||||
cJSON_AddNumberToObject(ret_body_json, ret_groupname, ret_del_group);
|
cJSON_AddNumberToObject(ret_body_json, ret_groupname, ret_del_group);
|
||||||
cJSON_AddItemToArray(ret_json, ret_body_json);
|
cJSON_AddItemToArray(ret_json, ret_body_json);
|
||||||
|
if(DELGROUP_SUCCESS == ret_del_group)
|
||||||
|
{
|
||||||
|
group_id_del_success[groupname->id_name.id] = groupname->id_name.id;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 强制下线删除成功的用户组 */
|
||||||
|
group_id_del_success_json = cJSON_CreateArray();
|
||||||
|
for(int j = 0; j < GROUP_INDEX_MAX; j++)
|
||||||
|
{
|
||||||
|
cJSON_AddItemToArray(group_id_del_success_json, cJSON_CreateNumber(group_id_del_success[j]));
|
||||||
|
}
|
||||||
|
printf("需要下线的用户组id:%s \n", cJSON_PrintUnformatted(group_id_del_success_json));
|
||||||
|
offline_force_by_groupid(cJSON_PrintUnformatted(group_id_del_success_json));
|
||||||
|
|
||||||
/* 处理返回结果 */
|
/* 处理返回结果 */
|
||||||
ret_char = cJSON_PrintUnformatted(ret_json);
|
ret_char = cJSON_PrintUnformatted(ret_json);
|
||||||
|
@ -155,7 +181,9 @@ static ret_code usergroup_config_del_proc(uint source, uint config_type,
|
||||||
/* 释放内存 */
|
/* 释放内存 */
|
||||||
cJSON_Delete(root);
|
cJSON_Delete(root);
|
||||||
cJSON_Delete(ret_json);
|
cJSON_Delete(ret_json);
|
||||||
|
cJSON_Delete(group_id_del_success_json);
|
||||||
UCHAR_FREE(ret_char);
|
UCHAR_FREE(ret_char);
|
||||||
|
UCHAR_FREE(groupname);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -220,5 +248,6 @@ ret_code usergroup_config_get_all(uint source,
|
||||||
pointer output, int *output_len)
|
pointer output, int *output_len)
|
||||||
{
|
{
|
||||||
ret_code ret = RET_OK;
|
ret_code ret = RET_OK;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
|
@ -96,4 +96,7 @@ bool move_user_group(unsigned short user_id, unsigned short group_id);
|
||||||
*/
|
*/
|
||||||
int usermanager_del_user(USER_DEL* id_name);
|
int usermanager_del_user(USER_DEL* id_name);
|
||||||
|
|
||||||
|
/* 强制下线用户 */
|
||||||
|
void offline_force_by_userid(char *userid);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -16,6 +16,9 @@
|
||||||
#define DELGROUP_FAIL_NOTEXIST 1
|
#define DELGROUP_FAIL_NOTEXIST 1
|
||||||
#define DELGROUP_FAIL_STRTEGY 2
|
#define DELGROUP_FAIL_STRTEGY 2
|
||||||
|
|
||||||
|
#define DELGROUP_BY_GROUPNAME 1
|
||||||
|
#define DELGROUP_BY_GROUPID 2
|
||||||
|
|
||||||
typedef struct usergroup
|
typedef struct usergroup
|
||||||
{
|
{
|
||||||
unsigned short ID;
|
unsigned short ID;
|
||||||
|
@ -23,6 +26,18 @@ typedef struct usergroup
|
||||||
char gdescription[GDESIZE];
|
char gdescription[GDESIZE];
|
||||||
}USERGROUP;
|
}USERGROUP;
|
||||||
|
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
unsigned short id;
|
||||||
|
char gname[GNAMESIZE];
|
||||||
|
}GROUP_ID_NAME;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int type;
|
||||||
|
GROUP_ID_NAME id_name;
|
||||||
|
}GROUP_DEL;
|
||||||
|
|
||||||
/* 初始化参数 */
|
/* 初始化参数 */
|
||||||
int init_group();
|
int init_group();
|
||||||
|
|
||||||
|
@ -42,7 +57,10 @@ bool find_group_by_name(char* UGNAME, USERGROUP* UGRES);
|
||||||
unsigned short get_groupid_by_name(char* UGNAME);
|
unsigned short get_groupid_by_name(char* UGNAME);
|
||||||
|
|
||||||
/* 根据用户组名删除用户组 */
|
/* 根据用户组名删除用户组 */
|
||||||
unsigned short del_group_by_name(char* UGNAME);
|
unsigned short del_group_by_name(GROUP_DEL* UGNAME);
|
||||||
|
|
||||||
|
/* 强制下线用户-按用户组ID */
|
||||||
|
void offline_force_by_groupid(char *groupid);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
#include "./include/user_mod.h"
|
#include "./include/user_mod.h"
|
||||||
#include "./include/user_group.h"
|
#include "./include/user_group.h"
|
||||||
#include "./include/user.h"
|
#include "./include/user.h"
|
||||||
|
#include "redisMq.h"
|
||||||
|
|
||||||
|
#define OFFLINE_USER_BY_UID "offuser_by_userid_channel"
|
||||||
|
|
||||||
extern ARRAY g_user_index_head;
|
extern ARRAY g_user_index_head;
|
||||||
extern USERGROUP g_group_table[];
|
extern USERGROUP g_group_table[];
|
||||||
|
@ -290,6 +293,33 @@ bool move_user_group(unsigned short user_id, unsigned short group_id)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 强制下线用户 */
|
||||||
|
void offline_force_by_userid(char *userid)
|
||||||
|
{
|
||||||
|
bool ret = redisPubInit();
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
printf("Init failed.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = redisPubConnect();
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
printf("connect failed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
redisPublish(OFFLINE_USER_BY_UID, userid);
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
redisPubDisconnect();
|
||||||
|
redisPubUninit();
|
||||||
|
}
|
||||||
|
|
||||||
/* 删除用户 */
|
/* 删除用户 */
|
||||||
int usermanager_del_user(USER_DEL* in)
|
int usermanager_del_user(USER_DEL* in)
|
||||||
{
|
{
|
||||||
|
@ -299,46 +329,42 @@ int usermanager_del_user(USER_DEL* in)
|
||||||
return DELUSER_FAIL_NOTEXIST;
|
return DELUSER_FAIL_NOTEXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 调用策略提供的接口,查询是否绑定策略,如果绑定了策略,返回删除失败-2:DELUSER_FAIL_STRTEGY*/
|
||||||
|
|
||||||
switch (in->type)
|
switch (in->type)
|
||||||
{
|
{
|
||||||
case DELUSER_BY_USERNAME:
|
case DELUSER_BY_USERNAME: //根据用户名删除数据
|
||||||
if(NULL == in->id_name.uname)
|
if(NULL == in->id_name.uname)
|
||||||
{
|
{
|
||||||
return DELUSER_FAIL_NOTEXIST;
|
return DELUSER_FAIL_NOTEXIST;
|
||||||
}
|
}
|
||||||
/* 根据用户名查询用户id */
|
|
||||||
user_id_temp = get_userid_by_name(in->id_name.uname);
|
user_id_temp = get_userid_by_name(in->id_name.uname);
|
||||||
if (INVALID_INDEX == user_id_temp)
|
if (INVALID_INDEX == user_id_temp)
|
||||||
{
|
{
|
||||||
return DELUSER_FAIL_NOTEXIST;
|
return DELUSER_FAIL_NOTEXIST;
|
||||||
}
|
}
|
||||||
|
in->id_name.id = user_id_temp;
|
||||||
break;
|
break;
|
||||||
|
case DELUSER_BY_USERID: //根据用户id删除数据
|
||||||
case DELUSER_BY_USERID:
|
|
||||||
user_id_temp = in->id_name.id;
|
user_id_temp = in->id_name.id;
|
||||||
if(user_id_temp < 1 || user_id_temp >= (USER_INDEX_MAX-1))
|
if(user_id_temp < 1 || user_id_temp >= (USER_INDEX_MAX-1))
|
||||||
{
|
{
|
||||||
return DELUSER_FAIL_NOTEXIST;
|
return DELUSER_FAIL_NOTEXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_user_table[user_id_temp].ID = 0;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return DELUSER_FAIL_NOTEXIST;
|
return DELUSER_FAIL_NOTEXIST;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 调用策略提供的接口,查询是否绑定策略,如果绑定了策略,返回删除失败-2:DELUSER_FAIL_STRTEGY*/
|
|
||||||
|
|
||||||
/* 根据用户ID删除用户列表中对应的用户 - 释放index、ID置0 */
|
/* 根据用户ID删除用户列表中对应的用户 - 释放index、ID置0 */
|
||||||
free_index(&g_user_index_head, user_id_temp);
|
free_index(&g_user_index_head, user_id_temp);
|
||||||
g_user_table[user_id_temp].ID = INVALID_INDEX;
|
g_user_table[user_id_temp].ID = INVALID_INDEX;
|
||||||
|
|
||||||
/* DELETE FROM user WHERE user_name = "" */
|
/* DELETE FROM user WHERE user_name = "" */
|
||||||
|
|
||||||
/* 强制用户下线
|
/* 强制用户下线,异步的将需要下线的用户id发送到消息队列 */
|
||||||
* 新起一个线程(理论上最多会起100个线程),异步的将需要下线的用户id发送到消息队列
|
//offline_user_force(user_id_temp);
|
||||||
*/
|
|
||||||
|
|
||||||
return DELUSER_SUCCESS;
|
return DELUSER_SUCCESS;
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
#include "./include/user_group.h"
|
#include "./include/user_group.h"
|
||||||
#include "./include/common_user.h"
|
#include "./include/common_user.h"
|
||||||
#include "./include/user.h"
|
#include "./include/user.h"
|
||||||
|
#include "redisMq.h"
|
||||||
|
|
||||||
|
#define OFFLINE_USER_BY_GID "offuser_by_groupid_channel"
|
||||||
|
|
||||||
extern ARRAY g_group_index_head;
|
extern ARRAY g_group_index_head;
|
||||||
extern ARRAY g_user_index_head;
|
extern ARRAY g_user_index_head;
|
||||||
|
@ -163,25 +166,71 @@ unsigned short get_groupid_by_name(char* gname)
|
||||||
return GID_temp;
|
return GID_temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*删除元素*/
|
/* 强制下线用户-按用户组id */
|
||||||
unsigned short del_group_by_name(char* gname)
|
void offline_force_by_groupid(char *groupid)
|
||||||
{
|
{
|
||||||
if (NULL == gname)
|
bool ret = redisPubInit();
|
||||||
|
if (!ret)
|
||||||
{
|
{
|
||||||
return DELGROUP_FAIL_NOTEXIST;
|
printf("Init failed.\n");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 判断被删除的用户组是否存在 */
|
ret = redisPubConnect();
|
||||||
unsigned short GID_temp = get_groupid_by_name(gname);
|
if (!ret)
|
||||||
|
{
|
||||||
|
printf("connect failed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (INVALID_INDEX == GID_temp)
|
while (true)
|
||||||
|
{
|
||||||
|
redisPublish(OFFLINE_USER_BY_GID, groupid);
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
redisPubDisconnect();
|
||||||
|
redisPubUninit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*删除元素*/
|
||||||
|
unsigned short del_group_by_name(GROUP_DEL* gname)
|
||||||
|
{
|
||||||
|
unsigned short GID_temp = 0;
|
||||||
|
if (NULL == gname)
|
||||||
{
|
{
|
||||||
return DELGROUP_FAIL_NOTEXIST;
|
return DELGROUP_FAIL_NOTEXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 调用策略提供的接口,查询是否绑定策略,如果绑定了策略,返回删除失败-2:DELGROUP_FAIL_STRTEGY */
|
/* 调用策略提供的接口,查询是否绑定策略,如果绑定了策略,返回删除失败-2:DELGROUP_FAIL_STRTEGY */
|
||||||
|
|
||||||
/* 根据用户组ID查询用户ID,按照用户ID删除用户 */
|
switch(gname->type)
|
||||||
|
{
|
||||||
|
case DELGROUP_BY_GROUPNAME: //根据用户组名删除数据
|
||||||
|
if(NULL == gname->id_name.gname)
|
||||||
|
{
|
||||||
|
return DELGROUP_FAIL_NOTEXIST;
|
||||||
|
}
|
||||||
|
GID_temp = get_groupid_by_name(gname->id_name.gname);
|
||||||
|
if (INVALID_INDEX == GID_temp)
|
||||||
|
{
|
||||||
|
return DELGROUP_FAIL_NOTEXIST;
|
||||||
|
}
|
||||||
|
gname->id_name.id = GID_temp;
|
||||||
|
break;
|
||||||
|
case DELGROUP_BY_GROUPID: //根据用户组id删除数据
|
||||||
|
GID_temp = gname->id_name.id;
|
||||||
|
if(GID_temp < 1 || GID_temp >= (GROUP_INDEX_MAX - 1))
|
||||||
|
{
|
||||||
|
return DELGROUP_FAIL_NOTEXIST;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return DELGROUP_FAIL_NOTEXIST;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 根据用户组ID查询用户ID,按照用户ID删除用户 - 释放index、ID置0 */
|
||||||
for(int i = 1; i < USER_INDEX_MAX-1; i++)
|
for(int i = 1; i < USER_INDEX_MAX-1; i++)
|
||||||
{
|
{
|
||||||
if(g_user_table[i].GID == GID_temp)
|
if(g_user_table[i].GID == GID_temp)
|
||||||
|
@ -190,16 +239,12 @@ unsigned short del_group_by_name(char* gname)
|
||||||
g_user_table[i].ID = INVALID_INDEX;
|
g_user_table[i].ID = INVALID_INDEX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 连接数据库,根据用户组ID删除用户表中对应数据:DELETE FROM user WHERE group_id = */
|
/* 连接数据库,根据用户组ID删除用户表中对应数据:DELETE FROM user WHERE group_id = */
|
||||||
|
|
||||||
/* 根据用户组ID删除用户组列表中对应的用户组 - 释放index、ID置0 */
|
/* 根据用户组ID删除用户组列表中对应的用户组 - 释放index、ID置0 */
|
||||||
free_index(&g_group_index_head, GID_temp);
|
free_index(&g_group_index_head, GID_temp);
|
||||||
g_group_table[GID_temp].ID = INVALID_INDEX;
|
g_group_table[GID_temp].ID = INVALID_INDEX;
|
||||||
|
|
||||||
/* DELETE FROM user_group WHERE gname = "" */
|
/* DELETE FROM user_group WHERE gname = "" */
|
||||||
|
|
||||||
/* 强制用户下线 */
|
|
||||||
|
|
||||||
return DELGROUP_SUCCESS;
|
return DELGROUP_SUCCESS;
|
||||||
}
|
}
|
|
@ -19,7 +19,7 @@ TARGET_BOX =
|
||||||
DEBUG = TRUE
|
DEBUG = TRUE
|
||||||
|
|
||||||
PLAT_LINUX ?= TRUE
|
PLAT_LINUX ?= TRUE
|
||||||
PLAT_ARM64 ?= FALSE
|
PLAT_ARM64 ?= TRUE
|
||||||
|
|
||||||
VPATH = ../user/user_manager/ ../../Platform/user/configm/config-server/user_manager_config/
|
VPATH = ../user/user_manager/ ../../Platform/user/configm/config-server/user_manager_config/
|
||||||
|
|
||||||
|
@ -36,26 +36,38 @@ PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
||||||
|
|
||||||
# gcc CFLAGS
|
# gcc CFLAGS
|
||||||
PLAT_ARM64_CFLAGS := -I../../Platform/user/configm/config-server/user_manager_config -I../../Platform/user/configm/config-server/user_manager_config/usermanager-server/include -I../../Common -I../common \
|
PLAT_ARM64_CFLAGS := -I../../Platform/user/configm/config-server/user_manager_config -I../../Platform/user/configm/config-server/user_manager_config/usermanager-server/include -I../../Common -I../common \
|
||||||
-I../../Platform/user/configm/config-server/include -I../../Platform/common/configm -I../../Platform/common/rpc -I../../Platform/common/rpc/hashtable \
|
-I../../Platform/user/configm/config-server/include -I../../Platform/common/redismq -I../../Platform/common/configm -I../../Platform/common/rpc -I../../Platform/common/rpc/hashtable \
|
||||||
-I../user/user_manager/usermanager-auth
|
-I../user/user_manager/usermanager-auth \
|
||||||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
-I../../Platform/thirdparty/arm64/usr/local/include
|
||||||
|
|
||||||
|
PLAT_LINUX_CFLAGS := -I../../Platform/user/configm/config-server/user_manager_config -I../../Platform/user/configm/config-server/user_manager_config/usermanager-server/include -I../../Common -I../common \
|
||||||
|
-I../../Platform/user/configm/config-server/include -I../../Platform/common/redismq -I../../Platform/common/configm -I../../Platform/common/rpc -I../../Platform/common/rpc/hashtable \
|
||||||
|
-I../user/user_manager/usermanager-auth \
|
||||||
|
-I../../Platform/thirdparty/x86_64/usr/local/include
|
||||||
|
|
||||||
|
|
||||||
PLAT_ARM64_LDFLAGS :=
|
PLAT_ARM64_LDFLAGS :=
|
||||||
PLAT_LINUX_LDFLAGS :=
|
PLAT_LINUX_LDFLAGS :=
|
||||||
|
|
||||||
|
THIRDLIB_LINUX_DIR := ../../Platform/thirdparty/x86_64/usr/local/lib
|
||||||
|
THIRDLIB_ARM64_DIR := ../../Platform/thirdparty/arm64/usr/local/lib
|
||||||
|
PLATLIB_DIR := ../../Platform/build/debug
|
||||||
#gcc libs
|
#gcc libs
|
||||||
ARM64_LIBS := -lcjson ./userauthapi-arm64.so -lpthread -lm
|
ARM64_LIBS := ./userauthapi-arm64.so ./libredismq-arm64.so
|
||||||
LINUX_LIBS := -lcjson ./userauthapi-linux.so -lpthread -lm
|
ARM64_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis
|
||||||
|
|
||||||
|
LINUX_LIBS := ./userauthapi-linux.so ./libredismq-linux.so
|
||||||
|
LINUX_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis
|
||||||
|
|
||||||
|
|
||||||
ifeq ($(PLAT_ARM64), TRUE)
|
ifeq ($(PLAT_ARM64), TRUE)
|
||||||
DEPEND_LIB += ./debug/userauthapi-arm64.so
|
DEPEND_LIB += ./debug/userauthapi-arm64.so $(PLATLIB_DIR)/libredismq-arm64.so
|
||||||
USER_CLEAN_ITEMS += ./userauthapi-arm64.so
|
USER_CLEAN_ITEMS += ./userauthapi-arm64.so ./libredismq-arm64.so
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(PLAT_LINUX), TRUE)
|
ifeq ($(PLAT_LINUX), TRUE)
|
||||||
DEPEND_LIB += ./debug/userauthapi-linux.so
|
DEPEND_LIB += ./debug/userauthapi-linux.so $(PLATLIB_DIR)/libredismq-linux.so
|
||||||
USER_CLEAN_ITEMS += ./userauthapi-linux.so
|
USER_CLEAN_ITEMS += ./userauthapi-linux.so ./libredismq-linux.so
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# this line must be at below of thus, because of...
|
# this line must be at below of thus, because of...
|
||||||
|
|
|
@ -12,114 +12,113 @@
|
||||||
#include "../usermanager-auth/user_auth.h"
|
#include "../usermanager-auth/user_auth.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern USERGROUP g_group_table[GROUP_INDEX_MAX];
|
extern USERGROUP g_group_table[GROUP_INDEX_MAX];
|
||||||
extern USERACCOUNT g_user_table[USER_INDEX_MAX];
|
extern USERACCOUNT g_user_table[USER_INDEX_MAX];
|
||||||
|
|
||||||
int main1(void)
|
// int main1(void)
|
||||||
{
|
// {
|
||||||
printf("初始化用户组:%d\n", init_group());
|
// printf("初始化用户组:%d\n", init_group());
|
||||||
|
|
||||||
printf("增加一个用户组:%d\n", add_group("aaa04", "描述04"));
|
// printf("增加一个用户组:%d\n", add_group("aaa04", "描述04"));
|
||||||
printf("增加一个用户组:%d\n", add_group("aaa07", "描述04"));
|
// printf("增加一个用户组:%d\n", add_group("aaa07", "描述04"));
|
||||||
printf("增加一个用户组:%d\n", add_group("aaa08", "描述04"));
|
// printf("增加一个用户组:%d\n", add_group("aaa08", "描述04"));
|
||||||
printf("增加一个用户组:%d\n", add_group("aaa09", "描述04"));
|
// printf("增加一个用户组:%d\n", add_group("aaa09", "描述04"));
|
||||||
printf("增加一个用户组:%d\n", add_group("aaa10", "描述04"));
|
// printf("增加一个用户组:%d\n", add_group("aaa10", "描述04"));
|
||||||
printf("增加一个用户组:%d\n", add_group("aaa11", "描述04"));
|
// printf("增加一个用户组:%d\n", add_group("aaa11", "描述04"));
|
||||||
printf("增加一个用户组:%d\n", add_group("aaa12", "描述04"));
|
// printf("增加一个用户组:%d\n", add_group("aaa12", "描述04"));
|
||||||
char *testgroupin = "{\"type\": 0,\"data\": {\"gname\": \"aaa21\",\"gdescription\": \"xxx\"}}";
|
// char *testgroupin = "{\"type\": 0,\"data\": {\"gname\": \"aaa21\",\"gdescription\": \"xxx\"}}";
|
||||||
char *testgroupin01 = "{\"type\": 0,\"data\": {\"gname\": \"aaa22\",\"gdescription\": \"xxx\"}}";
|
// char *testgroupin01 = "{\"type\": 0,\"data\": {\"gname\": \"aaa22\",\"gdescription\": \"xxx\"}}";
|
||||||
char * outputgroup;
|
// char * outputgroup;
|
||||||
char * outputgroup01;
|
// char * outputgroup01;
|
||||||
outputgroup = malloc(130);
|
// outputgroup = malloc(130);
|
||||||
outputgroup01 = malloc(130);
|
// outputgroup01 = malloc(130);
|
||||||
if (NULL == outputgroup || NULL == outputgroup01)
|
// if (NULL == outputgroup || NULL == outputgroup01)
|
||||||
{
|
// {
|
||||||
printf("ulist fail");
|
// printf("ulist fail");
|
||||||
}
|
// }
|
||||||
int *olenth = 1;
|
// int *olenth = 1;
|
||||||
ret_code ret_add_group = usergroup_config_proc(1,1,testgroupin,1,outputgroup,olenth);
|
// ret_code ret_add_group = usergroup_config_proc(1,1,testgroupin,1,outputgroup,olenth);
|
||||||
printf("测试对外接口-增加一个用户组:%d\n", ret_add_group);
|
// printf("测试对外接口-增加一个用户组:%d\n", ret_add_group);
|
||||||
printf("%s \n", outputgroup);
|
// printf("%s \n", outputgroup);
|
||||||
|
|
||||||
ret_code ret_add_group01 = usergroup_config_proc(1,1,testgroupin01,1,outputgroup01,olenth);
|
// ret_code ret_add_group01 = usergroup_config_proc(1,1,testgroupin01,1,outputgroup01,olenth);
|
||||||
printf("测试对外接口-增加一个用户组:%d\n", ret_add_group01);
|
// printf("测试对外接口-增加一个用户组:%d\n", ret_add_group01);
|
||||||
printf("%s \n", outputgroup01);
|
// printf("%s \n", outputgroup01);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
printf("初始化用户:%d\n", init_user());
|
// printf("初始化用户:%d\n", init_user());
|
||||||
|
|
||||||
USERADD* addUserResullt;
|
// USERADD* addUserResullt;
|
||||||
addUserResullt = (USERADD*)malloc(sizeof(USERADD));
|
// addUserResullt = (USERADD*)malloc(sizeof(USERADD));
|
||||||
if (NULL == addUserResullt)
|
// if (NULL == addUserResullt)
|
||||||
{
|
// {
|
||||||
printf("shibaile");
|
// printf("shibaile");
|
||||||
}
|
// }
|
||||||
|
|
||||||
usermanager_add_user("用户01", "aaa08", addUserResullt);
|
// usermanager_add_user("用户01", "aaa08", addUserResullt);
|
||||||
printf("%d,用户id:%d\n", addUserResullt->result, addUserResullt->userID);
|
// printf("%d,用户id:%d\n", addUserResullt->result, addUserResullt->userID);
|
||||||
usermanager_add_user("用户02", "aaa04", addUserResullt);
|
// usermanager_add_user("用户02", "aaa04", addUserResullt);
|
||||||
printf("%d,用户id:%d\n", addUserResullt->result, addUserResullt->userID);
|
// printf("%d,用户id:%d\n", addUserResullt->result, addUserResullt->userID);
|
||||||
usermanager_add_user("用户03", "aaa04", addUserResullt);
|
// usermanager_add_user("用户03", "aaa04", addUserResullt);
|
||||||
printf("%d,用户id:%d\n", addUserResullt->result, addUserResullt->userID);
|
// printf("%d,用户id:%d\n", addUserResullt->result, addUserResullt->userID);
|
||||||
usermanager_add_user("用户04", "aaa04", addUserResullt);
|
// usermanager_add_user("用户04", "aaa04", addUserResullt);
|
||||||
printf("%d,用户id:%d\n", addUserResullt->result, addUserResullt->userID);
|
// printf("%d,用户id:%d\n", addUserResullt->result, addUserResullt->userID);
|
||||||
usermanager_add_user("用户05", "aaa04", addUserResullt);
|
// usermanager_add_user("用户05", "aaa04", addUserResullt);
|
||||||
printf("%d,用户id:%d\n", addUserResullt->result, addUserResullt->userID);
|
// printf("%d,用户id:%d\n", addUserResullt->result, addUserResullt->userID);
|
||||||
|
|
||||||
char * output1;
|
// char * output1;
|
||||||
output1 = malloc(50);
|
// output1 = malloc(50);
|
||||||
if (NULL == output1)
|
// if (NULL == output1)
|
||||||
{
|
// {
|
||||||
printf("ulist fail");
|
// printf("ulist fail");
|
||||||
}
|
// }
|
||||||
|
|
||||||
char *testin = "{\"type\": 0,\"data\": {\"uname\": \"小明\",\"gname\": \"aaa08\"}}";
|
// char *testin = "{\"type\": 0,\"data\": {\"uname\": \"小明\",\"gname\": \"aaa08\"}}";
|
||||||
int *a = 1;
|
// int *a = 1;
|
||||||
ret_code c = user_config_proc(1, 1, testin, 1, output1, a);
|
// ret_code c = user_config_proc(1, 1, testin, 1, output1, a);
|
||||||
|
|
||||||
printf("*******************************************************************************\n");
|
// printf("*******************************************************************************\n");
|
||||||
printf("这里是个测试第一次结果,新增用户:%d\n", c);
|
// printf("这里是个测试第一次结果,新增用户:%d\n", c);
|
||||||
printf("%s\n", output1);
|
// printf("%s\n", output1);
|
||||||
printf("*******************************************************************************\n");
|
// printf("*******************************************************************************\n");
|
||||||
|
|
||||||
|
|
||||||
char *testmodweb = "{\"type\":2, \"data\":{\"ID\": 2,\"GID\" : 4,\"uname\" : \"用户05\",\"gname\" : \"xxx\",\"passwd\" : \"zhelishimima123\" , \
|
// char *testmodweb = "{\"type\":2, \"data\":{\"ID\": 2,\"GID\" : 4,\"uname\" : \"用户05\",\"gname\" : \"xxx\",\"passwd\" : \"zhelishimima123\" , \
|
||||||
\"udescription\" : \"修改用\",\"multi\" : 1,\"valid\" : 1,\"valid_begin_time\" : \"2013-07-04 15:04:23\",\"valid_end_time\" : \"2019-07-04 15:04:23\"}}";
|
// \"udescription\" : \"修改用\",\"multi\" : 1,\"valid\" : 1,\"valid_begin_time\" : \"2013-07-04 15:04:23\",\"valid_end_time\" : \"2019-07-04 15:04:23\"}}";
|
||||||
|
|
||||||
char * output2;
|
// char * output2;
|
||||||
output2 = malloc(50);
|
// output2 = malloc(50);
|
||||||
if (NULL == output2)
|
// if (NULL == output2)
|
||||||
{
|
// {
|
||||||
printf("ulist fail");
|
// printf("ulist fail");
|
||||||
}
|
// }
|
||||||
ret_code cc = user_config_proc(1, 1, testmodweb, 1, output2, a);
|
// ret_code cc = user_config_proc(1, 1, testmodweb, 1, output2, a);
|
||||||
printf("*******************************************************************************\n");
|
// printf("*******************************************************************************\n");
|
||||||
printf("这里是个测试第二次结果,修改用户web:%d\n", cc);
|
// printf("这里是个测试第二次结果,修改用户web:%d\n", cc);
|
||||||
printf("%s\n", output2);
|
// printf("%s\n", output2);
|
||||||
printf("*******************************************************************************\n");
|
// printf("*******************************************************************************\n");
|
||||||
UCHAR_FREE(output2);
|
// UCHAR_FREE(output2);
|
||||||
|
|
||||||
char *testmodline = "{\"type\":5, \"data\":{\"uname\": \"用户05\",\"attr_type\" : 6,\"attr_data\" : \"2018-03-03 15:04:23\"}}";
|
// char *testmodline = "{\"type\":5, \"data\":{\"uname\": \"用户05\",\"attr_type\" : 6,\"attr_data\" : \"2018-03-03 15:04:23\"}}";
|
||||||
char * output3;
|
// char * output3;
|
||||||
output3 = malloc(50);
|
// output3 = malloc(50);
|
||||||
if (NULL == output3)
|
// if (NULL == output3)
|
||||||
{
|
// {
|
||||||
printf("ulist fail");
|
// printf("ulist fail");
|
||||||
}
|
// }
|
||||||
ret_code ccc = user_config_proc(1, 1, testmodline, 1, output3, a);
|
// ret_code ccc = user_config_proc(1, 1, testmodline, 1, output3, a);
|
||||||
printf("*******************************************************************************\n");
|
// printf("*******************************************************************************\n");
|
||||||
printf("这里是个测试第三次结果,修改用户-line:%d\n", ccc);
|
// printf("这里是个测试第三次结果,修改用户-line:%d\n", ccc);
|
||||||
printf("%s\n", output3);
|
// printf("%s\n", output3);
|
||||||
printf("*******************************************************************************\n");
|
// printf("*******************************************************************************\n");
|
||||||
UCHAR_FREE(output3);
|
// UCHAR_FREE(output3);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
|
@ -156,10 +155,10 @@ int main(void)
|
||||||
printf("第 %d 用户组 ID : %d, NAME: %s, 描述:%s \n", i, U[i].ID, U[i].gname, U[i].gdescription);
|
printf("第 %d 用户组 ID : %d, NAME: %s, 描述:%s \n", i, U[i].ID, U[i].gname, U[i].gdescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* name1 = { "aaa18" };
|
// char* name1 = { "aaa18" };
|
||||||
printf("删除一个组:%s, %d\n", name1, del_group_by_name(name1));
|
// printf("删除一个组:%s, %d\n", name1, del_group_by_name(name1));
|
||||||
printf("删除一个组:%s, %d\n", "aaa03", del_group_by_name("aaa03"));
|
// printf("删除一个组:%s, %d\n", "aaa03", del_group_by_name("aaa03"));
|
||||||
printf("删除一个组:%s, %d\n", "aaaa03", del_group_by_name("aaaa03"));
|
// printf("删除一个组:%s, %d\n", "aaaa03", del_group_by_name("aaaa03"));
|
||||||
|
|
||||||
printf("增加一个用户组:%d\n", add_group("aaa30", "就爱看九分阿道夫就卡了阿道夫阿道夫就"));
|
printf("增加一个用户组:%d\n", add_group("aaa30", "就爱看九分阿道夫就卡了阿道夫阿道夫就"));
|
||||||
printf("增加一个用户组:%d\n", add_group("aaa31", "描述31"));
|
printf("增加一个用户组:%d\n", add_group("aaa31", "描述31"));
|
||||||
|
@ -181,7 +180,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
printf("ulist fail");
|
printf("ulist fail");
|
||||||
}
|
}
|
||||||
int *olenth = 1;
|
int olenth_01 = 1;
|
||||||
|
int *olenth = &olenth_01;
|
||||||
ret_code ret_add_group = usergroup_config_proc(1,1,testgroupin,1,outputgroup,olenth);
|
ret_code ret_add_group = usergroup_config_proc(1,1,testgroupin,1,outputgroup,olenth);
|
||||||
printf("测试对外接口-增加一个用户组:%d\n", ret_add_group);
|
printf("测试对外接口-增加一个用户组:%d\n", ret_add_group);
|
||||||
printf("%s \n", outputgroup);
|
printf("%s \n", outputgroup);
|
||||||
|
@ -281,7 +281,8 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
char *testin = "{\"type\": 0,\"data\": {\"uname\": \"小明\",\"gname\": \"aaa14\"}}";
|
char *testin = "{\"type\": 0,\"data\": {\"uname\": \"小明\",\"gname\": \"aaa14\"}}";
|
||||||
int *a = 1;
|
int a_01 = 1;
|
||||||
|
int *a = &a_01;
|
||||||
ret_code c = user_config_proc(1, 1, testin, 1, output1, a);
|
ret_code c = user_config_proc(1, 1, testin, 1, output1, a);
|
||||||
|
|
||||||
printf("*******************************************************************************\n");
|
printf("*******************************************************************************\n");
|
||||||
|
@ -401,7 +402,8 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
char *testin4 = "{\"type\": 1,\"data\":[\"用户01\", \"用户02\", \"用户04\"]}";
|
char *testin4 = "{\"type\": 1,\"data\":[\"用户01\", \"用户02\", \"用户04\"]}";
|
||||||
int *a4 = 1;
|
int a4_01 = 1;
|
||||||
|
int *a4 = &a4_01;;
|
||||||
ret_code c4 = user_config_proc(1, 1, testin4, 1, output4, a4);
|
ret_code c4 = user_config_proc(1, 1, testin4, 1, output4, a4);
|
||||||
|
|
||||||
printf("*******************************************************************************\n");
|
printf("*******************************************************************************\n");
|
||||||
|
@ -419,11 +421,12 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
char *testin5 = "{\"type\": 1,\"data\":[\"aaa\", \"aaa07\", \"aaa08\"]}";
|
char *testin5 = "{\"type\": 1,\"data\":[\"aaa\", \"aaa07\", \"aaa08\"]}";
|
||||||
int *a5 = 1;
|
int a5_01 = 1;
|
||||||
|
int *a5 = &a5_01;
|
||||||
ret_code c5 = usergroup_config_proc(1, 1, testin5, 1, output5, a5);
|
ret_code c5 = usergroup_config_proc(1, 1, testin5, 1, output5, a5);
|
||||||
|
|
||||||
printf("*******************************************************************************\n");
|
printf("*******************************************************************************\n");
|
||||||
printf("这里是个测试第四次结果,删除用户组:%d\n", c5);
|
printf("这里是个测试第五次结果,删除用户组:%d\n", c5);
|
||||||
printf("%s\n", output5);
|
printf("%s\n", output5);
|
||||||
printf("*******************************************************************************\n");
|
printf("*******************************************************************************\n");
|
||||||
UCHAR_FREE(output5);
|
UCHAR_FREE(output5);
|
||||||
|
|
Loading…
Reference in New Issue