Commit 577d3a90 authored by 任国军's avatar 任国军

add is_collected && class_hours

parent 28de6fce
Pipeline #18262 passed with stage
in 56 seconds
......@@ -16,6 +16,7 @@ module.exports = app => {
// image: STRING,
class_price: STRING,
class_frequency: STRING,
class_hours: STRING,
price: DECIMAL,
min_age: INTEGER,
max_age: INTEGER,
......
......@@ -592,6 +592,9 @@ class InstitutionSubService extends Service {
// 课程图片
const classImages = await ctx.classModel.V3.CourseImages.findAll({ where: { type: 2, type_id: { $in: classIds }, status: 'online', is_deleted: 0 }, raw: true });
// 用户收藏的课程
const userCollection = await ctx.classModel.V3.CourseUserCollection.findAll({ where: { user_uuid: ctx.userUuid, is_deleted: 0, type: 2 }, raw: true });
const collectedIds = R.pluck('type_id', userCollection);
for (const i in classes.rows) {
let images = [];
for (const v of classImages) {
......@@ -601,6 +604,7 @@ class InstitutionSubService extends Service {
}
images = _.orderBy(images, [ 'sort' ], [ 'asc' ]);
classes.rows[i].image = images.length > 0 ? images[0] : {};
classes.rows[i].is_collected = collectedIds.includes(classes.rows[i].id) ? 1 : 0;
}
const ret = {
......@@ -630,7 +634,10 @@ class InstitutionSubService extends Service {
input.institution_id = classInfo.institution_id;
const institution = await this.getInstitution(input);
classInfo.institution = ctx.isEmpty(institution) ? {} : institution.detail;
classInfo.area = ctx.isEmpty(institution) || ctx.isEmpty(institution.areas) ? {} : institution.areas[0];
const isCollected = await ctx.classModel.V3.CourseUserCollection.findOne({ where: { user_uuid: ctx.userUuid, type: 2, type_id: input.id, is_deleted: 0 } });
classInfo.is_collected = ctx.isEmpty(isCollected) ? 0 : 1;
return classInfo;
}
......
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