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 {
// 年龄段
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 options = {
cats,
ages,
model,
mode,
type,
};
return options;
......@@ -70,7 +70,7 @@ class OnlineService extends Service {
travel_tips: ctx.isEmpty(area) ? '' : area.travel_tips,
price: classInfo.price,
type: classInfo.type,
model: await this.getClassModelInfo(classInfo.model),
mode: await this.getClassModelInfo(classInfo.mode),
time: classInfo.time,
channel: classInfo.channel,
description: classInfo.description,
......@@ -88,8 +88,8 @@ class OnlineService extends Service {
const page = Number(input.page) || 1;
const limit = Number(input.limit) || 10;
const offset = (page - 1) * limit;
const { type, model, 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 { 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', 'mode', 'time', 'created_time' ] };
// 年龄段筛选
if (!ctx.isEmpty(age)) {
filter.where.age = age;
......@@ -100,21 +100,21 @@ class OnlineService extends Service {
filter.where.id = { $in: R.pluck('class_id', classes) };
}
// 课程状态筛选
if (!ctx.isEmpty(model)) {
filter.where.model = model;
if (!ctx.isEmpty(mode)) {
filter.where.mode = mode;
}
// 课程班型筛选
if (!ctx.isEmpty(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 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);
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');
let classCats = [];
for (const v of classToCats) {
......@@ -129,7 +129,7 @@ class OnlineService extends Service {
// 机构
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');
const result = [];
......@@ -141,7 +141,7 @@ class OnlineService extends Service {
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,
type: v.type,
model: await this.getClassModelInfo(v.model),
mode: await this.getClassModelInfo(v.mode),
price: v.price,
time: v.time,
created_time: v.created_time,
......@@ -159,9 +159,9 @@ class OnlineService extends Service {
}
// 判断课程状态(直播录播)
async getClassModelInfo(model) {
async getClassModelInfo(mode) {
let ret = '';
switch (model) {
switch (mode) {
case 1:
ret = '直播';
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