Merge branch 'weixin_guange' of https://git.trustie.net/jacknudt/trustieforge into weixin_guange

chenlw_dev
Yiang Gan 9 years ago
commit 1c5b22abf4

@ -1,17 +1,18 @@
#coding=utf-8 #coding=utf-8
module Mobile module Mobile
module Apis module Apis
class BlogComments< Grape::API class BlogComments< Grape::API
resources :blog_comments do resources :blog_comments do
desc "get special topic" desc "get special topic"
get ':id' do get ':id' do
blog = BlogComment.find params[:id] blog = BlogComment.find params[:id]
present :blog, message, with: Mobile::Entities::BlogComment present :data, blog, with: Mobile::Entities::BlogComment
present :status, 0 present :status, 0
end end
end end
end end
end end
end end

@ -1,46 +1,50 @@
module Mobile module Mobile
module Entities module Entities
class BlogComment < Grape::Entity class BlogComment < Grape::Entity
include ApplicationHelper include ApplicationHelper
include ApiHelper include ApiHelper
def self.blog_comment_expose(f) def self.blog_comment_expose(f)
expose f do |u,opt| expose f do |u,opt|
if u.is_a?(Hash) && u.key?(f) if u.is_a?(Hash) && u.key?(f)
u[f] u[f]
elsif u.is_a?(::BlogComment) elsif u.is_a?(::BlogComment)
if u.respond_to?(f) if u.respond_to?(f)
if f == :created_at if f == :created_at
format_time( u.send(f)) format_time( u.send(f))
else else
u.send(f) u.send(f)
end end
else else
# case f case f
# when :xx when :blog_praise_count
# # get_activity_praise_num(u)
# end when :lasted_comment
end time_from_now(u.created_at)
end end
end
end end
end
end
expose :user, using: Mobile::Entities::User do |c, opt| end
if c.is_a?(::BlogComment)
c.author expose :user, using: Mobile::Entities::User do |c, opt|
end if c.is_a?(::BlogComment)
end c.author
blog_comment_expose :blog_id end
blog_comment_expose :title end
blog_comment_expose :content blog_comment_expose :blog_id
blog_comment_expose :comments_count blog_comment_expose :title
blog_comment_expose :created_at blog_comment_expose :content
blog_comment_expose :id blog_comment_expose :comments_count
expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt| blog_comment_expose :created_at
if c.is_a? (::BlogComment) blog_comment_expose :lasted_comment
c.children blog_comment_expose :id
end blog_comment_expose :blog_praise_count
end expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt|
end if c.is_a? (::BlogComment)
end c.children
end
end
end
end
end end

@ -15,9 +15,9 @@ module Mobile
f.send(field) f.send(field)
end end
else else
case f case field
when :course_name when :lasted_comment
f[:jour_type] == "Course" ? f.course.name : "" time_from_now f.created_on
end end
end end
end end
@ -29,6 +29,7 @@ module Mobile
f.user f.user
end end
jours_expose :created_on jours_expose :created_on
jours_expose :lasted_comment
jours_expose :notes jours_expose :notes
jours_expose :m_reply_id jours_expose :m_reply_id
jours_expose :m_parent_id jours_expose :m_parent_id

@ -15,10 +15,16 @@ module Mobile
u.send(f) u.send(f)
end end
else else
# case f case f
# when :xx when :course_project_name
# # if u.board.project_id == -1
# end u.course.name
else
u.project.name
end
when :lasted_comment
time_from_now u.created_on
end
end end
end end
@ -30,12 +36,14 @@ module Mobile
c.author c.author
end end
end end
message_expose :course_project_name
message_expose :board_id message_expose :board_id
message_expose :subject message_expose :subject
message_expose :content message_expose :content
message_expose :replies_count message_expose :replies_count
message_expose :created_on message_expose :created_on
message_expose :id message_expose :id
message_expose :lasted_comment
expose :message_children,using:Mobile::Entities::Message do |c,opt| expose :message_children,using:Mobile::Entities::Message do |c,opt|
if c.is_a? (::Message) if c.is_a? (::Message)
c.children c.children

@ -7,10 +7,17 @@ module Mobile
if f.is_a?(Hash) && f.key?(field) if f.is_a?(Hash) && f.key?(field)
f[field] f[field]
elsif f.is_a?(::News) elsif f.is_a?(::News)
if field == :created_on if f.respond_to?(field)
format_time(f.send(field)) if f.respond_to?(field) if field == :created_on
format_time(f.send(field))
else
f.send(field)
end
else else
f.send(field) if f.respond_to?(field) case field
when :course_name
Course.find(f.course_id).name unless f.course_id == nil
end
end end
elsif f.is_a?(Hash) && !f.key?(field) elsif f.is_a?(Hash) && !f.key?(field)
n = f[:news] n = f[:news]
@ -52,6 +59,8 @@ module Mobile
news_expose :created_on news_expose :created_on
#评论数量 #评论数量
news_expose :comments_count news_expose :comments_count
#课程名字
news_expose :course_name
#评论 #评论
expose :comments, using: Mobile::Entities::Comment do |f, opt| expose :comments, using: Mobile::Entities::Comment do |f, opt|
if f.is_a?(Hash) && f.key?(:comments) if f.is_a?(Hash) && f.key?(:comments)

