Commit c4fba3b0 by sxy

feat: 发布系统公告

parent 534856a0
...@@ -72,6 +72,28 @@ class MsgCtl extends CtlBase { ...@@ -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 * @param {*} pobj
......
...@@ -11,7 +11,7 @@ class MsgService extends ServiceBase { ...@@ -11,7 +11,7 @@ class MsgService extends ServiceBase {
async create(pobj, qobj, req) { async create(pobj, qobj, req) {
let { let {
msgType, app_id, app_key, sender, sender_id, title, msgType, app_id, app_key, sender, sender_id, title,
content, jump_address, other, target content, jump_address, other, target, company_id
} = pobj; } = pobj;
let msg = { let msg = {
...@@ -23,7 +23,8 @@ class MsgService extends ServiceBase { ...@@ -23,7 +23,8 @@ class MsgService extends ServiceBase {
title, title,
content, content,
jump_address, jump_address,
other other,
company_id
} }
return this.db.transaction(async (t) => { return this.db.transaction(async (t) => {
const msgData = await this.dao.create(msg, t); const msgData = await this.dao.create(msg, t);
...@@ -110,11 +111,14 @@ class MsgService extends ServiceBase { ...@@ -110,11 +111,14 @@ class MsgService extends ServiceBase {
} }
async findSystemMsgCount(pobj, qobj, req) { async findSystemMsgCount(pobj, qobj, req) {
let { type } = pobj; let { type, company_id } = pobj;
let where = { let where = {
msgType: system.Msg.SYS, msgType: system.Msg.SYS,
is_undo: false, is_undo: false,
company_id: {
$in: [1, company_id]
}
} }
if (type === "recently") { if (type === "recently") {
// 查询 三天内的 // 查询 三天内的
...@@ -146,7 +150,7 @@ class MsgService extends ServiceBase { ...@@ -146,7 +150,7 @@ class MsgService extends ServiceBase {
} }
async list(pobj, qobj, req) { 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 msgData = [];
let other = { let other = {
limit: pageSize, limit: pageSize,
...@@ -170,6 +174,9 @@ class MsgService extends ServiceBase { ...@@ -170,6 +174,9 @@ class MsgService extends ServiceBase {
msgData = await this.dao.findAll({ msgData = await this.dao.findAll({
msgType: system.Msg.SYS, msgType: system.Msg.SYS,
is_undo: false, is_undo: false,
company_id: {
$in: [1, company_id]
}
}, [], other); }, [], other);
msgData = msgData.map(item => { msgData = msgData.map(item => {
return { 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