公告管理
This commit is contained in:
1 parent
374ce74e2d
commit
c0621ff48b
15 files changed
+4641
No files matched your search
@@ -0,0 +1,62 @@
|
||||
const Service = require('egg').Service;
|
||||
const validateUtil = require('@jianghujs/jianghu/app/common/validateUtil');
|
||||
const { BizError, errorInfoEnum } = require('../constant/error');
|
||||
const _ = require('lodash');
|
||||
const idGenerateUtil = require("@jianghujs/jianghu/app/common/idGenerateUtil");
|
||||
const dayjs = require('dayjs')
|
||||
|
||||
class NoticeService extends Service {
|
||||
|
||||
async insertAffiche() {
|
||||
const { jianghuKnex } = this.app;
|
||||
const { actionData } = this.ctx.request.body.appData;
|
||||
const { afficheId, afficheMemberIdList, afficheStatus } = actionData
|
||||
|
||||
let noticeInsertData = null
|
||||
|
||||
if (afficheStatus === "已发送") {
|
||||
// TODO:待完善
|
||||
noticeInsertData = {
|
||||
noticeId: await idGenerateUtil.uuid(),
|
||||
noticeName: "通知-公告-" + afficheId,
|
||||
noticeContent: afficheMemberIdList,
|
||||
pushContent: '{}',
|
||||
pushStatus: "success",
|
||||
pushAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
}
|
||||
|
||||
await jianghuKnex.transaction(async trx => {
|
||||
await trx("affiche", this.ctx).jhInsert(actionData);
|
||||
|
||||
if (noticeInsertData) await trx("notice_push", this.ctx).jhInsert(noticeInsertData);
|
||||
})
|
||||
}
|
||||
async updateAffiche() {
|
||||
const { jianghuKnex } = this.app;
|
||||
const { actionData } = this.ctx.request.body.appData;
|
||||
const { afficheId, afficheMemberIdList, afficheStatus } = actionData
|
||||
|
||||
let noticeInsertData = null
|
||||
|
||||
if (afficheStatus === "已发送") {
|
||||
// TODO:待完善
|
||||
noticeInsertData = {
|
||||
noticeId: await idGenerateUtil.uuid(),
|
||||
noticeName: "通知-公告-" + afficheId,
|
||||
noticeContent: afficheMemberIdList,
|
||||
pushContent: '{}',
|
||||
pushStatus: "success",
|
||||
pushAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
}
|
||||
|
||||
console.log('appData_+_+_+_+', actionData);
|
||||
await jianghuKnex.transaction(async trx => {
|
||||
await trx("affiche", this.ctx).jhUpdate(actionData);
|
||||
if (noticeInsertData) await trx("notice_push", this.ctx).jhInsert(noticeInsertData);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NoticeService;
|
||||
Reference in new issue
Block a user