@ -32,14 +32,14 @@ module Mobile
end end
end end
student_work_expose :student_id student_work_expose :student_id
student_work_expose :id student_work_expose :id
student_work_expose :name student_work_expose :name
student_work_expose :description student_work_expose :description
student_work_expose :final_score student_work_expose :final_score
student_work_expose :teacher_score student_work_expose :teacher_score
student_work_expose :student_score student_work_expose :student_score
student_work_expose :teacher_asistant_score student_work_expose :teacher_asistant_score
student_work_expose :created_at student_work_expose :created_at
end end
end end
end end

@ -1,66 +1,69 @@
# encoding: utf-8 # encoding: utf-8
module Mobile module Mobile
module Entities module Entities
class Whomework <Grape::Entity class Whomework <Grape::Entity
include ApiHelper include ApiHelper
include ApplicationHelper include ApplicationHelper
include Redmine::I18n include Redmine::I18n
def self.whomework_expose(f) def self.whomework_expose(f)
expose f do |wh, opt| expose f do |wh, opt|
if wh.is_a?(Hash) && wh.key?(f) if wh.is_a?(Hash) && wh.key?(f)
if f == :created_at wh[f]
format_time(wh[f]) elsif wh.is_a?(::HomeworkCommon)
else if wh.respond_to?(f)
wh[f] if f == :created_at
end format_time(wh.send(f))
elsif wh.is_a?(::HomeworkCommon) else
if wh.respond_to?(f) wh.send(f)
wh.send(f) end
else else
case f case f
when :absence_penalty when :absence_penalty
wh.nil? || wh.homework_detail_manual.nil? ? 0 : wh.homework_detail_manual.absence_penalty wh.nil? || wh.homework_detail_manual.nil? ? 0 : wh.homework_detail_manual.absence_penalty
when :evaluation_start when :evaluation_start
wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_start, 0) wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_start, 0)
when :evaluation_end when :evaluation_end
wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_end, 1) wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_end, 1)
when :whomework_praise_count when :whomework_praise_count
get_activity_praise_num(wh) get_activity_praise_num(wh)
when :whomework_journal_count when :whomework_journal_count
wh.journals_for_messages.count wh.journals_for_messages.count
end when :course_name
end wh.course.name
end end
end end
end end
end
expose :author, using: Mobile::Entities::User do |w, opt| end
if w.is_a?(::HomeworkCommon)
w.user expose :author, using: Mobile::Entities::User do |w, opt|
end if w.is_a?(::HomeworkCommon)
end w.user
expose :name end
expose :description end
expose :publish_time expose :name
expose :end_time expose :description
expose :homework_type expose :publish_time
expose :late_penalty expose :end_time
expose :course_id expose :homework_type
expose :anonymous_comment expose :late_penalty
expose :quotes expose :course_id
expose :is_open expose :anonymous_comment
whomework_expose :created_at expose :quotes
whomework_expose :absence_penalty expose :is_open
whomework_expose :evaluation_start whomework_expose :course_name
whomework_expose :evaluation_end whomework_expose :created_at
whomework_expose :whomework_praise_count whomework_expose :absence_penalty
whomework_expose :whomework_journal_count whomework_expose :evaluation_start
expose :journals_for_messages, using: Mobile::Entities::Jours do |f, opt| whomework_expose :evaluation_end
#f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages) whomework_expose :whomework_praise_count
if f.is_a?(::HomeworkCommon) whomework_expose :whomework_journal_count
f.journals_for_messages expose :journals_for_messages, using: Mobile::Entities::Jours do |f, opt|
end #f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages)
end if f.is_a?(::HomeworkCommon)
end f.journals_for_messages
end end
end
end
end
end end

@ -2,7 +2,7 @@ button:
- -
type: "view" type: "view"
name: "最新动态" name: "最新动态"
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=http://wechat.trustie.net/assets/wechat/issue.html&response_type=code&scope=snsapi_base&state=123#wechat_redirect" url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=http://wechat.trustie.net/assets/wechat/activities.html&response_type=code&scope=snsapi_base&state=123#wechat_redirect"
- -
type: "click" type: "click"
name: "意见返馈" name: "意见返馈"

Loading…
Cancel
Save