Get API
This commit is contained in:
@@ -20,6 +20,7 @@ long WrenchPromoLoad(CVars in, CVars &out);
|
||||
long WrenchPromoAdminLogin(CVars in, CVars &out);
|
||||
long WrenchPromoAddList(CVars in, CVars &out);
|
||||
long WrenchPromoGetList( CVars in, CVars &out );
|
||||
long WrenchPromoGetMember( CVars in, CVars &out );
|
||||
|
||||
long market_calls(CVars in, CVars &out) {
|
||||
logfmt(logINFO, "market_calls()");
|
||||
@@ -48,6 +49,9 @@ long market_calls(CVars in, CVars &out) {
|
||||
case WRENCHBOARD_PROMOADMIN_GETLIST:
|
||||
return WrenchPromoGetList(in, out);
|
||||
break;
|
||||
case WRENCHBOARD_PROMOADMIN_GETMEMBER:
|
||||
return WrenchPromoGetMember(in, out);
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (bad_parameter) {
|
||||
@@ -57,6 +61,51 @@ long market_calls(CVars in, CVars &out) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
long WrenchPromoGetMember( CVars in, CVars &out )
|
||||
{
|
||||
char vname[30];
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
|
||||
logfmt( logINFO, "WrenchPromoGetList()" );
|
||||
out["result"] = "Yes i go to this back end";
|
||||
|
||||
try {
|
||||
long admin_id = REQ_LONG(in, "promo_admin_id", 1, -1);
|
||||
REQ_STRING (in, "admin_uid", 5, 120, "(.*)");
|
||||
REQ_STRING (in, "mebmer_uid", 5, 120, "(.*)");
|
||||
OPTIONAL( in, "loc" ) REQ_STRING (in, "loc", 3, 15, "(.*)");
|
||||
|
||||
|
||||
|
||||
const PGresult *res;
|
||||
res = pgsql_query("SELECT count(id) FROM promo_member WHERE admin_id = %lu", admin_id);
|
||||
out["sum_total_record"] = pgsql_num_rows(res);
|
||||
|
||||
res = pgsql_query("SELECT * FROM promo_member"
|
||||
" WHERE admin_id = %lu AND uis = '%s' ",admin_id,in["mebmer_uid"].c_str());
|
||||
|
||||
if (res != NULL && pgsql_num_rows(res) > 0) {
|
||||
out["total_record"] = pgsql_num_rows(res);
|
||||
|
||||
for (int i = 0, n = pgsql_num_rows(res); i < n; i++) {
|
||||
map<const char*, const char*>f = pgsql_fetch_assoc(res, i);
|
||||
if (f.empty()) continue;
|
||||
CVars rec;
|
||||
map_to_cvars(f, rec);
|
||||
out = rec;
|
||||
}
|
||||
}
|
||||
ret = PHP_API_OK;
|
||||
out["status"] = "OK";
|
||||
} catch (bad_parameter) {
|
||||
logfmt(logINFO, "ERROR CALL long WrenchPromoGetMember(CVars in, CVars &out)");
|
||||
}
|
||||
|
||||
logfmt( logINFO, "/WrenchPromoGetMember()" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
long WrenchPromoGetList( CVars in, CVars &out )
|
||||
{
|
||||
char vname[30];
|
||||
|
||||
Reference in New Issue
Block a user