From 0f03f943f9190541b354a2a84ef4c9e05b4c7302 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Tue, 4 Jul 2023 11:22:36 -0400 Subject: [PATCH] Parents suggested list --- wrenchboard/src/include/wrenchboard_api.h | 1 + wrenchboard/src/shared_tool/family_acc.cc | 65 ++++++++++++++++++++++- www-api/app/Config/Constants.php | 1 + www-api/app/Config/Routes.php | 1 + www-api/app/Controllers/WrenchApi.php | 4 ++ www-api/app/Models/ResultFormatter.php | 4 +- 6 files changed, 74 insertions(+), 2 deletions(-) diff --git a/wrenchboard/src/include/wrenchboard_api.h b/wrenchboard/src/include/wrenchboard_api.h index 3683986d..12806543 100644 --- a/wrenchboard/src/include/wrenchboard_api.h +++ b/wrenchboard/src/include/wrenchboard_api.h @@ -312,6 +312,7 @@ enum { PARTNER_STRIPE }; #define WRENCHBOARD_FAMILY_SAMPLETASKS 22027 #define WRENCHBOARD_FAMILY_SGGESTTASKS 22028 #define WRENCHBOARD_FAMILY_SGGESTLIST 22029 +#define WRENCHBOARD_FAMILY_SGGESTWAITING 22030 #define WRENCHBOARD_FAMILY_END 22999 //************************************************************** diff --git a/wrenchboard/src/shared_tool/family_acc.cc b/wrenchboard/src/shared_tool/family_acc.cc index 0f0436d8..5d29872a 100644 --- a/wrenchboard/src/shared_tool/family_acc.cc +++ b/wrenchboard/src/shared_tool/family_acc.cc @@ -24,6 +24,7 @@ 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 WrenchSuggestWaitingList(CVars in, CVars &out); long family_calls(CVars in, CVars &out){ logfmt(logINFO, "family_calls()"); @@ -65,11 +66,73 @@ long family_calls(CVars in, CVars &out){ logfmt(logINFO, "ENTER CALL long WRENCHBOARD_FAMILY_SGGESTLIST"); return WrenchSuggestList(in, out); break; - +//long WrenchSuggestWaitingList(CVars in, CVars &out) + case WRENCHBOARD_FAMILY_SGGESTWAITING: + logfmt(logINFO, "ENTER CALL long WRENCHBOARD_FAMILY_SGGESTWAITING"); + return WrenchSuggestWaitingList(in, out); // this now the parent + break; } return 0; } + +long WrenchSuggestWaitingList(CVars in, CVars &out){ // this is the parent now + logfmt(logINFO, "ENTER CALL long WrenchSuggestWaitingList"); + 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 AND 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++) { + mapf = 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), "family_uid_%05d", i); + out[vname] = rec["family_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), "status_%05d", i); + out[vname] = rec["status"]; + + } + } + ret = PHP_API_OK; + out["status"] = "OK"; + + } catch (bad_parameter) { + logfmt(logINFO, "ERROR CALL long WrenchSuggestWaitingList"); + } + + logfmt(logINFO, "WrenchSuggestList()"); + return ret; +} + long WrenchSuggestList(CVars in, CVars &out){ logfmt(logINFO, "ENTER CALL long WrenchSuggestList"); char vname[30]; diff --git a/www-api/app/Config/Constants.php b/www-api/app/Config/Constants.php index b86eb8a2..37d75b5d 100644 --- a/www-api/app/Config/Constants.php +++ b/www-api/app/Config/Constants.php @@ -299,6 +299,7 @@ define('WRENCHBOARD_FAMILY_MANAGE', 22025); define('WRENCHBOARD_FAMILY_SAMPLETASKS', 22027); define('WRENCHBOARD_FAMILY_SGGESTTASKS', 22028); define('WRENCHBOARD_FAMILY_SGGESTLIST', 22029); +define('WRENCHBOARD_FAMILY_SGGESTWAITING', 22030); define('WRENCHBOARD_SMONEY_ADDRECIPIENT', 33010); define('WRENCHBOARD_SMONEY_MEMBER', 33020); diff --git a/www-api/app/Config/Routes.php b/www-api/app/Config/Routes.php index e38268e4..46f06852 100644 --- a/www-api/app/Config/Routes.php +++ b/www-api/app/Config/Routes.php @@ -101,6 +101,7 @@ $routes->post('/en/wrench/api/v1/familymanage', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/familysampletasks', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/familysuggesttasks', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/familysuggestlist', 'WrenchApi::apigate'); +$routes->post('/en/wrench/api/v1/familywaitingtasks', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/recipients', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/addrecipient', 'WrenchApi::apigate'); diff --git a/www-api/app/Controllers/WrenchApi.php b/www-api/app/Controllers/WrenchApi.php index b4af70e9..72d9b8c5 100644 --- a/www-api/app/Controllers/WrenchApi.php +++ b/www-api/app/Controllers/WrenchApi.php @@ -119,6 +119,7 @@ class WrenchApi extends BaseController 'familysampletasks' => ['POST'], 'familysuggesttasks' => ['POST'], 'familysuggestlist' => ['POST'], + 'familywaitingtasks' => ['POST'], ]; return $endpoints; } @@ -186,6 +187,9 @@ class WrenchApi extends BaseController case 'familysuggesttasks': $in["action"] = WRENCHBOARD_FAMILY_SGGESTTASKS; break; + case 'familywaitingtasks': + $in["action"] = WRENCHBOARD_FAMILY_SGGESTWAITING; + break; case 'familysuggestlist': $in["action"] = WRENCHBOARD_FAMILY_SGGESTLIST; break; diff --git a/www-api/app/Models/ResultFormatter.php b/www-api/app/Models/ResultFormatter.php index c3d13611..f6a98086 100644 --- a/www-api/app/Models/ResultFormatter.php +++ b/www-api/app/Models/ResultFormatter.php @@ -83,6 +83,7 @@ class ResultFormatter extends Model // id AS coupon_id, ca.code, ca.amount, ca.added::date,ca.status switch ($in["action"]) { case WRENCHBOARD_FAMILY_SGGESTLIST: + case WRENCHBOARD_FAMILY_SGGESTWAITING: $total = $out["total_record"]; $res = array( "status" => $out["status"], @@ -94,6 +95,7 @@ class ResultFormatter extends Model $key = sprintf("%05d", $i); $res["result_list"][] = array( "uid" => $out["uid_${key}"], + "family_uid" => $out["family_uid_${key}"], "description" => $out["description_${key}"], "title" => $out["title_${key}"], "added" => $out["added_${key}"], @@ -676,7 +678,7 @@ class ResultFormatter extends Model 'CT1'=>'Writings & Translations', 'CT2'=>'Marketing & Promotions', 'CT3'=>'Errands', - 'CT4'=>'Category 4', + 'CT4'=>'Others', ); } public function getBlogData(){