mirror of
https://github.com/mgerb/classic-wow-forums
synced 2026-01-11 17:42:48 +00:00
lots of things done: thread - reply - category - seeds
This commit is contained in:
16
lib/myapp_web/controllers/category_controller.ex
Normal file
16
lib/myapp_web/controllers/category_controller.ex
Normal file
@@ -0,0 +1,16 @@
|
||||
defmodule MyAppWeb.CategoryController do
|
||||
use MyAppWeb, :controller
|
||||
alias MyAppWeb.Response
|
||||
alias MyApp.Data
|
||||
|
||||
@spec get_collection(map, map) :: any
|
||||
def get_collection(conn, _params) do
|
||||
|
||||
output = Data.Category.get_categories()
|
||||
|
||||
conn
|
||||
|> put_status(200)
|
||||
|> Response.json(output)
|
||||
end
|
||||
|
||||
end
|
||||
22
lib/myapp_web/controllers/reply_controller.ex
Normal file
22
lib/myapp_web/controllers/reply_controller.ex
Normal file
@@ -0,0 +1,22 @@
|
||||
defmodule MyAppWeb.ReplyController do
|
||||
use MyAppWeb, :controller
|
||||
alias MyAppWeb.Response
|
||||
alias MyApp.Data
|
||||
|
||||
@spec insert(map, map) :: any
|
||||
def insert(conn, params) do
|
||||
user_id = conn
|
||||
|> MyApp.Guardian.Plug.current_claims
|
||||
|> Map.get("id")
|
||||
|
||||
{output, status} = params
|
||||
|> Map.put("user_id", user_id)
|
||||
|> Data.Reply.insert_reply
|
||||
|> Response.put_resp
|
||||
|
||||
conn
|
||||
|> put_status(status)
|
||||
|> Response.json(output)
|
||||
end
|
||||
|
||||
end
|
||||
38
lib/myapp_web/controllers/thread_controller.ex
Normal file
38
lib/myapp_web/controllers/thread_controller.ex
Normal file
@@ -0,0 +1,38 @@
|
||||
defmodule MyAppWeb.ThreadController do
|
||||
use MyAppWeb, :controller
|
||||
alias MyAppWeb.Response
|
||||
alias MyApp.Data
|
||||
|
||||
@spec insert(map, map) :: any
|
||||
def insert(conn, params) do
|
||||
user_id = conn
|
||||
|> MyApp.Guardian.Plug.current_claims
|
||||
|> Map.get("id")
|
||||
|
||||
{output, status} = params
|
||||
|> Map.put("user_id", user_id)
|
||||
|> Data.Thread.insert_thread
|
||||
|> Response.put_resp
|
||||
|
||||
conn
|
||||
|> put_status(status)
|
||||
|> Response.json(output)
|
||||
end
|
||||
|
||||
@spec update(map, map) :: any
|
||||
def update(conn, params) do
|
||||
user_id = conn
|
||||
|> MyApp.Guardian.Plug.current_claims
|
||||
|> Map.get("id")
|
||||
|
||||
{output, status} = params
|
||||
|> Map.put("user_id", user_id)
|
||||
|> Data.Thread.update_thread
|
||||
|> Response.put_resp
|
||||
|
||||
conn
|
||||
|> put_status(status)
|
||||
|> Response.json(output)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user