Commit 92903787 authored by 任国军's avatar 任国军

fix bugs

parent 0b686c64
Pipeline #16804 passed with stage
in 55 seconds
......@@ -87,11 +87,10 @@ class InstitutionSubService extends Service {
const student_video = await ctx.classModel.V2.CourseStudentVideo.findAll({ where: { institution_id, status: 'online', is_deleted: 0 }, order: [[ 'sort', 'asc' ]] });
// 教师
const teachers = await ctx.classModel.V2.CourseTeacher.findAll({ where: { institution_id, status: 'online', is_deleted: 0 } });
const teachers = await ctx.classModel.V2.CourseTeacher.findAll({ where: { institution_id, status: 'online', is_deleted: 0 }, raw: true });
// 课程
let classes = await ctx.classModel.V2.CourseClass.findAll({ where: { institution_id, status: 'online', is_deleted: 0 }, row: true });
classes = R.pluck('dataValues', classes);
const classes = await ctx.classModel.V2.CourseClass.findAll({ where: { institution_id, status: 'online', is_deleted: 0 }, raw: true });
// 处理课程封面图
const classHandle = [];
if (classes.length > 0) {
......@@ -110,7 +109,7 @@ class InstitutionSubService extends Service {
}
// 校区
let areas = await ctx.classModel.V2.CourseArea.findAll({ where: { institution_id, status: 'online', is_deleted: 0 } });
let areas = await ctx.classModel.V2.CourseArea.findAll({ where: { institution_id, status: 'online', is_deleted: 0 }, raw: true });
const areaHandle = [];
if (areas.length > 0) {
for (const v of areas) {
......@@ -439,7 +438,7 @@ class InstitutionSubService extends Service {
async getUserSearch() {
const { ctx } = this;
const userUuid = ctx.userUuid;
const search = await ctx.classModel.V2.CourseUserSearch.findAll({ where: { status: 'online', user_uuid: userUuid }, limit: 10, order: [[ 'id' ], [ 'desc' ]] });
const search = await ctx.classModel.V2.CourseUserSearch.findAll({ where: { status: 'online', user_uuid: userUuid }, limit: 10, order: [[ 'id', 'desc' ]] });
const result = _.uniq(R.pluck('content', search));
const ret = {
......@@ -631,7 +630,7 @@ class InstitutionSubService extends Service {
// 课程图片
let images = await ctx.classModel.V2.CourseImages.findAll({ where: { type: 2, type_id: id, status: 'online', is_deleted: 0 }, raw: true });
// 去重
images = _.uniqBy(images, function(v) { return (v.is_image === 1 ? v.image_url : v.video_url) ;});
images = _.uniqBy(images, function(v) { return (v.is_image === 1 ? v.image_url : v.video_url); });
images = _.orderBy(images, [ 'sort' ], [ 'asc' ]);
classInfo.images = images;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment