Quellcode durchsuchen

backend tag handling

master
Pascal Gloor vor 5 Jahren
Ursprung
Commit
66f9e7fdd7
2 geänderte Dateien mit 41 neuen und 1 gelöschten Zeilen
  1. 40
    0
      cgi/autodoc.fcgi
  2. 1
    1
      etc/openapi.json

+ 40
- 0
cgi/autodoc.fcgi Datei anzeigen

@@ -24,6 +24,10 @@ my %map = (
api_v1_GET_documents_id => \&api_v1_GET_documents_id,
api_v1_GET_pages_id => \&api_v1_GET_pages_id,
api_v1_PATCH_documents_id => \&api_v1_PATCH_documents_id,
api_v1_GET_tags => \&api_v1_GET_tags,
api_v1_POST_tags => \&api_v1_POST_tags,
api_v1_PATCH_tags_id => \&api_v1_PATCH_tags_id,
api_v1_DELETE_tags_id => \&api_v1_DELETE_tags_id
);

my $request = FCGI::Request();
@@ -435,6 +439,42 @@ sub api_v1_PATCH_documents_id {
return (200);
}

# handle tags
sub api_v1_GET_tags {
my($id, $qs, $post, $user) = @_;
my @tags;
my $q = sqlquery($dbh, "SELECT * FROM tags ORDER by tag DESC");
while(my $h = $q->fetchrow_array()) {
push @tags, {
id => $h->{id},
name => $h->{tag},
color => $h->{color}
}
}
return (200, undef, "application/json", \@tags);
}
sub api_v1_POST_tags {
my($id, $qs, $post, $user) = @_;

sqlquery($dbh, "INSERT INTO tags SET id=UUID(), tag=?, color=?", $qs->{tagName}, $qs->{tagColor});

return (200);
}
sub api_v1_PATCH_tags_id {
my($id, $qs, $post, $user) = @_;

sqlquery($dbh, "UPDATE tags SET tag=?, color=? WHERE id=?", $qs->{tagName}, $qs->{tagColor}, $id);
return (200);
}
sub api_v1_DELETE_tags_id {
my($id, $qs, $post, $user) = @_;

sqlquery($dbh, "DELETE FROM tags WHERE id=?", $id);
return (200);
}


sub get_array {
my($x) = @_;
my @arr;

+ 1
- 1
etc/openapi.json Datei anzeigen

@@ -225,7 +225,7 @@
"parameters": [
{
"name": "tagName",
"in":"query",
"in": "query",
"required": true,
"schema": {
"type": "string"

Laden…
Abbrechen
Speichern