Раздел api Календари #22
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
-module(core_calendar).
|
||||
-include("records.hrl").
|
||||
-export([create/4, create/5, get_by_id/1, list_by_owner/1, update/2, delete/1]).
|
||||
-export([count_calendars/0]).
|
||||
-export([count_calendars/0, list_all/0]).
|
||||
-export([freeze/2, unfreeze/2]). % ← новые функции
|
||||
|
||||
%% Создание календаря
|
||||
@@ -86,6 +86,13 @@ delete(Id) ->
|
||||
count_calendars() ->
|
||||
mnesia:table_info(calendar, size).
|
||||
|
||||
-spec list_all() -> [#calendar{}].
|
||||
list_all() ->
|
||||
{atomic, Calendars} = mnesia:transaction(fun() ->
|
||||
mnesia:foldl(fun(C, Acc) -> [C | Acc] end, [], calendar)
|
||||
end),
|
||||
Calendars.
|
||||
|
||||
%% ── НОВЫЕ ФУНКЦИИ ──────────────────────────────────────────
|
||||
freeze(Id, Reason) ->
|
||||
update(Id, [{status, frozen}, {reason, Reason}]).
|
||||
@@ -101,11 +108,16 @@ apply_updates(Calendar, Updates) ->
|
||||
|
||||
set_field(title, Value, C) -> C#calendar{title = Value};
|
||||
set_field(description, Value, C) -> C#calendar{description = Value};
|
||||
set_field(short_name, Value, C) -> C#calendar{short_name = Value};
|
||||
set_field(category, Value, C) -> C#calendar{category = Value};
|
||||
set_field(color, Value, C) -> C#calendar{color = Value};
|
||||
set_field(image_url, Value, C) -> C#calendar{image_url = Value};
|
||||
set_field(settings, Value, C) -> C#calendar{settings = Value};
|
||||
set_field(tags, Value, C) -> C#calendar{tags = Value};
|
||||
set_field(type, Value, C) -> C#calendar{type = Value};
|
||||
set_field(confirmation, Value, C) -> C#calendar{confirmation = Value};
|
||||
set_field(status, Value, C) -> C#calendar{status = Value};
|
||||
set_field(rating_avg, Value, C) -> C#calendar{rating_avg = Value};
|
||||
set_field(rating_count, Value, C) -> C#calendar{rating_count = Value};
|
||||
set_field(reason, Value, C) -> C#calendar{reason = Value}; % ← поддержка поля reason
|
||||
set_field(reason, Value, C) -> C#calendar{reason = Value};
|
||||
set_field(_, _, C) -> C.
|
||||
Reference in New Issue
Block a user