新增:项目搜索标签删除逻辑

This commit is contained in:
2023-04-06 15:40:01 +08:00
parent 08f89fd113
commit 7a6d549fa0
3 changed files with 18 additions and 2 deletions

View File

@@ -24,6 +24,21 @@ class Api::V1::ProjectTopicsController < Api::V1::BaseController
end
end
def destroy
ActiveRecord::Base.transaction do
@project = Project.find_by_id(create_params[:project_id])
return render_not_found unless @project.present?
@project_topic = ProjectTopic.find_by_id(params[:id])
@project_topic_ralate = @project_topic.project_topic_ralates.find_by(project_id: @project.id)
if @project_topic_ralate.destroy!
render_ok
else
render_error("项目取消关联搜索标签失败.")
end
end
end
private
def create_params
params.permit(:project_id, :name)