|
@@ -41,24 +41,34 @@ module.exports = app => {
|
|
|
const valuation = await this.getDataById(id);
|
|
|
const billsId = this._.map(valuation.bill_id.split(','), this._.toInteger);
|
|
|
const chaptersId = this._.map(valuation.chapter_id.split(','), this._.toInteger);
|
|
|
- const billsList = await this.db.select('zh_std_gcl_list', {
|
|
|
- where: {id: billsId},
|
|
|
- columns: ['id', 'name'],
|
|
|
- });
|
|
|
- billsList.sort(function (a, b) {
|
|
|
- return billsId.indexOf(a.id) - billsList.indexOf(b.id);
|
|
|
- });
|
|
|
- const chapterList = await this.db.select('zh_std_xmj_list', {
|
|
|
- where: {id: chaptersId},
|
|
|
- columns: ['id', 'name'],
|
|
|
- });
|
|
|
- chapterList.sort(function (a, b) {
|
|
|
- return chaptersId.indexOf(a.id) - chapterList.indexOf(b.id);
|
|
|
- });
|
|
|
+ // const billsList = await this.db.select('zh_std_gcl_list', {
|
|
|
+ // where: {id: billsId},
|
|
|
+ // columns: ['id', 'name'],
|
|
|
+ // });
|
|
|
+ // billsList.sort(function (a, b) {
|
|
|
+ // return billsId.indexOf(a.id) - billsList.indexOf(b.id);
|
|
|
+ // });
|
|
|
+ const sql = 'SELECT `id`, `name`' +
|
|
|
+ ' From ?? ' +
|
|
|
+ ' WHERE `id` in ( ? ) ORDER BY FIELD(`id`, ?)';
|
|
|
+ const sqlParam = ['zh_std_gcl_list', billsId, billsId];
|
|
|
+ const billsList = await this.db.query(sql, sqlParam);
|
|
|
+ // const chapterList = await this.db.select('zh_std_xmj_list', {
|
|
|
+ // where: {id: chaptersId},
|
|
|
+ // columns: ['id', 'name'],
|
|
|
+ // });
|
|
|
+ // chapterList.sort(function (a, b) {
|
|
|
+ // return chaptersId.indexOf(a.id) - chapterList.indexOf(b.id);
|
|
|
+ // });
|
|
|
+ const sql2 = 'SELECT `id`, `name`' +
|
|
|
+ ' From ?? ' +
|
|
|
+ ' WHERE `id` in ( ? ) ORDER BY FIELD(`id`, ?)';
|
|
|
+ const sqlParam2 = ['zh_std_xmj_list', chaptersId, chaptersId];
|
|
|
+ const chapterList = await this.db.query(sql2, sqlParam2);
|
|
|
return [billsList, chapterList];
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return Valuation;
|
|
|
-};
|
|
|
+};
|