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

add back_column

parent 6368489b
Pipeline #27252 passed with stage
in 4 seconds
...@@ -18,6 +18,7 @@ module.exports = app => { ...@@ -18,6 +18,7 @@ module.exports = app => {
description: TEXT, description: TEXT,
title: STRING, title: STRING,
pay_column: STRING, pay_column: STRING,
back_column: STRING,
status: INTEGER, status: INTEGER,
is_deleted: INTEGER, is_deleted: INTEGER,
created_time: { created_time: {
......
...@@ -14,5 +14,5 @@ module.exports = app => { ...@@ -14,5 +14,5 @@ module.exports = app => {
router.get('third', '/export/redeem', auth, 'course.back.exportRedeemCode'); router.get('third', '/export/redeem', auth, 'course.back.exportRedeemCode');
router.get('third', '/export/redeem/used', auth, 'course.back.exportUsedRedeemCode'); router.get('third', '/export/redeem/used', auth, 'course.back.exportUsedRedeemCode');
router.get('third', '/redeem/used', auth, 'course.back.getUsedRedeemCodeList'); router.get('third', '/redeem/used', auth, 'course.back.getUsedRedeemCodeList');
router.get('third', '/column/all', 'course.back.getBackColumns'); router.get('third', '/column/all', auth, 'course.back.getBackColumns');
}; };
...@@ -88,7 +88,7 @@ class BackService extends Service { ...@@ -88,7 +88,7 @@ class BackService extends Service {
ctx.failed('用户异常'); ctx.failed('用户异常');
} }
const filter = { where: { type: 1, status: 1, is_deleted: 0 }, limit, offset, attributes: [ 'id', 'order_no', 'class_id', 'pay', 'pay_time', 'address', 'columns' ], order: [[ 'pay_time', 'desc' ]] }; const filter = { where: { type: 1, status: 1, is_deleted: 0 }, limit, offset, attributes: [ 'id', 'order_no', 'class_id', 'pay', 'pay_time', 'redeem', 'address', 'columns' ], order: [[ 'pay_time', 'desc' ]] };
let filterClassIds = []; let filterClassIds = [];
if (!ctx.isEmpty(input.class_name)) { if (!ctx.isEmpty(input.class_name)) {
const classList = await ctx.classModel.V5.CourseV5Class.findAll({ where: { name: { $like: `%${input.class_name}%` } }, attributes: [ 'id' ] }); const classList = await ctx.classModel.V5.CourseV5Class.findAll({ where: { name: { $like: `%${input.class_name}%` } }, attributes: [ 'id' ] });
...@@ -138,6 +138,7 @@ class BackService extends Service { ...@@ -138,6 +138,7 @@ class BackService extends Service {
class_name: ctx.isEmpty(classList[v.class_id]) ? '' : classList[v.class_id][0].name, class_name: ctx.isEmpty(classList[v.class_id]) ? '' : classList[v.class_id][0].name,
pay: v.pay, pay: v.pay,
pay_time: v.pay_time, pay_time: v.pay_time,
redeem_code: v.redeem,
address: ctx.isEmpty(v.address) ? {} : JSON.parse(v.address), address: ctx.isEmpty(v.address) ? {} : JSON.parse(v.address),
columns: ctx.isEmpty(v.columns) ? {} : JSON.parse(v.columns), columns: ctx.isEmpty(v.columns) ? {} : JSON.parse(v.columns),
}); });
...@@ -519,8 +520,21 @@ class BackService extends Service { ...@@ -519,8 +520,21 @@ class BackService extends Service {
// 获取额外字段 // 获取额外字段
async getBackColumns() { async getBackColumns() {
const { ctx } = this; const { ctx } = this;
const userUuid = ctx.userUuid;
const columns = await ctx.classModel.CourseBackColumn.findAll({ where: { status: 1 }, attributes: [ 'title', 'column' ] }); const userInfo = await ctx.classModel.CourseBackUser.findOne({ where: { id: userUuid, is_deleted: 0 } });
if (ctx.isEmpty(userInfo)) {
ctx.failed('无效用户');
}
let columns = [];
if (userInfo.is_admin > 0) {
columns = await ctx.classModel.CourseBackColumn.findAll({ where: { status: 1 }, attributes: [ 'title', 'column' ] });
} else {
columns = await ctx.classModel.V5.CourseV5Institution.findOne({ where: { id: userInfo.institution_id }, attributes: [ 'back_column' ] });
columns = (ctx.isEmpty(columns) || ctx.isEmpty(columns.back_column)) ? [] : eval(columns.back_column);
columns = await ctx.classModel.CourseBackColumn.findAll({ where: { column: { $in: columns }, status: 1 }, attributes: [ 'title', 'column' ] });
}
const ret = { const ret = {
list: columns, list: columns,
}; };
......
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