64 lines
1.2 KiB
C++
64 lines
1.2 KiB
C++
#include "bs_util.h"
|
|
#include <vector>
|
|
using namespace std;
|
|
|
|
|
|
int main()
|
|
{
|
|
Request req;
|
|
Session se(req);
|
|
Response res;
|
|
json j;
|
|
|
|
auto jsonfail=[&](int errcode,const std::string& dtl="")
|
|
{
|
|
jsonfail_func(j,errcode,dtl);
|
|
};
|
|
|
|
do
|
|
{
|
|
if(!se.isReady())
|
|
{
|
|
jsonfail(err_session);
|
|
break;
|
|
}
|
|
|
|
if(se.getUser().empty())
|
|
{
|
|
jsonfail(err_need_login);
|
|
break;
|
|
}
|
|
|
|
if(req.requestMethod!="POST")
|
|
{
|
|
jsonfail(err_method_not_supported);
|
|
break;
|
|
}
|
|
|
|
startdb();
|
|
|
|
if(conn.exec("select book_type from bs_booktype",
|
|
[&](MySQLResult& res)
|
|
{
|
|
res.stepRow([&](char** val,unsigned long* len)
|
|
{
|
|
j["result"].push_back(string(len[0]>0?val[0]:""));
|
|
});
|
|
})<0)
|
|
{
|
|
jsonfail(err_sql,"Step 1");
|
|
break;
|
|
}
|
|
|
|
j["success"]=1;
|
|
}
|
|
while(0);
|
|
|
|
se.writeToResponse(res);
|
|
res.content.append(j.dump());
|
|
|
|
return 0;
|
|
}
|
|
|
|
|