add: notice system api

This commit is contained in:
2021-09-13 17:51:34 +08:00
parent 877a20350d
commit 465a3a67a5
11 changed files with 365 additions and 102 deletions

View File

@@ -0,0 +1,23 @@
class Notice::Write::CreateAtmeForm
include ActiveModel::Model
attr_accessor :receivers_login, :atmeable_type, :atmeable_id
validate :check_receivers
def check_receivers
receivers_login.each do |login|
receiver = User.find_by(login: login) || User.find_by_id(login)
raise 'receivers_login值无效.' unless receiver.present?
end
end
def check_atmeable
begin
raise 'atmeable对象无效.' unless atmeable_type.constantize.find_by_id(atmeable_id).present?
rescue => exception
raise 'atmeable对象无效.'
end
end
end