Add aaa-12 增加配置管理-新增用户组
RCA: SOL: 修改人:zhouzian 检视人:zhouzian
This commit is contained in:
parent
11a44646c0
commit
38299f627b
|
@ -4,14 +4,21 @@
|
|||
#include "rpc_common.h"
|
||||
#include "ipconfig.h"
|
||||
#include "configmapi.h"
|
||||
#include "user_group_config.h"
|
||||
/* 类型定义 */
|
||||
|
||||
/* IP CONFIG */
|
||||
#define IPCONFIG_MODULE 0x00000001
|
||||
|
||||
/* USER MANAGER CONFIG */
|
||||
#define USER_MANAGER_CONFIG_MODULE 0x00000002
|
||||
|
||||
/* config id define*/
|
||||
#define IPCONFIG_V4 (uint64)((uint64)IPCONFIG_MODULE<<32|1)
|
||||
|
||||
#define USER_MANAGER_CONFIG_GROUP (uint64)((uint64)USER_MANAGER_CONFIG_MODULE<<32|1)
|
||||
#define USER_MANAGER_CONFIG_USER (uint64)((uint64)USER_MANAGER_CONFIG_MODULE<<32|2)
|
||||
|
||||
/*
|
||||
1、配置ID,全局唯一,用于寻找对应的配置业务
|
||||
2、配置源检查,全局唯一,用于寻找对应的配置业务,
|
||||
|
@ -34,7 +41,17 @@
|
|||
ip_config_proc, \
|
||||
ip_config_get, \
|
||||
ip_config_get_all \
|
||||
}\
|
||||
},\
|
||||
{\
|
||||
USER_MANAGER_CONFIG_GROUP, \
|
||||
CONFIG_FROM_WEB, \
|
||||
FALSE, \
|
||||
FALSE, \
|
||||
usergroup_config_chk, \
|
||||
usergroup_config_proc, \
|
||||
usergroup_config_get, \
|
||||
usergroup_config_get_all \
|
||||
}\
|
||||
}
|
||||
|
||||
typedef ret_code (*cm_config_chk)(uint source, uint config_type,
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef USER_GROUP_CONFIG_H_
|
||||
#define USER_GROUP_CONFIG_H_
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include <cjson/cJSON.h>
|
||||
|
||||
|
||||
#include "../../../../common/configm/configmapi.h"
|
||||
#include "../../../../common/rpc/rpc_common.h"
|
||||
#include "../../../../../Product/user/user_manager/user_group.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/* user group config */
|
||||
ret_code usergroup_config_chk(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
ret_code usergroup_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
ret_code usergroup_config_get(uint source,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len);
|
||||
|
||||
ret_code usergroup_config_get_all(uint source, uint64 config_id,
|
||||
pointer output, short *single_len,
|
||||
int *output_len);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,160 @@
|
|||
#include "configm.h"
|
||||
#include "user_group_config.h"
|
||||
#include "rpc.h"
|
||||
#include "parsefile.h"
|
||||
|
||||
/* check暂时不做操作,所有的检查在业务接口中完成 */
|
||||
ret_code usergroup_config_chk(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
int code = 0;
|
||||
cJSON *root;
|
||||
cJSON *name, *description;
|
||||
|
||||
switch(config_type)
|
||||
{
|
||||
case CM_CONFIG_ADD:
|
||||
// root = cJSON_Parse(input);
|
||||
// if(!root)
|
||||
// {
|
||||
// ret = RET_INPUTERR;
|
||||
// ASSERT_RET(ret);
|
||||
// return ret;
|
||||
// }
|
||||
// name = cJSON_GetObjectItem(root, "gname");
|
||||
// if(!name)
|
||||
// {
|
||||
// cJSON_Delete(root);
|
||||
// ret = RET_INPUTERR;
|
||||
// ASSERT_RET(ret);
|
||||
// return ret;
|
||||
// }
|
||||
// description = cJSON_GetObjectItem(root, "gdescription");
|
||||
// if(!description)
|
||||
// {
|
||||
// cJSON_Delete(root);
|
||||
// ret = RET_INPUTERR;
|
||||
// ASSERT_RET(ret);
|
||||
// return ret;
|
||||
// }
|
||||
//cJSON_Delete(root);
|
||||
break;
|
||||
case CM_CONFIG_DEL:
|
||||
break;
|
||||
case CM_CONFIG_GET:
|
||||
break;
|
||||
case CM_CONFIG_GET_ALL:
|
||||
break;
|
||||
default:
|
||||
ret = RET_NOTSUPPORT;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* 新增用户组-处理 */
|
||||
ret_code usergroup_config_add_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
unsigned short result;
|
||||
cJSON *root, *name, *description, *res;
|
||||
char *des = NULL;
|
||||
char *ret_char = NULL;
|
||||
|
||||
root = cJSON_Parse(input);
|
||||
if(!root)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
name = cJSON_GetObjectItem(root, "gname");
|
||||
if(!name)
|
||||
{
|
||||
ret = RET_INPUTERR;
|
||||
ASSERT_RET(ret);
|
||||
cJSON_Delete(root);
|
||||
return ret;
|
||||
}
|
||||
|
||||
description = cJSON_GetObjectItem(root, "gdescription");
|
||||
if(description)
|
||||
{
|
||||
des = description->valuestring;
|
||||
}
|
||||
|
||||
result = add_group(name->valuestring, des); //增加用户组
|
||||
cJSON_Delete(root);
|
||||
|
||||
res = cJSON_CreateObject();
|
||||
if(!res)
|
||||
{
|
||||
ret = RET_ERR;
|
||||
ASSERT_RET(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
cJSON_AddNumberToObject(res, "result", result);
|
||||
ret_char = cJSON_PrintUnformatted(res);
|
||||
memcpy(output, ret_char, strlen(ret_char)+1);
|
||||
cJSON_Delete(res);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret_code usergroup_config_proc(uint source, uint config_type,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
int code;
|
||||
|
||||
switch(config_type)
|
||||
{
|
||||
case CM_CONFIG_ADD:
|
||||
ret = usergroup_config_add_proc(source, config_type,
|
||||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
case CM_CONFIG_DEL:
|
||||
ret = usergroup_config_del_proc(source, config_type,
|
||||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
case CM_CONFIG_GET:
|
||||
ret = usergroup_config_get_proc(source, config_type,
|
||||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
case CM_CONFIG_GET_ALL:
|
||||
ret = usergroup_config_getall_proc(source, config_type,
|
||||
input, input_len,
|
||||
output, output_len);
|
||||
break;
|
||||
default:
|
||||
ret = RET_NOTSUPPORT;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret_code usergroup_config_get(uint source,
|
||||
pointer input, int input_len,
|
||||
pointer output, int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret_code usergroup_config_get_all(uint source, uint64 config_id,
|
||||
pointer output, short *single_len,
|
||||
int *output_len)
|
||||
{
|
||||
ret_code ret = RET_OK;
|
||||
return ret;
|
||||
}
|
Loading…
Reference in New Issue