123456789101112131415161718192021222324252627282930 |
- 'use strict';
- const Service = require('../service/baseService');
- class ReadNoticeService extends Service {
- tag() {
- return this.ctx.model.ReadNoticeModel;
- }
- async add(data) {
- const { model } = this.ctx;
- const result = await model.ReadNoticeModel.create(data);
- return result;
- }
- async appList(data) {
- const { model } = this.ctx;
- const match = {};
- match._id = data.userid;
- const result = await model.ReadNoticeModel.aggregate([{ $group: { _id: '$userid', noticeId: { $addToSet: '$noticeId' } } }, { $match: match }]);
- if (result.length > 0) {
- return result[0].noticeId;
- }
- return [];
- }
- }
- module.exports = ReadNoticeService;
|