commit
7b1f61a514
@ -0,0 +1,48 @@
|
||||
*.swp
|
||||
/.project
|
||||
/.idea/*
|
||||
/.bundle
|
||||
*.swp
|
||||
/config/database.yml
|
||||
/config/configuration.yml
|
||||
/config/additional_environment.rb
|
||||
/config/oneapm.yml
|
||||
|
||||
/files/*
|
||||
/log/*
|
||||
/public/tmp/*
|
||||
/tmp/*
|
||||
/public/cache/*
|
||||
/config/newrelic.yml
|
||||
/public/images/avatars/*
|
||||
/db/schema.rb
|
||||
/Gemfile.lock
|
||||
/lib/plugins/acts_as_versioned/test/debug.log
|
||||
.rbenv-gemsets
|
||||
.DS_Store
|
||||
public/api_doc/
|
||||
/.metadata
|
||||
vendor/cache
|
||||
/files
|
||||
/public/images/avatars
|
||||
/public/files
|
||||
/tags
|
||||
/config/initializers/gitlab_config.rb
|
||||
public/javascripts/wechat/node_modules/
|
||||
.ruby-version
|
||||
.access_token
|
||||
tmux*.log
|
||||
config/wechat.yml
|
||||
config/oneapm.yml
|
||||
|
||||
/public/react/node_modules/
|
||||
/public/react/public/react/build/static/js/*.map
|
||||
/public/react-mobile/node_modules/
|
||||
/public/react-mobile7/node_modules/
|
||||
/public/react-gatsby/node_modules/
|
||||
/public/react-gatsby/.cache/
|
||||
|
||||
/public/react-mobile7/build/.project
|
||||
/public/npm-debug.log
|
||||
/vendor
|
||||
/workspace/*
|
Binary file not shown.
@ -0,0 +1,132 @@
|
||||
source 'http://gems.ruby-china.com'
|
||||
|
||||
unless RUBY_PLATFORM =~ /w32/
|
||||
# unix-like only
|
||||
gem 'iconv'
|
||||
if RUBY_PLATFORM =~ /darwin/
|
||||
#gem "rmagick", "= 2.15.4" ## osx must be this version
|
||||
gem 'pdfkit'
|
||||
gem 'wkhtmltopdf-binary'
|
||||
elsif RUBY_PLATFORM =~ /linux/
|
||||
gem "rmagick", "~> 2.13.1" ## centos yum install ImageMagick-devel
|
||||
gem 'pdfkit'
|
||||
gem 'wkhtmltopdf-binary'
|
||||
gem 'rqrcode', '~> 0.10.1'
|
||||
gem 'rqrcode_png'
|
||||
gem 'roo-xls'
|
||||
gem 'newrelic_rpm'
|
||||
end
|
||||
gem 'certified'
|
||||
gem 'net-ssh', '2.9.1'
|
||||
gem 'jenkins_api_client'
|
||||
gem 'nokogiri'
|
||||
end
|
||||
|
||||
gem 'seventeen_mon'
|
||||
gem 'mobinfo'
|
||||
gem 'simple_xlsx_reader'
|
||||
gem 'wechat',path: 'lib/wechat'
|
||||
gem 'grack', path:'lib/grack'
|
||||
gem 'gitlab', path: 'lib/gitlab-cli'
|
||||
gem 'rest-client'
|
||||
gem "mysql2", "= 0.3.18"
|
||||
gem 'redis-rails'
|
||||
gem 'rubyzip'
|
||||
gem 'delayed_job_active_record'#, :group => :production
|
||||
gem 'daemons'
|
||||
gem 'grape', '~> 0.15.0'
|
||||
gem 'grape-entity', '~> 0.6.0'
|
||||
gem 'rack-cors', :require => 'rack/cors'
|
||||
gem 'seems_rateable', '~> 1.0.13'
|
||||
gem 'rails', '~> 3.2'
|
||||
gem "jquery-rails", "~> 2.0.2"
|
||||
gem "i18n", "~> 0.6.0"
|
||||
gem 'coderay', '~> 1.1.0'
|
||||
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
|
||||
gem "builder", "3.0.0"
|
||||
gem 'acts-as-taggable-on', '2.4.1'
|
||||
gem 'spreadsheet'
|
||||
gem 'ruby-ole'
|
||||
gem 'rails_kindeditor',path:'lib/rails_kindeditor'
|
||||
gem 'binding_of_caller'
|
||||
gem 'chinese_pinyin'
|
||||
# gem 'sunspot_rails', '~> 1.3.3'
|
||||
# gem 'sunspot_solr'
|
||||
# gem 'sunspot'
|
||||
# gem 'progress_bar'
|
||||
gem 'ansi'
|
||||
|
||||
gem 'kaminari'
|
||||
gem 'elasticsearch-model'
|
||||
gem 'elasticsearch-rails'
|
||||
|
||||
#Ruby 2.2+ has removed test/unit from the core library.
|
||||
if RUBY_VERSION>='2.2'
|
||||
gem 'test-unit', '~> 3.0'
|
||||
end
|
||||
|
||||
|
||||
### profile
|
||||
# gem 'oneapm_rpm'
|
||||
# gem 'therubyracer'
|
||||
|
||||
group :development do
|
||||
gem 'grape-swagger', path: "./lib/grape-swagger-0.25.3"
|
||||
|
||||
gem 'better_errors', '~> 1.1.0'
|
||||
# gem "query_reviewer"
|
||||
gem 'rack-mini-profiler', '~> 0.9.3'
|
||||
if RUBY_PLATFORM =~ /w32/
|
||||
gem 'win32console'
|
||||
end
|
||||
|
||||
if RUBY_PLATFORM =~ /darwin/
|
||||
gem 'puma'
|
||||
end
|
||||
end
|
||||
|
||||
group :development, :test do
|
||||
if RUBY_VERSION >= '2.0.0'
|
||||
gem 'pry-byebug'
|
||||
# gem "test-unit", "~>3.0"
|
||||
end
|
||||
gem 'rspec-rails', '~> 3.0'
|
||||
gem 'factory_girl_rails'
|
||||
end
|
||||
|
||||
# Gems used only for assets and not required
|
||||
# in production environments by default.
|
||||
group :assets do
|
||||
gem 'sass-rails', '~> 3.2.3'
|
||||
gem 'coffee-rails', '~> 3.2.1'
|
||||
|
||||
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
||||
# gem 'therubyracer', :platforms => :ruby
|
||||
|
||||
gem 'uglifier', '>= 1.0.3'
|
||||
end
|
||||
|
||||
# Optional gem for LDAP authentication
|
||||
group :ldap do
|
||||
gem "net-ldap", "~> 0.3.1"
|
||||
end
|
||||
|
||||
|
||||
# Optional gem for OpenID authentication
|
||||
group :openid do
|
||||
gem "ruby-openid", "~> 2.1.4", :require => "openid"
|
||||
gem "rack-openid"
|
||||
end
|
||||
|
||||
|
||||
database_file = File.join(File.dirname(__FILE__), "config/database.yml")
|
||||
if File.exist?(database_file)
|
||||
else
|
||||
warn("Please configure your config/database.yml first")
|
||||
end
|
||||
|
||||
# Load plugins' Gemfiles
|
||||
Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file|
|
||||
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
|
||||
instance_eval File.read(file)
|
||||
end
|
@ -0,0 +1,40 @@
|
||||
# More info at https://github.com/guard/guard#readme
|
||||
|
||||
# guard 'rails' do
|
||||
# watch('Gemfile.lock')
|
||||
# watch(%r{^(config|lib)/.*})
|
||||
# end
|
||||
#
|
||||
guard 'spork', :test_unit => true, :test_unit_env => {'RAILS_ENV' => 'test'}, :wait => 60 do
|
||||
watch(%r{app/models/.+\.rb})
|
||||
watch('config/application.rb')
|
||||
watch('config/environment.rb')
|
||||
watch('config/environments/test.rb')
|
||||
watch(%r{^config/initializers/.+\.rb$})
|
||||
watch('Gemfile.lock')
|
||||
watch('spec/spec_helper.rb') { :rspec }
|
||||
watch('test/test_helper.rb') { :test_unit }
|
||||
watch(%r{features/support/}) { :cucumber }
|
||||
end
|
||||
|
||||
guard :test, :drb => true, :all_after_pass => false, :all_on_start => false do
|
||||
watch(%r{^test/.+_test\.rb$})
|
||||
watch('test/test_helper.rb') { 'test' }
|
||||
|
||||
# Non-rails
|
||||
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
||||
|
||||
# Rails 4
|
||||
# watch(%r{^app/(.+)\.rb}) { |m| "test/#{m[1]}_test.rb" }
|
||||
# watch(%r{^app/controllers/application_controller\.rb}) { 'test/controllers' }
|
||||
# watch(%r{^app/controllers/(.+)_controller\.rb}) { |m| "test/integration/#{m[1]}_test.rb" }
|
||||
# watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
|
||||
# watch(%r{^lib/(.+)\.rb}) { |m| "test/lib/#{m[1]}_test.rb" }
|
||||
|
||||
# Rails < 4
|
||||
watch(%r{^app/models/(.+)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
|
||||
watch(%r{^app/controllers/(.+)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
|
||||
watch(%r{^app/views/(.+)/.+\.erb$}) { |m| "test/functional/#{m[1]}_controller_test.rb" }
|
||||
watch(%r{^app/views/.+$}) { 'test/integration' }
|
||||
watch('app/controllers/application_controller.rb') { ['test/functional', 'test/integration'] }
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env rake
|
||||
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
||||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
||||
|
||||
require File.expand_path('../config/application', __FILE__)
|
||||
|
||||
RedmineApp::Application.load_tasks
|
@ -0,0 +1,69 @@
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Activities< Grape::API
|
||||
resources :activities do
|
||||
|
||||
desc "get user activities"
|
||||
|
||||
params do
|
||||
requires :page, type: Integer
|
||||
requires :token, type: String
|
||||
requires :container_type, type: String
|
||||
end
|
||||
post do
|
||||
begin
|
||||
authenticate!
|
||||
|
||||
user = current_user
|
||||
|
||||
container_type = params[:container_type] ? params[:container_type] : "All"
|
||||
|
||||
if container_type == "All" || container_type == "Project"
|
||||
shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
|
||||
user_project_ids = (user.projects.where("status = 1").map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.where("status = 1").map{|project| project.id}-shield_project_ids).join(",") + ")"
|
||||
project_types = "('Message','Issue','Project')"
|
||||
end
|
||||
|
||||
if container_type == "All" || container_type == "Course"
|
||||
shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
|
||||
user_course_ids = (user.courses.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.where("is_delete = 0").map{|course| course.id}-shield_course_ids).join(",") + ")"
|
||||
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
|
||||
end
|
||||
|
||||
page = params[:page] ? params[:page] : 0
|
||||
principal_types = "JournalsForMessage"
|
||||
watched_user_ids = User.watched_by(user.id).count == 0 ? " " : ("," + User.watched_by(user.id).map{|u| u.id.to_s }.join(','))
|
||||
user_ids = "(" + user.id.to_s + watched_user_ids + ")"
|
||||
watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}").count == 0 ? "-1" :Blog.select("id").where("author_id in #{user_ids}").map { |blog| blog.id}.join(",")
|
||||
blog_ids = "(" + watched_user_blog_ids + ")"
|
||||
|
||||
if container_type == "Course"
|
||||
activities = UserActivity.where("(container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})").order('updated_at desc')
|
||||
elsif container_type == "Project"
|
||||
activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})").order('updated_at desc')
|
||||
else
|
||||
activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" +
|
||||
"or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
|
||||
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " +
|
||||
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc')
|
||||
end
|
||||
all_count = activities.count
|
||||
activities = activities.limit(10).offset(page * 10)
|
||||
count = activities.count
|
||||
present :data, activities, with: Mobile::Entities::Activity,user: user
|
||||
present :all_count, all_count
|
||||
present :count, count
|
||||
present :page, page
|
||||
present :status, 0
|
||||
present :container_type, container_type
|
||||
rescue Exception=>e
|
||||
present :status, -1
|
||||
present :message, e.message
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,40 @@
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Assets< Grape::API
|
||||
resources :assets do
|
||||
|
||||
|
||||
desc "upload file"
|
||||
params do
|
||||
requires :avatar, type: File
|
||||
requires :token, type: String
|
||||
optional :compress, type: Boolean #是否需要服务器压缩
|
||||
end
|
||||
post 'upload' do
|
||||
authenticate!
|
||||
|
||||
# params[:avatar][:filename] # => 'avatar.png'
|
||||
# params[:avatar][:type] # => 'image/png'
|
||||
# params[:avatar][:tempfile] # => #<File>
|
||||
|
||||
attachment = ::Attachment.new(:file => params[:avatar][:tempfile])
|
||||
attachment.author = current_user
|
||||
attachment.filename = params[:avatar][:filename].presence || Redmine::Utils.random_hex(16)
|
||||
saved = attachment.save
|
||||
|
||||
if saved
|
||||
present :data, attachment, with: Mobile::Entities::Attachment
|
||||
present :status, 0
|
||||
else
|
||||
present :status, -1
|
||||
present :message, '上传失败'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,56 @@
|
||||
#coding=utf-8
|
||||
module Mobile
|
||||
|
||||
|
||||
module Apis
|
||||
class Auth < Grape::API
|
||||
|
||||
desc '认证相关'
|
||||
|
||||
resource :auth do
|
||||
desc "用户登录"
|
||||
params do
|
||||
requires :login, type: String, desc: 'Username or email'
|
||||
requires :password, type: String, desc: 'Password'
|
||||
end
|
||||
post do
|
||||
user,last_logon = ::User.try_to_login(params[:login], params[:password])
|
||||
if user
|
||||
::ApiKey.delete_all(user_id: user.id)
|
||||
key = ::ApiKey.create!(user_id: user.id)
|
||||
api_user = ::UsersService.new.show_user({id:user.id})
|
||||
present :data, {token: key.access_token, user: api_user}, with: Mobile::Entities::Auth
|
||||
present :status, 0
|
||||
else
|
||||
present :message, "无效的用户名或密码"
|
||||
present :status,1
|
||||
end
|
||||
end
|
||||
|
||||
desc "用户登出"
|
||||
params do
|
||||
requires :token, type: String
|
||||
end
|
||||
delete do
|
||||
authenticate!
|
||||
::ApiKey.delete_all(user_id: current_user.id)
|
||||
{status: 0}
|
||||
end
|
||||
|
||||
desc "忘记密码"
|
||||
params do
|
||||
requires :mail,type: String
|
||||
end
|
||||
post 'lost_password' do
|
||||
us = UsersService.new
|
||||
message = us.lost_password params
|
||||
present :message, message
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class BlogComments< Grape::API
|
||||
resources :blog_comments do
|
||||
|
||||
desc "get special topic"
|
||||
post ':id' do
|
||||
begin
|
||||
user = current_user
|
||||
|
||||
#0一级回复的更多 1 二级回复的更多
|
||||
type = params[:type] || 0
|
||||
page = params[:page] || 0
|
||||
|
||||
blog = BlogComment.find params[:id]
|
||||
present :data, blog, with: Mobile::Entities::BlogComment,user: user,type: type,page: page
|
||||
present :type, type
|
||||
present :page, page
|
||||
present :status, 0
|
||||
rescue Exception=>e
|
||||
present :status, -1
|
||||
present :message, e.message
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,118 @@
|
||||
# encoding=utf-8
|
||||
module Mobile
|
||||
module Apis
|
||||
class Careers < Grape::API
|
||||
before {career_authenticate!}
|
||||
content_type :json, 'application/json;charset=UTF-8'
|
||||
|
||||
resources :careers do
|
||||
|
||||
desc "创建职业路径课程介绍"
|
||||
params do
|
||||
requires :name, type: String, desc: "职业路径名称"
|
||||
requires :video_name, type: String, desc: "视频名称"
|
||||
end
|
||||
post 'create' do
|
||||
CareersService.new.create params, current_user
|
||||
end
|
||||
|
||||
desc "编辑职业路径"
|
||||
params do
|
||||
requires :id, type: Integer, desc: "职业路径id"
|
||||
end
|
||||
route_param :id do
|
||||
get 'edit' do
|
||||
CareersService.new.edit params
|
||||
end
|
||||
end
|
||||
|
||||
desc '添加实训路径弹框和弹框搜索'
|
||||
get 'get_paths_info' do
|
||||
CareersService.new.get_paths_info params
|
||||
end
|
||||
|
||||
desc "实训路径弹框选择路径"
|
||||
params do
|
||||
requires :id, type: Array, desc: "实训路径的id"
|
||||
end
|
||||
post 'add_paths' do
|
||||
CareersService.new.add_paths params
|
||||
end
|
||||
|
||||
desc "创建职业路径内容安排"
|
||||
params do
|
||||
requires :id, type: Integer, desc: "职业路径id"
|
||||
requires :career_stages, type: Array, desc: '阶段数据'
|
||||
end
|
||||
route_param :id do
|
||||
post 'create_career_stages' do
|
||||
CareersService.new.create_career_stages params
|
||||
end
|
||||
end
|
||||
|
||||
desc "课程介绍"
|
||||
params do
|
||||
requires :id, type: Integer, desc: "职业路径id"
|
||||
end
|
||||
route_param :id do
|
||||
get 'introduction' do
|
||||
CareersService.new.introduction params
|
||||
end
|
||||
end
|
||||
|
||||
desc "更新课程介绍"
|
||||
params do
|
||||
requires :id, type: Integer, desc: "职业路径id"
|
||||
requires :name, type: String, desc: '课程名称'
|
||||
requires :video_name, type: String, desc: '视频名称'
|
||||
end
|
||||
route_param :id do
|
||||
post 'update_introduction' do
|
||||
CareersService.new.update_introduction params
|
||||
end
|
||||
end
|
||||
|
||||
desc "内容安排"
|
||||
params do
|
||||
requires :id, type: Integer, desc: "职业路径id"
|
||||
end
|
||||
route_param :id do
|
||||
get 'contents' do
|
||||
CareersService.new.contents params, current_user
|
||||
end
|
||||
end
|
||||
|
||||
desc "更新内容安排"
|
||||
params do
|
||||
requires :id, type: Integer, desc: "职业路径id"
|
||||
requires :career_stages, type: Array, desc: "阶段内容(数组)"
|
||||
end
|
||||
route_param :id do
|
||||
post 'update_contents' do
|
||||
CareersService.new.update_contents params
|
||||
end
|
||||
end
|
||||
|
||||
# api/v1/careers/get_published_careers
|
||||
desc "获取已发布的职业路径"
|
||||
get 'get_published_careers' do
|
||||
CareersService.new.get_published_careers params
|
||||
end
|
||||
|
||||
# 公共接口
|
||||
desc "获取当前用户的信息"
|
||||
get 'get_current_user' do
|
||||
CareersService.new.get_current_user params, current_user
|
||||
end
|
||||
|
||||
# 工程认证头部url
|
||||
desc "获取已发布的职业路径"
|
||||
get 'get_navigation_url' do
|
||||
CareersService.new.get_navigation_url
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,5 @@
|
||||
module API
|
||||
module Helpers
|
||||
|
||||
end
|
||||
end
|
@ -0,0 +1,44 @@
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Issues< Grape::API
|
||||
resources :issues do
|
||||
include IssuesHelper
|
||||
|
||||
desc "get special issuse"
|
||||
post ':id' do
|
||||
begin
|
||||
# authenticate!
|
||||
user = current_user
|
||||
|
||||
#is_public true 公开 false 私有 1公开 0私有
|
||||
|
||||
#0一级回复的更多 1 二级回复的更多
|
||||
type = params[:type] || 0
|
||||
page = params[:page] || 0
|
||||
|
||||
is_public = 1
|
||||
|
||||
if type == 0
|
||||
issue = Issue.find params[:id]
|
||||
issue.project.is_public
|
||||
present :data, issue, with: Mobile::Entities::Issue,user: user,type: type,page: page
|
||||
else
|
||||
jour = Journal.find params[:id]
|
||||
present :data, jour, with: Mobile::Entities::Issue,user: user,type: type,page: page
|
||||
end
|
||||
|
||||
present :type, type
|
||||
present :page, page
|
||||
present :is_public,is_public
|
||||
present :status, 0
|
||||
rescue Exception=>e
|
||||
present :status, -1
|
||||
present :message, e.message
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,41 @@
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class JournalForMessages< Grape::API
|
||||
resources :journal_for_messages do
|
||||
|
||||
desc "get special journal"
|
||||
post ':id' do
|
||||
begin
|
||||
# authenticate!
|
||||
user = current_user
|
||||
|
||||
#0一级回复的更多 1 二级回复的更多
|
||||
type = params[:type] || 0
|
||||
page = params[:page] || 0
|
||||
|
||||
jour = JournalsForMessage.find params[:id]
|
||||
|
||||
is_public = 1
|
||||
|
||||
if jour.jour_type == "Project"
|
||||
is_public = jour.project.is_public
|
||||
elsif jour.jour_type == "Course"
|
||||
is_public = jour.course.is_public
|
||||
end
|
||||
|
||||
present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page
|
||||
present :type, type
|
||||
present :page, page
|
||||
present :is_public, is_public
|
||||
present :status, 0
|
||||
rescue Exception=>e
|
||||
present :status, -1
|
||||
present :message, e.message
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,44 @@
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Messages< Grape::API
|
||||
resources :messages do
|
||||
|
||||
desc "get special topic"
|
||||
post ':id' do
|
||||
begin
|
||||
# authenticate!
|
||||
user = current_user
|
||||
|
||||
#0一级回复的更多 1 二级回复的更多
|
||||
type = params[:type] || 0
|
||||
page = params[:page] || 0
|
||||
message = Message.find params[:id]
|
||||
|
||||
is_public = 1
|
||||
type_name = ""
|
||||
|
||||
if message.project
|
||||
is_public = message.project.is_public
|
||||
type_name = "project"
|
||||
elsif message.course
|
||||
is_public = message.course.is_public
|
||||
type_name = "course"
|
||||
end
|
||||
|
||||
present :data, message, with: Mobile::Entities::Message,user: user,type: type,page: page
|
||||
present :type, type
|
||||
present :page, page
|
||||
present :is_public, is_public
|
||||
present :type_name, type_name
|
||||
present :status, 0
|
||||
rescue Exception=>e
|
||||
present :status, -1
|
||||
present :message, e.message
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,321 @@
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class NewComment< Grape::API
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
resources :new_comment do
|
||||
|
||||
desc "add a new comment"
|
||||
params do
|
||||
requires :type, type: String
|
||||
requires :content, type: String
|
||||
end
|
||||
post ':id' do
|
||||
unless current_user
|
||||
#如果当前用户不存在 则需要根据微信昵称注册一个帐号
|
||||
openid = session[:wechat_openid]
|
||||
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||
us = UsersService.new
|
||||
|
||||
access_token = session[:access_token]
|
||||
refresh_token = session[:refresh_token]
|
||||
|
||||
if access_token.present? && refresh_token.present?
|
||||
begin
|
||||
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
|
||||
rescue
|
||||
info = Wechat.api.web_access_token(session[:wechat_code])
|
||||
openid =info["openid"]
|
||||
access_token =info["access_token"]
|
||||
if access_token
|
||||
session[:access_token] = access_token
|
||||
end
|
||||
refresh_token = info["refresh_token"]
|
||||
if refresh_token
|
||||
session[:refresh_token] = refresh_token
|
||||
end
|
||||
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
|
||||
end
|
||||
|
||||
access_token = refreshinfo["access_token"]
|
||||
refresh_token = refreshinfo["refresh_token"]
|
||||
session[:access_token] = access_token
|
||||
session[:refresh_token] = refresh_token
|
||||
|
||||
#获取用户信息
|
||||
userinfo = Wechat.api.web_userinfo(access_token,openid)
|
||||
Rails.logger.info "userinfo!!!!!!!!!"
|
||||
Rails.logger.info userinfo
|
||||
name = userinfo["nickname"]
|
||||
else
|
||||
name = openid[0..3]+"***"+openid.last
|
||||
end
|
||||
|
||||
user = us.register ({:login=>openid, :mail=>"#{openid}@163.com",
|
||||
:password=>"12345678", :password_confirmation=>"12345678",
|
||||
:should_confirmation_password => true})
|
||||
raise user.errors.full_messages.first if user.new_record?
|
||||
user.update_attributes(:lastname=>name)
|
||||
#自动激活
|
||||
if Setting.self_registration != '3'
|
||||
user.activate
|
||||
user.last_login_on = Time.now
|
||||
if user.save
|
||||
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
|
||||
end
|
||||
end
|
||||
UserWechat.create!(
|
||||
openid: openid,
|
||||
user: user,
|
||||
bindtype: 1
|
||||
)
|
||||
end
|
||||
|
||||
authenticate!
|
||||
|
||||
## 能进来的就是已关注
|
||||
## 因为取消订阅的记录被删除了
|
||||
subscribe = 1 #默认未关注
|
||||
|
||||
status = 0
|
||||
tip = 0 #0班级1项目
|
||||
type = params[:type]
|
||||
result = 1
|
||||
|
||||
#0回复 1回复的回复
|
||||
reply_type = params[:reply_type]
|
||||
|
||||
update_id = 0
|
||||
|
||||
if params[:content]!="" && current_user
|
||||
case type
|
||||
when "HomeworkCommon"
|
||||
#如果是私有的 并且不是成员则不能回复
|
||||
# is_public = homework_common.course.is_public
|
||||
# if is_public == 0 && !current_user.member_of_course?(homework_common.course)
|
||||
# status = -1
|
||||
# tip = 0
|
||||
# else
|
||||
# feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], params[:id])
|
||||
# if (feedback.errors.empty?)
|
||||
# homework_common.update_column(:updated_at, Time.now)
|
||||
# result = 2
|
||||
# end
|
||||
# end
|
||||
if reply_type == nil || reply_type == 0
|
||||
homework_common = HomeworkCommon.find(params[:id])
|
||||
feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], params[:id], params[:id])
|
||||
if (feedback.errors.empty?)
|
||||
homework_common.update_column(:updated_at, Time.now)
|
||||
result = 2
|
||||
update_id = homework_common.id
|
||||
end
|
||||
else
|
||||
#二级回复
|
||||
reply = JournalsForMessage.find params[:id].to_i
|
||||
homework_common = HomeworkCommon.find reply.jour_id
|
||||
|
||||
options = {:notes => params[:content], :reply_id => reply.user_id,:user_id => current_user.id,:m_parent_id => params[:id].to_i,:m_reply_id => params[:id].to_i}
|
||||
feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], reply.jour_id, reply.jour_id, options)
|
||||
if (feedback.errors.empty?)
|
||||
homework_common.update_column(:updated_at, Time.now)
|
||||
result = 2
|
||||
update_id = homework_common.id
|
||||
end
|
||||
end
|
||||
|
||||
when "News"
|
||||
# if news.project
|
||||
# if news.project.is_public == false && !current_user.member_of?(news.project)
|
||||
# status = -1
|
||||
# tip = 1
|
||||
# end
|
||||
# elsif news.course
|
||||
# if news.course.is_public == 0 && !current_user.member_of_course?(news.course)
|
||||
# status = -1
|
||||
# tip = 0
|
||||
# end
|
||||
# end
|
||||
if status == 0
|
||||
if reply_type == nil || reply_type == 0
|
||||
news = News.find(params[:id])
|
||||
comment = Comment.new
|
||||
comment.comments = params[:content]
|
||||
comment.author = current_user
|
||||
if news.comments << comment
|
||||
result = 2
|
||||
update_id = news.id
|
||||
end
|
||||
else
|
||||
#二级回复
|
||||
comment = Comment.find(params[:id])
|
||||
news = News.find comment.commented_id
|
||||
new_comment = news.comments.build(:author_id => current_user.id, :reply_id => params[:id], :comments => params[:content], :parent_id => comment.id)
|
||||
if new_comment.save
|
||||
result = 2
|
||||
update_id = news.id
|
||||
end
|
||||
end
|
||||
end
|
||||
when "Message"
|
||||
# if message.project
|
||||
# if message.project.is_public == false && !current_user.member_of?(message.project)
|
||||
# status = -1
|
||||
# tip = 1
|
||||
# end
|
||||
# elsif message.course
|
||||
# if message.course.is_public == 0 && !current_user.member_of_course?(message.course)
|
||||
# status = -1
|
||||
# tip = 0
|
||||
# end
|
||||
# end
|
||||
|
||||
if status == 0
|
||||
# if reply_type == nil || reply_type == 0
|
||||
message = Message.find(params[:id])
|
||||
board = Board.find(message.board_id)
|
||||
topic = message.root
|
||||
reply = Message.new
|
||||
reply.author = current_user
|
||||
reply.board = board
|
||||
reply.content = params[:content]
|
||||
reply.parent_id = params[:id]
|
||||
reply.subject = "RE: #{topic.subject}"
|
||||
reply.root_id = topic.id
|
||||
if message.children << reply
|
||||
result = 2
|
||||
update_id = topic.id
|
||||
end
|
||||
# else
|
||||
#二级回复
|
||||
|
||||
# end
|
||||
end
|
||||
when "JournalsForMessage"
|
||||
# if jour.jour_type == "Project"
|
||||
# if jour.project.is_public == false && !current_user.member_of?(jour.project)
|
||||
# status = -1
|
||||
# tip = 1
|
||||
# end
|
||||
# elsif jour.jour_type == "Course"
|
||||
# if jour.course.is_public == 0 && !current_user.member_of_course?(jour.course)
|
||||
# status = -1
|
||||
# tip = 0
|
||||
# end
|
||||
# end
|
||||
|
||||
if status == 0
|
||||
# if reply_type == nil || reply_type == 0
|
||||
jour = JournalsForMessage.find(params[:id]).root
|
||||
parent_id = params[:id]
|
||||
author_id = current_user.id
|
||||
reply_user_id = jour.user_id
|
||||
reply_id = params[:id]
|
||||
content = params[:content]
|
||||
options = {:user_id => author_id,
|
||||
:status => true,
|
||||
:m_parent_id => parent_id,
|
||||
:m_reply_id => reply_id,
|
||||
:reply_id => reply_user_id,
|
||||
:root_id => jour.id,
|
||||
:notes => content,
|
||||
:is_readed => false}
|
||||
jfm = jour.user.add_jour(nil, nil, nil, options)
|
||||
if jfm.errors.empty?
|
||||
(JournalsForMessage.find parent_id).update_attribute(:updated_on,Time.now)
|
||||
result = 2
|
||||
update_id = jour.id
|
||||
end
|
||||
# else
|
||||
#二级回复
|
||||
|
||||
# end
|
||||
end
|
||||
when 'Issue'
|
||||
# if issue.project.is_public == false && !current_user.member_of?(issue.project)
|
||||
# status = -1
|
||||
# tip = 1
|
||||
# end
|
||||
|
||||
if status == 0
|
||||
if reply_type == nil || reply_type == 0
|
||||
issue = Issue.find params[:id]
|
||||
is_jour = Journal.new
|
||||
is_jour.user_id = current_user.id
|
||||
is_jour.notes = params[:content]
|
||||
is_jour.journalized = issue
|
||||
if is_jour.save
|
||||
result = 2
|
||||
update_id = issue.id
|
||||
end
|
||||
else
|
||||
#二级回复
|
||||
jour = Journal.find(params[:id])
|
||||
issue = jour.journalized
|
||||
is_jour = Journal.new
|
||||
is_jour.user_id = current_user.id
|
||||
is_jour.notes = params[:content]
|
||||
is_jour.reply_id = params[:id]
|
||||
is_jour.parent_id = params[:id]
|
||||
is_jour.journalized = issue
|
||||
if is_jour.save
|
||||
result = 2
|
||||
update_id = issue.id
|
||||
end
|
||||
end
|
||||
end
|
||||
when 'BlogComment'
|
||||
if reply_type == nil || reply_type == 0
|
||||
blog = BlogComment.find(params[:id]).root
|
||||
blogComment = BlogComment.new
|
||||
blogComment.author = current_user
|
||||
blogComment.blog = blog.blog
|
||||
blogComment.content = params[:content]
|
||||
blogComment.title = "RE: #{blog.title}"
|
||||
blogComment.root_id = blog.id
|
||||
if blog.children << blogComment
|
||||
result = 2
|
||||
update_id = blog.id
|
||||
end
|
||||
else
|
||||
#二级回复
|
||||
blog = BlogComment.find(params[:id]).root
|
||||
blogComment = BlogComment.new
|
||||
blogComment.author = current_user
|
||||
blogComment.blog = blog.blog
|
||||
blogComment.content = params[:content]
|
||||
blogComment.title = "RE: #{blog.title}"
|
||||
parent = BlogComment.find params[:id]
|
||||
blogComment.parent_id = params[:id] #被回复的回复
|
||||
blogComment.reply_id = parent.author.id #被回复者id
|
||||
blogComment.root_id = blog.id
|
||||
|
||||
if parent.children << blogComment
|
||||
result = 2
|
||||
update_id = blog.id
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
if result == 2
|
||||
update_course_activity_api(type,update_id)
|
||||
update_user_activity_api(type,update_id)
|
||||
update_org_activity_api(type,update_id)
|
||||
update_forge_activity_api(type,update_id)
|
||||
update_principal_activity_api(type,update_id)
|
||||
end
|
||||
else
|
||||
result = 3
|
||||
end
|
||||
present :result, result
|
||||
present :status, status
|
||||
present :act_id, update_id
|
||||
present :tip, tip
|
||||
present :subscribe,subscribe
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,47 @@
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Newss< Grape::API
|
||||
resources :newss do
|
||||
|
||||
desc "get special news"
|
||||
post ':id' do
|
||||
begin
|
||||
# authenticate!
|
||||
user = current_user
|
||||
|
||||
#0一级回复的更多 1 二级回复的更多
|
||||
type = params[:type] || 0
|
||||
page = params[:page] || 0
|
||||
|
||||
is_public = 1
|
||||
|
||||
if type == 0
|
||||
news = News.find params[:id]
|
||||
|
||||
if news.project
|
||||
is_public = news.project.is_public
|
||||
elsif news.course
|
||||
is_public = news.course.is_public
|
||||
end
|
||||
else
|
||||
news = Comment.find params[:id]
|
||||
end
|
||||
|
||||
present :data, news, with: Mobile::Entities::News,user: user,type: type,page: page
|
||||
present :type, type
|
||||
present :page, page
|
||||
present :is_public, is_public
|
||||
present :status, 0
|
||||
rescue Exception=>e
|
||||
Rails.logger.info "course_notice is not find!"
|
||||
Rails.logger.info e
|
||||
present :status, -1
|
||||
present :message, e.message
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,350 @@
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Projects < Grape::API
|
||||
|
||||
resources :projects do
|
||||
desc "获取项目列表"
|
||||
params do
|
||||
requires :token, type: String
|
||||
end
|
||||
get do
|
||||
authenticate!
|
||||
|
||||
ps = ProjectsService.new
|
||||
projects = ps.user_projects(current_user)
|
||||
present :data, projects, with: Mobile::Entities::Project,user: current_user
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
desc "返回单个项目"
|
||||
params do
|
||||
requires :id, type: Integer
|
||||
requires :token,type:String
|
||||
end
|
||||
route_param :id do
|
||||
get do
|
||||
# course = Course.find(params[:id])
|
||||
ps = ProjectsService.new
|
||||
project = ps.show_project(params,current_user)
|
||||
|
||||
if project[:status] == 9
|
||||
{status:-1, message: '该项目不存在或已被删除啦' }
|
||||
else
|
||||
present :data, project, with: Mobile::Entities::Project,user: current_user
|
||||
present :status, 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "获取项目动态"
|
||||
params do
|
||||
requires :id, type: Integer
|
||||
requires :token, type: String
|
||||
end
|
||||
post 'activities' do
|
||||
authenticate!
|
||||
|
||||
user = current_user
|
||||
|
||||
project_types = "('Message','Issue','Project')"
|
||||
activities = UserActivity.where("(container_type = 'Project' and container_id = #{params[:id]} and act_type in #{project_types})").order('updated_at desc')
|
||||
|
||||
page = params[:page] ? params[:page] : 0
|
||||
all_count = activities.count
|
||||
activities = activities.limit(10).offset(page * 10)
|
||||
count = activities.count
|
||||
present :data, activities, with: Mobile::Entities::Activity,user: user
|
||||
present :all_count, all_count
|
||||
present :count, count
|
||||
present :page, page
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
desc "获取项目成员"
|
||||
params do
|
||||
requires :id, type: Integer
|
||||
requires :token, type: String
|
||||
end
|
||||
post 'members' do
|
||||
authenticate!
|
||||
|
||||
project = Project.find("#{params[:id]}")
|
||||
members = project.member_principals
|
||||
|
||||
master_members = project.member_principals.includes(:roles, :principal).where("member_roles.role_id=3").all.sort
|
||||
|
||||
master_members.each do |m|
|
||||
if m.user_id == project.user_id
|
||||
master_members.delete(m)
|
||||
master_members.insert(0,m)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
develop_members = project.member_principals.includes(:roles, :principal).where("member_roles.role_id=4").all.sort
|
||||
report_members = project.member_principals.includes(:roles, :principal).where("member_roles.role_id=5").all.sort
|
||||
|
||||
review_master_members = []
|
||||
review_develop_members = []
|
||||
|
||||
my_member = project.member_principals.where("users.id=#{current_user.id}").first
|
||||
if my_member && my_member.roles[0] && my_member.roles[0].id == 3
|
||||
ps = ProjectsService.new
|
||||
|
||||
user = current_user
|
||||
review_master_members = ps.get_project_review_members(project,3,user)
|
||||
review_develop_members = ps.get_project_review_members(project,4,user)
|
||||
|
||||
end
|
||||
|
||||
present :master_members,master_members, with: Mobile::Entities::ProjectMember
|
||||
present :develop_members,develop_members, with: Mobile::Entities::ProjectMember
|
||||
present :report_members,report_members, with: Mobile::Entities::ProjectMember
|
||||
present :review_master_members,review_master_members
|
||||
present :review_develop_members,review_develop_members
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
desc "获取项目某成员角色信息"
|
||||
params do
|
||||
requires :id, type: Integer
|
||||
requires :token, type: String
|
||||
requires :user_id, type: Integer
|
||||
end
|
||||
post 'get_member_info' do
|
||||
authenticate!
|
||||
|
||||
project = Project.find("#{params[:id]}")
|
||||
|
||||
my_member = project.member_principals.where("users.id=#{params[:user_id]}").first
|
||||
|
||||
if my_member && my_member.roles[0]
|
||||
present :project_id,params[:id]
|
||||
present :user_id,params[:user_id]
|
||||
present :member_info,my_member, with: Mobile::Entities::ProjectMember
|
||||
present :status, 0
|
||||
else
|
||||
present :status, -1
|
||||
present :message, "该用户已不在项目中"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc "修改项目某成员角色信息"
|
||||
params do
|
||||
requires :id, type: Integer
|
||||
requires :token, type: String
|
||||
requires :user_id, type: Integer
|
||||
requires :role_id, type: Integer
|
||||
end
|
||||
post 'edit_member_role' do
|
||||
authenticate!
|
||||
|
||||
project = Project.find("#{params[:id]}")
|
||||
|
||||
my_member = project.member_principals.where("users.id=#{current_user.id}").first
|
||||
|
||||
#3管理 4开发 5报告
|
||||
if !(my_member && my_member.roles[0] && my_member.roles[0].id == 3 ) || project.user_id == params[:user_id] || !(params[:role_id] == 3 || params[:role_id] == 4 || params[:role_id] == 5)
|
||||
present :status, -1
|
||||
else
|
||||
ps = ProjectsService.new
|
||||
|
||||
status = ps.modify_user_project_role params
|
||||
|
||||
present :status, status
|
||||
end
|
||||
end
|
||||
|
||||
desc "新建项目"
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :name, type: String, desc: '项目名称'
|
||||
end
|
||||
post 'create' do
|
||||
authenticate!
|
||||
|
||||
ps = ProjectsService.new
|
||||
|
||||
status = ps.createNewProject params,current_user
|
||||
|
||||
|
||||
present :status, 0
|
||||
|
||||
end
|
||||
|
||||
desc "加入项目"
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :invite_code, type: String, desc: '邀请码'
|
||||
requires :role_id, type: Integer, desc: '身份'
|
||||
end
|
||||
post "join_project" do
|
||||
authenticate!
|
||||
|
||||
role_id = params[:role_id]
|
||||
|
||||
if role_id != 3 && role_id != 4 && role_id != 5
|
||||
{status:-1,message:"请至少选择一个角色"}
|
||||
else
|
||||
ps = ProjectsService.new
|
||||
status = ps.join_project({role: role_id, openid: params[:openid], invite_code: params[:invite_code]}, current_user)
|
||||
|
||||
{status:status, message:ProjectsService::JoinProjectError.message(status)}
|
||||
end
|
||||
|
||||
# {status:-1, message: '该功能将在近日开放,敬请期待!' }
|
||||
end
|
||||
|
||||
desc "项目单个未审核用户信息"
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :project_id, type: Integer, desc: "项目id"
|
||||
requires :user_id, type: Integer, desc: "用户id"
|
||||
end
|
||||
post 'review_member_info' do
|
||||
authenticate!
|
||||
|
||||
ps = ProjectsService.new
|
||||
result = ps.get_reviewer_info(params,current_user)
|
||||
present :data, result[:reviewer], with: Mobile::Entities::User
|
||||
present :status, result[:status]
|
||||
end
|
||||
|
||||
desc "处理管理或开发的身份申请"
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :project_id, type: Integer, desc: "项目id"
|
||||
requires :user_id, type: Integer, desc: "用户id"
|
||||
requires :type, type: Integer, desc: "同意或拒绝"
|
||||
end
|
||||
post 'deal_join_apply' do
|
||||
authenticate!
|
||||
|
||||
ps = ProjectsService.new
|
||||
result = ps.deal_join_apply(params,current_user)
|
||||
|
||||
present :status, result[:status]
|
||||
present :message, result[:message]
|
||||
end
|
||||
|
||||
desc "发布项目帖子"
|
||||
params do
|
||||
requires :id, type: Integer
|
||||
requires :token, type: String
|
||||
requires :text, type: String
|
||||
end
|
||||
post ':id/publishnote' do
|
||||
authenticate!
|
||||
|
||||
project = Project.find("#{params[:id]}")
|
||||
|
||||
boards = project.boards.includes(:last_message => :author).all
|
||||
if project.boards.empty?
|
||||
board = project.boards.build
|
||||
board.name = "项目讨论区"
|
||||
board.description = project.name.to_s
|
||||
board.course_id = -1
|
||||
if board.save
|
||||
boards = project.boards.includes(:last_message => :author).all
|
||||
end
|
||||
end
|
||||
|
||||
board = boards.first
|
||||
|
||||
message = Message.new
|
||||
message.author = current_user
|
||||
message.board = board
|
||||
|
||||
tmpparams = {}
|
||||
tmpparams['subject'] = params[:title]
|
||||
tmpparams['content'] = params[:text]
|
||||
|
||||
message.safe_attributes = tmpparams
|
||||
|
||||
message.save!
|
||||
|
||||
present :status, 0
|
||||
|
||||
end
|
||||
|
||||
desc "删除项目成员"
|
||||
params do
|
||||
requires :id, type: Integer
|
||||
requires :token, type: String
|
||||
requires :user_id, type: Integer
|
||||
end
|
||||
post ':id/deletemember' do
|
||||
authenticate!
|
||||
|
||||
status = -1
|
||||
|
||||
if(current_user.id != params[:user_id].to_i)
|
||||
#权限
|
||||
project = Project.find("#{params[:id]}")
|
||||
if project.user_id != params[:user_id].to_i
|
||||
|
||||
my_member = project.member_principals.where("users.id=#{current_user.id}").first
|
||||
|
||||
roles_ids = []
|
||||
my_member.roles.each do |role|
|
||||
roles_ids << role.id
|
||||
end
|
||||
|
||||
if my_member && roles_ids.include?(3)
|
||||
#删除该成员
|
||||
ps = ProjectsService.new
|
||||
status = ps.project_delete_member(project,params[:user_id].to_i,current_user)
|
||||
else
|
||||
status = -2
|
||||
end
|
||||
else
|
||||
status = -3
|
||||
end
|
||||
else
|
||||
status = -4
|
||||
end
|
||||
|
||||
out = {status: status}
|
||||
message = case status
|
||||
when 0; "删除成功"
|
||||
when 1; "该用户不在该项目中"
|
||||
when -1; "您还未登录"
|
||||
when -2; "您没有权限"
|
||||
when -3; "不能删除项目创建者"
|
||||
when -4; "不能删除自己"
|
||||
else; "未知错误,请稍后再试"
|
||||
end
|
||||
out.merge(message: message)
|
||||
end
|
||||
|
||||
desc "退出项目"
|
||||
params do
|
||||
requires :id, type: Integer
|
||||
requires :token, type: String
|
||||
end
|
||||
post ':id/quit' do
|
||||
authenticate!
|
||||
|
||||
project = Project.find("#{params[:id]}")
|
||||
|
||||
ps = ProjectsService.new
|
||||
status = ps.exit_project(project,current_user)
|
||||
|
||||
out = {status: status}
|
||||
message = case status
|
||||
when 0; "退出项目成功"
|
||||
when -3; "您不是该项目成员"
|
||||
when -1; "您还未登录"
|
||||
when -2; "项目创建者不能退出项目"
|
||||
else; "未知错误,请稍后再试"
|
||||
end
|
||||
out.merge(message: message)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,119 @@
|
||||
#coding=utf-8
|
||||
module Mobile
|
||||
module Apis
|
||||
class Resources < Grape::API
|
||||
|
||||
resource :competition_teams do
|
||||
|
||||
desc '获取所有课件'
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :page, type: Integer
|
||||
end
|
||||
post do
|
||||
authenticate!
|
||||
page = params[:page] ? params[:page] : 0
|
||||
|
||||
rs = ResourcesService.new
|
||||
# data = current_user.course_attachments
|
||||
data = rs.all_course_attachments current_user
|
||||
all_count = data.count
|
||||
data = data.limit(10).offset(page * 10)
|
||||
count = data.count
|
||||
|
||||
present :data, data, with: Mobile::Entities::Attachment,user: current_user
|
||||
present :all_count, all_count
|
||||
present :count, count
|
||||
present :page, page
|
||||
present :status, 0
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
desc '获取所有作业'
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :page, type: Integer
|
||||
end
|
||||
post 'homeworks' do
|
||||
authenticate!
|
||||
|
||||
page = params[:page] ? params[:page] : 0
|
||||
|
||||
rs = ResourcesService.new
|
||||
homeworks = rs.all_homework_commons current_user
|
||||
|
||||
all_count = homeworks.count
|
||||
homeworks = homeworks.limit(10).offset(page * 10)
|
||||
count = homeworks.count
|
||||
|
||||
present :data, homeworks, with: Mobile::Entities::Homework,user: current_user
|
||||
present :all_count, all_count
|
||||
present :count, count
|
||||
present :page, page
|
||||
present :status, 0
|
||||
|
||||
end
|
||||
|
||||
desc '获取所有测验'
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :page, type: Integer
|
||||
end
|
||||
post 'exercises' do
|
||||
authenticate!
|
||||
|
||||
page = params[:page] ? params[:page] : 0
|
||||
|
||||
rs = ResourcesService.new
|
||||
exercises = rs.all_exercises current_user
|
||||
all_count = exercises.count
|
||||
exercises = exercises.limit(10).offset(page * 10)
|
||||
count = exercises.count
|
||||
|
||||
present :data, exercises, with: Mobile::Entities::Exercise,user: current_user
|
||||
present :all_count, all_count
|
||||
present :count, count
|
||||
present :page, page
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
|
||||
desc '发送资源'
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :course_ids, type: Array[Integer]
|
||||
requires :send_id, type: Integer
|
||||
requires :send_type, type: Integer
|
||||
end
|
||||
post 'send' do
|
||||
authenticate!
|
||||
|
||||
rs = ResourcesService.new
|
||||
|
||||
ori = nil
|
||||
flag = false
|
||||
save_message = nil
|
||||
|
||||
case params[:send_type]
|
||||
when 1
|
||||
ori, flag, save_message = rs.send_resource_to_course(current_user,params)
|
||||
when 2
|
||||
ori, flag, save_message = rs.send_homework_to_course(current_user,params)
|
||||
when 3
|
||||
ori, flag, save_message = rs.send_exercise_to_course(current_user,params)
|
||||
end
|
||||
|
||||
if flag
|
||||
present :status, 0
|
||||
else
|
||||
{status: -1, message: save_message.first}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,236 @@
|
||||
# encoding=utf-8
|
||||
module Mobile
|
||||
module Apis
|
||||
class Sources < Grape::API
|
||||
before {private_auth}
|
||||
content_type :json, 'application/json;charset=UTF-8'
|
||||
|
||||
resources :sources do
|
||||
# shixuns TPM start ############################################
|
||||
desc '所有实训列表'
|
||||
params do
|
||||
requires :time, type: Date, desc: '创建时间'
|
||||
end
|
||||
get "shixun_index" do
|
||||
SourcesService.new.shixun_index(params)
|
||||
end
|
||||
|
||||
desc '显示TPM详情'
|
||||
params do
|
||||
requires :identifier, type: String, desc: 'shixun identifier.'
|
||||
end
|
||||
route_param :identifier do
|
||||
get 'shixun_detail' do
|
||||
SourcesService.new.shixun_detail(params)
|
||||
end
|
||||
end
|
||||
|
||||
desc '显示实训的challenges'
|
||||
params do
|
||||
requires :identifier, type: String, desc: 'shixun identifier.'
|
||||
end
|
||||
route_param :identifier do
|
||||
get 'shixun_challenges' do
|
||||
SourcesService.new.shixun_challenges(params)
|
||||
end
|
||||
end
|
||||
|
||||
desc "获取TPM所有TPI的信息"
|
||||
params do
|
||||
requires :identifier, type: String, desc: "TPM的shixun.identifier"
|
||||
end
|
||||
route_param :identifier do
|
||||
get 'get_tpi_info' do
|
||||
SourcesService.new.get_tpi_info params
|
||||
end
|
||||
end
|
||||
|
||||
# games start ############################################
|
||||
desc '所有games'
|
||||
params do
|
||||
requires :time, type: Date, desc: '创建时间'
|
||||
end
|
||||
get "myshixuns_index" do
|
||||
SourcesService.new.myshixuns_index(params)
|
||||
end
|
||||
|
||||
# 搜索学员实训
|
||||
desc '搜索学员实训'
|
||||
params do
|
||||
requires :shixun_id, type: Integer
|
||||
requires :user_id, type: Integer
|
||||
end
|
||||
get "search_myshixun" do
|
||||
SourcesService.new.search_myshixun(params)
|
||||
end
|
||||
|
||||
desc '所有games'
|
||||
params do
|
||||
requires :time, type: Date, desc: '创建时间'
|
||||
end
|
||||
get "games" do
|
||||
SourcesService.new.games(params)
|
||||
end
|
||||
|
||||
desc 'game详情'
|
||||
params do
|
||||
requires :identifier, type: String, desc: 'game identifier'
|
||||
end
|
||||
route_param :identifier do
|
||||
get 'game_detail' do
|
||||
SourcesService.new.game_detail(params)
|
||||
end
|
||||
end
|
||||
|
||||
# 搜索学员实训
|
||||
desc '搜索学员实训'
|
||||
params do
|
||||
requires :user_id, type: Integer
|
||||
requires :challenge_id, type: Integer
|
||||
end
|
||||
get "search_game" do
|
||||
SourcesService.new.search_game(params)
|
||||
end
|
||||
|
||||
# paths start #####################################
|
||||
desc "实训路径信息"
|
||||
params do
|
||||
requires :id, type: Integer, desc: "实训路径id"
|
||||
end
|
||||
route_param :id do
|
||||
get 'get_paths_info' do
|
||||
SourcesService.new.get_paths_info params
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# users start ############################################
|
||||
desc '所有用户'
|
||||
params do
|
||||
requires :time, type: Date, desc: '创建时间'
|
||||
end
|
||||
get "users" do
|
||||
SourcesService.new.users(params)
|
||||
end
|
||||
|
||||
desc "登陆验证"
|
||||
params do
|
||||
requires :username, type: String, desc: "用户名"
|
||||
requires :password, type: String, desc: "密码"
|
||||
end
|
||||
post "login" do
|
||||
SourcesService.new.login params
|
||||
end
|
||||
|
||||
desc "获取用户信息"
|
||||
route_param :id do
|
||||
get "get_user_info" do
|
||||
SourcesService.new.get_user_info params
|
||||
end
|
||||
end
|
||||
|
||||
# courses start ############################################
|
||||
desc "所有课程列表"
|
||||
params do
|
||||
requires :time, type: Date, desc: '创建时间'
|
||||
end
|
||||
get 'courses' do
|
||||
SourcesService.new.courses params
|
||||
end
|
||||
|
||||
desc '课堂详情'
|
||||
route_param :id do
|
||||
get 'course_detail' do
|
||||
SourcesService.new.course_detail(params)
|
||||
end
|
||||
end
|
||||
|
||||
# Exercise start ###########################
|
||||
desc "所有试卷"
|
||||
params do
|
||||
requires :time, type: Date, desc: '创建时间'
|
||||
end
|
||||
get 'exercises' do
|
||||
SourcesService.new.exercises params
|
||||
end
|
||||
|
||||
desc '试卷详情'
|
||||
route_param :id do
|
||||
get 'exercise_detail' do
|
||||
SourcesService.new.exercise_detail(params)
|
||||
end
|
||||
end
|
||||
|
||||
desc "题目详情"
|
||||
params do
|
||||
requires :id, type: Integer, desc: "试卷id"
|
||||
end
|
||||
route_param :id do
|
||||
get 'get_exercise_questions' do
|
||||
SourcesService.new.get_exercise_questions params
|
||||
end
|
||||
end
|
||||
|
||||
desc '课堂实训作业'
|
||||
params do
|
||||
requires :course_id, type: Integer, desc: 'course id'
|
||||
end
|
||||
route_param :identifier do
|
||||
get 'exercise_detail' do
|
||||
SourcesService.new.shixun_homework_commons(params)
|
||||
end
|
||||
end
|
||||
|
||||
desc "获取竞赛用户所在组"
|
||||
params do
|
||||
requires :identifier, type: String, desc: 'competition.identifier竞赛唯一标识'
|
||||
requires :user_id, type: Integer, desc: "用户id"
|
||||
end
|
||||
route_param :identifier do
|
||||
get "get_competition_members" do
|
||||
SourcesService.new.get_competition_members(params)
|
||||
end
|
||||
end
|
||||
|
||||
desc "获取竞赛战队ID"
|
||||
params do
|
||||
requires :identifier, type: String, desc: 'competition.identifier竞赛唯一标识'
|
||||
end
|
||||
route_param :identifier do
|
||||
get 'get_team_ids' do
|
||||
SourcesService.new.get_team_ids params
|
||||
end
|
||||
end
|
||||
|
||||
desc "获取竞赛组内成员"
|
||||
params do
|
||||
requires :team_id, type: Integer, desc: "竞赛分组id"
|
||||
requires :identifier
|
||||
end
|
||||
route_param :identifier do
|
||||
get 'get_team_user_ids' do
|
||||
SourcesService.new.get_team_user_ids params
|
||||
end
|
||||
end
|
||||
|
||||
desc "获取用户在比赛中对应的组id"
|
||||
params do
|
||||
requires :educoder_userid
|
||||
requires :identifier
|
||||
end
|
||||
get 'get_user_competition_id' do
|
||||
SourcesService.new.get_user_competition_id params
|
||||
end
|
||||
|
||||
desc "获取竞赛小组信息"
|
||||
params do
|
||||
requires :identifier, type: String, desc: "竞赛标识"
|
||||
end
|
||||
get 'get_team_info' do
|
||||
SourcesService.new.get_team_info params
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,103 @@
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Syllabuses < Grape::API
|
||||
|
||||
resources :syllabuses do
|
||||
desc "获取大纲列表"
|
||||
params do
|
||||
requires :token, type: String
|
||||
end
|
||||
get do
|
||||
authenticate!
|
||||
|
||||
cs = SyllabusesService.new
|
||||
courses = cs.user_syllabus(current_user)
|
||||
present :data, courses, with: Mobile::Entities::Syllabus,user: current_user
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
desc "获取某个大纲"
|
||||
params do
|
||||
requires :token, type: String
|
||||
end
|
||||
get ':id' do
|
||||
authenticate!
|
||||
|
||||
ss = SyllabusesService.new
|
||||
|
||||
sy = ::Syllabus.find(params[:id])
|
||||
|
||||
result = {:title=>sy.title, :id=>sy.id , :user_id=>sy.user_id,:courses=>sy.courses.not_deleted}
|
||||
|
||||
present :data, result, with: Mobile::Entities::Syllabus,user: current_user
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
desc "获取新建大纲的权限"
|
||||
params do
|
||||
requires :token, type: String
|
||||
end
|
||||
post 'auth' do
|
||||
authenticate!
|
||||
|
||||
auth = 0
|
||||
|
||||
if (current_user.user_extensions && current_user.user_extensions.identity == 0 && current_user.allowed_to?(:add_course, nil, :global => true))
|
||||
auth = 1
|
||||
end
|
||||
|
||||
present :auth, auth
|
||||
end
|
||||
|
||||
desc "新建大纲"
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :title, type: String, desc: '大纲标题'
|
||||
requires :courses, type: Array[String], desc: '课程名'
|
||||
end
|
||||
post do
|
||||
authenticate!
|
||||
|
||||
ss = SyllabusesService.new
|
||||
|
||||
sy = ss.create(current_user, params[:title],
|
||||
params[:courses].map{|c| {name: c} })
|
||||
|
||||
if sy.new_record?
|
||||
{status:-1, message: '创建大纲失败' }
|
||||
else
|
||||
present :data, sy, with: Mobile::Entities::Syllabus,user: current_user
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc '编辑大纲'
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :title, type: String, desc: '大纲标题'
|
||||
# requires :add_courses, type: Array[String], desc: '课程名'
|
||||
# requires :modify_courses, type: Array[Integer,String], desc: '课程名'
|
||||
end
|
||||
post ':id/edit' do
|
||||
|
||||
authenticate!
|
||||
|
||||
ss = SyllabusesService.new
|
||||
|
||||
#修改课程大纲
|
||||
status = ss.edit(current_user, params)
|
||||
|
||||
if status == -1
|
||||
{status:status, message: '修改课程信息失败' }
|
||||
else
|
||||
present :status, status
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,49 @@
|
||||
#coding=utf-8
|
||||
module Mobile
|
||||
module Apis
|
||||
class Watches < Grape::API
|
||||
resource :watches do
|
||||
|
||||
desc "获取所有关注"
|
||||
params do
|
||||
requires :token, type: String
|
||||
end
|
||||
get do
|
||||
authenticate!
|
||||
us = UsersService.new
|
||||
ws = us.user_watcher(id: current_user.id)
|
||||
present :data, ws, with: Mobile::Entities::User
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
|
||||
desc "关注某人"
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :object_id, type: Integer, desc: '关注的用户的id'
|
||||
end
|
||||
post do
|
||||
authenticate!
|
||||
ws = WatchesService.new
|
||||
o = ws.watch(params.merge({current_user_id:current_user.id, object_type:'user' }) )
|
||||
present :data, o, with: Mobile::Entities::User
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
|
||||
desc "取消关注"
|
||||
params do
|
||||
requires :token, type: String
|
||||
requires :object_id, type: Integer, desc: '取消关注的用户的id'
|
||||
end
|
||||
delete do
|
||||
authenticate!
|
||||
ws = WatchesService.new
|
||||
ws.unwatch(params.merge({current_user_id:current_user.id, object_type:'user' }) )
|
||||
{status: 0}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,40 @@
|
||||
#coding=utf-8
|
||||
|
||||
module Mobile
|
||||
module Apis
|
||||
class Whomeworks< Grape::API
|
||||
resources :whomeworks do
|
||||
|
||||
desc "get one homework"
|
||||
post ':id' do
|
||||
begin
|
||||
# authenticate!
|
||||
user = current_user
|
||||
|
||||
#0一级回复的更多 1 二级回复的更多
|
||||
type = params[:type] || 0
|
||||
page = params[:page] || 0
|
||||
|
||||
is_public = 1
|
||||
|
||||
if type == 0
|
||||
homework = HomeworkCommon.find params[:id]
|
||||
is_public = homework.course.is_public
|
||||
present :data, homework, with: Mobile::Entities::Whomework,user: user,type: type,page: page,comment_type: "homework"
|
||||
else
|
||||
jour = JournalsForMessage.find params[:id]
|
||||
present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page,comment_type: "homework"
|
||||
end
|
||||
present :type, type
|
||||
present :page, page
|
||||
present :is_public, is_public
|
||||
present :status, 0
|
||||
rescue Exception=>e
|
||||
present :status, -1
|
||||
present :message, e.message
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,195 @@
|
||||
# encoding: utf-8
|
||||
module Mobile
|
||||
module Entities
|
||||
class Activity <Grape::Entity
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.act_expose(f)
|
||||
expose f do |ac,opt|
|
||||
if ac.is_a?(Hash) && ac.key?(f)
|
||||
ac[f]
|
||||
elsif ac.is_a?(::UserActivity)
|
||||
if ac.respond_to?(f)
|
||||
ac.send(f)
|
||||
else
|
||||
case f
|
||||
when :user_act
|
||||
if ac.act_type == "Project"
|
||||
ac unless ac.nil?
|
||||
else
|
||||
ac.act unless ac.nil? || ac.act.nil?
|
||||
end
|
||||
when :reply_count
|
||||
if ac.act_type == "HomeworkCommon"
|
||||
ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count
|
||||
elsif ac.act_type == "News"
|
||||
ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count
|
||||
elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage"
|
||||
className = ac.act_type.classify.constantize
|
||||
# all_comments = []
|
||||
# ac.nil? || ac.act.nil? ? 0 : get_all_children(all_comments, ac.act).count
|
||||
ac.nil? || ac.act.nil? ? 0 : className.where("root_id = #{ac.act.id}").count
|
||||
elsif ac.act_type == "Issue"
|
||||
ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count
|
||||
end
|
||||
|
||||
when :subject
|
||||
if ac.act_type == "HomeworkCommon"
|
||||
ac.act.name unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "News" || ac.act_type == "BlogComment"
|
||||
ac.act.title unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "Message" || ac.act_type == "Issue"
|
||||
ac.act.subject unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "JournalsForMessage"
|
||||
ac.act.private == 0 ? "留言" : "私信" unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "Poll"
|
||||
ac.act.polls_name unless ac.nil? || ac.act.nil?
|
||||
end
|
||||
when :description
|
||||
if ac.act_type == "HomeworkCommon" || ac.act_type == "Issue" || ac.act_type == "News"
|
||||
strip_html(ac.act.description) unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "Message" || ac.act_type == "BlogComment"
|
||||
strip_html(ac.act.content) unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "JournalsForMessage"
|
||||
strip_html(ac.act.notes) unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "Poll"
|
||||
ac.act.polls_description unless ac.nil? || ac.act.nil?
|
||||
end
|
||||
when :latest_update
|
||||
time_from_now ac.updated_at unless ac.nil?
|
||||
when :praise_count
|
||||
if ac.act_type == "HomeworkCommon" || ac.act_type == "News" || ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" || ac.act_type == "Issue"
|
||||
ac.nil? || ac.act.nil? ? 0 : get_activity_praise_num(ac.act)
|
||||
end
|
||||
#when :homework_common_detail_manual
|
||||
# if ac.act_type == "HomeworkCommon"
|
||||
# ac.act.homework_detail_manual unless ac.nil? || ac.act.nil? || ac.act.homework_detail_manual.nil?
|
||||
# end
|
||||
when :course_project_name
|
||||
if ac.container_type == "Course"
|
||||
name = (get_course(ac.container_id)).name
|
||||
name
|
||||
elsif ac.container_type == "Project"
|
||||
name = (get_project(ac.container_id)).name
|
||||
name
|
||||
elsif ac.container_type == "Blog"
|
||||
"发表博客"
|
||||
end
|
||||
when :syllabus_title
|
||||
if ac.container_type == "Course"
|
||||
course = get_course(ac.container_id)
|
||||
name = course.syllabus.nil? ? "":course.syllabus.title
|
||||
name
|
||||
end
|
||||
when :course_project_id
|
||||
if ac.container_type == "Course"
|
||||
ac.container_id
|
||||
elsif ac.container_type == "Project"
|
||||
ac.container_id
|
||||
end
|
||||
when :activity_type_name
|
||||
if ac.container_type == "Course"
|
||||
case ac.act_type
|
||||
when "HomeworkCommon"
|
||||
"班级作业"
|
||||
when "News"
|
||||
"班级通知"
|
||||
when "Message"
|
||||
"班级讨论区"
|
||||
when "Poll"
|
||||
"班级问卷"
|
||||
when "Course"
|
||||
"班级"
|
||||
end
|
||||
elsif ac.container_type == "Project"
|
||||
case ac.act_type
|
||||
when "Issue"
|
||||
"项目问题"
|
||||
when "Message"
|
||||
"项目讨论区"
|
||||
when "Project"
|
||||
"项目"
|
||||
end
|
||||
end
|
||||
when :homework_commit_count
|
||||
if ac.act_type == "HomeworkCommon"
|
||||
ac.act.student_works.has_committed.count
|
||||
end
|
||||
when :last_commit_info
|
||||
if ac.act_type == "HomeworkCommon"
|
||||
if ac.act.student_works.has_committed.count > 0
|
||||
lc = ac.act.student_works.has_committed.reorder("commit_time desc").first
|
||||
{:lasttime=>time_from_now(lc.commit_time), :lastname=>lc.user.show_name}
|
||||
end
|
||||
end
|
||||
when :last_score_info
|
||||
if ac.act_type == "HomeworkCommon"
|
||||
if ac.act.student_works.has_committed.count > 0
|
||||
sw_id = "("+ac.act.student_works.map{|sw| sw.id}.join(",")+")"
|
||||
student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id} and score is not null").reorder("created_at desc")
|
||||
unless student_work_scores.empty?
|
||||
last_score = student_work_scores.first
|
||||
{:lasttime=>time_from_now(last_score.created_at), :lastname=>last_score.user.show_name}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
expose :act_type #缺陷/作业/讨论区/留言等类型
|
||||
expose :act_id
|
||||
expose :id
|
||||
expose :container_type #课程/项目/博客/个人
|
||||
expose :author, using: Mobile::Entities::User do |a, opt| #用户信息
|
||||
if a.is_a? ::UserActivity
|
||||
if a.act_type == "Project"
|
||||
get_user(get_project(a.act_id).user_id)
|
||||
elsif !a.act.nil?
|
||||
if a.act_type == 'Issue' || a.act_type == 'News' || a.act_type == 'Message' || a.act_type == 'BlogComment'
|
||||
a.act.author
|
||||
elsif a.act_type == 'HomeworkCommon' || a.act_type == 'Poll' || a.act_type == 'JournalsForMessage'
|
||||
a.act.user
|
||||
elsif a.act_type == 'Course'
|
||||
a.act.teacher
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
expose :homework_common_detail , using: Mobile::Entities::Whomework do |a, opt| #作业相关信息
|
||||
if a.act_type == "HomeworkCommon"
|
||||
a.act
|
||||
end
|
||||
end
|
||||
expose :issue_detail, using: Mobile::Entities::Issue do |a, opt| #缺陷信息
|
||||
if a.act_type == "Issue"
|
||||
a.act
|
||||
end
|
||||
end
|
||||
act_expose :reply_count #回复数
|
||||
act_expose :praise_count #点赞数
|
||||
#act_expose :user_act #某个动态
|
||||
act_expose :subject #标题
|
||||
act_expose :description #描述
|
||||
act_expose :latest_update #最新更新时间
|
||||
act_expose :course_project_id #课程/项目ID
|
||||
act_expose :course_project_name #课程/项目名字
|
||||
act_expose :syllabus_title #课程名字
|
||||
act_expose :activity_type_name #课程问答区/项目缺陷等
|
||||
act_expose :homework_commit_count #作品提交数
|
||||
act_expose :last_commit_info #最近提交信息
|
||||
act_expose :last_score_info #最近评阅信息
|
||||
|
||||
expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
if instance.act_type == "HomeworkCommon" || instance.act_type == "News" || instance.act_type == "Message" || instance.act_type == "BlogComment" || instance.act_type == "JournalsForMessage" || instance.act_type == "Issue"
|
||||
has_praise = false
|
||||
current_user = options[:user]
|
||||
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
|
||||
end
|
||||
end
|
@ -0,0 +1,36 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
#匿评作品页面相关参数
|
||||
class AnonymousWorksParams < Grape::Entity
|
||||
def self.anonymous_works_params_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
f[field]
|
||||
elsif f.is_a?(Hash) && !f.key?(field)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
anonymous_works_params_expose :is_teacher
|
||||
anonymous_works_params_expose :m_score
|
||||
anonymous_works_params_expose :is_anonymous_comments
|
||||
anonymous_works_params_expose :cur_type
|
||||
anonymous_works_params_expose :cur_page
|
||||
expose :jours ,using: Mobile::Entities::Jours do |f, opt|
|
||||
if f.is_a?(Hash) && f.key?(:jours)
|
||||
f[:jours]
|
||||
end
|
||||
end
|
||||
expose :teacher_stars,using: Mobile::Entities::HomeworkJours do |f, opt|
|
||||
if f.is_a?(Hash) && f.key?(:teacher_stars)
|
||||
f[:teacher_stars]
|
||||
end
|
||||
end
|
||||
expose :student_stars , using: Mobile::Entities::HomeworkJours do |f, opt|
|
||||
if f.is_a?(Hash) && f.key?(:student_stars)
|
||||
f[:student_stars]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,58 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class Attachment < Grape::Entity
|
||||
include Redmine::I18n
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include ApplicationHelper
|
||||
def self.attachment_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
f[field]
|
||||
elsif f.is_a?(::Attachment)
|
||||
if f.respond_to?(field)
|
||||
if field == :created_on
|
||||
format_time(f.send(field))
|
||||
else
|
||||
f.send(field)
|
||||
end
|
||||
else
|
||||
case field
|
||||
when :download_url
|
||||
"attachments/download/#{f.try(:id)}"
|
||||
when :file_dir
|
||||
"attachments/download/" << f.send(:id).to_s << '/'
|
||||
when :attafile_size
|
||||
(number_to_human_size(f.filesize)).gsub("ytes", "").to_s
|
||||
when :coursename
|
||||
f.try(:course).try(:name) || ''
|
||||
when :syllabus_title
|
||||
f.try(:course).try(:syllabus).try(:title) || ''
|
||||
when :course_id
|
||||
f.try(:course).try(:id) || 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
attachment_expose :id
|
||||
attachment_expose :filename
|
||||
attachment_expose :description
|
||||
attachment_expose :downloads
|
||||
attachment_expose :quotes
|
||||
attachment_expose :created_on
|
||||
attachment_expose :file_dir
|
||||
attachment_expose :attafile_size
|
||||
attachment_expose :coursename #所属班级名
|
||||
attachment_expose :syllabus_title #所属班级名
|
||||
attachment_expose :course_id #所属班级名
|
||||
expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
current_user = options[:user]
|
||||
current_user_is_teacher = false
|
||||
current_user_is_teacher = is_course_teacher(current_user,instance.course)
|
||||
current_user_is_teacher
|
||||
end
|
||||
|
||||
attachment_expose :download_url
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,13 @@
|
||||
module Mobile
|
||||
|
||||
|
||||
module Entities
|
||||
class Auth < Grape::Entity
|
||||
expose :token
|
||||
expose :user, using: Mobile::Entities::User do |f, u|
|
||||
f[:user]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,139 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class BlogComment < Grape::Entity
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.blog_comment_expose(f)
|
||||
expose f do |u,opt|
|
||||
if u.is_a?(Hash) && u.key?(f)
|
||||
u[f]
|
||||
elsif u.is_a?(::BlogComment)
|
||||
if u.respond_to?(f)
|
||||
if f == :created_at
|
||||
format_time( u.send(f))
|
||||
else
|
||||
u.send(f)
|
||||
end
|
||||
else
|
||||
case f
|
||||
when :praise_count
|
||||
get_activity_praise_num(u)
|
||||
when :lasted_comment
|
||||
time_from_now(u.created_at)
|
||||
when :act_type
|
||||
'BlogComment'
|
||||
when :act_id
|
||||
u.id
|
||||
when :comment_count
|
||||
# u.children.count
|
||||
all_comments = []
|
||||
get_all_children(all_comments, u).count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
expose :user, using: Mobile::Entities::User do |c, opt|
|
||||
if c.is_a?(::BlogComment)
|
||||
c.author
|
||||
end
|
||||
end
|
||||
blog_comment_expose :act_type
|
||||
blog_comment_expose :act_id
|
||||
blog_comment_expose :blog_id
|
||||
blog_comment_expose :title
|
||||
blog_comment_expose :content
|
||||
blog_comment_expose :comment_count
|
||||
blog_comment_expose :created_at
|
||||
blog_comment_expose :lasted_comment
|
||||
blog_comment_expose :id
|
||||
blog_comment_expose :locked
|
||||
blog_comment_expose :praise_count
|
||||
expose :all_children, using:Mobile::Entities::BlogComment do |c,opt|
|
||||
if c.is_a? (::BlogComment)
|
||||
if !opt[:children]
|
||||
if c.parent.nil? && opt[:type] == 0
|
||||
opt[:children] = true
|
||||
all_comments = []
|
||||
tStart = opt[:page]*5
|
||||
tEnd = (opt[:page]+1)*5 - 1
|
||||
|
||||
all_comments = get_all_children(all_comments, c)[tStart..tEnd]
|
||||
all_comments
|
||||
end
|
||||
end
|
||||
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
|
||||
|
||||
expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
parents_reply = []
|
||||
parents_reply = get_reply_parents_no_root(parents_reply, instance)
|
||||
parents_reply.count
|
||||
end
|
||||
|
||||
expose :parents_reply_bottom, using:Mobile::Entities::BlogComment do |c,opt|
|
||||
if c.is_a? (::BlogComment)
|
||||
#取二级回复的底楼层
|
||||
parents_reply = []
|
||||
parents_reply = get_reply_parents_no_root(parents_reply, c)
|
||||
if parents_reply.count > 0 && !opt[:bottom]
|
||||
if opt[:type] == 1
|
||||
# opt[:bottom] = true
|
||||
# parents_reply[opt[:page]..opt[:page]]
|
||||
else
|
||||
opt[:bottom] = true
|
||||
parents_reply[0..0]
|
||||
end
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
expose :parents_reply_top, using:Mobile::Entities::BlogComment do |c,opt|
|
||||
if c.is_a? (::BlogComment)
|
||||
#取二级回复的顶楼层
|
||||
parents_reply = []
|
||||
parents_reply = get_reply_parents_no_root(parents_reply, c)
|
||||
if parents_reply.count > 2 && !opt[:top]
|
||||
if opt[:type] == 1
|
||||
opt[:top] = true
|
||||
tStart = (opt[:page]-1)*5+2
|
||||
tEnd = (opt[:page])*5+2 - 1
|
||||
|
||||
if tEnd >= parents_reply.count - 1
|
||||
tEnd = parents_reply.count - 2
|
||||
end
|
||||
|
||||
if tStart <= parents_reply.count - 2
|
||||
parents_reply = parents_reply.reverse[tStart..tEnd]
|
||||
parents_reply.reverse
|
||||
else
|
||||
[]
|
||||
end
|
||||
else
|
||||
opt[:top] = true
|
||||
parents_reply = parents_reply.reverse[0..1]
|
||||
parents_reply.reverse
|
||||
end
|
||||
elsif parents_reply.count == 2 && !opt[:top]
|
||||
opt[:top] = true
|
||||
parents_reply = parents_reply.reverse[0..0]
|
||||
parents_reply.reverse
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,30 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class Comment < Grape::Entity
|
||||
include Redmine::I18n
|
||||
def self.comment_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
f[field]
|
||||
elsif f.is_a?(::Comment)
|
||||
if f.respond_to?(field)
|
||||
if field == :created_on
|
||||
time_from_now(f.send(field))
|
||||
else
|
||||
f.send(field)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
comment_expose :id
|
||||
expose :author, using: Mobile::Entities::User do |c, opt|
|
||||
if c.is_a? ::Comment
|
||||
c.author
|
||||
end
|
||||
end
|
||||
comment_expose :comments
|
||||
comment_expose :created_on
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,123 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class Course < Grape::Entity
|
||||
|
||||
include Redmine::I18n
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.course_expose(field)
|
||||
expose field do |f,opt|
|
||||
c = nil
|
||||
if f.is_a? ::Course
|
||||
c = f
|
||||
else
|
||||
c = f[:course]
|
||||
end
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
f[field] if f.is_a?(Hash) && f.key?(field)
|
||||
#f.img_url if f.respond_to?(:img_url)
|
||||
elsif field == :created_at || field == :updated_at
|
||||
(format_time(c[field]) if (c.is_a?(Hash) && c.key?(field))) || (format_time(c.send(field)) if c.respond_to?(field))
|
||||
elsif field == :member_count
|
||||
::Course===c ? c.members.count : 0
|
||||
else
|
||||
(c[field] if (c.is_a?(Hash) && c.key?(field))) || (c.send(field) if c.respond_to?(field))
|
||||
end
|
||||
end
|
||||
end
|
||||
course_expose :img_url
|
||||
course_expose :attachmenttype
|
||||
course_expose :class_period
|
||||
course_expose :code
|
||||
course_expose :created_at
|
||||
course_expose :description
|
||||
course_expose :endup_time
|
||||
course_expose :extra
|
||||
course_expose :id
|
||||
course_expose :inherit_members
|
||||
course_expose :is_public
|
||||
course_expose :lft
|
||||
course_expose :location
|
||||
course_expose :name
|
||||
course_expose :open_student
|
||||
# course_expose :password
|
||||
course_expose :rgt
|
||||
course_expose :school_id
|
||||
course_expose :setup_time
|
||||
course_expose :state
|
||||
course_expose :status
|
||||
course_expose :string
|
||||
course_expose :tea_id
|
||||
course_expose :term
|
||||
course_expose :time
|
||||
course_expose :invite_code
|
||||
course_expose :qrcode
|
||||
course_expose :updated_at
|
||||
course_expose :course_student_num
|
||||
course_expose :member_count
|
||||
course_expose :groupnum
|
||||
expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
current_user = options[:user]
|
||||
can_setting = false
|
||||
|
||||
if instance[:course]
|
||||
course = instance[:course]
|
||||
else
|
||||
course = instance
|
||||
end
|
||||
|
||||
member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0]
|
||||
role_ids = member.role_ids if member
|
||||
|
||||
if role_ids && (role_ids.include?(7) || role_ids.include?(9) )
|
||||
can_setting = true
|
||||
end
|
||||
|
||||
if course.tea_id == current_user.id
|
||||
can_setting = true
|
||||
end
|
||||
can_setting
|
||||
end
|
||||
expose :is_member, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
current_user = options[:user]
|
||||
if instance[:course]
|
||||
course = instance[:course]
|
||||
else
|
||||
course = instance
|
||||
end
|
||||
current_user.member_of_course?(course)
|
||||
end
|
||||
expose :teacher, using: Mobile::Entities::User do |c, opt|
|
||||
if c.is_a? ::Course
|
||||
c.teacher
|
||||
else
|
||||
c[:course].teacher
|
||||
end
|
||||
end
|
||||
expose :my_homework,using: Mobile::Entities::Homework do |f, opt|
|
||||
f[:my_homework] if f.is_a?(Hash) && f.key?(:my_homework)
|
||||
end
|
||||
expose :is_creator, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
if instance[:course]
|
||||
course = instance[:course]
|
||||
else
|
||||
course = instance
|
||||
end
|
||||
current_user = options[:user]
|
||||
course.tea_id == current_user.id
|
||||
end
|
||||
course_expose :current_user_is_member
|
||||
course_expose :current_user_is_teacher
|
||||
course_expose :work_unit
|
||||
course_expose :syllabus_title
|
||||
|
||||
expose :boards, using: Mobile::Entities::Courses::Board do |f,opt|
|
||||
if f.is_a? ::Course
|
||||
f.boards
|
||||
else
|
||||
f[:course].boards
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,90 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class CourseDynamic < Grape::Entity
|
||||
include Redmine::I18n
|
||||
def self.course_dynamic_expose(field)
|
||||
expose field do |c,opt|
|
||||
# if field == :news_count
|
||||
# obj = nil
|
||||
# c[:dynamics].each do |d|
|
||||
# if d[:type] == 1
|
||||
# obj = d[:count]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# elsif field == :document_count
|
||||
# obj = nil
|
||||
# c[:dynamics].each do |d|
|
||||
# if d[:type] == 3
|
||||
# obj = d[:count]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# elsif field == :topic_count
|
||||
# obj = nil
|
||||
# c[:dynamics].each do |d|
|
||||
# if d[:type] == 2
|
||||
# obj = d[:count]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# elsif field == :homework_count
|
||||
# obj = nil
|
||||
# c[:dynamics].each do |d|
|
||||
# if d[:type] == 4
|
||||
# obj = d[:count]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# else
|
||||
c[field] if (c.is_a?(Hash) && c.key?(field))
|
||||
# end
|
||||
|
||||
end
|
||||
end
|
||||
course_dynamic_expose :course_name
|
||||
course_dynamic_expose :course_term
|
||||
course_dynamic_expose :course_time
|
||||
course_dynamic_expose :course_id
|
||||
course_dynamic_expose :course_img_url
|
||||
course_dynamic_expose :message
|
||||
course_dynamic_expose :news_count
|
||||
course_dynamic_expose :document_count
|
||||
course_dynamic_expose :topic_count
|
||||
course_dynamic_expose :homework_count
|
||||
course_dynamic_expose :course_student_num
|
||||
course_dynamic_expose :time_from_now
|
||||
course_dynamic_expose :current_user_is_member
|
||||
course_dynamic_expose :current_user_is_teacher
|
||||
|
||||
# expose :documents,using:Mobile::Entities::Attachment do |f,opt|
|
||||
# obj = nil
|
||||
# f[:dynamics].each do |d|
|
||||
# if d[:type] == 3
|
||||
# obj = d[:documents]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# end
|
||||
expose :topics,using:Mobile::Entities::Message do |f,opt|
|
||||
f[:topics]
|
||||
end
|
||||
expose :homeworks,using:Mobile::Entities::Homework do |f,opt|
|
||||
f[:homeworks]
|
||||
end
|
||||
|
||||
expose :news,using:Mobile::Entities::News do |f,opt|
|
||||
f[:news]
|
||||
end
|
||||
|
||||
expose :better_students,using:Mobile::Entities::User do |f,opt|
|
||||
f[:better_students]
|
||||
end
|
||||
|
||||
expose :active_students,using:Mobile::Entities::User do |f,opt|
|
||||
f[:active_students]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,19 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class CourseGroup < Grape::Entity
|
||||
include Redmine::I18n
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.course_group_expose(f)
|
||||
expose f do |u,opt|
|
||||
if u.is_a?(Hash) && u.key?(f)
|
||||
u[f]
|
||||
end
|
||||
end
|
||||
end
|
||||
expose :id
|
||||
expose :name
|
||||
expose :users, using: Mobile::Entities::User
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,12 @@
|
||||
# encoding: utf-8
|
||||
module Mobile
|
||||
module Entities
|
||||
module Courses
|
||||
class Board < Grape::Entity
|
||||
expose :id
|
||||
expose :name
|
||||
expose :description
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,21 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
|
||||
module Courses
|
||||
class Comment < Grape::Entity
|
||||
expose :created_on
|
||||
expose :id
|
||||
|
||||
expose :author, using: Mobile::Entities::ShortUser do |f,u|
|
||||
f.author
|
||||
end
|
||||
|
||||
expose :to_user, using: Mobile::Entities::ShortUser do |f, u|
|
||||
f.reply.try(:author)
|
||||
end
|
||||
|
||||
expose :content
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,32 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
module Courses
|
||||
class Message < Grape::Entity
|
||||
def self.message_expose field
|
||||
expose field do |f, opt|
|
||||
f[:topic].try(field)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
message_expose :id
|
||||
message_expose :subject
|
||||
message_expose :content
|
||||
message_expose :created_on
|
||||
|
||||
expose :author, using: Mobile::Entities::User do |f, opt|
|
||||
f[:topic].author
|
||||
end
|
||||
|
||||
expose :comments, using: Mobile::Entities::Courses::Comment do |f, opt|
|
||||
f[:comments]
|
||||
end
|
||||
|
||||
expose :attachments, using: Mobile::Entities::Attachment do |f,opt|
|
||||
f[:topic].attachments
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,43 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class Exercise < Grape::Entity
|
||||
include Redmine::I18n
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.exercise_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
if field == :created_on
|
||||
format_time(f[field])
|
||||
else
|
||||
f[field]
|
||||
end
|
||||
elsif f.is_a?(::Exercise)
|
||||
if f.respond_to?(field)
|
||||
f.send(field)
|
||||
else
|
||||
case field
|
||||
when :coursename
|
||||
f.course.nil? ? "" : f.course.name
|
||||
when :syllabus_title
|
||||
f.course.nil? ? "" : f.course.syllabus.nil? ? "" : f.course.syllabus.title
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
expose :exercise_name
|
||||
expose :exercise_description
|
||||
exercise_expose :coursename #所属班级名
|
||||
exercise_expose :syllabus_title
|
||||
|
||||
expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
current_user = options[:user]
|
||||
current_user_is_teacher = false
|
||||
current_user_is_teacher = is_course_teacher(current_user,instance.course)
|
||||
current_user_is_teacher
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,29 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
#带评分的留言(教师评论、学生匿名评分都属于此类)
|
||||
class HomeworkJours < Grape::Entity
|
||||
include Redmine::I18n
|
||||
def self.homework_jours_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
if field == :created_at
|
||||
format_time(f[field])
|
||||
else
|
||||
f[field]
|
||||
end
|
||||
elsif f.is_a?(::SeemsRateableRates)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
homework_jours_expose :rater_id
|
||||
homework_jours_expose :rater_name
|
||||
homework_jours_expose :created_at
|
||||
homework_jours_expose :stars
|
||||
expose :comment,using: Mobile::Entities::Jours do |f,opt|
|
||||
f[:comment]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,18 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class Homeworkscore < Grape::Entity
|
||||
include Redmine::I18n
|
||||
include ApplicationHelper
|
||||
def self.homeworkscore_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
f[field]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
homeworkscore_expose :name
|
||||
homeworkscore_expose :score
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,187 @@
|
||||
#coding=utf-8
|
||||
module Mobile
|
||||
module Entities
|
||||
class Issue <Grape::Entity
|
||||
include ApiHelper
|
||||
include Redmine::I18n
|
||||
def self.issue_expose(f)
|
||||
expose f do |issue, opt|
|
||||
if issue.is_a?(Hash) && issue.key?(f)
|
||||
issue[f]
|
||||
elsif issue.is_a?(::Issue)
|
||||
if issue.respond_to?(f)
|
||||
if f == :created_on
|
||||
format_time(issue.send(f))
|
||||
else
|
||||
issue.send(f)
|
||||
end
|
||||
else
|
||||
case f
|
||||
when :issue_priority
|
||||
get_issue_priority_api issue.priority_id
|
||||
when :issue_assigned_to
|
||||
issue.assigned_to_id.nil? ? "未指派" : (get_user(issue.assigned_to_id)).login
|
||||
when :issue_status
|
||||
IssueStatus.find(issue.status_id).name
|
||||
when :comment_count
|
||||
issue.journals.where("notes is not null and notes != ''").count
|
||||
# all_comments = []
|
||||
# get_all_children(all_comments, f).count
|
||||
when :project_name
|
||||
issue.project.name
|
||||
when :praise_count
|
||||
get_activity_praise_num(issue)
|
||||
when :act_type
|
||||
'Issue'
|
||||
when :act_id
|
||||
issue.id
|
||||
when :title
|
||||
issue.subject
|
||||
when :subject
|
||||
issue.subject
|
||||
when :description
|
||||
issue.description
|
||||
when :done_ratio
|
||||
issue.done_ratio
|
||||
end
|
||||
end
|
||||
elsif issue.is_a?(::Journal)
|
||||
case f
|
||||
when :content
|
||||
issue[:notes]
|
||||
when :lasted_comment
|
||||
time_from_now issue.created_on
|
||||
when :act_id
|
||||
issue.id
|
||||
when :act_type
|
||||
'Journal'
|
||||
when :praise_count
|
||||
get_activity_praise_num(issue)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
issue_expose :subject
|
||||
issue_expose :description
|
||||
expose :author, using: Mobile::Entities::User do |f, opt|
|
||||
if f.is_a?(::Issue)
|
||||
f.send(:author)
|
||||
end
|
||||
end
|
||||
expose :user,using: Mobile::Entities::User do |f, opt|
|
||||
if f.is_a?(::Journal)
|
||||
f.send(:user)
|
||||
end
|
||||
end
|
||||
issue_expose :content
|
||||
issue_expose :lasted_comment
|
||||
|
||||
issue_expose :done_ratio
|
||||
issue_expose :title
|
||||
issue_expose :act_type
|
||||
issue_expose :act_id
|
||||
issue_expose :created_on
|
||||
issue_expose :issue_priority
|
||||
issue_expose :issue_assigned_to
|
||||
issue_expose :issue_status
|
||||
issue_expose :comment_count
|
||||
issue_expose :project_name
|
||||
issue_expose :praise_count
|
||||
|
||||
expose :id
|
||||
# expose :issue_journals, using: Mobile::Entities::Journal do |f, opt|
|
||||
# if f.is_a?(::Issue)
|
||||
# f.journals.where("notes is not null and notes != ''").reverse
|
||||
# end
|
||||
# end
|
||||
|
||||
expose :all_children, using: Mobile::Entities::Issue do |f, opt|
|
||||
#f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages)
|
||||
if f.is_a?(::Issue)
|
||||
# f.journals_for_messages.reverse
|
||||
if !opt[:children] && opt[:type] == 0
|
||||
opt[:children] = true
|
||||
tStart = opt[:page]*5
|
||||
tEnd = (opt[:page]+1)*5 - 1
|
||||
|
||||
all_comments = f.journals.where("notes is not null and notes != ''").reorder("created_on desc")
|
||||
all_comments[tStart..tEnd]
|
||||
end
|
||||
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
|
||||
|
||||
expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
if instance.is_a?(::Journal)
|
||||
parents_reply = []
|
||||
parents_reply = get_reply_parents(parents_reply, instance)
|
||||
parents_reply.count
|
||||
end
|
||||
end
|
||||
|
||||
expose :parents_reply_bottom, using:Mobile::Entities::Issue do |f,opt|
|
||||
if f.is_a? (::Journal)
|
||||
#取二级回复的底楼层
|
||||
parents_reply = []
|
||||
parents_reply = get_reply_parents(parents_reply, f)
|
||||
if parents_reply.count > 0 && !opt[:bottom]
|
||||
if opt[:type] == 1
|
||||
# opt[:bottom] = true
|
||||
# parents_reply[opt[:page]..opt[:page]]
|
||||
else
|
||||
opt[:bottom] = true
|
||||
parents_reply[0..0]
|
||||
end
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
expose :parents_reply_top, using:Mobile::Entities::Issue do |f,opt|
|
||||
if f.is_a? (::Journal)
|
||||
#取二级回复的顶楼层
|
||||
parents_reply = []
|
||||
parents_reply = get_reply_parents(parents_reply, f)
|
||||
if parents_reply.count > 2 && !opt[:top]
|
||||
if opt[:type] == 1
|
||||
opt[:top] = true
|
||||
tStart = (opt[:page]-1)*5+2
|
||||
tEnd = (opt[:page])*5+2 - 1
|
||||
|
||||
if tEnd >= parents_reply.count - 1
|
||||
tEnd = parents_reply.count - 2
|
||||
end
|
||||
|
||||
if tStart <= parents_reply.count - 2
|
||||
parents_reply = parents_reply.reverse[tStart..tEnd]
|
||||
parents_reply.reverse
|
||||
else
|
||||
[]
|
||||
end
|
||||
else
|
||||
opt[:top] = true
|
||||
parents_reply = parents_reply.reverse[0..1]
|
||||
parents_reply.reverse
|
||||
end
|
||||
elsif parents_reply.count == 2 && !opt[:top]
|
||||
opt[:top] = true
|
||||
parents_reply = parents_reply.reverse[0..0]
|
||||
parents_reply.reverse
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
expose :attachments, using: Mobile::Entities::Attachment
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,44 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class Journal <Grape::Entity
|
||||
include Redmine::I18n
|
||||
=begin
|
||||
include Redmine::I18n
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
include IssuesHelper
|
||||
include ActionView::Helpers::TagHelper
|
||||
include ActionView::Helpers::UrlHelper
|
||||
=end
|
||||
def self.journal_expose(f)
|
||||
expose f do |journal, opt|
|
||||
if journal.is_a?(Hash) && journal.key?(f)
|
||||
journal[f]
|
||||
elsif journal.is_a?(::Journal)
|
||||
if journal.respond_to?(f)
|
||||
if f == :created_on
|
||||
time_from_now(journal.send(f))
|
||||
else
|
||||
journal.send(f)
|
||||
end
|
||||
else
|
||||
case f
|
||||
when :detail_journal
|
||||
if journal.details.any?
|
||||
details_to_strings(journal.details)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
expose :notes
|
||||
journal_expose :created_on
|
||||
expose :user,using: Mobile::Entities::User do |f, opt|
|
||||
f.user
|
||||
end
|
||||
#journal_expose :detail_journal
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,161 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
#普通留言
|
||||
class Jours < Grape::Entity
|
||||
include Redmine::I18n
|
||||
def self.jours_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
f[field]
|
||||
elsif f.is_a?(::JournalsForMessage) && f.respond_to?(field)
|
||||
if field == :created_on
|
||||
format_time(f.send(field))
|
||||
else
|
||||
f.send(field)
|
||||
end
|
||||
else
|
||||
case field
|
||||
when :lasted_comment
|
||||
time_from_now f.created_on
|
||||
when :comment_count
|
||||
# f.children.count
|
||||
all_comments = []
|
||||
get_all_children(all_comments, f).count
|
||||
when :praise_count
|
||||
get_activity_praise_num(f)
|
||||
when :act_type
|
||||
'JournalsForMessage'
|
||||
when :act_id
|
||||
f.id
|
||||
when :content
|
||||
f.notes
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
jours_expose :act_type
|
||||
jours_expose :act_id
|
||||
jours_expose :id
|
||||
jours_expose :jour_type
|
||||
jours_expose :jour_id
|
||||
expose :user,using: Mobile::Entities::User do |f, opt|
|
||||
f.user
|
||||
end
|
||||
jours_expose :created_on
|
||||
jours_expose :lasted_comment
|
||||
jours_expose :content
|
||||
jours_expose :m_reply_id
|
||||
jours_expose :m_parent_id
|
||||
jours_expose :comment_count
|
||||
jours_expose :praise_count
|
||||
expose :course,using:Mobile::Entities::Course do |f,opt|
|
||||
if f.is_a?(::JournalsForMessage) && f[:jour_type] == "Course"
|
||||
f.course
|
||||
end
|
||||
end
|
||||
expose :reply_user,using: Mobile::Entities::User do |f, opt|
|
||||
f.at_user
|
||||
end
|
||||
expose :all_children,using: Mobile::Entities::Jours do |f, opt|
|
||||
if f.is_a?(::JournalsForMessage)
|
||||
# f.children.reverse
|
||||
if !opt[:children] && opt[:comment_type].nil?
|
||||
if f.parent.nil? && opt[:type] == 0
|
||||
opt[:children] = true
|
||||
all_comments = []
|
||||
tStart = opt[:page]*5
|
||||
tEnd = (opt[:page]+1)*5 - 1
|
||||
|
||||
all_comments = get_all_children(all_comments, f)[tStart..tEnd]
|
||||
all_comments
|
||||
end
|
||||
end
|
||||
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
|
||||
|
||||
expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
parents_reply = []
|
||||
|
||||
if options[:comment_type].nil?
|
||||
parents_reply = get_reply_parents_no_root(parents_reply, instance)
|
||||
elsif options[:comment_type] == "homework"
|
||||
parents_reply = get_reply_parents(parents_reply, instance)
|
||||
end
|
||||
parents_reply.count
|
||||
end
|
||||
|
||||
expose :parents_reply_bottom, using:Mobile::Entities::Jours do |f,opt|
|
||||
if f.is_a? (::JournalsForMessage)
|
||||
#取二级回复的底楼层
|
||||
parents_reply = []
|
||||
if opt[:comment_type].nil?
|
||||
parents_reply = get_reply_parents_no_root(parents_reply, f)
|
||||
elsif opt[:comment_type] == "homework"
|
||||
parents_reply = get_reply_parents(parents_reply, f)
|
||||
end
|
||||
if parents_reply.count > 0 && !opt[:bottom]
|
||||
if opt[:type] == 1
|
||||
# opt[:bottom] = true
|
||||
# parents_reply[opt[:page]..opt[:page]]
|
||||
else
|
||||
opt[:bottom] = true
|
||||
parents_reply[0..0]
|
||||
end
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
expose :parents_reply_top, using:Mobile::Entities::Jours do |f,opt|
|
||||
if f.is_a? (::JournalsForMessage)
|
||||
#取二级回复的顶楼层
|
||||
parents_reply = []
|
||||
|
||||
if opt[:comment_type].nil?
|
||||
parents_reply = get_reply_parents_no_root(parents_reply, f)
|
||||
elsif opt[:comment_type] == "homework"
|
||||
parents_reply = get_reply_parents(parents_reply, f)
|
||||
end
|
||||
if parents_reply.count > 2 && !opt[:top]
|
||||
if opt[:type] == 1
|
||||
opt[:top] = true
|
||||
tStart = (opt[:page]-1)*5+2
|
||||
tEnd = (opt[:page])*5+2 - 1
|
||||
|
||||
if tEnd >= parents_reply.count - 1
|
||||
tEnd = parents_reply.count - 2
|
||||
end
|
||||
|
||||
if tStart <= parents_reply.count - 2
|
||||
parents_reply = parents_reply.reverse[tStart..tEnd]
|
||||
parents_reply.reverse
|
||||
else
|
||||
[]
|
||||
end
|
||||
else
|
||||
opt[:top] = true
|
||||
parents_reply = parents_reply.reverse[0..1]
|
||||
parents_reply.reverse
|
||||
end
|
||||
elsif parents_reply.count == 2 && !opt[:top]
|
||||
opt[:top] = true
|
||||
parents_reply = parents_reply.reverse[0..0]
|
||||
parents_reply.reverse
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,34 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class Member < Grape::Entity
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.member_expose(f)
|
||||
expose f do |u,opt|
|
||||
if u.is_a?(Hash) && u.key?(f)
|
||||
u[f]
|
||||
elsif u.is_a?(::Member)
|
||||
if u.respond_to?(f)
|
||||
u.send(f)
|
||||
else
|
||||
case f
|
||||
when :student_id
|
||||
u.user.user_extensions.student_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
expose :user, using: Mobile::Entities::User do |c, opt|
|
||||
if c.is_a?(::Member)
|
||||
c.user
|
||||
end
|
||||
end
|
||||
member_expose :student_id
|
||||
member_expose :score
|
||||
member_expose :id
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,154 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class Message < Grape::Entity
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.message_expose(f)
|
||||
expose f do |u,opt|
|
||||
if u.is_a?(Hash) && u.key?(f)
|
||||
u[f]
|
||||
elsif u.is_a?(::Message)
|
||||
if u.respond_to?(f)
|
||||
if f == :created_on
|
||||
format_time( u.send(f))
|
||||
else
|
||||
u.send(f)
|
||||
end
|
||||
else
|
||||
case f
|
||||
when :course_project_name
|
||||
if u.board.project_id == -1
|
||||
u.course.name
|
||||
else
|
||||
u.project.name
|
||||
end
|
||||
when :syllabus_title
|
||||
if u.board.project_id == -1
|
||||
u.course.syllabus.nil? ? "" : u.course.syllabus.title
|
||||
end
|
||||
when :lasted_comment
|
||||
time_from_now u.created_on
|
||||
when :praise_count
|
||||
get_activity_praise_num(u)
|
||||
when :act_type
|
||||
'Message'
|
||||
when :act_id
|
||||
u.id
|
||||
when :comment_count
|
||||
all_comments = []
|
||||
get_all_children(all_comments, u).count
|
||||
when :title
|
||||
u.subject
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
expose :user, using: Mobile::Entities::User do |c, opt|
|
||||
if c.is_a?(::Message)
|
||||
c.author
|
||||
end
|
||||
end
|
||||
message_expose :act_type
|
||||
message_expose :act_id
|
||||
message_expose :course_project_name
|
||||
message_expose :syllabus_title
|
||||
message_expose :board_id
|
||||
message_expose :subject
|
||||
message_expose :title
|
||||
message_expose :content
|
||||
message_expose :comment_count
|
||||
message_expose :praise_count
|
||||
message_expose :created_on
|
||||
message_expose :locked
|
||||
message_expose :id
|
||||
message_expose :lasted_comment
|
||||
expose :all_children,using:Mobile::Entities::Message do |c,opt|
|
||||
if c.is_a? (::Message)
|
||||
# c.children.reverse
|
||||
if !opt[:children]
|
||||
if c.parent.nil? && opt[:type] == 0
|
||||
opt[:children] = true
|
||||
all_comments = []
|
||||
tStart = opt[:page]*5
|
||||
tEnd = (opt[:page]+1)*5 - 1
|
||||
|
||||
all_comments = get_all_children(all_comments, c)[tStart..tEnd]
|
||||
all_comments
|
||||
end
|
||||
end
|
||||
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
|
||||
|
||||
expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
parents_reply = []
|
||||
parents_reply = get_reply_parents_no_root(parents_reply, instance)
|
||||
parents_reply.count
|
||||
end
|
||||
|
||||
expose :parents_reply_bottom, using:Mobile::Entities::Message do |c,opt|
|
||||
if c.is_a? (::Message)
|
||||
#取二级回复的底楼层
|
||||
parents_reply = []
|
||||
parents_reply = get_reply_parents_no_root(parents_reply, c)
|
||||
if parents_reply.count > 0 && !opt[:bottom]
|
||||
if opt[:type] == 1
|
||||
# opt[:bottom] = true
|
||||
# parents_reply[opt[:page]..opt[:page]]
|
||||
else
|
||||
opt[:bottom] = true
|
||||
parents_reply[0..0]
|
||||
end
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
expose :parents_reply_top, using:Mobile::Entities::Message do |c,opt|
|
||||
if c.is_a? (::Message)
|
||||
#取二级回复的顶楼层
|
||||
parents_reply = []
|
||||
parents_reply = get_reply_parents_no_root(parents_reply, c)
|
||||
if parents_reply.count > 2 && !opt[:top]
|
||||
if opt[:type] == 1
|
||||
opt[:top] = true
|
||||
tStart = (opt[:page]-1)*5+2
|
||||
tEnd = (opt[:page])*5+2 - 1
|
||||
|
||||
if tEnd >= parents_reply.count - 1
|
||||
tEnd = parents_reply.count - 2
|
||||
end
|
||||
|
||||
if tStart <= parents_reply.count - 2
|
||||
parents_reply = parents_reply.reverse[tStart..tEnd]
|
||||
parents_reply.reverse
|
||||
else
|
||||
[]
|
||||
end
|
||||
else
|
||||
opt[:top] = true
|
||||
parents_reply = parents_reply.reverse[0..1]
|
||||
parents_reply.reverse
|
||||
end
|
||||
elsif parents_reply.count == 2 && !opt[:top]
|
||||
opt[:top] = true
|
||||
parents_reply = parents_reply.reverse[0..0]
|
||||
parents_reply.reverse
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,198 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class News < Grape::Entity
|
||||
include Redmine::I18n
|
||||
include ApiHelper
|
||||
def self.news_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
f[field]
|
||||
elsif f.is_a?(::News)
|
||||
if f.respond_to?(field)
|
||||
if field == :created_on
|
||||
format_time(f.send(field))
|
||||
else
|
||||
f.send(field)
|
||||
end
|
||||
else
|
||||
case field
|
||||
when :course_name
|
||||
get_course(f.course_id).name unless f.course_id == nil
|
||||
when :praise_count
|
||||
get_activity_praise_num(f)
|
||||
when :act_type
|
||||
'News'
|
||||
when :act_id
|
||||
f.id
|
||||
when :comment_count
|
||||
f.comments.count
|
||||
when :syllabus_title
|
||||
unless f.course_id == nil
|
||||
course = get_course(f.course_id)
|
||||
course.syllabus.nil? ? "" : course.syllabus.title
|
||||
end
|
||||
end
|
||||
end
|
||||
elsif f.is_a?(::Comment)
|
||||
case field
|
||||
when :content
|
||||
f[:comments]
|
||||
when :lasted_comment
|
||||
time_from_now f.created_on
|
||||
when :act_id
|
||||
f.id
|
||||
when :praise_count
|
||||
get_activity_praise_num(f)
|
||||
when :act_type
|
||||
'Comment'
|
||||
end
|
||||
|
||||
elsif f.is_a?(Hash) && !f.key?(field)
|
||||
n = f[:news]
|
||||
comments = f[:comments]
|
||||
if n.is_a?(::News)
|
||||
if field == :created_on
|
||||
format_time(n.send(field)) if n.respond_to?(field)
|
||||
else
|
||||
n.send(field) if n.respond_to?(field)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
expose :id
|
||||
#新闻标题
|
||||
news_expose :title
|
||||
|
||||
expose :user,using: Mobile::Entities::User do |f, opt|
|
||||
obj = nil
|
||||
if f.is_a?(::News) && f.respond_to?(:author)
|
||||
obj = f.send(:author)
|
||||
elsif f.is_a?(::Comment) && f.respond_to?(:author)
|
||||
obj = f.send(:author)
|
||||
elsif f.is_a?(Hash) && f.key?(:author)
|
||||
obj = f[:author]
|
||||
end
|
||||
obj
|
||||
end
|
||||
news_expose :act_type
|
||||
news_expose :act_id
|
||||
#作者id
|
||||
news_expose :author_id
|
||||
#作者名
|
||||
news_expose :author_name
|
||||
#作者头像url
|
||||
news_expose :author_img_url
|
||||
#新闻内容
|
||||
news_expose :description
|
||||
#发布时间
|
||||
news_expose :created_on
|
||||
#评论数量
|
||||
news_expose :comment_count
|
||||
news_expose :praise_count
|
||||
#课程名字
|
||||
news_expose :course_name
|
||||
news_expose :syllabus_title
|
||||
news_expose :lasted_comment
|
||||
|
||||
#评论
|
||||
# expose :comments, using: Mobile::Entities::Comment do |f, opt|
|
||||
# if f.is_a?(Hash) && f.key?(:comments)
|
||||
# f[:comments]
|
||||
# elsif f.is_a?(::News) && f.respond_to?(:comments)
|
||||
# f.comments.reverse
|
||||
# end
|
||||
# end
|
||||
|
||||
news_expose :content
|
||||
|
||||
expose :all_children, using: Mobile::Entities::News do |f, opt|
|
||||
#f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages)
|
||||
if f.is_a?(::News)
|
||||
# f.journals_for_messages.reverse
|
||||
if !opt[:children] && opt[:type] == 0
|
||||
opt[:children] = true
|
||||
tStart = opt[:page]*5
|
||||
tEnd = (opt[:page]+1)*5 - 1
|
||||
|
||||
all_comments = f.comments.reorder("created_on desc")
|
||||
all_comments[tStart..tEnd]
|
||||
end
|
||||
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
|
||||
|
||||
expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
if instance.is_a?(::Comment)
|
||||
parents_reply = []
|
||||
parents_reply = get_reply_parents(parents_reply, instance)
|
||||
parents_reply.count
|
||||
end
|
||||
end
|
||||
|
||||
expose :parents_reply_bottom, using:Mobile::Entities::News do |f,opt|
|
||||
if f.is_a? (::Comment)
|
||||
#取二级回复的底楼层
|
||||
parents_reply = []
|
||||
parents_reply = get_reply_parents(parents_reply, f)
|
||||
if parents_reply.count > 0 && !opt[:bottom]
|
||||
if opt[:type] == 1
|
||||
# opt[:bottom] = true
|
||||
# parents_reply[opt[:page]..opt[:page]]
|
||||
else
|
||||
opt[:bottom] = true
|
||||
parents_reply[0..0]
|
||||
end
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
expose :parents_reply_top, using:Mobile::Entities::News do |f,opt|
|
||||
if f.is_a? (::Comment)
|
||||
#取二级回复的顶楼层
|
||||
parents_reply = []
|
||||
parents_reply = get_reply_parents(parents_reply, f)
|
||||
if parents_reply.count > 2 && !opt[:top]
|
||||
if opt[:type] == 1
|
||||
opt[:top] = true
|
||||
tStart = (opt[:page]-1)*5+2
|
||||
tEnd = (opt[:page])*5+2 - 1
|
||||
|
||||
if tEnd >= parents_reply.count - 1
|
||||
tEnd = parents_reply.count - 2
|
||||
end
|
||||
|
||||
if tStart <= parents_reply.count - 2
|
||||
parents_reply = parents_reply.reverse[tStart..tEnd]
|
||||
parents_reply.reverse
|
||||
else
|
||||
[]
|
||||
end
|
||||
else
|
||||
opt[:top] = true
|
||||
parents_reply = parents_reply.reverse[0..1]
|
||||
parents_reply.reverse
|
||||
end
|
||||
elsif parents_reply.count == 2 && !opt[:top]
|
||||
opt[:top] = true
|
||||
parents_reply = parents_reply.reverse[0..0]
|
||||
parents_reply.reverse
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,43 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class Project < Grape::Entity
|
||||
expose :name
|
||||
expose :id
|
||||
expose :is_public
|
||||
expose :user_id
|
||||
expose :invite_code
|
||||
expose :qrcode
|
||||
expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
current_user = options[:user]
|
||||
|
||||
my_member = instance.member_principals.where("users.id=#{current_user.id}").first
|
||||
can_setting = false
|
||||
if my_member && my_member.roles[0] && my_member.roles[0].id == 3
|
||||
can_setting = true
|
||||
end
|
||||
can_setting
|
||||
end
|
||||
|
||||
expose :is_creator, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
current_user = options[:user]
|
||||
|
||||
current_user.id == instance.user_id
|
||||
end
|
||||
|
||||
expose :is_member, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
current_user = options[:user]
|
||||
if instance[:project]
|
||||
project = instance[:project]
|
||||
else
|
||||
project = instance
|
||||
end
|
||||
current_user.member_of?(project)
|
||||
end
|
||||
|
||||
|
||||
expose :member_count, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
instance.members.count
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,35 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class ProjectMember < Grape::Entity
|
||||
include Redmine::I18n
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.member_expose(f)
|
||||
expose f do |u,opt|
|
||||
if u.is_a?(Hash) && u.key?(f)
|
||||
u[f]
|
||||
elsif u.is_a?(::Member)
|
||||
if u.respond_to?(f)
|
||||
u.send(f)
|
||||
else
|
||||
case f
|
||||
when :roles_id
|
||||
# u.roles[0].id
|
||||
u.roles.map {|r| r.id}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
expose :user, using: Mobile::Entities::User do |c, opt|
|
||||
if c.is_a?(::Member)
|
||||
c.user
|
||||
end
|
||||
end
|
||||
|
||||
member_expose :roles_id
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,9 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class Response < Grape::Entity
|
||||
expose :status
|
||||
expose :message
|
||||
expose :data
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,18 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class ShortUser < Grape::Entity
|
||||
|
||||
include ApplicationHelper
|
||||
|
||||
expose :id
|
||||
expose :login
|
||||
expose :name do |f, u|
|
||||
f.try(:show_real_name)
|
||||
end
|
||||
|
||||
expose :img_url do |f, u|
|
||||
"/images/#{url_to_avatar(f)}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,45 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class StudentWork < Grape::Entity
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.student_work_expose(f)
|
||||
expose f do |u,opt|
|
||||
if u.is_a?(Hash) && u.key?(f)
|
||||
u[f]
|
||||
elsif u.is_a?(::StudentWork)
|
||||
if u.respond_to?(f)
|
||||
if f == :created_at
|
||||
format_time(u.send(:created_at))
|
||||
else
|
||||
u.send(f)
|
||||
end
|
||||
|
||||
else
|
||||
case f
|
||||
when :student_id
|
||||
u.user.user_extensions.student_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
expose :user, using: Mobile::Entities::User do |c, opt|
|
||||
if c.is_a?(::StudentWork)
|
||||
c.user
|
||||
end
|
||||
end
|
||||
student_work_expose :student_id
|
||||
student_work_expose :id
|
||||
student_work_expose :name
|
||||
student_work_expose :description
|
||||
student_work_expose :final_score
|
||||
student_work_expose :teacher_score
|
||||
student_work_expose :student_score
|
||||
student_work_expose :teacher_asistant_score
|
||||
student_work_expose :created_at
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,15 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class Syllabus < Grape::Entity
|
||||
expose :title
|
||||
expose :id
|
||||
expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
current_user = options[:user]
|
||||
can_setting = instance[:user_id] == current_user.id ? true : false
|
||||
can_setting = false if instance[:id].nil?
|
||||
can_setting
|
||||
end
|
||||
expose :courses, using: Mobile::Entities::Course
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,95 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class User < Grape::Entity
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
|
||||
def self.user_expose(f)
|
||||
expose f do |u, opt|
|
||||
if u.is_a?(Hash) && u.key?(f)
|
||||
u[f]
|
||||
elsif u.is_a?(::User)
|
||||
if u.respond_to?(f)
|
||||
u.send(f) unless u.user_extensions.nil?
|
||||
else
|
||||
case f
|
||||
when :img_url
|
||||
"/images/#{url_to_avatar(u)}"
|
||||
when :gender
|
||||
u.nil? || u.user_extensions.nil? || u.user_extensions.gender.nil? ? 0 : u.user_extensions.gender
|
||||
when :work_unit
|
||||
get_user_work_unit u unless u.user_extensions.nil?
|
||||
when :location
|
||||
get_user_location u unless u.user_extensions.nil?
|
||||
when :brief_introduction
|
||||
u.nil? || u.user_extensions.nil? ? "" : u.user_extensions.brief_introduction
|
||||
when :student_num
|
||||
u.nil? || u.user_extensions.nil? ? "" : u.user_extensions.student_id
|
||||
when :real_name
|
||||
u.nil? ? "" : u.show_real_name;
|
||||
when :name
|
||||
u.nil? ? "" : u.show_name
|
||||
when :roles_id
|
||||
u[:roles_id].nil? ? nil : u.roles_id
|
||||
when :login
|
||||
u.login
|
||||
when :mail
|
||||
u.mail
|
||||
when :is_me
|
||||
defined? u.is_me ? u.is_me : 0
|
||||
when :is_teacher
|
||||
u.is_teacher
|
||||
when :fans_count
|
||||
u.watcher_users.count
|
||||
when :watched_count
|
||||
::User.watched_by(u.id).count
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
expose :id
|
||||
#头像
|
||||
user_expose :login
|
||||
#邮箱地址
|
||||
user_expose :mail
|
||||
#真名
|
||||
user_expose :img_url
|
||||
#昵称
|
||||
user_expose :real_name
|
||||
#性别
|
||||
user_expose :gender
|
||||
#我的二维码
|
||||
#工作单位
|
||||
user_expose :work_unit
|
||||
#地区
|
||||
user_expose :location
|
||||
#签名
|
||||
user_expose :brief_introduction
|
||||
#总成绩
|
||||
user_expose :score
|
||||
#学号
|
||||
user_expose :student_num
|
||||
# 活跃值
|
||||
user_expose :active_count
|
||||
|
||||
user_expose :is_me
|
||||
|
||||
user_expose :is_teacher
|
||||
|
||||
# 金币
|
||||
user_expose :grade
|
||||
|
||||
# 经验
|
||||
user_expose :experience
|
||||
|
||||
# 粉丝
|
||||
user_expose :fans_count
|
||||
|
||||
# 关注
|
||||
user_expose :watched_count
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,33 @@
|
||||
# encoding: utf-8
|
||||
module Mobile
|
||||
module Entities
|
||||
module Users
|
||||
class Course < Grape::Entity
|
||||
|
||||
def self.course_expose(field)
|
||||
expose field do |f, u|
|
||||
if field == :teacher_name
|
||||
::User.find(f[:course].try(:tea_id)).show_name
|
||||
elsif field==:student_num
|
||||
f[:course].try(:student).try(:count)
|
||||
else
|
||||
f[:course].try(field)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
course_expose :id
|
||||
course_expose :name
|
||||
course_expose :teacher_name
|
||||
expose :is_teacher
|
||||
course_expose :invite_code
|
||||
course_expose :student_num
|
||||
|
||||
expose :boards, using: Mobile::Entities::Courses::Board do |f, opt|
|
||||
f[:course].boards
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,24 @@
|
||||
# encoding: utf-8
|
||||
module Mobile
|
||||
module Entities
|
||||
module Users
|
||||
class Tiding < Grape::Entity
|
||||
|
||||
expose :user, using: ShortUser
|
||||
expose :title
|
||||
|
||||
expose :content do |f,u|
|
||||
f.key_word
|
||||
end
|
||||
|
||||
expose :created_at
|
||||
|
||||
expose :container_id
|
||||
expose :container_type
|
||||
expose :parent_container_id
|
||||
expose :parent_container_type
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,119 @@
|
||||
# encoding: utf-8
|
||||
module Mobile
|
||||
module Entities
|
||||
class Whomework <Grape::Entity
|
||||
include ApiHelper
|
||||
include ApplicationHelper
|
||||
include Redmine::I18n
|
||||
def self.whomework_expose(f)
|
||||
expose f do |wh, opt|
|
||||
if wh.is_a?(Hash) && wh.key?(f)
|
||||
wh[f]
|
||||
elsif wh.is_a?(::HomeworkCommon)
|
||||
if wh.respond_to?(f)
|
||||
if f == :created_at
|
||||
format_time(wh.send(f))
|
||||
else
|
||||
wh.send(f)
|
||||
end
|
||||
else
|
||||
case f
|
||||
when :absence_penalty
|
||||
wh.nil? || wh.homework_detail_manual.nil? ? 0 : wh.homework_detail_manual.absence_penalty
|
||||
when :evaluation_start
|
||||
wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_start, 0)
|
||||
when :evaluation_end
|
||||
wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_end, 1)
|
||||
when :praise_count
|
||||
get_activity_praise_num(wh)
|
||||
when :comment_count
|
||||
wh.journals_for_messages.count
|
||||
when :course_name
|
||||
wh.course.name
|
||||
when :syllabus_title
|
||||
wh.course.syllabus.nil? ? "" : wh.course.syllabus.title
|
||||
when :act_type
|
||||
'HomeworkCommon'
|
||||
when :act_id
|
||||
wh.id
|
||||
when :title
|
||||
wh.name
|
||||
when :homework_commit_count
|
||||
wh.student_works.has_committed.count
|
||||
when :last_commit_info
|
||||
if wh.student_works.has_committed.count > 0
|
||||
lc = wh.student_works.has_committed.reorder("commit_time desc").first
|
||||
{:lasttime=>time_from_now(lc.commit_time), :lastname=>lc.user.show_name}
|
||||
end
|
||||
when :last_score_info
|
||||
if wh.student_works.has_committed.count > 0
|
||||
sw_id = "("+wh.student_works.map{|sw| sw.id}.join(",")+")"
|
||||
student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id} and score is not null").reorder("created_at desc")
|
||||
unless student_work_scores.empty?
|
||||
last_score = student_work_scores.first
|
||||
{:lasttime=>time_from_now(last_score.created_at), :lastname=>last_score.user.show_name}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
expose :author, using: Mobile::Entities::User do |w, opt|
|
||||
if w.is_a?(::HomeworkCommon)
|
||||
w.user
|
||||
end
|
||||
end
|
||||
expose :current_user, using: Mobile::Entities::User do |w, opt|
|
||||
current_user
|
||||
end
|
||||
expose :name
|
||||
expose :description
|
||||
expose :publish_time
|
||||
expose :end_time
|
||||
expose :homework_type
|
||||
expose :late_penalty
|
||||
expose :course_id
|
||||
expose :anonymous_comment
|
||||
expose :quotes
|
||||
expose :is_open
|
||||
expose :id
|
||||
whomework_expose :title
|
||||
whomework_expose :act_type
|
||||
whomework_expose :act_id
|
||||
whomework_expose :course_name
|
||||
whomework_expose :syllabus_title
|
||||
whomework_expose :created_at
|
||||
whomework_expose :absence_penalty
|
||||
whomework_expose :evaluation_start
|
||||
whomework_expose :evaluation_end
|
||||
whomework_expose :praise_count
|
||||
whomework_expose :comment_count
|
||||
whomework_expose :homework_commit_count #作品提交数
|
||||
whomework_expose :last_commit_info #最近提交信息
|
||||
whomework_expose :last_score_info #最近评阅信息
|
||||
expose :all_children, using: Mobile::Entities::Jours do |f, opt|
|
||||
#f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages)
|
||||
if f.is_a?(::HomeworkCommon)
|
||||
# f.journals_for_messages.reverse
|
||||
if !opt[:children] && opt[:type] == 0
|
||||
opt[:children] = true
|
||||
tStart = opt[:page]*5
|
||||
tEnd = (opt[:page]+1)*5 - 1
|
||||
|
||||
all_comments = f.journals_for_messages.reorder("created_on desc")
|
||||
all_comments[tStart..tEnd]
|
||||
end
|
||||
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
|
@ -0,0 +1,13 @@
|
||||
#coding=utf-8
|
||||
#
|
||||
module Mobile
|
||||
module Exceptions
|
||||
class AuthException < StandardError
|
||||
attr_reader :err_code, :msg
|
||||
def initialize(code, msg)
|
||||
@err_code = code
|
||||
@msg = msg
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,26 @@
|
||||
#coding=utf-8
|
||||
|
||||
|
||||
module Mobile
|
||||
module Middleware
|
||||
class ErrorHandler < Grape::Middleware::Base
|
||||
def call!(env)
|
||||
@env = env
|
||||
begin
|
||||
@app.call(@env)
|
||||
rescue =>e
|
||||
code = -1
|
||||
|
||||
message = {status: code, message: e.message }.to_json
|
||||
|
||||
Rails.logger.error e.inspect
|
||||
Rails.logger.error e.backtrace.join("\n")
|
||||
status = 200
|
||||
headers = { 'Content-Type' => content_type }
|
||||
Rack::Response.new([message], status, headers).finish
|
||||
# throw :error, :message => e.message || options[:default_message], :status => 500
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
@ -0,0 +1,2 @@
|
||||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,2 @@
|
||||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue