22 lines
645 B
Ruby
22 lines
645 B
Ruby
class Api::Pm::IssueLinksController < Api::Pm::BaseController
|
|
before_action :load_project
|
|
before_action :load_issue
|
|
def index
|
|
@links = PmLink.where(be_linkable_id: @issue.id,be_linkable_type: 'Issue').or(PmLink.where(linkable_id: @issue.id,linkable_type: 'Issue'))
|
|
end
|
|
|
|
def create
|
|
params[:link_ids].map { |e| @issue.pm_links.find_or_create_by(be_linkable_type: 'Issue', be_linkable_id: e) }
|
|
render_ok
|
|
end
|
|
|
|
def destroy
|
|
@link = @issue.pm_links.find_by(be_linkable_type: 'Issue', be_linkable_id: params[:id])
|
|
if @link.try(:destroy)
|
|
render_ok
|
|
else
|
|
render_error('删除失败!')
|
|
end
|
|
end
|
|
end
|