251 lines
8.4 KiB
Erlang
251 lines
8.4 KiB
Erlang
%% ===================================================================
|
|
%% EventHub Records Definition
|
|
%% ===================================================================
|
|
|
|
%% ------------------- Пользователи и аутентификация -------------------
|
|
-record(user, {
|
|
id :: binary(),
|
|
email :: binary(),
|
|
password_hash :: binary(),
|
|
role :: user | bot,
|
|
status :: active | frozen | deleted,
|
|
reason :: binary(),
|
|
nickname :: binary(),
|
|
avatar_url :: binary() | default,
|
|
timezone :: binary(),
|
|
language :: binary(),
|
|
social_links :: [binary()],
|
|
phone :: binary(),
|
|
preferences :: map(),
|
|
last_login :: calendar:datetime(),
|
|
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(admin, {
|
|
id :: binary(),
|
|
email :: binary(),
|
|
password_hash :: binary(),
|
|
role :: superadmin | admin | moderator | support,
|
|
status :: active | blocked,
|
|
nickname :: binary(),
|
|
avatar_url :: binary() | default,
|
|
timezone :: binary(),
|
|
language :: binary(),
|
|
phone :: binary(),
|
|
preferences :: map(),
|
|
last_login :: calendar:datetime(),
|
|
created_at :: calendar:datetime(),
|
|
updated_at :: calendar:datetime()
|
|
}).
|
|
|
|
%% ------------------- СЕССИИ АДМИНИСТРАТОРОВ ---------------------------
|
|
-record(admin_session, {
|
|
token :: binary(),
|
|
admin_id :: binary(),
|
|
expires_at :: calendar:datetime(),
|
|
type :: refresh
|
|
}).
|
|
|
|
%% ------------------- Календари ---------------------------------------
|
|
-record(calendar, {
|
|
id :: binary(),
|
|
owner_id :: binary(),
|
|
title :: binary(),
|
|
description :: binary(),
|
|
short_name :: binary(),
|
|
category :: binary(),
|
|
color :: binary(),
|
|
image_url :: binary(),
|
|
settings :: map(),
|
|
tags :: [binary()],
|
|
type :: personal | commercial,
|
|
confirmation :: auto | manual | {timeout, integer()}, % секунд
|
|
rating_avg :: float(),
|
|
rating_count :: non_neg_integer(),
|
|
status :: active | frozen | deleted,
|
|
reason :: binary(),
|
|
created_at :: calendar:datetime(),
|
|
updated_at :: calendar:datetime()
|
|
}).
|
|
|
|
-record(calendar_share, {
|
|
calendar_id :: binary(),
|
|
user_id :: binary(),
|
|
rights :: read | write | admin
|
|
}).
|
|
|
|
%% ------------------- Специалисты календаря ---------------------------
|
|
-record(calendar_specialist, {
|
|
calendar_id :: binary(),
|
|
user_id :: binary(), % id пользователя-специалиста
|
|
name :: binary(), % отображаемое имя в этом календаре
|
|
specialization :: [binary()], % список специализаций (услуг)
|
|
status :: active | inactive,
|
|
added_at :: calendar:datetime(),
|
|
updated_at :: calendar:datetime()
|
|
}).
|
|
|
|
-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(),
|
|
master_id :: binary(),
|
|
is_instance :: boolean(),
|
|
specialist_id :: binary(),
|
|
location :: #location{},
|
|
tags :: [binary()],
|
|
capacity :: integer(),
|
|
online_link :: binary(),
|
|
status :: active | cancelled | completed,
|
|
reason :: binary(),
|
|
rating_avg :: float(),
|
|
rating_count :: non_neg_integer(),
|
|
attachments :: [binary()],
|
|
edit_history :: [map()],
|
|
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()
|
|
}).
|
|
|
|
%% ------------------- Бронирования ------------------------------------
|
|
-record(booking, {
|
|
id :: binary(),
|
|
event_id :: binary(), % ссылка на конкретный экземпляр события
|
|
user_id :: binary(),
|
|
status :: pending | confirmed | cancelled,
|
|
notes :: binary(),
|
|
reminder_sent :: boolean(),
|
|
confirmed_at :: calendar:datetime(),
|
|
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,
|
|
reason :: binary(),
|
|
likes :: non_neg_integer(),
|
|
dislikes :: non_neg_integer(),
|
|
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(),
|
|
resolved_by :: binary()
|
|
}).
|
|
|
|
-record(banned_word, {
|
|
id :: binary(),
|
|
word :: binary(),
|
|
added_by :: binary(), % id администратора, добавившего слово
|
|
added_at :: calendar:datetime()
|
|
}).
|
|
|
|
%% ------------------- Баг-трекер --------------------------------------
|
|
-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(),
|
|
resolution_note :: binary()
|
|
}).
|
|
|
|
%% ------------------- Подписки ----------------------------------------
|
|
-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(admin_audit, {
|
|
id :: binary(),
|
|
admin_id :: binary(),
|
|
email :: binary(),
|
|
role :: atom(),
|
|
action :: binary(),
|
|
entity_type :: binary(),
|
|
entity_id :: binary(),
|
|
timestamp :: calendar:datetime(),
|
|
ip :: binary(),
|
|
reason :: binary()
|
|
}).
|
|
|
|
%% ------------------- Уведомления ------------------------
|
|
-record(notification, {
|
|
id :: binary(),
|
|
user_id :: binary(),
|
|
type :: booking_confirmed | event_reminder | event_cancelled | custom,
|
|
title :: binary(),
|
|
body :: binary(),
|
|
is_read :: boolean(),
|
|
created_at :: calendar:datetime()
|
|
}).
|
|
|
|
-record(stats, {
|
|
id :: binary(),
|
|
metric :: atom(),
|
|
entity_id :: binary(),
|
|
value :: integer() | {integer(), integer()},
|
|
timestamp :: calendar:datetime()
|
|
}).
|
|
|
|
-record(schema_migration, {
|
|
version :: string(),
|
|
applied_at :: calendar:datetime()
|
|
}). |