本文整理汇总了C++中Admin::getId方法的典型用法代码示例。如果您正苦于以下问题:C++ Admin::getId方法的具体用法?C++ Admin::getId怎么用?C++ Admin::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Admin
的用法示例。
在下文中一共展示了Admin::getId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addAdmin
/**
* return 103;//管理员添加成功
* return 104;//管理员添加失败
* return 105;//管理员添加失败:ID重复
*/
int AdminService::addAdmin(Admin admin){
string sql="insert into admin(a_id,a_name,a_psd,a_priority)values('"+admin.getId()+"','"
+admin.getName()+"','"+admin.getPsd()+"','"+admin.getPriority()+"')";
string sql1="update admin set a_loginState='0' where a_id='"+admin.getId()+"'";
cout<<"insert admin sql:"<<sql<<endl;
int tmp = this->SelectAdminExist(admin.getId());
if(tmp==0){
DBConn db;
if(db.Execute_mysql(sql)==0){
db.Execute_mysql(sql1); //添加成功一个admin,默认登录状况为未登录把loginState设置为“0”
db.Close_mysql();
return 103; //添加成功
}
db.Close_mysql();
return 104; //添加失败
}else{
return 105; //添加失败:ID重复
}
}
示例2: test_LogoutOperation_self
void Admintest::test_LogoutOperation_self()
{
Account_LogoutOperation_called = 0;
Operation op;
OpVector res;
Anonymous arg;
arg->setId(m_account->getId());
op->setArgs1(arg);
m_account->LogoutOperation(op, res);
ASSERT_EQUAL(res.size(), 0u);
ASSERT_EQUAL(Account_LogoutOperation_called, m_account);
}
示例3: WorkThread
void* Job::WorkThread(void* connect_fd){
int conn_fd = *(int*) connect_fd;
char buff[4096],utf8buff[4096];
int n = recv(conn_fd, buff, 4096, 0);
buff[n] = '\0';
Utils util;
util.gb2312toutf8(buff, n, utf8buff, 4096);
printf("recv msg from client: %s\n", utf8buff);
string receive(utf8buff);
Json::Reader reader;
Json::Value value;
int object;
if (reader.parse(receive, value)) {
object = value["m_object"].asInt();
}
switch(object)
{
case 0:{
Facility fac;
FacilityService fs;
fac=fs.GetParasFRomJson(receive);
if(fac.getOp()==SELECT_ALL_FACILITY){
string res=fs.SelectAll();
send(conn_fd, res.c_str(), (unsigned int) strlen(res.c_str()), 0);
}else if(fac.getOp()==SELECT_SINGLE_FACILITY){
string res=fs.SelectSignle(fac.getFacilityId());
send(conn_fd, res.c_str(), (unsigned int) strlen(res.c_str()), 0);
}else if(fac.getOp()==ADD_FACILITY){
int res=fs.Add(fac);
char buff[20];memset(buff,0,20);
sprintf(buff,"%d",res);
send(conn_fd, buff, 26, 0);
}else if(fac.getOp()==DELETE_FACILITY){
int res=fs.DeleteSignle(fac.getFacilityId());
char buff[20];memset(buff,0,20);
sprintf(buff,"%d",res);
send(conn_fd, buff, 26, 0);
}else if(fac.getOp()==UPDATE_FACILITY){
int res=fs.Update(fac);
char buff[20];memset(buff,0,20);
sprintf(buff,"%d",res);
send(conn_fd, buff, 26, 0);
}else if(fac.getOp()==UPDATE_FACILITY_FOR_ROOM){
int res=fs.UpdateForRoom(fac.getFacilityId(),fac.getMeetroomId());
char buff[20];memset(buff,0,20);
sprintf(buff,"%d",res);
send(conn_fd, buff, 26, 0);
}
}
break;
case 1:
{
User user;
UserService us;
user=us.GetParasFRomJson(receive);
if(user.getOp()==SELECT_ALL_USER){
string res=us.SelectAll();
send(conn_fd, res.c_str(), (unsigned int) strlen(res.c_str()), 0);
}else if(user.getOp()==SELECT_SINGLE_USER){
string res=us.SelectSignle(user.getId());
send(conn_fd, res.c_str(), (unsigned int) strlen(res.c_str()), 0);
}else if(user.getOp()==UPDATE_USER){
int res=us.Update(user);
char buff[20];memset(buff,0,20);
sprintf(buff,"%d",res);
send(conn_fd,buff, 26, 0);
}else if(user.getOp()==DELETE_USER){
int res=us.DeleteSignle(user.getId());
char buff[20];memset(buff,0,20);
sprintf(buff,"%d",res);
send(conn_fd, buff, 26, 0);
}else if(user.getOp()==ADD_USER){
int res=us.Add(user);
char buff[20];memset(buff,0,20);
sprintf(buff,"%d",res);
send(conn_fd, buff, 26, 0);
}
}
break;
case 2:
{
AdminService as;
Admin admin;
admin=as.GetParasFRomJson(receive);
if(admin.getOp()==LOGIN){
char buff[20];memset(buff,0,20);
int res=as.LoginSys(admin.getId(),admin.getPsd());
sprintf(buff,"%d",res);
send(conn_fd, buff, 26, 0);//重复
}
}
break;
case 3:{
MeetroomService mrs;
Meetroom mr;
mr=mrs.GetParasFRomJson(receive);
if(mr.getOp()==SELECT_ALL_MEETROOM){
string res=mrs.SelectAll();
//.........这里部分代码省略.........
示例4: updateAdmin
/**
* return 108;//管理员更新成功
* return 109;//管理员更新失败
*/
int AdminService::updateAdmin(Admin admin){
string sql = "update admin set a_name='"+ admin.getName() + "',a_psd='" + admin.getPsd() + "',a_priority='"+ admin.getPriority() +"' where u_id='"+admin.getId()+"'";
cout<<"AdminService::updateAdmin ---- update sql="<<sql<<endl;
DBConn db;
if(db.Execute_mysql(sql)==0){
db.Close_mysql();
return 108;
}else{
db.Close_mysql();
return 109;
}
}
示例5: AddAdmin
int AdminService::AddAdmin(Admin admin){
string sql="insert into admin(a_id,a_name,a_psd,a_priority)values('"+admin.getId()+"','"+admin.getName()+"','"+admin.getPsd()+"','"+admin.getPriority()+"')";
}
示例6: WorkThread
void* Job::WorkThread(void* connect_fd){
cout << "connect..." << endl;
int conn_fd = *(int*) connect_fd;
char buff[4096],utf8buff[4096];
int n = recv(conn_fd, buff, 4096, 0);
buff[n] = '\0';
printf("recv msg from client: %s\n", buff);
Utils util;
util.gb2312toutf8(buff, n, utf8buff, 4096);
printf("recv msg from client: %s\n", utf8buff);
string receive(utf8buff);
Json::Reader reader;
Json::Value value;
int object;
if (reader.parse(receive, value)) {
object = value["m_object"].asInt();
cout<<"object="<<object<<endl;
}
switch(object)
{
case 0:{
Facility fac;
FacilityService fs;
fac=fs.GetParasFRomJson(receive);
if(fac.getOp()=="selectFacility"){
string res=fs.SelectAll();
send(conn_fd, res.c_str(), (unsigned int) strlen(res.c_str()), 0);
cout<<"the selectFacility res is :"<<res<<endl;
}else if(fac.getOp()=="selectSFacility"){
string res=fs.SelectSignle(fac.getFacilityId());
send(conn_fd, res.c_str(), (unsigned int) strlen(res.c_str()), 0);
cout<<"the selectSFacility res is :"<<res<<endl;
}else if(fac.getOp()=="addFacility"){
int res=fs.Add(fac);
char buff[20];
memset(buff,0,20);
sprintf(buff,"%d",res);
send(conn_fd, buff, 26, 0);
cout<<"the addFacility res is :"<<res<<endl;
}else if(fac.getOp()=="deleteFacility"){
int res=fs.DeleteSignle(fac.getFacilityId());
}
}
break;
case 1:
{
User user;
UserService us;
user=us.GetParasFRomJson(receive);
if(user.getOp()==SELECT_ALL_USER){
string res=us.SelectAll();
cout<<"i'm in the Job res="<<res<<endl;
send(conn_fd, res.c_str(), (unsigned int) strlen(res.c_str()), 0);
}else if(user.getOp()==SELECT_SINGLE_USER){
string res=us.SelectSignle(user.getId());
send(conn_fd, res.c_str(), (unsigned int) strlen(res.c_str()), 0);
}else if(user.getOp()==UPDATE_USER){
if(us.Update(user)==0){
send(conn_fd, "300", 26, 0);
}else{
send(conn_fd, "301", 26, 0);
}
}else if(user.getOp()==DELETE_USER){
int res=us.DeleteSignle(user.getId());
char buff[20];
memset(buff,0,20);
sprintf(buff,"%d",res);
send(conn_fd, buff, 26, 0);
}else if(user.getOp()==ADD_USER){
int res=us.Add(user);
char buff[20];
memset(buff,0,20);
sprintf(buff,"%d",res);
send(conn_fd, buff, 26, 0);
}
}
break;
/*
* 超级管理员:权限为1
*
*/
case 2:
{
AdminService as;
Admin admin;
string loginId;
admin=as.GetParasFRomJson(receive);
loginId =admin.getLoginId(); //拿到目前登录状态的管理员的id
string info= "对不起,您不是超级管理员,没有权限!";
if(admin.getOp()==LOGIN){
cout<<"i'm in the login, admin_id = "<<admin.getOp()<<endl;
char buff[20];
memset(buff,0,20);
int res = as.LoginSys(admin.getId(),admin.getPsd());
sprintf(buff,"%d",res);
send(conn_fd, buff,strlen(buff), 0);//重复
}else if(admin.getOp()==ADD_ADMIN){
//.........这里部分代码省略.........