|
@@ -34,7 +34,7 @@ module.exports = app => {
|
|
|
* @param {Integer} pid - 项目id
|
|
|
* @param {Integer} uid - 查询人id
|
|
|
*/
|
|
|
- async getNotice(pid, uid = 0) {
|
|
|
+ async getNotice(pid, uid = 0, spid = '') {
|
|
|
// const noticeList = [];
|
|
|
// for (const type in auditConst.pushType) {
|
|
|
// const wheres = { pid, type: auditConst.pushType[type] };
|
|
@@ -55,16 +55,21 @@ module.exports = app => {
|
|
|
// noticeList.push(...notice);
|
|
|
// }
|
|
|
// return this._.orderBy(noticeList, ['create_time'], ['desc']);
|
|
|
- const wheres = { pid };
|
|
|
- if (uid !== 0) {
|
|
|
- wheres.uid = uid;
|
|
|
- }
|
|
|
- let notice = await this.db.select(this.tableName, {
|
|
|
- where: wheres,
|
|
|
- orders: [['create_time', 'desc']],
|
|
|
- limit: 30,
|
|
|
- offset: 0
|
|
|
- });
|
|
|
+ // const wheres = { pid };
|
|
|
+ // if (uid !== 0) {
|
|
|
+ // wheres.uid = uid;
|
|
|
+ // }
|
|
|
+ // let notice = await this.db.select(this.tableName, {
|
|
|
+ // where: wheres,
|
|
|
+ // orders: [['create_time', 'desc']],
|
|
|
+ // limit: 30,
|
|
|
+ // offset: 0
|
|
|
+ // });
|
|
|
+ const uidSql = uid ? ' AND a.`uid` = ' + uid : '';
|
|
|
+ const spidSql = spid ? ' AND (a.`spid` = "' + spid + '" OR t.`spid` = "' + spid + '")': '';
|
|
|
+ const sql = 'SELECT a.* FROM ?? AS a LEFT JOIN ?? AS t ON a.`tid` = t.`id` WHERE a.`pid` = ?' + uidSql + spidSql + ' ORDER BY a.`create_time` DESC LIMIT 0,30';
|
|
|
+ const params = [this.tableName, this.ctx.service.tender.tableName, pid];
|
|
|
+ let notice = await this.db.query(sql, params);
|
|
|
notice = notice.map(v => {
|
|
|
const extra = JSON.parse(v.content);
|
|
|
delete v.content;
|