|
|
|
|
|
|
|
|
api_v1_GET_documents_id => \&api_v1_GET_documents_id, |
|
|
api_v1_GET_documents_id => \&api_v1_GET_documents_id, |
|
|
api_v1_GET_pages_id => \&api_v1_GET_pages_id, |
|
|
api_v1_GET_pages_id => \&api_v1_GET_pages_id, |
|
|
api_v1_PATCH_documents_id => \&api_v1_PATCH_documents_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(); |
|
|
my $request = FCGI::Request(); |
|
|
|
|
|
|
|
|
return (200); |
|
|
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 { |
|
|
sub get_array { |
|
|
my($x) = @_; |
|
|
my($x) = @_; |
|
|
my @arr; |
|
|
my @arr; |