ORE Studio 0.0.4
Loading...
Searching...
No Matches
business_centre_service.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_REFDATA_CORE_SERVICE_BUSINESS_CENTRE_SERVICE_HPP
21#define ORES_REFDATA_CORE_SERVICE_BUSINESS_CENTRE_SERVICE_HPP
22
23#include <string>
24#include <vector>
25#include <optional>
26#include "ores.database/domain/context.hpp"
27#include "ores.refdata.api/domain/business_centre.hpp"
28#include "ores.refdata.core/repository/business_centre_repository.hpp"
29#include "ores.logging/make_logger.hpp"
30
31namespace ores::refdata::service {
32
40private:
41 inline static std::string_view logger_name =
42 "ores.refdata.service.business_centre_service";
43
44 [[nodiscard]] static auto& lg() {
45 using namespace ores::logging;
46 static auto instance = make_logger(logger_name);
47 return instance;
48 }
49
50public:
52
56 explicit business_centre_service(context ctx);
57
61 std::vector<domain::business_centre> list_business_centres(
62 std::uint32_t offset, std::uint32_t limit);
63
67 std::uint32_t count_business_centres();
68
73
78 const std::vector<domain::business_centre>& business_centres);
79
83 void delete_business_centre(const std::string& code);
84
88 void delete_business_centres(const std::vector<std::string>& codes);
89
93 std::optional<domain::business_centre>
94 get_business_centre(const std::string& code);
95
99 std::vector<domain::business_centre>
100 get_business_centre_history(const std::string& code);
101
102private:
103 context ctx_;
105};
106
107}
108
109#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Context for the operations on a postgres database.
Definition context.hpp:47
Represents a business centre using FpML-style codes.
Definition business_centre.hpp:37
Reads and writes business centres off of data storage.
Definition business_centre_repository.hpp:35
Service for managing business centres.
Definition business_centre_service.hpp:39
std::optional< domain::business_centre > get_business_centre(const std::string &code)
Retrieves a single business centre by its code.
Definition business_centre_service.cpp:81
std::vector< domain::business_centre > get_business_centre_history(const std::string &code)
Retrieves all historical versions of a business centre.
Definition business_centre_service.cpp:91
void save_business_centres(const std::vector< domain::business_centre > &business_centres)
Saves a batch of business centres.
Definition business_centre_service.cpp:58
void delete_business_centres(const std::vector< std::string > &codes)
Deletes business centres by their codes.
Definition business_centre_service.cpp:76
std::vector< domain::business_centre > list_business_centres(std::uint32_t offset, std::uint32_t limit)
Lists business centres with pagination support.
Definition business_centre_service.cpp:35
void delete_business_centre(const std::string &code)
Deletes a business centre by its code.
Definition business_centre_service.cpp:71
void save_business_centre(const domain::business_centre &bc)
Saves a business centre (creates or updates).
Definition business_centre_service.cpp:47
std::uint32_t count_business_centres()
Gets the total count of active business centres.
Definition business_centre_service.cpp:42