Commit 3e8f497d authored by Aria's avatar Aria

fix bugs

parent 7d19f17e
Pipeline #19399 passed with stage
in 8 seconds
...@@ -15,14 +15,14 @@ class OnlineService extends Service { ...@@ -15,14 +15,14 @@ class OnlineService extends Service {
// 年龄段 // 年龄段
const ages = [ '学龄前', '幼儿园', '小学', '初中', '高中' ]; const ages = [ '学龄前', '幼儿园', '小学', '初中', '高中' ];
// 课程状态 // 课程状态
const model = [{ id: 0, name: '全部' }, { id: 1, name: '直播' }, { id: 2, name: '录播' }]; const mode = [{ id: 0, name: '全部' }, { id: 1, name: '直播' }, { id: 2, name: '录播' }];
// 课程班型 // 课程班型
const type = [ '1对1', '1对多', '讲座' ]; const type = [ '1对1', '1对多', '讲座' ];
const options = { const options = {
cats, cats,
ages, ages,
model, mode,
type, type,
}; };
return options; return options;
...@@ -70,7 +70,7 @@ class OnlineService extends Service { ...@@ -70,7 +70,7 @@ class OnlineService extends Service {
travel_tips: ctx.isEmpty(area) ? '' : area.travel_tips, travel_tips: ctx.isEmpty(area) ? '' : area.travel_tips,
price: classInfo.price, price: classInfo.price,
type: classInfo.type, type: classInfo.type,
model: await this.getClassModelInfo(classInfo.model), mode: await this.getClassModelInfo(classInfo.mode),
time: classInfo.time, time: classInfo.time,
channel: classInfo.channel, channel: classInfo.channel,
description: classInfo.description, description: classInfo.description,
...@@ -88,8 +88,8 @@ class OnlineService extends Service { ...@@ -88,8 +88,8 @@ class OnlineService extends Service {
const page = Number(input.page) || 1; const page = Number(input.page) || 1;
const limit = Number(input.limit) || 10; const limit = Number(input.limit) || 10;
const offset = (page - 1) * limit; const offset = (page - 1) * limit;
const { type, model, age, cat } = input; const { type, mode, age, cat } = input;
const filter = { where: { status: 'online', is_deleted: 0 }, order: [[ 'institution_id', 'desc' ]], limit, offset, attributes: [ 'id', 'institution_id', 'name', 'price', 'type', 'age', 'model', 'time', 'created_time' ] }; const filter = { where: { status: 'online', is_deleted: 0 }, order: [[ 'institution_id', 'desc' ]], limit, offset, attributes: [ 'id', 'institution_id', 'name', 'price', 'type', 'age', 'mode', 'time', 'created_time' ] };
// 年龄段筛选 // 年龄段筛选
if (!ctx.isEmpty(age)) { if (!ctx.isEmpty(age)) {
filter.where.age = age; filter.where.age = age;
...@@ -100,21 +100,21 @@ class OnlineService extends Service { ...@@ -100,21 +100,21 @@ class OnlineService extends Service {
filter.where.id = { $in: R.pluck('class_id', classes) }; filter.where.id = { $in: R.pluck('class_id', classes) };
} }
// 课程状态筛选 // 课程状态筛选
if (!ctx.isEmpty(model)) { if (!ctx.isEmpty(mode)) {
filter.where.model = model; filter.where.mode = mode;
} }
// 课程班型筛选 // 课程班型筛选
if (!ctx.isEmpty(type)) { if (!ctx.isEmpty(type)) {
filter.where.type = type; filter.where.type = type;
} }
const classes = await ctx.classModel.CourseOnlineClass.findAndCountAll(filter); const classes = await ctx.classModel.V4.CourseOnlineClass.findAndCountAll(filter);
const classIds = R.pluck('id', classes.rows); const classIds = R.pluck('id', classes.rows);
// 分类 // 分类
const classToCats = await ctx.classModel.CourseOnlineClassToCat.findAll({ where: { class_id: { $in: classIds }, status: 'online', is_deleted: 0 }, attributes: [ 'class_id', 'cat_id' ] }); const classToCats = await ctx.classModel.V4.CourseOnlineClassToCat.findAll({ where: { class_id: { $in: classIds }, status: 'online', is_deleted: 0 }, attributes: [ 'class_id', 'cat_id' ] });
const catIds = R.pluck('cat_id', classToCats); const catIds = R.pluck('cat_id', classToCats);
let cats = await ctx.classModel.CourseOnlineCat.findAll({ where: { id: { $in: catIds } } }); let cats = await ctx.classModel.V4.CourseOnlineCat.findAll({ where: { id: { $in: catIds } } });
cats = _.groupBy(cats, 'id'); cats = _.groupBy(cats, 'id');
let classCats = []; let classCats = [];
for (const v of classToCats) { for (const v of classToCats) {
...@@ -129,7 +129,7 @@ class OnlineService extends Service { ...@@ -129,7 +129,7 @@ class OnlineService extends Service {
// 机构 // 机构
const institutionIds = R.pluck('institution_id', classes.rows); const institutionIds = R.pluck('institution_id', classes.rows);
let institutions = await ctx.classModel.CourseOnlineInstitution.findAll({ where: { id: { $in: institutionIds } }, attributes: [ 'id', 'name', 'logo' ] }); let institutions = await ctx.classModel.V4.CourseOnlineInstitution.findAll({ where: { id: { $in: institutionIds } }, attributes: [ 'id', 'name', 'logo' ] });
institutions = _.groupBy(institutions, 'id'); institutions = _.groupBy(institutions, 'id');
const result = []; const result = [];
...@@ -141,7 +141,7 @@ class OnlineService extends Service { ...@@ -141,7 +141,7 @@ class OnlineService extends Service {
institution_name: ctx.isEmpty(institutions[v.institution_id]) ? '' : institutions[v.institution_id][0].name, institution_name: ctx.isEmpty(institutions[v.institution_id]) ? '' : institutions[v.institution_id][0].name,
logo: ctx.isEmpty(institutions[v.institution_id]) ? '' : institutions[v.institution_id][0].logo, logo: ctx.isEmpty(institutions[v.institution_id]) ? '' : institutions[v.institution_id][0].logo,
type: v.type, type: v.type,
model: await this.getClassModelInfo(v.model), mode: await this.getClassModelInfo(v.mode),
price: v.price, price: v.price,
time: v.time, time: v.time,
created_time: v.created_time, created_time: v.created_time,
...@@ -159,9 +159,9 @@ class OnlineService extends Service { ...@@ -159,9 +159,9 @@ class OnlineService extends Service {
} }
// 判断课程状态(直播录播) // 判断课程状态(直播录播)
async getClassModelInfo(model) { async getClassModelInfo(mode) {
let ret = ''; let ret = '';
switch (model) { switch (mode) {
case 1: case 1:
ret = '直播'; ret = '直播';
break; break;
......
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