diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index 9e37571b1..63dd509fe 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -494,7 +494,15 @@ class StudentWorksController < ApplicationController # 删除实训作品评阅 def destroy_work_comment ActiveRecord::Base.transaction do - @work.shixun_work_comments.find_by!(id: params[:comment_id]).destroy_all + tip_exception("visible_comment参数有误") if params[:visible_comment].blank? + + comment = @work.shixun_work_comments.find_by!(id: params[:comment_id]) + params[:visible_comment] ? comment.comment = nil : comment.hidden_comment = nil + if comment.comment.nil? && comment.hidden_comment.nil? + comment.destroy! + else + comment.save! + end normal_status("删除成功") end end