Browse Source

工作台按项目来展示对应项目通知

ellisran 3 months ago
parent
commit
be067a3315
2 changed files with 3 additions and 2 deletions
  1. 1 1
      app/controller/dashboard_controller.js
  2. 2 1
      app/service/message.js

+ 1 - 1
app/controller/dashboard_controller.js

@@ -139,7 +139,7 @@ module.exports = app => {
             // 获取版本信息
             const versionList = await ctx.service.version.getAllDataByCondition({ orders: [['id', 'desc']], limit: 5, offset: 0 });
             // 获取项目通知
-            const msgList = await ctx.service.message.getMsgList(ctx.session.sessionProject.id, '', 10);
+            const msgList = await ctx.service.message.getMsgList(ctx.session.sessionProject.id, ctx.helper._.map(subProjects, 'id'), 10);
             // 获取系统通知
             const sysMsgList = await ctx.service.message.getMsgList(ctx.session.sessionProject.id, '', 1, 0, 2);
             // 获取系统维护信息

+ 2 - 1
app/service/message.js

@@ -148,7 +148,8 @@ module.exports = app => {
          * @return {Boolean} - 返回修改结果
          */
         async getMsgList(projectId, spid = '', limit = 5, offset = 0, type = 1) {
-            const sqSql = spid ? ' AND (`spid` = "' + spid + '" OR `spid` = "")' : '';
+            const spids = spid ? (spid instanceof Array ? spid : [spid]) : '';
+            const sqSql = spids ? ' AND (`spid` in (' + this.ctx.helper.getInArrStrSqlFilter(spids) + ') OR `spid` = "")' : '';
             if (type === 1) {
                 const sql = 'SELECT * FROM ?? WHERE `project_id` = ?' + sqSql + ' AND `type` = ? ORDER BY CONCAT(`istop`,`release_time`) DESC LIMIT ?,?';
                 const sqlParam = [this.tableName, projectId, type, offset, limit];