Commit c4fba3b0 by sxy

feat: 发布系统公告

parent 534856a0
......@@ -72,6 +72,28 @@ class MsgCtl extends CtlBase {
}
}
async createSysMessage(pobj, qobj, req) {
if (!pobj.title) {
return system.getResult(null, "title can not be empty,100290");
}
if (!pobj.content) {
return system.getResult(null, "content can not be empty,100290");
}
try {
const rs = await this.service.create({
...pobj,
msgType: system.Msg.SYS,
sender: pobj.username,
sender_id: pobj.userid,
company_id: pobj.company_id
}, qobj, req);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
/**
* 返回未提醒 消息
* @param {*} pobj
......
......@@ -11,7 +11,7 @@ class MsgService extends ServiceBase {
async create(pobj, qobj, req) {
let {
msgType, app_id, app_key, sender, sender_id, title,
content, jump_address, other, target
content, jump_address, other, target, company_id
} = pobj;
let msg = {
......@@ -23,7 +23,8 @@ class MsgService extends ServiceBase {
title,
content,
jump_address,
other
other,
company_id
}
return this.db.transaction(async (t) => {
const msgData = await this.dao.create(msg, t);
......@@ -110,11 +111,14 @@ class MsgService extends ServiceBase {
}
async findSystemMsgCount(pobj, qobj, req) {
let { type } = pobj;
let { type, company_id } = pobj;
let where = {
msgType: system.Msg.SYS,
is_undo: false,
company_id: {
$in: [1, company_id]
}
}
if (type === "recently") {
// 查询 三天内的
......@@ -146,7 +150,7 @@ class MsgService extends ServiceBase {
}
async list(pobj, qobj, req) {
let { userid, msgType, pageSize = 10, pageNo = 1 } = pobj;
let { userid, msgType, pageSize = 10, pageNo = 1, company_id } = pobj;
let msgData = [];
let other = {
limit: pageSize,
......@@ -170,6 +174,9 @@ class MsgService extends ServiceBase {
msgData = await this.dao.findAll({
msgType: system.Msg.SYS,
is_undo: false,
company_id: {
$in: [1, company_id]
}
}, [], other);
msgData = msgData.map(item => {
return {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment