42 行
780 B
C++
42 行
780 B
C++
#pragma once
|
|
|
|
#include "csp/db/sqlite_db.h"
|
|
#include "csp/domain/entities.h"
|
|
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace csp::services {
|
|
|
|
struct ProblemQuery {
|
|
std::string q;
|
|
std::string tag;
|
|
std::vector<std::string> tags;
|
|
std::string source_prefix;
|
|
int difficulty = 0;
|
|
int page = 1;
|
|
int page_size = 20;
|
|
std::string order_by = "id";
|
|
std::string order = "asc";
|
|
};
|
|
|
|
struct ProblemListResult {
|
|
std::vector<domain::Problem> items;
|
|
int total_count = 0;
|
|
};
|
|
|
|
class ProblemService {
|
|
public:
|
|
explicit ProblemService(db::SqliteDb& db) : db_(db) {}
|
|
|
|
ProblemListResult List(const ProblemQuery& query);
|
|
std::optional<domain::Problem> GetById(int64_t id);
|
|
|
|
private:
|
|
db::SqliteDb& db_;
|
|
};
|
|
|
|
} // namespace csp::services
|