Commit 1a562059 authored by 任国军's avatar 任国军

add course

parent dd401208
Pipeline #16297 passed with stage
in 46 seconds
'use strict';
const Controller = require('egg').Controller;
class InstitutionSubController extends Controller {
/**
* 机构列表
*/
async institutionList() {
const { ctx } = this;
const input_params = ctx.request.body;
const results = await ctx.service.course.institutionSub.getInstitutions(input_params);
ctx.success({ results });
}
/**
* 机构详情
*/
async institutionInfo() {
const { ctx } = this;
let input_params = ctx.params;
const query = ctx.query;
input_params = Object.assign(input_params, query);
const result = await ctx.service.course.institutionSub.getInstitution(input_params);
ctx.success({ result });
}
/**
* 课程列表
*/
async classList() {
const { ctx } = this;
const input_params = ctx.request.body;
const results = await ctx.service.course.institutionSub.getClasses(input_params);
ctx.success({ results });
}
/**
* 课程详情
*/
async classInfo() {
const { ctx } = this;
const class_id = ctx.params.class_id;
if (!class_id) {
ctx.failed('error class_id');
}
const ret = await ctx.service.course.institutionSub.getClass(class_id);
ctx.success(ret);
}
/**
* 老师列表
*/
async teacherList() {
const { ctx } = this;
const input_params = ctx.request.body;
const ret = await ctx.service.course.institutionSub.getTeachers(input_params);
ctx.success(ret);
}
/**
* 老师详情
*/
async teacherInfo() {
const { ctx } = this;
const teacher_id = ctx.params.teacher_id;
if (!teacher_id) {
ctx.failed('error teacher_id');
}
const ret = await ctx.service.course.institutionSub.getTeacher(teacher_id);
ctx.success(ret);
}
// 获取分类
async getCats() {
const { ctx } = this;
const ret = await ctx.service.course.institutionSub.getCats();
ctx.success(ret);
}
}
module.exports = InstitutionSubController;
'use strict';
const moment = require('moment');
module.exports = app => {
const { STRING, INTEGER, DATE, DECIMAL, TEXT, ENUM } = app.Sequelize;
const CourseStudentVideo = app.classModel.define('course_student_video', {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true,
},
institution_id: INTEGER,
video_url: STRING,
title: STRING,
age: STRING,
time: STRING,
sort: INTEGER,
status: ENUM('offline', 'online'),
is_deleted: INTEGER,
created_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('created_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
updated_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('updated_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
}, {
timestamps: false,
tableName: 'course_student_video',
});
return CourseStudentVideo;
};
'use strict';
'use strict';
const moment = require('moment');
......@@ -10,30 +10,29 @@ module.exports = app => {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true
autoIncrement: true,
},
first_id: INTEGER,
parent_id: INTEGER,
level: INTEGER,
name: STRING,
image: STRING,
color: STRING,
tips: STRING,
status: ENUM('offline', 'online'),
is_deleted: INTEGER,
created_at: {
sort: INTEGER,
created_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('created_at');
const date = this.getDataValue('created_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
updated_at: {
updated_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('updated_at');
const date = this.getDataValue('updated_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
......@@ -42,25 +41,25 @@ module.exports = app => {
tableName: 'course_cat',
});
CourseCat.one = async (data) => {
CourseCat.one = async data => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
return await CourseCat.findOne({
attributes: attributes,
where: where,
attributes,
where,
});
}
};
CourseCat.all = async (data) => {
CourseCat.all = async data => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const order = data.order ? data.order : [];
return await CourseCat.findAll({
attributes: attributes,
where: where,
attributes,
where,
order,
});
}
};
CourseCat.list = async (data = {}) => {
const limit = data.limit ? Number(data.limit) : 10;
......@@ -71,35 +70,35 @@ module.exports = app => {
const condition = {
offset: (page - 1) * limit,
limit,
where: where,
order: order,
attributes: attributes,
where,
order,
attributes,
};
const { count, rows } = await CourseCat.findAndCountAll(condition);
return { page, count, rows };
}
};
CourseCat.add = async (data) => {
CourseCat.add = async data => {
try {
//返回promise对象实力 instance
// 返回promise对象实力 instance
const res = await CourseCat.create(data);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
// 从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return res.id;
} catch (error) {
throw (error);
}
}
};
CourseCat.edit = async (data) => {
CourseCat.edit = async data => {
const where = data.where;
const params = data.params;
try {
const res = await CourseCat.update(params, { where: where })
const res = await CourseCat.update(params, { where });
return res;
} catch (error) {
throw (error);
}
}
};
return CourseCat;
......
'use strict';
'use strict';
const moment = require('moment');
......@@ -11,7 +11,7 @@ module.exports = app => {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true
autoIncrement: true,
},
type: INTEGER,
type_id: INTEGER,
......@@ -20,6 +20,8 @@ module.exports = app => {
is_cover: INTEGER,
is_video: INTEGER,
sort: INTEGER,
status: ENUM('offline', 'online'),
is_deleted: INTEGER,
created_time: {
type: DATE,
allowNull: true,
......@@ -33,25 +35,25 @@ module.exports = app => {
tableName: 'course_images',
});
CourseImages.one = async (data) => {
CourseImages.one = async data => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
return await CourseImages.findOne({
attributes: attributes,
where: where,
attributes,
where,
});
}
};
CourseImages.all = async (data) => {
CourseImages.all = async data => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const order = data.order ? data.order : [];
return await CourseImages.findAll({
attributes: attributes,
where: where,
attributes,
where,
order,
});
}
};
CourseImages.list = async (data = {}) => {
const limit = data.limit ? Number(data.limit) : 10;
......@@ -62,35 +64,35 @@ module.exports = app => {
const condition = {
offset: (page - 1) * limit,
limit,
where: where,
order: order,
attributes: attributes,
where,
order,
attributes,
};
const { count, rows } = await CourseImages.findAndCountAll(condition);
return { page, count, rows };
}
};
CourseImages.add = async (data) => {
CourseImages.add = async data => {
try {
//返回promise对象实力 instance
// 返回promise对象实力 instance
const res = await CourseImages.create(data);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
// 从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return res.id;
} catch (error) {
throw (error);
}
}
};
CourseImages.edit = async (data) => {
CourseImages.edit = async data => {
const where = data.where;
const params = data.params;
try {
const res = await CourseImages.update(params, { where: where })
const res = await CourseImages.update(params, { where });
return res;
} catch (error) {
throw (error);
}
}
};
return CourseImages;
......
......@@ -16,19 +16,19 @@ module.exports = app => {
cat_id: INTEGER,
status: ENUM('offline', 'online'),
is_deleted: INTEGER,
created_at: {
created_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('created_at');
const date = this.getDataValue('created_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
updated_at: {
updated_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('updated_at');
const date = this.getDataValue('updated_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
......
......@@ -17,19 +17,19 @@ module.exports = app => {
lat: DECIMAL,
lng: DECIMAL,
is_deleted: INTEGER,
created_at: {
created_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('created_at');
const date = this.getDataValue('created_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
updated_at: {
updated_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('updated_at');
const date = this.getDataValue('updated_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
......
'use strict';
'use strict';
const moment = require('moment');
......@@ -10,7 +10,7 @@ module.exports = app => {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true
autoIncrement: true,
},
uuid: STRING,
app_id: STRING,
......@@ -23,19 +23,19 @@ module.exports = app => {
sex: STRING,
openid: STRING,
is_deleted: INTEGER,
created_at: {
created_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('created_at');
const date = this.getDataValue('created_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
updated_at: {
updated_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('updated_at');
const date = this.getDataValue('updated_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
......@@ -44,25 +44,25 @@ module.exports = app => {
tableName: 'course_user',
});
CourseUser.one = async (data) => {
CourseUser.one = async data => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
return await CourseUser.findOne({
attributes: attributes,
where: where,
attributes,
where,
});
}
};
CourseUser.all = async (data) => {
CourseUser.all = async data => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const order = data.order ? data.order : [];
return await CourseUser.findAll({
attributes: attributes,
where: where,
attributes,
where,
order,
});
}
};
CourseUser.list = async (data = {}) => {
const limit = data.limit ? Number(data.limit) : 10;
......@@ -73,35 +73,35 @@ module.exports = app => {
const condition = {
offset: (page - 1) * limit,
limit,
where: where,
order: order,
attributes: attributes,
where,
order,
attributes,
};
const { count, rows } = await CourseUser.findAndCountAll(condition);
return { page, count, rows };
}
};
CourseUser.add = async (data) => {
CourseUser.add = async data => {
try {
//返回promise对象实力 instance
// 返回promise对象实力 instance
const res = await CourseUser.create(data);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
// 从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return res.id;
} catch (error) {
throw (error);
}
}
};
CourseUser.edit = async (data) => {
CourseUser.edit = async data => {
const where = data.where;
const params = data.params;
try {
const res = await CourseUser.update(params, { where: where })
const res = await CourseUser.update(params, { where });
return res;
} catch (error) {
throw (error);
}
}
};
return CourseUser;
......
'use strict';
'use strict';
const moment = require('moment');
......@@ -10,7 +10,7 @@ module.exports = app => {
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true
autoIncrement: true,
},
user_uuid: STRING,
gender: ENUM('boy', 'girl'),
......@@ -19,19 +19,19 @@ module.exports = app => {
lat: DECIMAL,
lng: DECIMAL,
is_deleted: INTEGER,
created_at: {
created_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('created_at');
const date = this.getDataValue('created_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
updated_at: {
updated_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('updated_at');
const date = this.getDataValue('updated_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
......@@ -40,25 +40,25 @@ module.exports = app => {
tableName: 'course_user_baby',
});
CourseUserBaby.one = async (data) => {
CourseUserBaby.one = async data => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
return await CourseUserBaby.findOne({
attributes: attributes,
where: where,
attributes,
where,
});
}
};
CourseUserBaby.all = async (data) => {
CourseUserBaby.all = async data => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const order = data.order ? data.order : [];
return await CourseUserBaby.findAll({
attributes: attributes,
where: where,
attributes,
where,
order,
});
}
};
CourseUserBaby.list = async (data = {}) => {
const limit = data.limit ? Number(data.limit) : 10;
......@@ -69,35 +69,35 @@ module.exports = app => {
const condition = {
offset: (page - 1) * limit,
limit,
where: where,
order: order,
attributes: attributes,
where,
order,
attributes,
};
const { count, rows } = await CourseUserBaby.findAndCountAll(condition);
return { page, count, rows };
}
};
CourseUserBaby.add = async (data) => {
CourseUserBaby.add = async data => {
try {
//返回promise对象实力 instance
// 返回promise对象实力 instance
const res = await CourseUserBaby.create(data);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
// 从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return res.id;
} catch (error) {
throw (error);
}
}
};
CourseUserBaby.edit = async (data) => {
CourseUserBaby.edit = async data => {
const where = data.where;
const params = data.params;
try {
const res = await CourseUserBaby.update(params, { where: where })
const res = await CourseUserBaby.update(params, { where });
return res;
} catch (error) {
throw (error);
}
}
};
return CourseUserBaby;
......
......@@ -15,19 +15,19 @@ module.exports = app => {
user_uuid: STRING,
institution_id: INTEGER,
is_deleted: INTEGER,
created_at: {
created_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('created_at');
const date = this.getDataValue('created_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
updated_at: {
updated_time: {
type: DATE,
allowNull: true,
get() {
const date = this.getDataValue('updated_at');
const date = this.getDataValue('updated_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
......
......@@ -31,4 +31,36 @@ module.exports = app => {
router.get('third', '/wechat/callbackAction', 'course.wechat.check');
router.post('third', '/wechat/callbackAction', 'course.wechat.callbackAction');
router.post('third', '/wechat/test', 'course.wechat.test');
// 版本二
router.get('third', '/sub/cats', 'course.institutionSub.getCats');// 分类
router.get('third', '/sub/options', 'course.option.getOptions');// 筛选项
router.post('third', '/sub/address', miniAuth, 'course.location.getAddress');// 根据经纬度或ip获取地理位置信息
router.post('third', '/sub/institutions', miniAuth, 'course.institutionSub.institutionList');// 机构列表
router.get('third', '/sub/institutions', miniAuth, 'course.institutionSub.institutionList');// 机构列表
router.get('third', '/sub/institution/:institution_id', miniAuth, 'course.institutionSub.institutionInfo');// 机构详情
router.post('third', '/sub/classes', miniAuth, 'course.institution.classList');// 课程列表
router.get('third', '/sub/classes', miniAuth, 'course.institution.classList');// 课程列表
router.get('third', '/sub/class/:class_id', miniAuth, 'course.institution.classInfo');// 课程详情
router.post('third', '/sub/teachers', miniAuth, 'course.institution.teacherList');// 老师列表
router.get('third', '/sub/teachers', miniAuth, 'course.institution.teacherList');// 老师详情
router.get('third', '/sub/teacher/:teacher_id', miniAuth, 'course.institution.teacherInfo');// 老师详情
router.post('third', '/sub/user/auth', 'course.user.auth');// 微信授权登录
router.post('third', '/sub/user/register_user', miniAuth, 'course.user.registerUserInfo');// 授权后注册用户
router.get('third', '/sub/user/baby', miniAuth, 'course.user.getBabyInfo');// 获取baby信息
router.post('third', '/sub/user/baby', miniAuth, 'course.user.saveBabyInfo');// 保存baby信息
router.delete('third', '/sub/user/baby', miniAuth, 'course.user.delBabyInfo');// 删除baby信息
router.get('third', '/sub/user/collection/institution', miniAuth, 'course.user.getCollectInstitutions');// 收藏的机构列表
router.post('third', '/sub/user/collection/institution', miniAuth, 'course.user.collectInstitution');// 收藏机构
router.delete('third', '/sub/user/collection/institution', miniAuth, 'course.user.delCollectInstitution');// 取消收藏机构
router.get('third', '/sub/wechat/callbackAction', 'course.wechat.check');
router.post('third', '/sub/wechat/callbackAction', 'course.wechat.callbackAction');
router.post('third', '/sub/wechat/test', 'course.wechat.test');
};
This diff is collapsed.
......@@ -17,7 +17,7 @@ module.exports = appInfo => {
domainWhiteList: [],
};
config.middleware = ['errorHandler', 'deviceLogin', 'deviceInit', 'responseSet'];
config.middleware = [ 'errorHandler', 'deviceLogin', 'deviceInit', 'responseSet' ];
config.middleware = [];
exports.multipart = {
......@@ -90,7 +90,7 @@ module.exports = appInfo => {
// other sequelize configurations
dialect: 'mysql',
host: 'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com',
database: 'prometheus_uat',
database: 'prometheus_dev',
username: 'prometheus',
password: 'q9t8Ay4qIUW4sw3s25K28',
port: 3306,
......@@ -103,7 +103,7 @@ module.exports = appInfo => {
// other sequelize configurations
dialect: 'mysql',
host: 'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com',
database: 'class_uat',
database: 'class_dev',
username: 'class_testing',
password: 'WV862L32451I6KD58tU9K',
port: 3306,
......@@ -170,11 +170,11 @@ module.exports = appInfo => {
config.TX_LBS_URL = 'https://apis.map.qq.com/ws'; // 地址解析;逆地址解析
//我的信用-通化检测
// 我的信用-通化检测
config.YYS_APP_KEY = 'A86BB96F55B64DCE87A46E919A347993';
config.YYS_APPLY_APPSECRET = 'a695e9b3c0f1e3f15fb0b958fd3a4b67';
//运营商报告
// 运营商报告
config.YYS_REPORT_KEY = 'F4E0CA710F484CFFB1756741696E29A3';
config.YYS_REPORT_APPSECRET = '233B8E10E31B4C899EE6FEB3AEC22F140B6528BF';
config.YYS_REPORT_URL = 'http://47.96.253.64:8049/mycredit/thxdReport';
......
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