commit
a165657915
@ -1,2 +1,15 @@
|
||||
module SchoolHelper
|
||||
def schoolMember_num school
|
||||
count = student_num(school) + teacher_num(school)
|
||||
count.to_s
|
||||
end
|
||||
|
||||
def student_num school
|
||||
UserExtensions.find_by_sql("SELECT * FROM user_extensions WHERE occupation = '#{school.name}' AND identity = '1'").count
|
||||
end
|
||||
|
||||
def teacher_num school
|
||||
UserExtensions.find_by_sql("SELECT * FROM user_extensions AS ue, schools AS s WHERE ue.school_id = s.id AND s.name = '#{school.name}' AND ue.identity = '0'").count
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -1,6 +1,11 @@
|
||||
[
|
||||
<% @users && @users.each_with_index do |person,index| %>
|
||||
<% if index == 0 %>
|
||||
{"id":<%=index%>, "userid": "<%=person.id%>", "name": "所有人", "login": "<%=person.name%>", "searchKey": "<%=person.name%>"}
|
||||
<%= index != @users.size-1 ? ',' : '' %>
|
||||
<% else %>
|
||||
{"id":<%=index%>, "userid": <%=person.id%>, "name": "<%=person.show_name%>", "login": "<%=person.login%>", "searchKey": "<%=person.get_at_show_name%>"}
|
||||
<%= index != @users.size-1 ? ',' : '' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
]
|
||||
|
@ -0,0 +1,23 @@
|
||||
#coding=utf-8
|
||||
|
||||
module Trustie
|
||||
module At
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
module ClassMethods
|
||||
def act_as_at_message(content, send_id)
|
||||
self.send :define_method, :act_as_at_message_func do
|
||||
users = self[content].scan /<span class="at" data-user-id="(.+?)">/m
|
||||
users && users.flatten.uniq.each do |uids|
|
||||
uids.split(",").each do |uid|
|
||||
self.at_messages << AtMessage.new(user_id: uid, sender_id: self[send_id])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ActiveRecord::Base.send(:include, Trustie::At)
|
Loading…
Reference in new issue