85 行
1.4 KiB
C++
85 行
1.4 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
namespace csp::domain {
|
|
|
|
// Notes:
|
|
// - All *_at fields use Unix timestamp seconds (int64).
|
|
// - id fields match SQLite INTEGER PRIMARY KEY AUTOINCREMENT (int64).
|
|
|
|
struct User {
|
|
int64_t id = 0;
|
|
std::string username;
|
|
std::string password_salt;
|
|
std::string password_hash;
|
|
int32_t rating = 0;
|
|
int64_t created_at = 0;
|
|
};
|
|
|
|
struct Session {
|
|
std::string token; // PK
|
|
int64_t user_id = 0;
|
|
int64_t expires_at = 0;
|
|
int64_t created_at = 0;
|
|
};
|
|
|
|
struct Problem {
|
|
int64_t id = 0;
|
|
std::string slug;
|
|
std::string title;
|
|
std::string statement_md;
|
|
int32_t difficulty = 1;
|
|
std::string source;
|
|
int64_t created_at = 0;
|
|
};
|
|
|
|
struct ProblemTag {
|
|
int64_t problem_id = 0;
|
|
std::string tag;
|
|
};
|
|
|
|
enum class SubmissionStatus {
|
|
Pending,
|
|
Compiling,
|
|
Running,
|
|
AC,
|
|
WA,
|
|
TLE,
|
|
MLE,
|
|
RE,
|
|
CE,
|
|
Unknown,
|
|
};
|
|
|
|
// MVP: only C++ is supported.
|
|
enum class Language {
|
|
Cpp,
|
|
Unknown,
|
|
};
|
|
|
|
struct Submission {
|
|
int64_t id = 0;
|
|
int64_t user_id = 0;
|
|
int64_t problem_id = 0;
|
|
Language language = Language::Cpp;
|
|
std::string code;
|
|
SubmissionStatus status = SubmissionStatus::Pending;
|
|
int32_t score = 0;
|
|
int32_t time_ms = 0;
|
|
int32_t memory_kb = 0;
|
|
int64_t created_at = 0;
|
|
};
|
|
|
|
struct WrongBookItem {
|
|
int64_t user_id = 0;
|
|
int64_t problem_id = 0;
|
|
std::optional<int64_t> last_submission_id;
|
|
std::string note;
|
|
int64_t updated_at = 0;
|
|
};
|
|
|
|
} // namespace csp::domain
|