Files
TJWaterServer/script/sql/api/api.sql
2022-10-09 23:25:31 +08:00

38 lines
737 B
PL/PgSQL

drop function if exists execute_command;
drop function if exists execute_update;
create function execute_update(cs jsonb) returns jsonb as
$$
declare
begin
assert cs->>'operation' = 'update';
case cs->>'type'
when 'title' then
return update_title(cs);
else
return '{}'::jsonb;
end case;
end;
$$
language plpgsql;
create function execute_command(cs jsonb) returns jsonb as
$$
declare
begin
case cs->>'operation'
when 'add' then
return '{}'::jsonb;
when 'update' then
return execute_update(cs);
when 'delete' then
return '{}'::jsonb;
else
return '{}'::jsonb;
end case;
end;
$$
language plpgsql;