u
This commit is contained in:
16
jtlsrv-cpp/src/endpoints/customer.cpp
Normal file
16
jtlsrv-cpp/src/endpoints/customer.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "../http.hpp"
|
||||
#include "../tls_server.hpp"
|
||||
#include "../router.hpp"
|
||||
#include "../queries/customer_list.hpp"
|
||||
#include "../queries/shop.hpp"
|
||||
|
||||
void handle_customer(HttpRequest& req, HttpResponse& resp, RouteContext& /*ctx*/) {
|
||||
int64_t cursor = req.get_query_int64("lastChangedCustomer");
|
||||
int limit = req.get_query_int("limit", 20);
|
||||
int shop = get_active_shop_id();
|
||||
int subshop = get_active_shop_subshop_id();
|
||||
int64_t max_last_changed = get_active_max_last_changed();
|
||||
|
||||
auto customers = get_customer_list(cursor, limit, shop, subshop, max_last_changed);
|
||||
resp.send_json(200, customers);
|
||||
}
|
||||
@@ -10,23 +10,26 @@
|
||||
void handle_init(HttpRequest& req, HttpResponse& resp, RouteContext& /*ctx*/) {
|
||||
int64_t product_cursor = req.get_query_int64("lastChangedProduct");
|
||||
int64_t category_cursor = req.get_query_int64("lastChangedCategory");
|
||||
int64_t customer_cursor = req.get_query_int64("lastChangedCustomer");
|
||||
int64_t cg_cursor = req.get_query_int64("lastChangedCustomerGroup");
|
||||
int64_t composite_cursor = req.get_query_int64("lastChangedCompositeProduct");
|
||||
int64_t deleted_cursor = req.get_query_int64("lastChangedDeletedEntity");
|
||||
|
||||
int root = config::get_int("ROOT_CATEGORY_ID", 1);
|
||||
int shop = get_active_shop_id();
|
||||
int subshop = get_active_shop_subshop_id();
|
||||
|
||||
int64_t product_count = 0, category_count = 0, cg_count = 0, composite_count = 0, deleted_count = 0;
|
||||
int64_t product_count = 0, category_count = 0, customer_count = 0, cg_count = 0, composite_count = 0, deleted_count = 0;
|
||||
int64_t max_order_id_count = 0;
|
||||
|
||||
if (get_pool().execute_scalar("SELECT 1") != 0) {
|
||||
product_count = get_product_count(root, shop, product_cursor);
|
||||
category_count = get_category_count(root, shop, category_cursor);
|
||||
customer_count = get_customer_count(shop, subshop, customer_cursor);
|
||||
cg_count = get_customer_group_count(cg_cursor);
|
||||
composite_count = get_composite_count(shop, composite_cursor);
|
||||
deleted_count = get_deleted_count(deleted_cursor);
|
||||
max_order_id_count = get_max_order_id_count(get_active_shop_subshop_id());
|
||||
max_order_id_count = get_max_order_id_count(subshop);
|
||||
if (product_cursor == 0 && category_cursor == 0 &&
|
||||
product_count == 0 && category_count == 0 && deleted_count == 0) {
|
||||
logc::warn("init: all counts zero with cursors at 0 — check DB connectivity and shop/category config");
|
||||
@@ -39,7 +42,7 @@ void handle_init(HttpRequest& req, HttpResponse& resp, RouteContext& /*ctx*/) {
|
||||
{"version", "1.10.12.0"},
|
||||
{"product_count", std::to_string(product_count)},
|
||||
{"category_count", std::to_string(category_count)},
|
||||
{"customer_count", "0"},
|
||||
{"customer_count", std::to_string(customer_count)},
|
||||
{"customerGroup_count", std::to_string(cg_count)},
|
||||
{"compositeProduct_count", std::to_string(composite_count)},
|
||||
{"configurationGroup_count", "0"},
|
||||
|
||||
Reference in New Issue
Block a user