api: add update endpoints for characters, weapons, and summons
Add PATCH/PUT update actions to all three entity controllers with editor role authorization. Routes updated to include :update action. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
29cb276a2a
commit
707c0436c5
4 changed files with 39 additions and 9 deletions
|
|
@ -5,8 +5,8 @@ module Api
|
|||
class CharactersController < Api::V1::ApiController
|
||||
include IdResolvable
|
||||
|
||||
before_action :set, only: %i[show related download_images download_status]
|
||||
before_action :ensure_editor_role, only: %i[create validate download_images]
|
||||
before_action :set, only: %i[show related download_images download_status update]
|
||||
before_action :ensure_editor_role, only: %i[create update validate download_images]
|
||||
|
||||
# GET /characters/:id
|
||||
def show
|
||||
|
|
@ -34,6 +34,16 @@ module Api
|
|||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /characters/:id
|
||||
# Updates an existing character record
|
||||
def update
|
||||
if @character.update(character_params)
|
||||
render json: CharacterBlueprint.render(@character, view: :full)
|
||||
else
|
||||
render_validation_error_response(@character)
|
||||
end
|
||||
end
|
||||
|
||||
# GET /characters/validate/:granblue_id
|
||||
# Validates that a granblue_id has accessible images on Granblue servers
|
||||
def validate
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ module Api
|
|||
class SummonsController < Api::V1::ApiController
|
||||
include IdResolvable
|
||||
|
||||
before_action :set, only: %i[show download_images download_status]
|
||||
before_action :ensure_editor_role, only: %i[create validate download_images]
|
||||
before_action :set, only: %i[show download_images download_status update]
|
||||
before_action :ensure_editor_role, only: %i[create update validate download_images]
|
||||
|
||||
# GET /summons/:id
|
||||
def show
|
||||
|
|
@ -25,6 +25,16 @@ module Api
|
|||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /summons/:id
|
||||
# Updates an existing summon record
|
||||
def update
|
||||
if @summon.update(summon_params)
|
||||
render json: SummonBlueprint.render(@summon, view: :full)
|
||||
else
|
||||
render_validation_error_response(@summon)
|
||||
end
|
||||
end
|
||||
|
||||
# GET /summons/validate/:granblue_id
|
||||
# Validates that a granblue_id has accessible images on Granblue servers
|
||||
def validate
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ module Api
|
|||
class WeaponsController < Api::V1::ApiController
|
||||
include IdResolvable
|
||||
|
||||
before_action :set, only: %i[show download_images download_status]
|
||||
before_action :ensure_editor_role, only: %i[create validate download_images]
|
||||
before_action :set, only: %i[show download_images download_status update]
|
||||
before_action :ensure_editor_role, only: %i[create update validate download_images]
|
||||
|
||||
# GET /weapons/:id
|
||||
def show
|
||||
|
|
@ -25,6 +25,16 @@ module Api
|
|||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /weapons/:id
|
||||
# Updates an existing weapon record
|
||||
def update
|
||||
if @weapon.update(weapon_params)
|
||||
render json: WeaponBlueprint.render(@weapon, view: :full)
|
||||
else
|
||||
render_validation_error_response(@weapon)
|
||||
end
|
||||
end
|
||||
|
||||
# GET /weapons/validate/:granblue_id
|
||||
# Validates that a granblue_id has accessible images on Granblue servers
|
||||
def validate
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ Rails.application.routes.draw do
|
|||
resources :grid_weapons, only: %i[create update destroy]
|
||||
resources :grid_characters, only: %i[create update destroy]
|
||||
resources :grid_summons, only: %i[create update destroy]
|
||||
resources :weapons, only: %i[show create] do
|
||||
resources :weapons, only: %i[show create update] do
|
||||
collection do
|
||||
get 'validate/:granblue_id', action: :validate, as: :validate
|
||||
end
|
||||
|
|
@ -21,7 +21,7 @@ Rails.application.routes.draw do
|
|||
get 'download_status'
|
||||
end
|
||||
end
|
||||
resources :characters, only: %i[show create] do
|
||||
resources :characters, only: %i[show create update] do
|
||||
collection do
|
||||
get 'validate/:granblue_id', action: :validate, as: :validate
|
||||
end
|
||||
|
|
@ -30,7 +30,7 @@ Rails.application.routes.draw do
|
|||
get 'download_status'
|
||||
end
|
||||
end
|
||||
resources :summons, only: %i[show create] do
|
||||
resources :summons, only: %i[show create update] do
|
||||
collection do
|
||||
get 'validate/:granblue_id', action: :validate, as: :validate
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue