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

add relation

parent 79b5cdbf
Pipeline #24806 passed with stage
in 4 seconds
......@@ -6,14 +6,14 @@ const moment = require('moment');
module.exports = app => {
const { INTEGER, DATE } = app.Sequelize;
const CourseV5ClassToScore = app.classModel.define('course_v5_class_to_score', {
const CourseV5ClassRelation = app.classModel.define('course_v5_class_relation', {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true,
},
class_id: INTEGER,
score_id: INTEGER,
relation_id: INTEGER,
status: INTEGER,
is_deleted: INTEGER,
created_time: {
......@@ -34,9 +34,9 @@ module.exports = app => {
},
}, {
timestamps: false,
tableName: 'course_v5_class_to_score',
tableName: 'course_v5_class_relation',
});
return CourseV5ClassToScore;
return CourseV5ClassRelation;
};
......@@ -147,6 +147,13 @@ class InstitutionSubService extends Service {
const frequencyList = await ctx.classModel.V5.CourseV5ClassToFrequency.findAll({ where: { class_id: id, status: 1, is_deleted: 0 }, attributes: [ 'frequency_id' ] });
const frequency = await ctx.classModel.V5.CourseV5Frequency.findAll({ where: { id: { $in: R.pluck('frequency_id', frequencyList) } }, attributes: [ 'id', 'name' ] });
// 关联课程
const relationList = await ctx.classModel.V5.CourseV5ClassRelation.findAll({ where: { class_id: id, status: 1, is_deleted: 0 }, attributes: [ 'relation_id' ] });
const relation = await ctx.classModel.V5.CourseV5Class.findAll({ where: { id: { $in: R.pluck('relation_id', relationList) } }, attributes: [ 'id', 'name', 'price', 'mode' ], raw: true });
for (const i in relation) {
relation[i].mode = await this.getClassMode(relation[i].mode);
}
const columns = [];
for (const v of classColumns) {
if (!ctx.isEmpty(columnList[v.column_id])) {
......@@ -186,6 +193,7 @@ class InstitutionSubService extends Service {
classInfo.pay_count += orderCount;
classInfo.video_count = videoCount;
classInfo.frequency = frequency;
classInfo.relation = relation;
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