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

fix bugs

parent 3e8f497d
Pipeline #19401 passed with stage
in 1 minute 5 seconds
'use strict';
'use strict';
const moment = require('moment');
module.exports = app => {
const { STRING, INTEGER, DATE, DECIMAL, TEXT, ENUM, FLOAT } = app.Sequelize;
const CourseOnlineArea = app.classModel.define('courseOnlineArea', {
const CourseOnlineArea = app.classModel.define('course_online_area', {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true
autoIncrement: true,
},
institution_id: INTEGER,
name: STRING,
......@@ -27,31 +27,31 @@ module.exports = app => {
const date = this.getDataValue('created_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
}
},
}, {
timestamps: false,
tableName: 'courseOnlineArea',
tableName: 'course_online_area',
});
CourseOnlineArea.one = async (data) => {
CourseOnlineArea.one = async data => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
return await CourseOnlineArea.findOne({
attributes: attributes,
where: where,
attributes,
where,
});
}
};
CourseOnlineArea.all = async (data) => {
CourseOnlineArea.all = async data => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const order = data.order ? data.order : [];
return await CourseOnlineArea.findAll({
attributes: attributes,
where: where,
attributes,
where,
order,
});
}
};
CourseOnlineArea.list = async (data = {}) => {
const limit = data.limit ? Number(data.limit) : 10;
......@@ -62,35 +62,35 @@ module.exports = app => {
const condition = {
offset: (page - 1) * limit,
limit,
where: where,
order: order,
attributes: attributes,
where,
order,
attributes,
};
const { count, rows } = await CourseOnlineArea.findAndCountAll(condition);
return { page, count, rows };
}
};
CourseOnlineArea.add = async (data) => {
CourseOnlineArea.add = async data => {
try {
//返回promise对象实力 instance
// 返回promise对象实力 instance
const res = await CourseOnlineArea.create(data);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
// 从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return res.id;
} catch (error) {
throw (error);
}
}
};
CourseOnlineArea.edit = async (data) => {
CourseOnlineArea.edit = async data => {
const where = data.where;
const params = data.params;
try {
const res = await CourseOnlineArea.update(params, { where: where })
const res = await CourseOnlineArea.update(params, { where });
return res;
} catch (error) {
throw (error);
}
}
};
return CourseOnlineArea;
......
......@@ -56,7 +56,7 @@ class OnlineService extends Service {
const cats = await ctx.classModel.V4.CourseOnlineCat.findAll({ where: { id: { $in: catIds } }, attributes: [ 'id', 'name' ] });
// 收藏信息
const userCollect = await ctx.classModel.V4.CourseUserCollection.findOne({ where: { user_uuid: ctx.userUuid, type: 3, type_id: id, status: 'online', is_deleted: 0 } });
const userCollect = await ctx.classModel.V4.CourseUserCollection.findOne({ where: { user_uuid: ctx.userUuid, type: 3, type_id: id, is_deleted: 0 } });
const ret = {
id,
......
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