diff --git a/wrenchboard/src/include/history.h b/wrenchboard/src/include/history.h index 07dc65d3..8e168bb3 100644 --- a/wrenchboard/src/include/history.h +++ b/wrenchboard/src/include/history.h @@ -5,4 +5,6 @@ long WrenchPurchaseHx( CVars in, CVars &out ); long WrenchRefferHx( CVars in, CVars &out ); +long WrenchMyFilesList( CVars in, CVars &out ); + #endif \ No newline at end of file diff --git a/wrenchboard/src/include/wrenchboard_api.h b/wrenchboard/src/include/wrenchboard_api.h index a1b6646f..5c96b937 100644 --- a/wrenchboard/src/include/wrenchboard_api.h +++ b/wrenchboard/src/include/wrenchboard_api.h @@ -241,6 +241,7 @@ enum { PARTNER_STRIPE }; #define WRENCHBOARD_ACCOUNT_DASHRECENT 11206 #define WRENCHBOARD_RESOURCE_MYFILES 11307 +#define WRENCHBOARD_MYFILES_LIST 11309 #define WRENCHBOARD_USER_DELETEACC 11990 #define WRENCHBOARD_ACCOUNT_END 11999 diff --git a/wrenchboard/src/shared_tool/account.cc b/wrenchboard/src/shared_tool/account.cc index 52b9b081..94beb2e1 100644 --- a/wrenchboard/src/shared_tool/account.cc +++ b/wrenchboard/src/shared_tool/account.cc @@ -480,6 +480,11 @@ long account_calls(CVars in, CVars &out) { case WRENCHBOARD_RESOURCE_MYFILES: return WrenchRegisterMyFileUpload(in, out); break; + + case WRENCHBOARD_MYFILES_LIST: + return WrenchMyFilesList(in, out); + break; + } logfmt(logINFO, "/account_calls()"); return ret; diff --git a/wrenchboard/src/shared_tool/history.cc b/wrenchboard/src/shared_tool/history.cc index 853c26ad..5d3ee82a 100644 --- a/wrenchboard/src/shared_tool/history.cc +++ b/wrenchboard/src/shared_tool/history.cc @@ -14,6 +14,88 @@ #include "cfg.h" #include +/* +CREATE TABLE members_myfiles ( + id SERIAL, + member_id INT REFERENCES members(id) NOT NULL, + uid uuid DEFAULT uuid_generate_v4(), + file_name VARCHAR(35), + saved_file_name VARCHAR(35) UNIQUE NOT NULL, + file_size INT DEFAULT 0, + file_type VARCHAR(15), + title VARCHAR(35), + description VARCHAR(100), + status INT DEFAULT 1, + added timestamp without time zone DEFAULT now(), + updated timestamp without time zone DEFAULT now() + ); + ALTER TABLE ONLY members_myfiles + ADD CONSTRAINT members_myfiles_id_key UNIQUE (id); +*/ +long WrenchMyFilesList( CVars in, CVars &out ) +{ + char vname[30]; + long ret = PHP_API_BAD_PARAM; + + logfmt( logINFO, "WrenchMyFilesList()" ); + out["result"] = "Yes i go to this back end"; + + try { + long member_id = REQ_LONG( in, "member_id", 1, -1 ); + long limit = REQ_LONG( in, "limit", 1, -1 ); + REQ_LONG( in, "page", 1, -1 ); + REQ_STRING (in, "uid", 10, 100, "(.*)"); + + out["total_record"] = "0"; + const PGresult *res; + res = pgsql_query("SELECT * FROM members_myfiles " + "WHERE member_id = %lu AND status = 1 ORDER BY id DESC LIMIT %lu",member_id,limit); + + 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), "added_%05d", i); + out[vname] = rec["added"]; + + snprintf(vname, sizeof (vname), "description_%05d", i); + out[vname] = rec["description"]; + + snprintf(vname, sizeof (vname), "title_%05d", i); + out[vname] = rec["title"]; + + snprintf(vname, sizeof (vname), "file_type_%05d", i); + out[vname] = rec["file_type"]; + + snprintf(vname, sizeof (vname), "file_size_%05d", i); + out[vname] = rec["file_size"]; + + // snprintf(vname, sizeof (vname), "confirmation_%05d", i); + // out[vname] = rec["confirmation"]; + + // snprintf(vname, sizeof (vname), "id_%05d", i); + // out[vname] = rec["id"]; + + snprintf(vname, sizeof (vname), "file_uid_%05d", i); + out[vname] = rec["uid"]; + + } + } + ret = PHP_API_OK; + out["status"] = "OK"; + } catch (bad_parameter) { + logfmt(logINFO, "ERROR CALL long WrenchMyFilesList(CVars in, CVars &out)"); + } + + logfmt( logINFO, "/WrenchMyFilesList()" ); + return 0; +} + long WrenchPurchaseHx( CVars in, CVars &out ) { diff --git a/www-api/app/Config/Constants.php b/www-api/app/Config/Constants.php index 5ded6610..151ff896 100644 --- a/www-api/app/Config/Constants.php +++ b/www-api/app/Config/Constants.php @@ -256,6 +256,7 @@ define('WRENCHBOARD_PICTURE_PROFILE', 11300); define('WRENCHBOARD_PICTURE_FAMMEMBER',11305); const WRENCHBOARD_RESOURCE_MYFILES = 11307; +const WRENCHBOARD_MYFILES_LIST = 11309; define('WRENCHBOARD_USER_DELETEACC', 11990); define('WRENCHBOARD_ACCOUNT_END', 11999); diff --git a/www-api/app/Config/Routes.php b/www-api/app/Config/Routes.php index 376b81c8..c10fc1ba 100644 --- a/www-api/app/Config/Routes.php +++ b/www-api/app/Config/Routes.php @@ -151,6 +151,7 @@ $routes->post('/en/wrench/api/v1/pendingjobcancel', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/assigntask', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/uploads', 'WrenchApi::apigate'); +$routes->post('/en/wrench/api/v1/myfiles', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/marketmessage', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/marketinterest', 'WrenchApi::apigate'); diff --git a/www-api/app/Controllers/WrenchApi.php b/www-api/app/Controllers/WrenchApi.php index 2e5fc822..7dbab946 100644 --- a/www-api/app/Controllers/WrenchApi.php +++ b/www-api/app/Controllers/WrenchApi.php @@ -19,6 +19,9 @@ class WrenchApi extends BaseController } private function prepareEndPointData($endpoint, $in, &$call_backend=true,&$local_out=[]){ switch ($endpoint) { + case 'myfiles': + $in["action"] = WRENCHBOARD_MYFILES_LIST; + break; case 'setaccsettings': $in["action"] = WRENCHBOARD_USER_SETTINGS; break;