list data

This commit is contained in:
CHIEFSOFT\ameye
2023-07-03 17:17:20 -04:00
parent 6b4b28d163
commit 4504042ae2
+57 -8
View File
@@ -23,6 +23,7 @@ long WrenchFamilyUpdate(CVars in, CVars &out);
long WrenchFamilyManage(CVars in, CVars &out);
long WrenchSampleTasks(CVars in, CVars &out);
long WrenchSuggestTasks(CVars in, CVars &out);
long WrenchSuggestList(CVars in, CVars &out);
long family_calls(CVars in, CVars &out){
logfmt(logINFO, "family_calls()");
@@ -62,19 +63,67 @@ long family_calls(CVars in, CVars &out){
case WRENCHBOARD_FAMILY_SGGESTLIST:
logfmt(logINFO, "ENTER CALL long WRENCHBOARD_FAMILY_SGGESTLIST");
return WrenchSuggestList(in, out);
break;
}
return 0;
}
/*
'member_id' => int 188
'sessionid' => string '2620D99AC6E222F1C68A98BC77DC3B28410FC62AE129FA4148FB38196F09305E' (length=64)
'uid' => string '745db27f-db41-4045-a9a8-6c2a4abceea7' (length=36)
'title' => string 'This is the job title 8564 job title' (length=36)
'description' => string 'This is the job description 5790 job description' (length=48)
'action' => int 13010
*/
long WrenchSuggestList(CVars in, CVars &out){
logfmt(logINFO, "ENTER CALL long WrenchSuggestList");
char vname[30];
long ret = PHP_API_BAD_PARAM;
const PGresult *res;
try{
long member_id = REQ_LONG(in, "member_id", 1, -1);
long offset = REQ_LONG(in, "offset", 1, -1);
long limit = REQ_LONG(in, "limit", 1, -1);
out["total_record"] = "0";
// res = pgsql_query("SELECT id FROM family_task_suggestion WHERE status=1 ");
// out["total_record"] = pgsql_num_rows(res);
res = pgsql_query(" SELECT * FROM members_family_suggesttask WHERE member_id = %lu status IN ( 1,2,3,4,5) "
" ORDER BY created DESC LIMIT %lu OFFSET %lu", member_id, limit, offset);
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);
snprintf(vname, sizeof (vname), "uid_%05d", i);
out[vname] = rec["uid"];
snprintf(vname, sizeof (vname), "title_%05d", i);
out[vname] = rec["title"];
snprintf(vname, sizeof (vname), "description_%05d", i);
out[vname] = rec["description"];
snprintf(vname, sizeof (vname), "added_%05d", i);
out[vname] = rec["created"];
snprintf(vname, sizeof (vname), "banner_%05d", i);
out[vname] = rec["banner"];
}
}
ret = PHP_API_OK;
out["status"] = "OK";
} catch (bad_parameter) {
logfmt(logINFO, "ERROR CALL long WrenchSuggestList");
}
logfmt(logINFO, "WrenchSuggestList()");
return ret;
}
long WrenchSuggestTasks(CVars in, CVars &out){
long ret = PHP_API_BAD_PARAM;