Избавление от undefined, всем необязательным полям присваиваются дефолтные значения #22
This commit is contained in:
@@ -101,8 +101,12 @@ update_report(Req) ->
|
||||
ReportId = cowboy_req:binding(id, Req1),
|
||||
{ok, Body, Req2} = cowboy_req:read_body(Req1),
|
||||
try jsx:decode(Body, [return_maps]) of
|
||||
#{<<"status">> := Status} ->
|
||||
case logic_report:update_report_status(AdminId, ReportId, Status) of
|
||||
#{<<"status">> := StatusBin} ->
|
||||
% Преобразуем бинарный статус в атом
|
||||
StatusAtom = try binary_to_existing_atom(StatusBin, utf8)
|
||||
catch _:_ -> StatusBin
|
||||
end,
|
||||
case logic_report:update_report_status(AdminId, ReportId, StatusAtom) of
|
||||
{ok, Report} ->
|
||||
% Аудит изменения статуса жалобы
|
||||
admin_utils:log_admin_action(AdminId, <<"update_report_status">>, <<"report">>, ReportId, Req2),
|
||||
|
||||
Reference in New Issue
Block a user