164 lines
5.7 KiB
Erlang
164 lines
5.7 KiB
Erlang
%% ===================================================================
|
|
%% EventHub Records Definition
|
|
%% ===================================================================
|
|
|
|
%% ------------------- Пользователи и аутентификация -------------------
|
|
-record(user, {
|
|
id :: binary(),
|
|
email :: binary(),
|
|
password_hash :: binary(),
|
|
role :: user | admin,
|
|
status :: active | frozen | deleted,
|
|
created_at :: calendar:datetime(),
|
|
updated_at :: calendar:datetime()
|
|
}).
|
|
|
|
-record(session, {
|
|
token :: binary(), % JWT или refresh токен
|
|
user_id :: binary(),
|
|
expires_at :: calendar:datetime(),
|
|
type :: access | refresh
|
|
}).
|
|
|
|
%% ------------------- Календари ---------------------------------------
|
|
-record(calendar, {
|
|
id :: binary(),
|
|
owner_id :: binary(),
|
|
title :: binary(),
|
|
description :: binary(),
|
|
tags :: [binary()],
|
|
type :: personal | commercial,
|
|
confirmation :: auto | manual | {timeout, integer()}, % секунд
|
|
rating_avg :: float(),
|
|
rating_count :: non_neg_integer(),
|
|
status :: active | frozen | deleted,
|
|
created_at :: calendar:datetime(),
|
|
updated_at :: calendar:datetime()
|
|
}).
|
|
|
|
-record(calendar_share, {
|
|
calendar_id :: binary(),
|
|
user_id :: binary(),
|
|
rights :: read | write | admin
|
|
}).
|
|
|
|
-record(location, {
|
|
address :: binary(),
|
|
lat :: float(),
|
|
lon :: float()
|
|
}).
|
|
|
|
%% ------------------- События (включая повторяющиеся) ----------------
|
|
-record(event, {
|
|
id :: binary(),
|
|
calendar_id :: binary(),
|
|
title :: binary(),
|
|
description :: binary(),
|
|
event_type :: single | recurring,
|
|
start_time :: calendar:datetime(),
|
|
duration :: integer(), % минуты
|
|
recurrence_rule :: binary() | undefined,
|
|
master_id :: binary() | undefined,
|
|
is_instance :: boolean(),
|
|
specialist_id :: binary() | undefined,
|
|
location :: #location{} | undefined,
|
|
tags :: [binary()],
|
|
capacity :: integer() | undefined,
|
|
online_link :: binary() | undefined,
|
|
status :: active | cancelled | completed,
|
|
rating_avg :: float(),
|
|
rating_count :: non_neg_integer(),
|
|
created_at :: calendar:datetime(),
|
|
updated_at :: calendar:datetime()
|
|
}).
|
|
|
|
-record(recurrence_exception, {
|
|
master_id :: binary(),
|
|
original_start :: calendar:datetime(),
|
|
action :: cancel | reschedule,
|
|
new_start :: calendar:datetime() | undefined
|
|
}).
|
|
|
|
%% ------------------- Бронирования ------------------------------------
|
|
-record(booking, {
|
|
id :: binary(),
|
|
event_id :: binary(), % ссылка на конкретный экземпляр события
|
|
user_id :: binary(),
|
|
status :: pending | confirmed | cancelled,
|
|
confirmed_at :: calendar:datetime() | undefined,
|
|
created_at :: calendar:datetime(),
|
|
updated_at :: calendar:datetime()
|
|
}).
|
|
|
|
%% ------------------- Отзывы ------------------------------------------
|
|
-record(review, {
|
|
id :: binary(),
|
|
user_id :: binary(),
|
|
target_type :: calendar | event,
|
|
target_id :: binary(),
|
|
rating :: 1..5,
|
|
comment :: binary(),
|
|
status :: visible | hidden | deleted,
|
|
created_at :: calendar:datetime(),
|
|
updated_at :: calendar:datetime()
|
|
}).
|
|
|
|
%% ------------------- Жалобы и модерация ------------------------------
|
|
-record(report, {
|
|
id :: binary(),
|
|
reporter_id :: binary(),
|
|
target_type :: calendar | event | review,
|
|
target_id :: binary(),
|
|
reason :: binary(),
|
|
status :: pending | reviewed | dismissed,
|
|
created_at :: calendar:datetime(),
|
|
resolved_at :: calendar:datetime() | undefined,
|
|
resolved_by :: binary() | undefined
|
|
}).
|
|
|
|
-record(banned_word, {
|
|
id :: binary(),
|
|
word :: binary(),
|
|
added_by :: binary() | undefined, % id администратора, добавившего слово
|
|
added_at :: calendar:datetime() | undefined
|
|
}).
|
|
|
|
%% ------------------- Баг-трекер --------------------------------------
|
|
-record(ticket, {
|
|
id :: binary(),
|
|
reporter_id :: binary(),
|
|
error_hash :: binary(),
|
|
error_message :: binary(),
|
|
stacktrace :: binary(),
|
|
context :: binary(), % ← новое поле (term_to_binary)
|
|
count :: non_neg_integer(),
|
|
first_seen :: calendar:datetime(),
|
|
last_seen :: calendar:datetime(),
|
|
status :: open | in_progress | resolved | closed,
|
|
assigned_to :: binary() | undefined,
|
|
resolution_note :: binary() | undefined
|
|
}).
|
|
|
|
%% ------------------- Подписки ----------------------------------------
|
|
-record(subscription, {
|
|
id :: binary(),
|
|
user_id :: binary(),
|
|
plan :: monthly | quarterly | biannual | annual,
|
|
status :: active | expired | cancelled,
|
|
trial_used :: boolean(),
|
|
started_at :: calendar:datetime(),
|
|
expires_at :: calendar:datetime(),
|
|
created_at :: calendar:datetime(),
|
|
updated_at :: calendar:datetime()
|
|
}).
|
|
|
|
%% ------------------- Аудит -------------------------------------------
|
|
-record(audit_log, {
|
|
id :: binary(),
|
|
admin_id :: binary(),
|
|
action :: binary(),
|
|
target_type :: binary() | undefined,
|
|
target_id :: binary() | undefined,
|
|
details :: binary() | undefined,
|
|
created_at :: calendar:datetime()
|
|
}). |