diff --git a/app/api/mobile/apis/blog_comments.rb b/app/api/mobile/apis/blog_comments.rb index 01fd05c0f..5a064245a 100644 --- a/app/api/mobile/apis/blog_comments.rb +++ b/app/api/mobile/apis/blog_comments.rb @@ -7,8 +7,9 @@ module Mobile desc "get special topic" get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user blog = BlogComment.find params[:id] - present :data, blog, with: Mobile::Entities::BlogComment + present :data, blog, with: Mobile::Entities::BlogComment,user: user present :status, 0 end end diff --git a/app/api/mobile/apis/issues.rb b/app/api/mobile/apis/issues.rb index 1815c85f3..b767bd768 100644 --- a/app/api/mobile/apis/issues.rb +++ b/app/api/mobile/apis/issues.rb @@ -8,8 +8,9 @@ module Mobile desc "get special issuse" get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user issue = Issue.find params[:id] - present :data, issue, with: Mobile::Entities::Issue + present :data, issue, with: Mobile::Entities::Issue,user: user present :status, 0 end end diff --git a/app/api/mobile/apis/journal_for_messages.rb b/app/api/mobile/apis/journal_for_messages.rb index 648924912..15a571a82 100644 --- a/app/api/mobile/apis/journal_for_messages.rb +++ b/app/api/mobile/apis/journal_for_messages.rb @@ -7,8 +7,9 @@ module Mobile desc "get special journal" get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user jour = JournalsForMessage.find params[:id] - present :data, jour, with: Mobile::Entities::Jours + present :data, jour, with: Mobile::Entities::Jours,user: user present :status, 0 end end diff --git a/app/api/mobile/apis/messages.rb b/app/api/mobile/apis/messages.rb index 5e2fb05b7..ae2f9a39c 100644 --- a/app/api/mobile/apis/messages.rb +++ b/app/api/mobile/apis/messages.rb @@ -7,8 +7,9 @@ module Mobile desc "get special topic" get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user message = Message.find params[:id] - present :data, message, with: Mobile::Entities::Message + present :data, message, with: Mobile::Entities::Message,user: user present :status, 0 end end diff --git a/app/api/mobile/apis/newss.rb b/app/api/mobile/apis/newss.rb index 6f15ae2ee..8bdd460cc 100644 --- a/app/api/mobile/apis/newss.rb +++ b/app/api/mobile/apis/newss.rb @@ -7,8 +7,9 @@ module Mobile desc "get special news" get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user news = News.find params[:id] - present :data, news, with: Mobile::Entities::News + present :data, news, with: Mobile::Entities::News,user: user present :status, 0 end end diff --git a/app/api/mobile/apis/whomeworks.rb b/app/api/mobile/apis/whomeworks.rb index 39a6faa68..a88d509a3 100644 --- a/app/api/mobile/apis/whomeworks.rb +++ b/app/api/mobile/apis/whomeworks.rb @@ -7,8 +7,9 @@ module Mobile desc "get one homework" get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user homework = HomeworkCommon.find params[:id] - present :data, homework, with: Mobile::Entities::Whomework + present :data, homework, with: Mobile::Entities::Whomework,user: user present :status, 0 end end diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index 945601bd6..59127dedd 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -131,8 +131,11 @@ module Mobile act_expose :course_project_name #课程/项目名字 act_expose :activity_type_name #课程问答区/项目缺陷等 expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + has_praise = false current_user = options[:user] - false + obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.act_id,instance.act_type.to_s,current_user.id) + has_praise = obj.empty? ? false : true + has_praise end end end diff --git a/app/api/mobile/entities/blog_comment.rb b/app/api/mobile/entities/blog_comment.rb index ac3fc3d9e..6961823d0 100644 --- a/app/api/mobile/entities/blog_comment.rb +++ b/app/api/mobile/entities/blog_comment.rb @@ -45,6 +45,13 @@ module Mobile c.children end end + expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + has_praise = false + current_user = options[:user] + obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id) + has_praise = obj.empty? ? false : true + has_praise + end end end end \ No newline at end of file diff --git a/app/api/mobile/entities/issue.rb b/app/api/mobile/entities/issue.rb index d0bb0fa0d..e64248353 100644 --- a/app/api/mobile/entities/issue.rb +++ b/app/api/mobile/entities/issue.rb @@ -49,6 +49,13 @@ module Mobile f.journals.where("notes is not null and notes != ''") end end + expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + has_praise = false + current_user = options[:user] + obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id) + has_praise = obj.empty? ? false : true + has_praise + end end end end \ No newline at end of file diff --git a/app/api/mobile/entities/jours.rb b/app/api/mobile/entities/jours.rb index 9d4d85f7a..87bbd0184 100644 --- a/app/api/mobile/entities/jours.rb +++ b/app/api/mobile/entities/jours.rb @@ -51,6 +51,13 @@ module Mobile f.children end end + expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + has_praise = false + current_user = options[:user] + obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id) + has_praise = obj.empty? ? false : true + has_praise + end end end end diff --git a/app/api/mobile/entities/message.rb b/app/api/mobile/entities/message.rb index d182e5965..7a00b5725 100644 --- a/app/api/mobile/entities/message.rb +++ b/app/api/mobile/entities/message.rb @@ -52,6 +52,13 @@ module Mobile c.children end end + expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + has_praise = false + current_user = options[:user] + obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id) + has_praise = obj.empty? ? false : true + has_praise + end end end end \ No newline at end of file diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb index d1ec9c5c3..85504a280 100644 --- a/app/api/mobile/entities/news.rb +++ b/app/api/mobile/entities/news.rb @@ -73,8 +73,13 @@ module Mobile f.send(:comments) end end - - + expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + has_praise = false + current_user = options[:user] + obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id) + has_praise = obj.empty? ? false : true + has_praise + end end end end \ No newline at end of file diff --git a/app/api/mobile/entities/whomework.rb b/app/api/mobile/entities/whomework.rb index b24c50aa2..76b88ec6f 100644 --- a/app/api/mobile/entities/whomework.rb +++ b/app/api/mobile/entities/whomework.rb @@ -67,6 +67,13 @@ module Mobile f.journals_for_messages end end + expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| + has_praise = false + current_user = options[:user] + obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id) + has_praise = obj.empty? ? false : true + has_praise + end end end end \ No newline at end of file diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 2db18be26..39da65ce4 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -116,7 +116,7 @@