Add endpoint for fetching all jobs
This commit is contained in:
parent
1eec816111
commit
c3566944cd
5 changed files with 30 additions and 3 deletions
6
app/controllers/api/v1/jobs_controller.rb
Normal file
6
app/controllers/api/v1/jobs_controller.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
class Api::V1::JobsController < Api::V1::ApiController
|
||||||
|
def all
|
||||||
|
@jobs = Job.all()
|
||||||
|
render :all, status: :ok
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
class Job < ApplicationRecord
|
class Job < ApplicationRecord
|
||||||
belongs_to :party
|
belongs_to :party
|
||||||
|
|
||||||
def display_resource(class)
|
def display_resource(job)
|
||||||
class.name_en
|
job.name_en
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
3
app/views/api/v1/jobs/all.json.rabl
Normal file
3
app/views/api/v1/jobs/all.json.rabl
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
collection @jobs, object_root: false
|
||||||
|
|
||||||
|
extends 'jobs/base'
|
||||||
17
app/views/api/v1/jobs/base.json.rabl
Normal file
17
app/views/api/v1/jobs/base.json.rabl
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
object :job
|
||||||
|
|
||||||
|
attributes :id, :row, :ml, :order
|
||||||
|
|
||||||
|
node :name do |j|
|
||||||
|
{
|
||||||
|
:en => j.name_en,
|
||||||
|
:ja => j.name_jp
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
node :proficiency do |j|
|
||||||
|
[
|
||||||
|
j.proficiency1,
|
||||||
|
j.proficiency2
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
@ -26,6 +26,7 @@ Rails.application.routes.draw do
|
||||||
post 'search/weapons', to: 'search#weapons'
|
post 'search/weapons', to: 'search#weapons'
|
||||||
post 'search/summons', to: 'search#summons'
|
post 'search/summons', to: 'search#summons'
|
||||||
|
|
||||||
|
get 'jobs', to: 'jobs#all'
|
||||||
get 'raids', to: 'raids#all'
|
get 'raids', to: 'raids#all'
|
||||||
get 'weapon_keys', to: 'weapon_keys#all'
|
get 'weapon_keys', to: 'weapon_keys#all'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue