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

format price_type & mode

parent 2f522f2e
Pipeline #22272 passed with stage
in 3 seconds
......@@ -76,6 +76,8 @@ class InstitutionSubService extends Service {
}
}
}
classList.rows[i].price_type = await this.getClassPriceType(classList.rows[i].price_type);
classList.rows[i].mode = await this.getClassMode(classList.rows[i].mode);
classList.rows[i].category = classCategoryList;
classList.rows[i].institution_name = ctx.isEmpty(institutionList[classList.rows[i].institution_id]) ? '' : institutionList[classList.rows[i].institution_id][0].name;
classList.rows[i].institution_logo = ctx.isEmpty(institutionList[classList.rows[i].institution_id]) ? '' : institutionList[classList.rows[i].institution_id][0].logo;
......@@ -150,6 +152,8 @@ class InstitutionSubService extends Service {
}
classInfo.columns = columns;
classInfo.price_type = await this.getClassPriceType(classInfo.price_type);
classInfo.mode = await this.getClassMode(classInfo.mode);
classInfo.student_works = studentWorks;
classInfo.images = images;
classInfo.category = category;
......@@ -173,6 +177,10 @@ class InstitutionSubService extends Service {
const collectedIds = R.pluck('type_id', userCollection.rows);
const filter = { where: { id: { $in: collectedIds }, status: 1, is_deleted: 0 }, page_size, offset, attributes, raw: true };
const classList = await ctx.classModel.V5.CourseV5Class.findAll(filter);
for (const i in classList) {
classList[i].price_type = await this.getClassPriceType(classList[i].price_type);
classList[i].mode = await this.getClassMode(classList[i].mode);
}
const ret = {
list: classList,
......@@ -247,6 +255,23 @@ class InstitutionSubService extends Service {
return ret;
}
// 课程类型映射
async getClassPriceType(key) {
const list = [ '免费公益课', '低价体验课', '正价课' ];
const ret = (key > 0 && key <= list.length) ? list[key - 1] : '';
return ret;
}
// 课程状态映射
async getClassMode(key) {
const list = [ '直播', '录播(动画)', '录播(真人)', 'APP', '小程序' ];
const ret = (key > 0 && key <= list.length) ? list[key - 1] : '';
return ret;
}
}
module.exports = InstitutionSubService;
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