好大学字段命名修改

pre_develop
daiao 6 years ago
parent d3772615f8
commit 72e401d7d2

@ -6,7 +6,7 @@ class CnmoocsService
page = params[:pageNo].to_i
limit = params[:pageSize] || 16
offset = page * limit.to_i
resouces = []
resources = []
if params[:level].to_s == "1"
subjects = Subject.find_by_sql("SELECT subjects.id, subjects.name, subjects.status, COUNT(myshixuns.id) AS myshixun_member_count
FROM myshixuns, stage_shixuns, subjects WHERE myshixuns.shixun_id = stage_shixuns.shixun_id
@ -14,8 +14,8 @@ class CnmoocsService
GROUP BY subjects.id ORDER BY myshixun_member_count DESC limit #{offset},#{limit}")
subjects.each do |subject|
resouces << {resouceId: subject.id, parentId: nil, resouceName: subject.name, accessType: 0, nodeType: 0,
resouceType: 2}
resources << {resourceId: subject.id, parentId: nil, resourceName: subject.name, accessType: 0, nodeType: 0,
resourceType: 2}
end
totalCount = Subject.where(:status => 2, :hidden => 0).count
count = subjects.count
@ -23,8 +23,8 @@ class CnmoocsService
return {error: -1, messages: "请求二级及其更高目录时parentId不能为空"} if params[:parentId].blank?
stages = Stage.where(:subject_id => params[:parentId]).offset(offset).limit(limit)
stages.each do |stage|
resouces << {resouceId: stage.id, parentId: params[:parentId], resouceName: stage.name, accessType: 0, nodeType: 0,
resouceType: 2}
resources << {resourceId: stage.id, parentId: params[:parentId], resourceName: stage.name, accessType: 0, nodeType: 0,
resourceType: 2}
end
totalCount = Stage.where(:subject_id => params[:parentId]).count
count = stages.count
@ -33,8 +33,8 @@ class CnmoocsService
shixun_ids = StageShixun.where(:stage_id => params[:parentId]).pluck(:shixun_id)
shixuns = Shixun.where(:id => shixun_ids).offset(offset).limit(limit)
shixuns.each do |shixun|
resouces << {resouceId: shixun.id, parentId: params[:parentId], resouceName: shixun.name, accessType: 2,
nodeType: 1, resouceType: 1}
resources << {resourceId: shixun.id, parentId: params[:parentId], resourceName: shixun.name, accessType: 2,
nodeType: 1, resourceType: 1}
end
totalCount = Shixun.where(:id => shixun_ids).count
count = shixuns.count
@ -42,7 +42,7 @@ class CnmoocsService
pageCount = ((totalCount / limit.to_f) == (totalCount / limit)) ? (totalCount / limit) : ((totalCount / limit) + 1)
{error: 0, messages: "请求成功",
page: {count: count, totalCount: totalCount, pageNo: page, pageSize: limit, pageCount: pageCount},
data: {resouces: resouces} }
data: {resources: resources} }
end
def search_resources params
@ -115,7 +115,7 @@ class CnmoocsService
end
def source_url(params, token)
shixun = Shixun.find_by_id(params[:resouceId])
shixun = Shixun.find_by_id(params[:resourceId])
if shixun.blank?
return { error: -1, messages: '资源不存在' }
end
@ -123,7 +123,7 @@ class CnmoocsService
end
def get_students_data params
shixun = Shixun.find_by_id params[:resouceId]
shixun = Shixun.find_by_id params[:resourceId]
return {error: -1, messages: "资源id不对请使用资源的id查找"} if shixun.blank?
myshixun = shixun.myshixuns.where(:user_id => params[:userId]).includes(:games).first
if myshixun.present?
@ -150,7 +150,7 @@ class CnmoocsService
challenges_count: shixun.challenges_count, score_info: shixun.averge_star, level: level}
end
{resouces: shixun_list}
{resources: shixun_list}
end
# 为新创建的用户随机生成以m为前缀的用户名m表示该用户是用邮箱注册

Loading…
Cancel
Save