mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
init project
This commit is contained in:
42
app/controllers/praise_tread_controller.rb
Normal file
42
app/controllers/praise_tread_controller.rb
Normal file
@@ -0,0 +1,42 @@
|
||||
class PraiseTreadController < ApplicationController
|
||||
before_action :require_login, except: %i[index]
|
||||
before_action :find_project_with_id
|
||||
|
||||
def index
|
||||
scope = @project.praise_treads.includes(:user)
|
||||
@praises = paginate(scope)
|
||||
end
|
||||
|
||||
def like
|
||||
begin
|
||||
return normal_status(2, "你已点过赞了") if current_user.liked?(@project)
|
||||
current_user.like!(@project)
|
||||
render_ok
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
|
||||
def unlike
|
||||
begin
|
||||
return normal_status(2, "你还没有点过赞噢") unless current_user.liked?(@project)
|
||||
current_user.unlike!(@project)
|
||||
render_ok
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
|
||||
def check_like
|
||||
is_like = current_user.liked?(@project)
|
||||
render_result(is_like ? 1 : 0)
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user