24 lines
892 B
Ruby
24 lines
892 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
|
|
params ={"pm_project_id":"17", "issue_id":"4279", "id":3117}
|
|
@links = PmLink.where(be_linkable_id: @issue.id, be_linkable_type: 'Issue', linkable_id: params[:id], linkable_type: 'Issue').or(PmLink.where(linkable_id: @issue.id, linkable_type: 'Issue', be_linkable_id: params[:id], be_linkable_type: 'Issue'))
|
|
@link =@links.last
|
|
if @link.try(:destroy)
|
|
render_ok
|
|
else
|
|
render_error('删除失败!')
|
|
end
|
|
end
|
|
end
|