diff options
-rw-r--r-- | src/guff/api-methods.cr | 12 | ||||
-rw-r--r-- | src/guff/model.cr | 4 | ||||
-rw-r--r-- | src/guff/models.cr | 2 | ||||
-rw-r--r-- | src/guff/post-model.cr | 19 |
4 files changed, 28 insertions, 9 deletions
diff --git a/src/guff/api-methods.cr b/src/guff/api-methods.cr index 6cc3087..f0df8bc 100644 --- a/src/guff/api-methods.cr +++ b/src/guff/api-methods.cr @@ -321,32 +321,28 @@ module Guff context : HTTP::Server::Context, args : Hash(String, String) ) - # TODO - [{foo: "bar"}, {foo: "asdf"}].to_json + @models.post.get_posts(args).to_json end private def do_post_add_post( context : HTTP::Server::Context, args : Hash(String, String) ) - # TODO: return post id - {ok: true}.to_json + @models.post.add_post(args).to_json end private def do_post_remove_posts( context : HTTP::Server::Context, args : Hash(String, String) ) - # TODO - {ok: true}.to_json + @models.post.remove_posts(args).to_json end private def do_post_set_tags( context : HTTP::Server::Context, args : Hash(String, String) ) - # TODO - {ok: true}.to_json + @models.post.set_tags(args).to_json end ############### diff --git a/src/guff/model.cr b/src/guff/model.cr index 823d33b..ce24427 100644 --- a/src/guff/model.cr +++ b/src/guff/model.cr @@ -2,5 +2,9 @@ module Guff class Model def initialize(@models : Models) end + + def db + @models.db + end end end diff --git a/src/guff/models.cr b/src/guff/models.cr index 7962c73..631be8d 100644 --- a/src/guff/models.cr +++ b/src/guff/models.cr @@ -4,7 +4,7 @@ require "./database-updater" private macro define_model_getters(hash) {% for name, klass in hash %} def {{ name.id }} - @cache[name] ||= {{ klass.id }}.new(self) + @cache[{{ name }}] ||= {{ klass.id }}.new(self) end {% end %} end diff --git a/src/guff/post-model.cr b/src/guff/post-model.cr index 20ccf22..e0e82a4 100644 --- a/src/guff/post-model.cr +++ b/src/guff/post-model.cr @@ -1,4 +1,23 @@ module Guff class PostModel < Model + def get_posts(req) + # TODO + [{foo: "bar"}, {foo: "asdf"}] + end + + def add_post(req) + # TODO: return post id + {ok: true} + end + + def remove_posts(req) + # TODO + {ok: true} + end + + def set_tags(req) + # TODO + {ok: true} + end end end |