|
@@ -21,7 +21,7 @@ class NoticeService extends CrudService {
|
|
|
assert(content, '通知内容为必填项');
|
|
|
const res = await this.model.create(data);
|
|
|
if (res) {
|
|
|
- for (const elm of notified) {
|
|
|
+ for (const elm of res.notified) {
|
|
|
const user = await this.umodel.findOne({ uid: elm.notifiedid });
|
|
|
if (!user) {
|
|
|
continue;
|
|
@@ -42,9 +42,12 @@ class NoticeService extends CrudService {
|
|
|
const { noticeid, uid } = data;
|
|
|
const notice = await this.model.findById(noticeid);
|
|
|
if (notice) {
|
|
|
- const res = await notice.notified.id(uid);
|
|
|
- res.status = '1';
|
|
|
- res.readtime = sd.format(new Date(), 'YYYY-MM-DD HH:mm');
|
|
|
+ for (const elm of notice.notified) {
|
|
|
+ if (elm.notifiedid === uid) {
|
|
|
+ elm.status = '1';
|
|
|
+ elm.readtime = sd.format(new Date(), 'YYYY-MM-DD HH:mm:ss');
|
|
|
+ }
|
|
|
+ }
|
|
|
await notice.save();
|
|
|
}
|
|
|
}
|