2019-07-08 07:12:06 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <cjson/cJSON.h>
|
2019-08-15 09:44:52 +00:00
|
|
|
|
#include <string.h>
|
2019-07-08 07:12:06 +00:00
|
|
|
|
#include "common_user.h"
|
|
|
|
|
#include "array_index.h"
|
|
|
|
|
#include "user_group.h"
|
|
|
|
|
#include "user.h"
|
2019-07-10 09:15:33 +00:00
|
|
|
|
#include "user_account_config.h"
|
|
|
|
|
#include "user_group_config.h"
|
2019-08-23 06:12:49 +00:00
|
|
|
|
#include "user_recover_config.h"
|
2019-07-23 09:52:43 +00:00
|
|
|
|
#include "user_auth.h"
|
2019-08-08 07:33:16 +00:00
|
|
|
|
#include "database.h"
|
|
|
|
|
#include "redisMq.h"
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
2019-08-23 06:12:49 +00:00
|
|
|
|
extern USERGROUP g_group_table[];
|
|
|
|
|
extern USERACCOUNT g_user_table[];
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
2019-07-23 02:49:58 +00:00
|
|
|
|
// int main1(void)
|
|
|
|
|
// {
|
|
|
|
|
// printf("初始化用户组:%d\n", init_group());
|
|
|
|
|
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa04", "描述04"));
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa07", "描述04"));
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa08", "描述04"));
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa09", "描述04"));
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa10", "描述04"));
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa11", "描述04"));
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa12", "描述04"));
|
|
|
|
|
// char *testgroupin = "{\"type\": 0,\"data\": {\"gname\": \"aaa21\",\"gdescription\": \"xxx\"}}";
|
|
|
|
|
// char *testgroupin01 = "{\"type\": 0,\"data\": {\"gname\": \"aaa22\",\"gdescription\": \"xxx\"}}";
|
|
|
|
|
// char * outputgroup;
|
|
|
|
|
// char * outputgroup01;
|
|
|
|
|
// outputgroup = malloc(130);
|
|
|
|
|
// outputgroup01 = malloc(130);
|
|
|
|
|
// if (NULL == outputgroup || NULL == outputgroup01)
|
|
|
|
|
// {
|
|
|
|
|
// printf("ulist fail");
|
|
|
|
|
// }
|
|
|
|
|
// int *olenth = 1;
|
|
|
|
|
// ret_code ret_add_group = usergroup_config_proc(1,1,testgroupin,1,outputgroup,olenth);
|
|
|
|
|
// printf("测试对外接口-增加一个用户组:%d\n", ret_add_group);
|
|
|
|
|
// printf("%s \n", outputgroup);
|
|
|
|
|
|
|
|
|
|
// ret_code ret_add_group01 = usergroup_config_proc(1,1,testgroupin01,1,outputgroup01,olenth);
|
|
|
|
|
// printf("测试对外接口-增加一个用户组:%d\n", ret_add_group01);
|
|
|
|
|
// printf("%s \n", outputgroup01);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// printf("初始化用户:%d\n", init_user());
|
|
|
|
|
|
|
|
|
|
// USERADD* addUserResullt;
|
|
|
|
|
// addUserResullt = (USERADD*)malloc(sizeof(USERADD));
|
|
|
|
|
// if (NULL == addUserResullt)
|
|
|
|
|
// {
|
|
|
|
|
// printf("shibaile");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// usermanager_add_user("用户01", "aaa08", addUserResullt);
|
|
|
|
|
// printf("%d,用户id:%d\n", addUserResullt->result, addUserResullt->userID);
|
|
|
|
|
// usermanager_add_user("用户02", "aaa04", addUserResullt);
|
|
|
|
|
// printf("%d,用户id:%d\n", addUserResullt->result, addUserResullt->userID);
|
|
|
|
|
// usermanager_add_user("用户03", "aaa04", addUserResullt);
|
|
|
|
|
// printf("%d,用户id:%d\n", addUserResullt->result, addUserResullt->userID);
|
|
|
|
|
// usermanager_add_user("用户04", "aaa04", addUserResullt);
|
|
|
|
|
// printf("%d,用户id:%d\n", addUserResullt->result, addUserResullt->userID);
|
|
|
|
|
// usermanager_add_user("用户05", "aaa04", addUserResullt);
|
|
|
|
|
// printf("%d,用户id:%d\n", addUserResullt->result, addUserResullt->userID);
|
|
|
|
|
|
|
|
|
|
// char * output1;
|
|
|
|
|
// output1 = malloc(50);
|
|
|
|
|
// if (NULL == output1)
|
|
|
|
|
// {
|
|
|
|
|
// printf("ulist fail");
|
|
|
|
|
// }
|
2019-07-10 09:15:33 +00:00
|
|
|
|
|
2019-07-23 02:49:58 +00:00
|
|
|
|
// char *testin = "{\"type\": 0,\"data\": {\"uname\": \"小明\",\"gname\": \"aaa08\"}}";
|
|
|
|
|
// int *a = 1;
|
|
|
|
|
// ret_code c = user_config_proc(1, 1, testin, 1, output1, a);
|
|
|
|
|
|
|
|
|
|
// printf("*******************************************************************************\n");
|
|
|
|
|
// printf("这里是个测试第一次结果,新增用户:%d\n", c);
|
|
|
|
|
// printf("%s\n", output1);
|
|
|
|
|
// printf("*******************************************************************************\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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\"}}";
|
|
|
|
|
|
|
|
|
|
// char * output2;
|
|
|
|
|
// output2 = malloc(50);
|
|
|
|
|
// if (NULL == output2)
|
|
|
|
|
// {
|
|
|
|
|
// printf("ulist fail");
|
|
|
|
|
// }
|
|
|
|
|
// ret_code cc = user_config_proc(1, 1, testmodweb, 1, output2, a);
|
|
|
|
|
// printf("*******************************************************************************\n");
|
|
|
|
|
// printf("这里是个测试第二次结果,修改用户web:%d\n", cc);
|
|
|
|
|
// printf("%s\n", output2);
|
|
|
|
|
// printf("*******************************************************************************\n");
|
|
|
|
|
// UCHAR_FREE(output2);
|
|
|
|
|
|
|
|
|
|
// char *testmodline = "{\"type\":5, \"data\":{\"uname\": \"用户05\",\"attr_type\" : 6,\"attr_data\" : \"2018-03-03 15:04:23\"}}";
|
|
|
|
|
// char * output3;
|
|
|
|
|
// output3 = malloc(50);
|
|
|
|
|
// if (NULL == output3)
|
|
|
|
|
// {
|
|
|
|
|
// printf("ulist fail");
|
|
|
|
|
// }
|
|
|
|
|
// ret_code ccc = user_config_proc(1, 1, testmodline, 1, output3, a);
|
|
|
|
|
// printf("*******************************************************************************\n");
|
|
|
|
|
// printf("这里是个测试第三次结果,修改用户-line:%d\n", ccc);
|
|
|
|
|
// printf("%s\n", output3);
|
|
|
|
|
// printf("*******************************************************************************\n");
|
|
|
|
|
// UCHAR_FREE(output3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return 0;
|
|
|
|
|
// }
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
int main(void)
|
2019-08-23 06:12:49 +00:00
|
|
|
|
{
|
|
|
|
|
char * testrec;
|
|
|
|
|
int testnum;
|
|
|
|
|
userecover_config_get_all(CONFIG_FROM_RECOVER1,testrec, &testnum);
|
|
|
|
|
|
|
|
|
|
printf("hello. \n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main1(void)
|
2019-08-08 07:33:16 +00:00
|
|
|
|
{
|
2019-08-21 10:51:54 +00:00
|
|
|
|
char * testin; //input
|
|
|
|
|
char testout[2000]; //output
|
|
|
|
|
ret_code ret_pro; //执行结果
|
|
|
|
|
int outlen = 1; //out数据长度
|
2019-08-08 07:33:16 +00:00
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
printf("************************************start*******************************************\n");
|
|
|
|
|
printf("初始化用户组:%d\n", init_group());
|
|
|
|
|
printf("初始化用户:%d\n", init_user());
|
2019-08-08 07:33:16 +00:00
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
printf("************************************新增 group*******************************************\n");
|
|
|
|
|
testin = "{\"type\": 0,\"data\": {\"gname\": \"group01\",\"gdescription\": \"描述group01\"}}";
|
|
|
|
|
ret_pro = usergroup_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
2019-08-08 07:33:16 +00:00
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
testin = "{\"type\": 0,\"data\": {\"gname\": \"group02\",\"gdescription\": \"描述group02\"}}";
|
|
|
|
|
ret_pro = usergroup_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
2019-08-08 07:33:16 +00:00
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
testin = "{\"type\": 0,\"data\": {\"gname\": \"group03\",\"gdescription\": \"描述group03\"}}";
|
|
|
|
|
ret_pro = usergroup_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
|
|
|
|
|
|
|
|
|
testin = "{\"type\": 0,\"data\": {\"gname\": \"group04\",\"gdescription\": \"描述group04\"}}";
|
|
|
|
|
ret_pro = usergroup_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
2019-08-08 07:33:16 +00:00
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
testin = "{\"type\": 0,\"data\": {\"gname\": \"group05\",\"gdescription\": \"描述group05\"}}";
|
|
|
|
|
ret_pro = usergroup_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
|
|
|
|
|
|
|
|
|
testin = "{\"type\": 0,\"data\": {\"gname\": \"group06\",\"gdescription\": \"描述group06\"}}";
|
|
|
|
|
ret_pro = usergroup_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
2019-08-08 07:33:16 +00:00
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
|
|
|
|
|
printf("\n************************************查询 group 列表*******************************************\n");
|
|
|
|
|
testin = "{\"type\": 4,\"data\": \"\"}";
|
|
|
|
|
ret_pro = usergroup_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n************************************group name -> group uuid*******************************************\n");
|
|
|
|
|
testin = "{\"type\": 7,\"data\": {\"gname\":\"group04\"}}";
|
|
|
|
|
ret_pro = usergroup_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n************************************修改 group 描述*******************************************\n");
|
|
|
|
|
testin = "{\"type\": 2,\"data\": {\"gid\": 938,\"gdescription\": \"修改用户组的描述\"}}";
|
|
|
|
|
ret_pro = usergroup_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n************************************新增 user*******************************************\n");
|
|
|
|
|
testin = "{\"type\": 0,\"data\": {\"uname\": \"user01\",\"gname\": \"group01\"}}";
|
|
|
|
|
ret_pro = user_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
|
|
|
|
|
|
|
|
|
testin = "{\"type\": 0,\"data\": {\"uname\": \"user00\",\"gname\": \"group01\",\"udesp\": \"用户描述\",\"pwd\": \"A31as%4Gb\",\"multi\":0,\"valid\":1, \"valid_begin_time\": \"2013-07-04 15:04:23\",\"valid_end_time\": \"2020-07-04 15:04:23\"}}";
|
|
|
|
|
ret_pro = user_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
|
|
|
|
|
|
|
|
|
testin = "{\"type\": 0,\"data\": {\"uname\": \"user02\",\"gname\": \"group02\",\"pwd\": \"123456\"}}";
|
|
|
|
|
ret_pro = user_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
|
|
|
|
|
|
|
|
|
testin = "{\"type\": 0,\"data\": {\"uname\": \"user03\",\"gname\": \"group03\"}}";
|
|
|
|
|
ret_pro = user_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
|
|
|
|
|
|
|
|
|
testin = "{\"type\": 0,\"data\": {\"uname\": \"user04\",\"gname\": \"group04\"}}";
|
|
|
|
|
ret_pro = user_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n************************************修改 user web*******************************************\n");
|
|
|
|
|
testin = "{\"type\": 2,\"data\": {\"ID\":3,\"GID\":938,\"resetpwd\":0,\"uname\": \"user02\",\"gname\": \"group01\",\"udescription\": \"修改用户描述\",\"passwd\": \"A31as%4Gb\",\"multi\":0,\"valid\":1, \"valid_begin_time\": \"2013-07-04 15:04:23\",\"valid_end_time\": \"2020-07-04 15:04:23\"}}";
|
|
|
|
|
ret_pro = user_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n************************************查询 user list*******************************************\n");
|
|
|
|
|
testin = "{\"type\": 4,\"data\":{\"group_id\": 0, \"user_name\": \"3\",\"page_start\": 1,\"page_counts\": 20}}";
|
|
|
|
|
ret_pro = user_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n************************************user name -> user uuid*******************************************\n");
|
|
|
|
|
testin = "{\"type\": 7,\"data\":{\"uname\": \"user03\"}}";
|
|
|
|
|
ret_pro = user_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n************************************user uuid -> user 详情*******************************************\n");
|
|
|
|
|
testin = "{\"type\": 3,\"data\":{\"user_id\": 2}}";
|
|
|
|
|
ret_pro = user_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n************************************移动分组*******************************************\n");
|
|
|
|
|
testin = "{\"type\": 6,\"data\":{\"user_id\": [2],\"batch\":{\"all\":1,\"old_group_id\":0},\"new_group_id\":927}}";
|
|
|
|
|
ret_pro = user_config_proc(1, 1, testin, strlen(testin)+1, testout, &outlen);
|
|
|
|
|
printf("执行结果:%d, 返回数据:%s .\n", ret_pro, testout);
|
2019-08-08 07:33:16 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
int main2(void)
|
2019-07-08 07:12:06 +00:00
|
|
|
|
{
|
2019-08-21 10:51:54 +00:00
|
|
|
|
|
2019-08-15 09:44:52 +00:00
|
|
|
|
int ID = 1;
|
|
|
|
|
int GID_temp = 2;
|
|
|
|
|
char *uname = "xiaoming";
|
|
|
|
|
char *udesp = "";
|
|
|
|
|
int multi = 0;
|
|
|
|
|
int valid = 0;
|
|
|
|
|
char *valid_begin_time = "";
|
|
|
|
|
char *valid_end_time = "";
|
|
|
|
|
void *adduser_hdbc = connect_database(USER_ACCOUNT_DATABASE_ID);
|
|
|
|
|
int num1;
|
|
|
|
|
char * retptr1 = NULL;
|
|
|
|
|
if(NULL == adduser_hdbc)
|
|
|
|
|
{
|
|
|
|
|
printf("aaaaaaaaa");
|
|
|
|
|
}
|
2019-08-08 07:33:16 +00:00
|
|
|
|
// char *adduser_sql = "INSERT INTO `user_account` SET id = ?, group_id = ?, user_name = ?, password = ?, udescription = ?, \
|
|
|
|
|
// multi_player = ?, valid_always = ?, valid_begin_time = ?, valid_end_time = ?";
|
|
|
|
|
// int ret_adduser = update_database(USER_ACCOUNT_DATABASE_ID, adduser_hdbc, DB_OP_INSERT, USER_TABLE, adduser_sql, 9,
|
|
|
|
|
// DB_DATA_INT_TYPE, sizeof(ID), ID,
|
|
|
|
|
// DB_DATA_INT_TYPE, sizeof(GID_temp), GID_temp,
|
|
|
|
|
// DB_DATA_STRING_TYPE, strlen(uname)+1, uname,
|
|
|
|
|
// DB_DATA_STRING_TYPE, 9, "12345678",
|
|
|
|
|
// DB_DATA_STRING_TYPE, strlen(udesp)+1, udesp,
|
|
|
|
|
// DB_DATA_INT_TYPE, sizeof(multi), multi,
|
|
|
|
|
// DB_DATA_INT_TYPE, sizeof(valid), valid,
|
|
|
|
|
// DB_DATA_STRING_TYPE, strlen(valid_begin_time)+1, valid_begin_time,
|
|
|
|
|
// DB_DATA_STRING_TYPE, strlen(valid_end_time)+1,valid_end_time);
|
|
|
|
|
// printf("ret_adduser = %d .\n",ret_adduser);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
/*
|
2019-08-15 09:44:52 +00:00
|
|
|
|
char * aa = "户";
|
|
|
|
|
int len = strlen(aa)+strlen("*")*2+1;
|
|
|
|
|
char user_name_para[len];
|
|
|
|
|
memset(user_name_para, 0, len);
|
|
|
|
|
strcat(user_name_para, "%");
|
|
|
|
|
strcat(user_name_para, aa);
|
|
|
|
|
strcat(user_name_para, "%");
|
|
|
|
|
printf("user_name_para = %s\n",user_name_para);
|
|
|
|
|
|
|
|
|
|
int rett = create_database_table(1, adduser_hdbc, "ctest", "create table ctest ( id bigint, fl double, dt character(10), status character(7))");
|
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
retptr1 = select_datebase_by_number(1, adduser_hdbc, "user_account", "SELECT id FROM `user_account` WHERE user_name LIKE ?", 1, 0, &num1, 2,
|
|
|
|
|
DB_DATA_STRING_TYPE, 20, user_name_para,
|
|
|
|
|
DB_DATA_STRING_TYPE, 20, aa);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
//printf("长度:%d \n",strlen(retptr1));
|
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
char * moveug_sql = "UPDATE `user_account` \
|
|
|
|
|
SET group_id = ( \
|
|
|
|
|
SELECT \
|
|
|
|
|
user_group.id \
|
|
|
|
|
FROM \
|
|
|
|
|
user_group \
|
|
|
|
|
WHERE \
|
|
|
|
|
user_group.uuid = ? \
|
|
|
|
|
) \
|
|
|
|
|
WHERE \
|
|
|
|
|
uuid = ?";
|
|
|
|
|
int new_group_uuid = 712;
|
|
|
|
|
int user_uuid[1] = {3};
|
|
|
|
|
unsigned short *user_uuid_1 = user_uuid;
|
|
|
|
|
int temp_i = 0;
|
|
|
|
|
rett = update_database(1, adduser_hdbc, DB_OP_UPDATE, USER_TABLE, moveug_sql, 2,
|
|
|
|
|
DB_DATA_INT_TYPE, sizeof(new_group_uuid), new_group_uuid,
|
|
|
|
|
DB_DATA_INT_TYPE, sizeof(user_uuid_1[temp_i]), user_uuid_1[temp_i]);
|
|
|
|
|
|
|
|
|
|
printf("更新用户组id结果:%d\n",rett);
|
|
|
|
|
|
|
|
|
|
//printf("user = %s\n", retptr1);
|
|
|
|
|
|
|
|
|
|
char * sele_sql = "SELECT \
|
|
|
|
|
user_group.uuid gid,\
|
|
|
|
|
user_group.gname,\
|
|
|
|
|
user_group.gdescription,\
|
|
|
|
|
IFNULL(t1.count1, 0) useraccount\
|
|
|
|
|
FROM\
|
|
|
|
|
user_group\
|
|
|
|
|
LEFT JOIN (\
|
|
|
|
|
SELECT\
|
|
|
|
|
user_account.group_id,\
|
|
|
|
|
COUNT(*) count1\
|
|
|
|
|
FROM\
|
|
|
|
|
user_account\
|
|
|
|
|
GROUP BY\
|
|
|
|
|
user_account.group_id\
|
|
|
|
|
) t1 ON user_group.id = t1.group_id\
|
|
|
|
|
ORDER BY\
|
|
|
|
|
user_group.uuid";
|
|
|
|
|
|
|
|
|
|
retptr1 = select_datebase_by_number(1, adduser_hdbc, "user_account", sele_sql, 1, 0, &num1, 0);
|
|
|
|
|
//printf("user = %s\n", retptr1);
|
|
|
|
|
disconnect_database(USER_ACCOUNT_DATABASE_ID, adduser_hdbc);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
return 0;
|
|
|
|
|
*/
|
2019-08-21 10:51:54 +00:00
|
|
|
|
|
|
|
|
|
int outsize;
|
2019-08-15 09:44:52 +00:00
|
|
|
|
char output7[5000];
|
2019-08-21 10:51:54 +00:00
|
|
|
|
char *testin7 = "{\"type\": 4,\"data\":{\"group_id\": 0, \"user_name\": \"\",\"page_start\": 1,\"page_counts\": 20}}";
|
2019-08-15 09:44:52 +00:00
|
|
|
|
int a7 = 1;
|
|
|
|
|
ret_code c7 = user_config_proc(1, 1, testin7, strlen(testin7)+1, output7, &a7);
|
2019-08-21 10:51:54 +00:00
|
|
|
|
outsize = strlen(output7);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
printf("*******************************************************************************\n");
|
2019-08-21 10:51:54 +00:00
|
|
|
|
printf("这里是个测试第7次结果,查询用户列表,查询结果:%d\n", c7);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
printf("%s\n", output7);
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
|
|
|
|
|
char output8[100];
|
|
|
|
|
char *testin8 = "{\"type\": 7,\"data\":{\"uname\": \"用户07\"}}";
|
|
|
|
|
int a8 = 1;
|
|
|
|
|
ret_code c8 = user_config_proc(1, 1, testin8, strlen(testin8)+1, output8, &a8);
|
|
|
|
|
|
|
|
|
|
printf("*******************************************************************************\n");
|
2019-08-21 10:51:54 +00:00
|
|
|
|
printf("这里是个测试第8次结果,根据用户名->用户uuid,查询结果:%d\n", c8);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
printf("%s\n", output8);
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char output9[100];
|
|
|
|
|
char *testin9 = "{\"type\": 7,\"data\":{\"gname\": \"aaa30\"}}";
|
|
|
|
|
int a9 = 1;
|
|
|
|
|
ret_code c9 = usergroup_config_proc(1, 1, testin9, strlen(testin9)+1, output9, &a9);
|
|
|
|
|
|
|
|
|
|
printf("*******************************************************************************\n");
|
2019-08-21 10:51:54 +00:00
|
|
|
|
printf("这里是个测试第9次结果,根据用户组名->用户组uuid,查询结果:%d\n", c9);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
printf("%s\n", output9);
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
|
|
|
|
|
char output10[200];
|
|
|
|
|
char *testin10 = "{\"type\": 3,\"data\":{\"user_id\": 4}}";
|
|
|
|
|
int a10 = 1;
|
|
|
|
|
ret_code c10 = user_config_proc(1, 1, testin10, strlen(testin10)+1, output10, &a10);
|
|
|
|
|
|
|
|
|
|
printf("*******************************************************************************\n");
|
2019-08-21 10:51:54 +00:00
|
|
|
|
printf("这里是个测试第10次结果,根据用户uuid->用户详情,查询结果:%d\n", c10);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
printf("%s\n", output10);
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
char output11[200];
|
|
|
|
|
char *testin11 = "{\"type\": 6,\"data\":{\"user_id\": [3,4,5],\"batch\":{\"all\":1,\"old_group_id\":0},\"new_group_id\":717}}";
|
|
|
|
|
int a11 = 1;
|
|
|
|
|
ret_code c11 = user_config_proc(1, 1, testin11, strlen(testin11)+1, output11, &a11);
|
|
|
|
|
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
printf("这里是个测试第11次结果,移动分组,结果:%d\n", c11);
|
|
|
|
|
printf("%s\n", output11);
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
|
|
|
|
|
char output12[2000];
|
|
|
|
|
char *testin12 = "{\"type\": 4,\"data\":\"\"}";
|
|
|
|
|
int a12 = 1;
|
|
|
|
|
ret_code c12 = usergroup_config_proc(1, 1, testin12, strlen(testin12)+1, output12, &a12);
|
|
|
|
|
outsize = strlen(output12);
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
printf("这里是个测试第12次结果,用户组列表,查询结果:%d\n", c12);
|
|
|
|
|
printf("%s\n", output12);
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
|
|
|
|
|
char output13[100];
|
|
|
|
|
char *testin13 = "{\"type\":2,\"data\":{\"ID\":4,\"GID\":811,\"uname\":\"用户06\",\"gname\":\"aaa03\",\"resetpwd\":1,\"passwd\":\"A31as%4Gb\",\
|
|
|
|
|
\"udescription\":\"测试修改描述\",\"multi\":1,\"valid\":1,\"valid_begin_time\":\"2018-01-01 00:00:00\",\"valid_end_time\":\"2019-01-01 00:00:00\"}}";
|
|
|
|
|
int a13 = 1;
|
|
|
|
|
ret_code c13 = user_config_proc(1, 1, testin13, strlen(testin13)+1, output13, &a13);
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
printf("这里是个测试第13次结果,修改用户,结果:%d\n", c13);
|
|
|
|
|
printf("%s\n", output13);
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
|
|
|
|
|
char output14[100];
|
|
|
|
|
char *testin14 = "{\"type\": 2,\"data\":{\"gid\":835,\"gdescription\":\"111\"}}";
|
|
|
|
|
int a14 = 1;
|
|
|
|
|
ret_code c14 = usergroup_config_proc(1, 1, testin14, strlen(testin14)+1, output14, &a14);
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
printf("这里是个测试第14次结果,修改用户组描述,结果:%d\n", c14);
|
|
|
|
|
printf("%s\n", output14);
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
|
2019-08-15 09:44:52 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
2019-08-08 07:33:16 +00:00
|
|
|
|
|
2019-07-08 07:12:06 +00:00
|
|
|
|
printf("初始化用户组:%d\n", init_group());
|
|
|
|
|
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("", ""));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa01", "描述02"));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa03", "描述03"));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa,", "描述04"));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("", "描述04"));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa04", "描述04"));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa07", "描述04"));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa08", "描述04"));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa09", "描述04"));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa10", "描述04"));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa11", "描述04"));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa12", "描述04"));
|
|
|
|
|
|
|
|
|
|
//USERGROUP U[22] = { 0 };
|
|
|
|
|
int gsize = get_group_count();
|
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
// USERGROUP* U;
|
|
|
|
|
// U = (USERGROUP*)malloc(sizeof(USERGROUP) * gsize);
|
|
|
|
|
// if (NULL == U)
|
|
|
|
|
// {
|
|
|
|
|
// printf("shibaile");
|
|
|
|
|
// }
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
//show_group_list(U);
|
|
|
|
|
// for (int i = 0; i < gsize; i++)
|
|
|
|
|
// {
|
|
|
|
|
// printf("第 %d 用户组 ID : %d, NAME: %s, 描述:%s \n", i, U[i].ID, U[i].gname, U[i].gdescription);
|
|
|
|
|
// }
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
2019-07-23 02:49:58 +00:00
|
|
|
|
// char* name1 = { "aaa18" };
|
|
|
|
|
// printf("删除一个组:%s, %d\n", name1, del_group_by_name(name1));
|
|
|
|
|
// printf("删除一个组:%s, %d\n", "aaa03", del_group_by_name("aaa03"));
|
|
|
|
|
// printf("删除一个组:%s, %d\n", "aaaa03", del_group_by_name("aaaa03"));
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa30", "就爱看九分阿道夫就卡了阿道夫阿道夫就"));
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa31", "描述31"));
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa32", "描述31"));
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa13", "描述04"));
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa14", "描述04"));
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa15", "描述04"));
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa16", "描述04"));
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa17", "描述04"));
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa18", "描述04"));
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa18", "描述04"));
|
|
|
|
|
// printf("增加一个用户组:%d\n", add_group("aaa20", "描述04"));
|
2019-07-10 09:15:33 +00:00
|
|
|
|
//printf("增加一个用户组:%d\n", add_group("aaa21", "描述04"));
|
|
|
|
|
|
|
|
|
|
char *testgroupin = "{\"type\": 0,\"data\": {\"gname\": \"aaa21\",\"gdescription\": \"xxx\"}}";
|
|
|
|
|
char * outputgroup;
|
|
|
|
|
outputgroup = malloc(130);
|
|
|
|
|
if (NULL == outputgroup)
|
|
|
|
|
{
|
|
|
|
|
printf("ulist fail");
|
|
|
|
|
}
|
2019-07-23 02:49:58 +00:00
|
|
|
|
int olenth_01 = 1;
|
|
|
|
|
int *olenth = &olenth_01;
|
2019-07-10 09:15:33 +00:00
|
|
|
|
ret_code ret_add_group = usergroup_config_proc(1,1,testgroupin,1,outputgroup,olenth);
|
|
|
|
|
printf("测试对外接口-增加一个用户组:%d\n", ret_add_group);
|
|
|
|
|
printf("%s \n", outputgroup);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
//UCHAR_FREE(outputgroup);
|
2019-07-10 09:15:33 +00:00
|
|
|
|
|
2019-07-08 07:12:06 +00:00
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa22", "描述04"));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa23", "描述04"));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa20", "描述04"));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa20", "描述04"));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa24", "描述04"));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa25", "描述04"));
|
|
|
|
|
printf("增加一个用户组:%d\n", add_group("aaa26", "描述04"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gsize = get_group_count();
|
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
// USERGROUP* U1;
|
|
|
|
|
// U1 = (USERGROUP*)malloc(sizeof(USERGROUP) * gsize);
|
|
|
|
|
// if (NULL == U1)
|
|
|
|
|
// {
|
|
|
|
|
// printf("shibaile");
|
|
|
|
|
// }
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
2019-08-21 10:51:54 +00:00
|
|
|
|
//show_group_list(U1);
|
|
|
|
|
// for (int i = 0; i < gsize; i++)
|
|
|
|
|
// {
|
|
|
|
|
// printf("第 %d 用户组 ID : %d, NAME: %s, 描述:%s \n", i, U1[i].ID, U1[i].gname, U1[i].gdescription);
|
|
|
|
|
// }
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char* name2 = { "aaa10" };
|
|
|
|
|
USERGROUP* U2;
|
|
|
|
|
U2 = (USERGROUP*)malloc(sizeof(USERGROUP));
|
|
|
|
|
if (NULL == U2)
|
|
|
|
|
{
|
|
|
|
|
printf("shibaile");
|
|
|
|
|
}
|
|
|
|
|
find_group_by_name(name2, U2);
|
|
|
|
|
if (NULL != U2)
|
|
|
|
|
{
|
|
|
|
|
printf("%s, %d, %s, %s \n", name2, U2->ID, U2->gname, U2->gdescription);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("*************************************\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("初始化用户:%d\n", init_user());
|
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
|
{
|
|
|
|
|
printf("初始化后的第 %d 个用户,ID:%d, PWD:%s \n", i, g_user_table[i].ID, g_user_table[i].passwd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
USERADD* addUserResullt;
|
|
|
|
|
addUserResullt = (USERADD*)malloc(sizeof(USERADD));
|
2019-08-21 10:51:54 +00:00
|
|
|
|
printf("sizeof(USERADD): %ld\n",sizeof(USERADD));
|
2019-08-08 07:33:16 +00:00
|
|
|
|
memset(addUserResullt, 0, sizeof(USERADD));
|
|
|
|
|
|
2019-07-08 07:12:06 +00:00
|
|
|
|
if (NULL == addUserResullt)
|
|
|
|
|
{
|
|
|
|
|
printf("shibaile");
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-15 09:44:52 +00:00
|
|
|
|
usermanager_add_user("用户01", "aaa04", "hello", NULL, 0, 0, NULL, NULL,addUserResullt);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
|
|
|
|
//addUserResullt = AddUser("用户02", "aaa04", NULL);
|
|
|
|
|
//printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
usermanager_add_user(NULL, "aaa04", NULL,NULL,0, 0, NULL, NULL, addUserResullt);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
usermanager_add_user("", "aaa04", NULL, NULL, 0, 0, NULL, NULL, addUserResullt);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
usermanager_add_user("用户04,", "aaa04", NULL,NULL,0, 0, NULL, NULL, addUserResullt);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
usermanager_add_user("用户05", "aCaa04", NULL,NULL, 0, 0, NULL, NULL, addUserResullt);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
usermanager_add_user("用户01", "aaa04", NULL,NULL, 0, 0, NULL, NULL,addUserResullt);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
usermanager_add_user("用户04", "aaa07", NULL,NULL, 0, 0, NULL, NULL, addUserResullt);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
usermanager_add_user("用户05", "aaa07", NULL,NULL, 0, 0, NULL, NULL, addUserResullt);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
usermanager_add_user("用户06", "aaa07", NULL,NULL, 0, 0, NULL, NULL, addUserResullt);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
usermanager_add_user("用户07", "aaa07", NULL,NULL, 0, 0, NULL, NULL, addUserResullt);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
usermanager_add_user("用户08", "aaa07", NULL,NULL, 0, 0, NULL, NULL, addUserResullt);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
2019-08-15 09:44:52 +00:00
|
|
|
|
usermanager_add_user("用户09", "aaa07", NULL,NULL, 0, 0, NULL, NULL, addUserResullt);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
printf("%d,%d\n", addUserResullt->result, addUserResullt->userID);
|
|
|
|
|
|
2019-07-10 09:15:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char * output1;
|
|
|
|
|
output1 = malloc(40);
|
|
|
|
|
if (NULL == output1)
|
|
|
|
|
{
|
|
|
|
|
printf("ulist fail");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *testin = "{\"type\": 0,\"data\": {\"uname\": \"小明\",\"gname\": \"aaa14\"}}";
|
2019-07-23 02:49:58 +00:00
|
|
|
|
int a_01 = 1;
|
|
|
|
|
int *a = &a_01;
|
2019-07-10 09:15:33 +00:00
|
|
|
|
ret_code c = user_config_proc(1, 1, testin, 1, output1, a);
|
|
|
|
|
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
printf("这里是个测试第一次结果,新增用户:%d\n", c);
|
|
|
|
|
printf("%s\n", output1);
|
|
|
|
|
printf("*******************************************************************************\n");
|
2019-08-15 09:44:52 +00:00
|
|
|
|
|
2019-07-10 09:15:33 +00:00
|
|
|
|
|
2019-07-08 07:12:06 +00:00
|
|
|
|
for (int i = 0; i < USER_INDEX_MAX; i++)
|
|
|
|
|
{
|
|
|
|
|
if (g_user_table[i].ID != 0)
|
|
|
|
|
{
|
|
|
|
|
printf("tianjia后的第 %d 个用户, ID:%d, GID:%d, 用户名:%s, PWD:%s \n", i, g_user_table[i].ID, g_user_table[i].GID, g_user_table[i].uname, g_user_table[i].passwd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("*****************************************************\n");
|
|
|
|
|
|
|
|
|
|
USERLIST* ulist;
|
|
|
|
|
ulist = (USERLIST*)malloc(sizeof(USERLIST));
|
|
|
|
|
if (NULL == ulist)
|
|
|
|
|
{
|
|
|
|
|
printf("ulist fail");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned short id1 = 2;
|
|
|
|
|
get_user_by_id(id1, ulist);
|
|
|
|
|
printf("查找id为:%d, 用户名:%s, 用户组ID:%d,用户组名:%s,描述:%s", id1, ulist->uname, ulist->GID, ulist->gname, ulist->udescription);
|
|
|
|
|
printf(" ,多用户登陆:%d, 永久性:%d, 开始时间:%s, 结束时间:%s", ulist->multi, ulist->valid, ulist->valid_begin_time, ulist->valid_end_time);
|
|
|
|
|
printf("密码:%s\n", ulist->passwd);
|
|
|
|
|
|
2019-07-10 09:15:33 +00:00
|
|
|
|
// USERLIST* ulist2;
|
|
|
|
|
// ulist2 = (USERLIST*)malloc(sizeof(USERLIST));
|
|
|
|
|
// if (NULL == ulist2)
|
|
|
|
|
// {
|
|
|
|
|
// printf("ulist fail");
|
|
|
|
|
// }
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
2019-07-10 09:15:33 +00:00
|
|
|
|
// ulist2->ID = 2;
|
|
|
|
|
// ulist2->GID = 4;
|
|
|
|
|
// strcpy(ulist2->udescription, "修改用");
|
|
|
|
|
// strcpy(ulist2->passwd, "zhelishimima123");
|
|
|
|
|
// ulist2->multi = 1;
|
|
|
|
|
// ulist2->valid = 1;
|
|
|
|
|
// strcpy(ulist2->valid_begin_time, "2013-07-04 15:04:23");
|
|
|
|
|
// strcpy(ulist2->valid_end_time, "2019-07-04 15:04:23");
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
|
2019-07-10 09:15:33 +00:00
|
|
|
|
// printf("%d\n", mod_user_web(ulist2));
|
|
|
|
|
|
2019-08-08 07:33:16 +00:00
|
|
|
|
char *testmodweb = "{\"type\":2, \"data\":{\"ID\": 3,\"GID\" : 5,\"uname\" : \"用户05\",\"gname\" : \"aaa07\", \"resetpwd\" : 1,\
|
|
|
|
|
\"udescription\" : \"修改用\",\"multi\" : 1,\"valid\" : 1,\"valid_begin_time\" : \"2013-07-04 15:04:23\",\"valid_end_time\" : \"2019-10-04 15:04:23\"}}";
|
2019-07-10 09:15:33 +00:00
|
|
|
|
|
|
|
|
|
char * output2;
|
|
|
|
|
output2 = malloc(50);
|
|
|
|
|
if (NULL == output2)
|
|
|
|
|
{
|
|
|
|
|
printf("ulist fail");
|
|
|
|
|
}
|
2019-08-08 07:33:16 +00:00
|
|
|
|
//printf("123 .\n");
|
2019-07-10 09:15:33 +00:00
|
|
|
|
ret_code cc = user_config_proc(1, 1, testmodweb, 1, output2, a);
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
printf("这里是个测试第二次结果,修改用户web:%d\n", cc);
|
|
|
|
|
printf("%s\n", output2);
|
|
|
|
|
printf("*******************************************************************************\n");
|
2019-08-15 09:44:52 +00:00
|
|
|
|
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
USERLIST* ulist22;
|
|
|
|
|
ulist22 = (USERLIST*)malloc(sizeof(USERLIST));
|
|
|
|
|
if (NULL == ulist22)
|
|
|
|
|
{
|
|
|
|
|
printf("ulist fail");
|
|
|
|
|
}
|
2019-08-08 07:33:16 +00:00
|
|
|
|
// get_user_by_id(id1, ulist22);
|
|
|
|
|
// printf("查找id为:%d, 用户名:%s, 用户组ID:%d,用户组名:%s,描述:%s", id1, ulist22->uname, ulist22->GID, ulist22->gname, ulist22->udescription);
|
|
|
|
|
// printf(" ,多用户登陆:%d, 永久性:%d, 开始时间:%s, 结束时间:%s", ulist22->multi, ulist22->valid, ulist22->valid_begin_time, ulist22->valid_end_time);
|
|
|
|
|
// printf("密码:%s\n", ulist22->passwd);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
//printf("内存表中的时间:%lld,%lld, mul_avil:%d", g_user_table[2].valid_begin_time, g_user_table[2].valid_end_time, g_user_table[2].multi_valid);
|
|
|
|
|
|
|
|
|
|
|
2019-08-08 07:33:16 +00:00
|
|
|
|
mod_user_line("用户06", 0, "testtest描述");
|
|
|
|
|
mod_user_line("用户06", 1, "aaa12");
|
|
|
|
|
mod_user_line("用户06", 2, "zhelishidenglumima");
|
|
|
|
|
mod_user_line("用户05", 3, "1");
|
|
|
|
|
mod_user_line("用户06", 4, "1");
|
|
|
|
|
mod_user_line("用户06", 5, "2013-03-03 15:04:23");
|
|
|
|
|
mod_user_line("用户05", 6, "2018-03-03 15:04:23");
|
|
|
|
|
mod_user_line("用户05", 7, "2020-03-03 15:04:23");
|
|
|
|
|
char *testmodline = "{\"type\":5, \"data\":{\"uname\": \"用户06\",\"attr_type\" : 6,\"attr_data\" : \"2018-03-03 15:04:23\"}}";
|
2019-07-10 09:15:33 +00:00
|
|
|
|
|
|
|
|
|
char * output3;
|
|
|
|
|
output3 = malloc(50);
|
|
|
|
|
if (NULL == output3)
|
|
|
|
|
{
|
|
|
|
|
printf("ulist fail");
|
|
|
|
|
}
|
|
|
|
|
ret_code ccc = user_config_proc(1, 1, testmodline, 1, output3, a);
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
printf("这里是个测试第三次结果,修改用户-line:%d\n", ccc);
|
|
|
|
|
printf("%s\n", output3);
|
|
|
|
|
printf("*******************************************************************************\n");
|
2019-08-15 09:44:52 +00:00
|
|
|
|
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
2019-08-08 07:33:16 +00:00
|
|
|
|
// unsigned short id2 = 3;
|
|
|
|
|
// get_user_by_id(id2, ulist22);
|
|
|
|
|
// printf("查找id为:%d, 用户名:%s, 用户组ID:%d,用户组名:%s,描述:%s", id2, ulist22->uname, ulist22->GID, ulist22->gname, ulist22->udescription);
|
|
|
|
|
// printf(" ,多用户登陆:%d, 永久性:%d, 开始时间:%s, 结束时间:%s", ulist22->multi, ulist22->valid, ulist22->valid_begin_time, ulist22->valid_end_time);
|
|
|
|
|
// printf("密码:%s\n", ulist22->passwd);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
2019-08-08 07:33:16 +00:00
|
|
|
|
// printf("*********************************************************************************\n");
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
2019-07-12 06:43:42 +00:00
|
|
|
|
char * output4;
|
|
|
|
|
output4 = malloc(100);
|
|
|
|
|
if (NULL == output4)
|
|
|
|
|
{
|
|
|
|
|
printf("ulist fail");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *testin4 = "{\"type\": 1,\"data\":[\"用户01\", \"用户02\", \"用户04\"]}";
|
2019-07-23 02:49:58 +00:00
|
|
|
|
int a4_01 = 1;
|
|
|
|
|
int *a4 = &a4_01;;
|
2019-07-12 06:43:42 +00:00
|
|
|
|
ret_code c4 = user_config_proc(1, 1, testin4, 1, output4, a4);
|
|
|
|
|
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
printf("这里是个测试第四次结果,删除用户:%d\n", c4);
|
|
|
|
|
printf("%s\n", output4);
|
|
|
|
|
printf("*******************************************************************************\n");
|
2019-08-15 09:44:52 +00:00
|
|
|
|
|
2019-07-12 06:43:42 +00:00
|
|
|
|
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
2019-07-12 06:43:42 +00:00
|
|
|
|
char * output5;
|
|
|
|
|
output5 = malloc(100);
|
|
|
|
|
if (NULL == output5)
|
|
|
|
|
{
|
|
|
|
|
printf("ulist fail");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *testin5 = "{\"type\": 1,\"data\":[\"aaa\", \"aaa07\", \"aaa08\"]}";
|
2019-07-23 02:49:58 +00:00
|
|
|
|
int a5_01 = 1;
|
|
|
|
|
int *a5 = &a5_01;
|
2019-07-12 06:43:42 +00:00
|
|
|
|
ret_code c5 = usergroup_config_proc(1, 1, testin5, 1, output5, a5);
|
|
|
|
|
|
|
|
|
|
printf("*******************************************************************************\n");
|
2019-07-23 02:49:58 +00:00
|
|
|
|
printf("这里是个测试第五次结果,删除用户组:%d\n", c5);
|
2019-07-12 06:43:42 +00:00
|
|
|
|
printf("%s\n", output5);
|
|
|
|
|
printf("*******************************************************************************\n");
|
2019-08-15 09:44:52 +00:00
|
|
|
|
//UCHAR_FREE(output5);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
2019-07-23 09:52:43 +00:00
|
|
|
|
USER_AUTH_RET *aret;
|
2019-07-16 07:13:02 +00:00
|
|
|
|
aret = (USER_AUTH_RET*)malloc(sizeof(USER_AUTH_RET));
|
|
|
|
|
if (NULL == aret)
|
|
|
|
|
{
|
|
|
|
|
printf("111111111111");
|
|
|
|
|
}
|
|
|
|
|
time_t t1 = time(NULL);
|
|
|
|
|
|
2019-08-08 07:33:16 +00:00
|
|
|
|
user_auth_login("用户07", "12345678", aret);
|
2019-07-16 07:13:02 +00:00
|
|
|
|
printf("%d,%d,%d\n", aret->ret, aret->user_id, aret->group_id);
|
|
|
|
|
|
|
|
|
|
sleep(1);
|
|
|
|
|
t1 = time(NULL);
|
2019-07-23 09:52:43 +00:00
|
|
|
|
USER_AUTH_RET aret01;
|
|
|
|
|
user_auth_login("用户05", "zhelishidenglumima", &aret01);
|
|
|
|
|
printf("%d,%d,%d\n", aret01.ret, aret01.user_id, aret01.group_id);
|
2019-07-16 07:13:02 +00:00
|
|
|
|
|
2019-08-08 07:33:16 +00:00
|
|
|
|
// sleep(1);
|
|
|
|
|
// t1 = time(NULL);
|
|
|
|
|
// user_auth_login("用户05", "zhelishidenglumima", aret);
|
|
|
|
|
// printf("%d,%d,%d\n",aret->ret,aret->user_id,aret->group_id);
|
2019-07-16 07:13:02 +00:00
|
|
|
|
|
2019-08-08 07:33:16 +00:00
|
|
|
|
// sleep(1);
|
|
|
|
|
// t1 = time(NULL);
|
|
|
|
|
// user_auth_login("用户05", "zhelishidenglumima", aret);
|
|
|
|
|
// printf("%d,%d,%d\n", aret->ret, aret->user_id, aret->group_id);
|
2019-07-16 07:13:02 +00:00
|
|
|
|
|
2019-08-08 07:33:16 +00:00
|
|
|
|
// sleep(1);
|
|
|
|
|
// t1 = time(NULL);
|
|
|
|
|
// user_auth_login("用户05", "zhelishidenglumima", aret);
|
|
|
|
|
// printf("%d,%d,%d\n", aret->ret, aret->user_id, aret->group_id);
|
2019-07-16 07:13:02 +00:00
|
|
|
|
|
2019-08-08 07:33:16 +00:00
|
|
|
|
// sleep(1);
|
|
|
|
|
// t1 = time(NULL);
|
|
|
|
|
// user_auth_login("用户05", "zhelishidenglumima", aret);
|
|
|
|
|
// printf("%d,%d,%d\n", aret->ret, aret->user_id, aret->group_id);
|
2019-07-16 07:13:02 +00:00
|
|
|
|
|
2019-08-08 07:33:16 +00:00
|
|
|
|
// mod_user_line("用户05", 6, "2020-03-03 15:04:23");
|
|
|
|
|
// sleep(1);
|
|
|
|
|
// t1 = time(NULL);
|
|
|
|
|
// user_auth_login("用户05", "zhelishidenglumima", aret);
|
|
|
|
|
// printf("%d,%d,%d\n", aret->ret, aret->user_id, aret->group_id);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
|
|
|
|
|
2019-07-23 09:52:43 +00:00
|
|
|
|
char * output6;
|
|
|
|
|
output6 = malloc(100);
|
|
|
|
|
if (NULL == output6)
|
|
|
|
|
{
|
|
|
|
|
printf("ulist fail");
|
|
|
|
|
}
|
|
|
|
|
char *testin6 = "{\"type\": 1,\"data\":[\"用户01\", \"用户02\", \"用户04\", \"用户05\"]}";
|
|
|
|
|
int a6_01 = 1;
|
|
|
|
|
int *a6 = &a6_01;;
|
|
|
|
|
ret_code c6 = user_config_proc(1, 1, testin6, 1, output6, a6);
|
|
|
|
|
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
printf("这里是个测试第六次结果,删除用户05:%d\n", c4);
|
|
|
|
|
printf("%s\n", output6);
|
|
|
|
|
printf("*******************************************************************************\n");
|
2019-08-15 09:44:52 +00:00
|
|
|
|
//UCHAR_FREE(output6);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
2019-07-23 09:52:43 +00:00
|
|
|
|
int user_ids[3] = {1,2,4};
|
|
|
|
|
reset_online_by_userid(user_ids, 3);
|
2019-07-08 07:12:06 +00:00
|
|
|
|
|
2019-08-08 07:33:16 +00:00
|
|
|
|
void * test_hdbc;
|
|
|
|
|
|
|
|
|
|
/* 连接数据库 */
|
|
|
|
|
test_hdbc = connect_database(12);
|
|
|
|
|
if(NULL == test_hdbc)
|
|
|
|
|
{
|
|
|
|
|
printf("fall connnect database. \n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int num_sql;
|
|
|
|
|
int ret;
|
|
|
|
|
char * ret_sql = NULL;
|
|
|
|
|
char * select_sql = "SELECT U.uid, U.id FROM `user_group` U WHERE id > ?";
|
|
|
|
|
ret_sql = select_datebase_by_number(1, test_hdbc, "user_group", select_sql, 1, 20, &num_sql, 1,
|
|
|
|
|
DB_DATA_INT_TYPE, 8, 2);
|
|
|
|
|
|
|
|
|
|
printf("num_sql = %d \n", num_sql);
|
2019-08-21 10:51:54 +00:00
|
|
|
|
printf("test_hdbc = %p \n", test_hdbc);
|
2019-08-08 07:33:16 +00:00
|
|
|
|
//printf("ret_sql = %s \n",ret_sql);
|
|
|
|
|
|
|
|
|
|
/* 创建table, 其中列类型包括长整形、浮点型、字符串 */
|
|
|
|
|
//ret = create_database_table(1, test_hdbc, "ctest", "create table ctest ( id bigint, fl double, dt character(10), status character(7))");
|
|
|
|
|
|
|
|
|
|
/* 根据指定信息查询数据库的获取的结果的条目数 */
|
|
|
|
|
ret = get_select_datebase_number(1, test_hdbc, "ctest", "select * from ctest where id = '911231233333333337'", &num_sql, 0);
|
|
|
|
|
printf("num_sql = %d \n", num_sql);
|
|
|
|
|
printf("ret = %d \n", ret);
|
|
|
|
|
|
|
|
|
|
int num;
|
|
|
|
|
char * retptr = NULL;
|
|
|
|
|
retptr = select_datebase_by_number(1, test_hdbc, "user_group", " SELECT UG.id FROM user_group UG WHERE UG.gname = '用户组01'", 1, 0, &num, 0);
|
|
|
|
|
printf("user_group = %s\n", retptr);
|
|
|
|
|
|
|
|
|
|
retptr = select_datebase_by_number(1, test_hdbc, "user_account", " SELECT * FROM user_account WHERE id = 4", 1, 0, &num, 0);
|
|
|
|
|
printf("user_group = %s\n", retptr);
|
|
|
|
|
|
|
|
|
|
char *usergrouname = "test17";
|
|
|
|
|
num = update_database(1, test_hdbc, DB_OP_INSERT, "user_group", "INSERT INTO user_group SET id = ?, gname = ? ", 2,
|
|
|
|
|
DB_DATA_INT_TYPE, 4, 26,
|
|
|
|
|
DB_DATA_STRING_TYPE, strlen(usergrouname), usergrouname);
|
|
|
|
|
printf("insert user_group ret = %d \n", num);
|
|
|
|
|
|
|
|
|
|
num = update_database(1, test_hdbc, DB_OP_DEL, "user_group", "DELETE FROM user_group WHERE gname = ? ", 1,
|
|
|
|
|
DB_DATA_STRING_TYPE, 10, "用户组03");
|
|
|
|
|
printf("delete user_group ret = %d \n", num);
|
|
|
|
|
|
|
|
|
|
num = update_database(1, test_hdbc, DB_OP_UPDATE, "user_group", "UPDATE user_group SET gdescription = ? WHERE gname = ? ", 2,
|
|
|
|
|
DB_DATA_STRING_TYPE, 10, "z111111111111111111",
|
|
|
|
|
DB_DATA_STRING_TYPE, 10, "test04");
|
|
|
|
|
printf("update user_group ret = %d \n", num);
|
|
|
|
|
|
|
|
|
|
// num = update_database(1, test_hdbc, 1, "user_account",
|
|
|
|
|
// "INSERT INTO user_account SET id = ?, group_id = ?, user_name = ?", 3,
|
|
|
|
|
// DB_DATA_INT_TYPE, 4, 9,
|
|
|
|
|
// DB_DATA_INT_TYPE, 4, 3,
|
|
|
|
|
// DB_DATA_STRING_TYPE, 10, "test01");
|
|
|
|
|
// printf("insert user01 ret = %d \n", num);
|
|
|
|
|
|
|
|
|
|
// num = update_database(1, test_hdbc, 1, "user_account",
|
|
|
|
|
// "INSERT INTO user_account SET id = 8, group_id = 12, user_name = 'test02' ", 0);
|
|
|
|
|
// printf("insert user02 ret = %d \n", num);
|
|
|
|
|
|
|
|
|
|
// num = update_database(1, test_hdbc, 1, "user_group",
|
|
|
|
|
// "INSERT INTO user_group SET id = ?, gname = ?", 2,
|
|
|
|
|
// DB_DATA_INT_TYPE, 4, 10,
|
|
|
|
|
// DB_DATA_STRING_TYPE, 10, "test04");
|
|
|
|
|
// printf("insert user_group ret = %d \n", num);
|
|
|
|
|
|
|
|
|
|
// ret = update_database(1, test_hdbc, 1, "ctest", "insert into ctest values(?, ?, ?, '30' )", 3,
|
|
|
|
|
// DB_DATA_INT_TYPE, 4, 91123123333333333,
|
|
|
|
|
// DB_DATA_FLOAT_TYPE, 8, 11111111.555555555,
|
|
|
|
|
// DB_DATA_STRING_TYPE, 4, "TEMP");
|
|
|
|
|
// printf("insert ret = %d \n", ret);
|
|
|
|
|
ret = disconnect_database(1, test_hdbc);
|
|
|
|
|
|
2019-08-15 09:44:52 +00:00
|
|
|
|
/* char * output7;
|
|
|
|
|
output7 = malloc(100);
|
|
|
|
|
if (NULL == output7)
|
|
|
|
|
{
|
|
|
|
|
printf("ulist fail");
|
|
|
|
|
}
|
|
|
|
|
char *testin7 = "{\"type\": 4,\"data\":{\"group_id\": 0, \"user_name\": \"户\",\"page_start\": 1,\"page_counts\": 10}}";
|
|
|
|
|
int a7_01 = 1;
|
|
|
|
|
int *a7 = &a7_01;;
|
|
|
|
|
ret_code c7 = user_config_proc(1, 1, testin7, strlen(testin7)+1, output7, a7);
|
|
|
|
|
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
printf("这里是个测试第7次结果,查询:%d\n", c7);
|
|
|
|
|
printf("%s\n", output7);
|
|
|
|
|
printf("*******************************************************************************\n");
|
|
|
|
|
UCHAR_FREE(output7);
|
|
|
|
|
*/
|
2019-07-08 07:12:06 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|