常规推送
This commit is contained in:
@@ -16,8 +16,8 @@ const KEY = CryptoJS.enc.Utf8.parse('BDQH');
|
|||||||
|
|
||||||
const decryptRequest = (body) => {
|
const decryptRequest = (body) => {
|
||||||
return CryptoJS.AES.decrypt(body, KEY, {
|
return CryptoJS.AES.decrypt(body, KEY, {
|
||||||
mode: CryptoJS.mode.ECB,
|
mode: CryptoJS.mode.ECB,
|
||||||
padding: CryptoJS.pad.Pkcs7
|
padding: CryptoJS.pad.Pkcs7
|
||||||
}).toString(CryptoJS.enc.Utf8);
|
}).toString(CryptoJS.enc.Utf8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ class HomeController extends Controller {
|
|||||||
}
|
}
|
||||||
const uid = JSON.parse(rdmcode).uid;
|
const uid = JSON.parse(rdmcode).uid;
|
||||||
const result = await ctx.service.home.getCard(uid);
|
const result = await ctx.service.home.getCard(uid);
|
||||||
if(result == "error") {
|
if (result == "error") {
|
||||||
setResponse(ctx, 500, '服务器错误', "none");
|
setResponse(ctx, 500, '服务器错误', "none");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ class HomeController extends Controller {
|
|||||||
const uid = JSON.parse(rdmcode).uid;
|
const uid = JSON.parse(rdmcode).uid;
|
||||||
const { cardID } = ctx.request.body;
|
const { cardID } = ctx.request.body;
|
||||||
const result = await ctx.service.home.searchCard(cardID);
|
const result = await ctx.service.home.searchCard(cardID);
|
||||||
if(result == "error") {
|
if (result == "error") {
|
||||||
setResponse(ctx, 500, '服务器错误', "none");
|
setResponse(ctx, 500, '服务器错误', "none");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,7 @@ class HomeController extends Controller {
|
|||||||
const uid = JSON.parse(rdmcode).uid;
|
const uid = JSON.parse(rdmcode).uid;
|
||||||
const body = ctx.request.body;
|
const body = ctx.request.body;
|
||||||
const result = await ctx.service.home.bindCard(uid, body);
|
const result = await ctx.service.home.bindCard(uid, body);
|
||||||
if(result == "error") {
|
if (result == "error") {
|
||||||
setResponse(ctx, 500, '服务器错误', "none");
|
setResponse(ctx, 500, '服务器错误', "none");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ class HomeController extends Controller {
|
|||||||
const uid = JSON.parse(rdmcode).uid;
|
const uid = JSON.parse(rdmcode).uid;
|
||||||
const body = ctx.request.body;
|
const body = ctx.request.body;
|
||||||
const result = await ctx.service.home.unBindingCard(uid, body);
|
const result = await ctx.service.home.unBindingCard(uid, body);
|
||||||
if(result == "error") {
|
if (result == "error") {
|
||||||
setResponse(ctx, 500, '服务器错误', "none");
|
setResponse(ctx, 500, '服务器错误', "none");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -193,7 +193,7 @@ class HomeController extends Controller {
|
|||||||
const password = decryptRequest(body.password);
|
const password = decryptRequest(body.password);
|
||||||
const requestMsg = body.userMsg;
|
const requestMsg = body.userMsg;
|
||||||
const result = await ctx.service.home.unBindManager(uid, model, password, requestMsg);
|
const result = await ctx.service.home.unBindManager(uid, model, password, requestMsg);
|
||||||
if(result == "error") {
|
if (result == "error") {
|
||||||
setResponse(ctx, 500, '服务器错误', "none");
|
setResponse(ctx, 500, '服务器错误', "none");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -221,7 +221,7 @@ class HomeController extends Controller {
|
|||||||
const uid = JSON.parse(rdmcode).uid;
|
const uid = JSON.parse(rdmcode).uid;
|
||||||
const body = ctx.request.body;
|
const body = ctx.request.body;
|
||||||
const result = await ctx.service.home.getRecord(uid, body);
|
const result = await ctx.service.home.getRecord(uid, body);
|
||||||
if(result == "error") {
|
if (result == "error") {
|
||||||
setResponse(ctx, 500, '服务器错误', "none");
|
setResponse(ctx, 500, '服务器错误', "none");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -261,7 +261,7 @@ class HomeController extends Controller {
|
|||||||
created_at: created_at
|
created_at: created_at
|
||||||
};
|
};
|
||||||
const result = await ctx.service.home.shortMsg(form);
|
const result = await ctx.service.home.shortMsg(form);
|
||||||
if(result == "error") {
|
if (result == "error") {
|
||||||
setResponse(ctx, 500, '服务器错误', "none");
|
setResponse(ctx, 500, '服务器错误', "none");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -277,6 +277,35 @@ class HomeController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 保存未知消息
|
||||||
|
async saveUnknown() {
|
||||||
|
const { ctx } = this;
|
||||||
|
try {
|
||||||
|
const body = ctx.request.body;
|
||||||
|
const { card_id, original_msg, msg_data, created_at } = body;
|
||||||
|
const form = {
|
||||||
|
card_id: card_id,
|
||||||
|
original_msg: original_msg,
|
||||||
|
msg_data: msg_data,
|
||||||
|
created_at: created_at
|
||||||
|
};
|
||||||
|
const result = await ctx.service.home.saveUnknown(form);
|
||||||
|
if (result == "error") {
|
||||||
|
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (result) {
|
||||||
|
this.setResponse(ctx, 200, '保存未知消息成功', "none");
|
||||||
|
} else {
|
||||||
|
this.setResponse(ctx, 404, '保存未知消息失败', "none");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
const blockName = fileName + "--" + "saveUnknown";
|
||||||
|
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||||
|
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 获取历史消息
|
// 获取历史消息
|
||||||
async getHistoryMsg() {
|
async getHistoryMsg() {
|
||||||
const ctx = this.ctx;
|
const ctx = this.ctx;
|
||||||
@@ -289,7 +318,7 @@ class HomeController extends Controller {
|
|||||||
const uid = JSON.parse(rdmcode).uid;
|
const uid = JSON.parse(rdmcode).uid;
|
||||||
const body = ctx.request.body;
|
const body = ctx.request.body;
|
||||||
const result = await ctx.service.home.getHistoryMsg(uid, body);
|
const result = await ctx.service.home.getHistoryMsg(uid, body);
|
||||||
if(result == "error") {
|
if (result == "error") {
|
||||||
setResponse(ctx, 500, '服务器错误', "none");
|
setResponse(ctx, 500, '服务器错误', "none");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -313,36 +342,36 @@ class HomeController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除历史消息
|
// 删除历史消息
|
||||||
async delHistoryMsg() {
|
async delHistoryMsg() {
|
||||||
const ctx = this.ctx;
|
const ctx = this.ctx;
|
||||||
try {
|
try {
|
||||||
let rdmcode = await checkUid(ctx);
|
let rdmcode = await checkUid(ctx);
|
||||||
if (!rdmcode) {
|
if (!rdmcode) {
|
||||||
setResponse(ctx, 401, 'token过期或错误', "none");
|
setResponse(ctx, 401, 'token过期或错误', "none");
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
const uid = JSON.parse(rdmcode).uid;
|
|
||||||
const body = ctx.request.body;
|
|
||||||
const model = decryptRequest(body.model);
|
|
||||||
const password = decryptRequest(body.password);
|
|
||||||
const requestMsg = body.userMsg;
|
|
||||||
const resetList = await ctx.service.home.delHistoryMsg(uid, model, password, requestMsg);
|
|
||||||
if(resetList == "error") {
|
|
||||||
setResponse(ctx, 500, '服务器错误', "none");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (resetList) {
|
|
||||||
setResponse(ctx, 200, '删除历史消息成功', "none");
|
|
||||||
} else {
|
|
||||||
setResponse(ctx, 404, '删除历史消息失败', "none");
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
const blockName = fileName + "--" + "delHistoryMsg";
|
|
||||||
ctx.app.middleware.utils.log('../../../controllerLog', blockName + ">>>>" + error);
|
|
||||||
setResponse(ctx, 500, '服务器错误', "none");
|
|
||||||
}
|
}
|
||||||
|
const uid = JSON.parse(rdmcode).uid;
|
||||||
|
const body = ctx.request.body;
|
||||||
|
const model = decryptRequest(body.model);
|
||||||
|
const password = decryptRequest(body.password);
|
||||||
|
const requestMsg = body.userMsg;
|
||||||
|
const resetList = await ctx.service.home.delHistoryMsg(uid, model, password, requestMsg);
|
||||||
|
if (resetList == "error") {
|
||||||
|
setResponse(ctx, 500, '服务器错误', "none");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (resetList) {
|
||||||
|
setResponse(ctx, 200, '删除历史消息成功', "none");
|
||||||
|
} else {
|
||||||
|
setResponse(ctx, 404, '删除历史消息失败', "none");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
const blockName = fileName + "--" + "delHistoryMsg";
|
||||||
|
ctx.app.middleware.utils.log('../../../controllerLog', blockName + ">>>>" + error);
|
||||||
|
setResponse(ctx, 500, '服务器错误', "none");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 获取单位用户
|
// 获取单位用户
|
||||||
async bsideManager() {
|
async bsideManager() {
|
||||||
@@ -355,11 +384,11 @@ class HomeController extends Controller {
|
|||||||
}
|
}
|
||||||
const uid = JSON.parse(rdmcode).uid;
|
const uid = JSON.parse(rdmcode).uid;
|
||||||
let result;
|
let result;
|
||||||
if(uid[uid.length - 1] == 'B') {
|
if (uid[uid.length - 1] == 'B') {
|
||||||
const body = ctx.request.body;
|
const body = ctx.request.body;
|
||||||
result = await ctx.service.home.bsideManager(uid, body);
|
result = await ctx.service.home.bsideManager(uid, body);
|
||||||
}
|
}
|
||||||
if(result == "error") {
|
if (result == "error") {
|
||||||
setResponse(ctx, 500, '服务器错误', "none");
|
setResponse(ctx, 500, '服务器错误', "none");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ module.exports = (app) => {
|
|||||||
const { senderAddress, msgData, encodingCategory } = outboundMsg;
|
const { senderAddress, msgData, encodingCategory } = outboundMsg;
|
||||||
// socket接收消息后触发事件监听器,将消息发送给websocket客户端并存储在数据库中
|
// socket接收消息后触发事件监听器,将消息发送给websocket客户端并存储在数据库中
|
||||||
shunt.socketEmitter().emit(senderAddress.data, { encode_type: parseInt(encodingCategory.data), msg_data: msgData.data, created_at: new Date() });
|
shunt.socketEmitter().emit(senderAddress.data, { encode_type: parseInt(encodingCategory.data), msg_data: msgData.data, created_at: new Date() });
|
||||||
await app.curl('http://127.0.0.1:' + app.server.address().port + '/shortMsg', {
|
const shortMsg = await app.curl('http://127.0.0.1:' + app.server.address().port + '/shortMsg', {
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
contentType: 'application/x-www-form-urlencoded',
|
contentType: 'application/x-www-form-urlencoded',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -107,6 +107,20 @@ module.exports = (app) => {
|
|||||||
created_at: new Date()
|
created_at: new Date()
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
if (shortMsg.data.code == 404) {
|
||||||
|
await app.curl('http://127.0.0.1:' + app.server.address().port + '/saveUnknown', {
|
||||||
|
dataType: 'json',
|
||||||
|
contentType: 'application/x-www-form-urlencoded',
|
||||||
|
method: 'POST',
|
||||||
|
timeout: 3000,
|
||||||
|
data: {
|
||||||
|
card_id: senderAddress.data,
|
||||||
|
original_msg: originalMsg,
|
||||||
|
msg_data: msgData.data,
|
||||||
|
created_at: new Date()
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 重发消息处理
|
// 重发消息处理
|
||||||
if (resendResult && resendResult.type == 4) {
|
if (resendResult && resendResult.type == 4) {
|
||||||
@@ -114,8 +128,8 @@ module.exports = (app) => {
|
|||||||
const { outboundMsg, receiverAddress } = msgContent;
|
const { outboundMsg, receiverAddress } = msgContent;
|
||||||
const { senderAddress, msgData, encodingCategory } = outboundMsg;
|
const { senderAddress, msgData, encodingCategory } = outboundMsg;
|
||||||
// socket接收消息后触发事件监听器,将消息发送给websocket客户端并存储在数据库中
|
// socket接收消息后触发事件监听器,将消息发送给websocket客户端并存储在数据库中
|
||||||
shunt.socketEmitter().emit(senderAddress.data, msgData.data);
|
shunt.socketEmitter().emit(senderAddress.data, { encode_type: parseInt(encodingCategory.data), msg_data: msgData.data, created_at: new Date() });
|
||||||
await app.curl('http://127.0.0.1:' + app.server.address().port + '/shortMsg', {
|
const shortMsg = await app.curl('http://127.0.0.1:' + app.server.address().port + '/shortMsg', {
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
contentType: 'application/x-www-form-urlencoded',
|
contentType: 'application/x-www-form-urlencoded',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -129,6 +143,20 @@ module.exports = (app) => {
|
|||||||
msg_data: msgData.data,
|
msg_data: msgData.data,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
if (shortMsg.data.code == 404) {
|
||||||
|
await app.curl('http://127.0.0.1:' + app.server.address().port + '/saveUnknown', {
|
||||||
|
dataType: 'json',
|
||||||
|
contentType: 'application/x-www-form-urlencoded',
|
||||||
|
method: 'POST',
|
||||||
|
timeout: 3000,
|
||||||
|
data: {
|
||||||
|
card_id: senderAddress.data,
|
||||||
|
original_msg: originalMsg,
|
||||||
|
msg_data: msgData.data,
|
||||||
|
created_at: new Date()
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
20
app/model3/UnknownBDCard.js
Normal file
20
app/model3/UnknownBDCard.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = (app) => {
|
||||||
|
const { INTEGER, CHAR, TEXT, DATE } = app.Sequelize;
|
||||||
|
|
||||||
|
const UnknownBDCard = app.model3.define('unknown-bdcard', {
|
||||||
|
id: { type: INTEGER(8), primaryKey: true, autoIncrement: true },
|
||||||
|
card_id: CHAR(8),
|
||||||
|
original_msg: TEXT,
|
||||||
|
msg_data: TEXT,
|
||||||
|
created_at: DATE,
|
||||||
|
},{
|
||||||
|
freezeTableName: true,
|
||||||
|
timestamp: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
return UnknownBDCard;
|
||||||
|
};
|
||||||
@@ -32,6 +32,8 @@ module.exports = app => {
|
|||||||
router.post('/getRecord', controller.home.getRecord);
|
router.post('/getRecord', controller.home.getRecord);
|
||||||
// 存储消息记录
|
// 存储消息记录
|
||||||
router.post('/shortMsg', controller.home.shortMsg);
|
router.post('/shortMsg', controller.home.shortMsg);
|
||||||
|
// 保存未知消息
|
||||||
|
router.post("/saveUnknown", controller.home.saveUnknown);
|
||||||
// 获取历史消息
|
// 获取历史消息
|
||||||
router.post('/getHistoryMsg', controller.home.getHistoryMsg);
|
router.post('/getHistoryMsg', controller.home.getHistoryMsg);
|
||||||
// 删除历史消息
|
// 删除历史消息
|
||||||
|
|||||||
@@ -203,18 +203,18 @@ class HomeService extends Service {
|
|||||||
let { offset, limit, searchOptions, sortOptions } = body;
|
let { offset, limit, searchOptions, sortOptions } = body;
|
||||||
offset = (offset - 1) * limit;
|
offset = (offset - 1) * limit;
|
||||||
let attributes = ['card_id', 'type', 'created_at'],
|
let attributes = ['card_id', 'type', 'created_at'],
|
||||||
where = { user_uid: uid }, order = [], dbOptions, joinSubstring = [],
|
where = { user_uid: uid }, order = [], dbOptions, joinSubstring = [],
|
||||||
substring = ['card_id'], key = ['type'], between = ['created_at'];
|
substring = ['card_id'], key = ['type'], between = ['created_at'];
|
||||||
const uidLastCode = shunt(uid);
|
const uidLastCode = shunt(uid);
|
||||||
attributes.forEach(element => {
|
attributes.forEach(element => {
|
||||||
if (searchOptions[element]) {
|
if (searchOptions[element]) {
|
||||||
if(searchOptions[element] == '*空') {
|
if (searchOptions[element] == '*空') {
|
||||||
if(joinSubstring.includes(element)) {
|
if (joinSubstring.includes(element)) {
|
||||||
where[element] = null;
|
where[element] = null;
|
||||||
} else {
|
} else {
|
||||||
where[element] = [null, ''];
|
where[element] = [null, ''];
|
||||||
}
|
}
|
||||||
} else if(substring.includes(element)) {
|
} else if (substring.includes(element)) {
|
||||||
where[element] = { [Op.substring]: searchOptions[element] };
|
where[element] = { [Op.substring]: searchOptions[element] };
|
||||||
} else if (key.includes(element)) {
|
} else if (key.includes(element)) {
|
||||||
where[element] = searchOptions[element] == "1" ? uidLastCode === 'B' ? 1 : 2 : 0;
|
where[element] = searchOptions[element] == "1" ? uidLastCode === 'B' ? 1 : 2 : 0;
|
||||||
@@ -275,6 +275,19 @@ class HomeService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 保存未知消息
|
||||||
|
async saveUnknown(form) {
|
||||||
|
const { ctx } = this;
|
||||||
|
try {
|
||||||
|
const result = await ctx.model3.UnknownBDCard.create(form);
|
||||||
|
return result || false;
|
||||||
|
} catch (error) {
|
||||||
|
const blockName = fileName + "--" + "saveUnknown";
|
||||||
|
ctx.app.middleware.log('../../serviceLog', blockName + ">>>>" + error);
|
||||||
|
return 'error';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 获取历史消息
|
// 获取历史消息
|
||||||
async getHistoryMsg(uid, body) {
|
async getHistoryMsg(uid, body) {
|
||||||
const { ctx } = this;
|
const { ctx } = this;
|
||||||
@@ -282,15 +295,15 @@ class HomeService extends Service {
|
|||||||
let { offset, limit, searchOptions, sortOptions } = body;
|
let { offset, limit, searchOptions, sortOptions } = body;
|
||||||
offset = (offset - 1) * limit;
|
offset = (offset - 1) * limit;
|
||||||
let attributes = ['card_id', 'encode_type', 'msg_data', 'created_at'],
|
let attributes = ['card_id', 'encode_type', 'msg_data', 'created_at'],
|
||||||
where = { user_uid: uid }, order = [], dbOptions, joinSubstring = [],
|
where = { user_uid: uid }, order = [], dbOptions, joinSubstring = [],
|
||||||
substring = ['card_id', 'msg_data'], key = ['encode_type'], between = ['created_at'];
|
substring = ['card_id', 'msg_data'], key = ['encode_type'], between = ['created_at'];
|
||||||
attributes.forEach(element => {
|
attributes.forEach(element => {
|
||||||
if (searchOptions[element]) {
|
if (searchOptions[element]) {
|
||||||
if(searchOptions[element] == '*空') {
|
if (searchOptions[element] == '*空') {
|
||||||
if(joinSubstring.includes(element)) {
|
if (joinSubstring.includes(element)) {
|
||||||
where[element] = null;
|
where[element] = null;
|
||||||
} else {
|
} else {
|
||||||
where[element] = [null, ''];
|
where[element] = [null, ''];
|
||||||
}
|
}
|
||||||
} else if (substring.includes(element)) {
|
} else if (substring.includes(element)) {
|
||||||
where[element] = { [Op.substring]: searchOptions[element] };
|
where[element] = { [Op.substring]: searchOptions[element] };
|
||||||
@@ -343,9 +356,9 @@ class HomeService extends Service {
|
|||||||
for (const key in requestMsg) {
|
for (const key in requestMsg) {
|
||||||
requestMsg[key].forEach(element => {
|
requestMsg[key].forEach(element => {
|
||||||
card_id.push(element.card_id),
|
card_id.push(element.card_id),
|
||||||
encode_type.push(element.encode_type),
|
encode_type.push(element.encode_type),
|
||||||
msg_data.push(element.msg_data),
|
msg_data.push(element.msg_data),
|
||||||
created_at.push(element.origin_time)
|
created_at.push(element.origin_time)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
where = { user_uid: uid, card_id, encode_type, msg_data, created_at };
|
where = { user_uid: uid, card_id, encode_type, msg_data, created_at };
|
||||||
@@ -358,7 +371,7 @@ class HomeService extends Service {
|
|||||||
"T": ctx.model4.TShortMsg,
|
"T": ctx.model4.TShortMsg,
|
||||||
};
|
};
|
||||||
const resetList = await modelName[uidLastCode].destroy({ where });
|
const resetList = await modelName[uidLastCode].destroy({ where });
|
||||||
return resetList.length == 0 ? false : resetList;
|
return resetList == 0 ? false : resetList;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const blockName = fileName + "--" + "delHistoryMsg";
|
const blockName = fileName + "--" + "delHistoryMsg";
|
||||||
ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error);
|
ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error);
|
||||||
@@ -375,16 +388,16 @@ class HomeService extends Service {
|
|||||||
let { offset, limit, searchOptions } = body;
|
let { offset, limit, searchOptions } = body;
|
||||||
offset = (offset - 1) * limit;
|
offset = (offset - 1) * limit;
|
||||||
let attributes = ['account_name', 'user_name', 'phone'],
|
let attributes = ['account_name', 'user_name', 'phone'],
|
||||||
where = { organization: result.organization, role: { [Op.not]: 1 } }, dbOptions, joinSubstring = [];
|
where = { organization: result.organization, role: { [Op.not]: 1 } }, dbOptions, joinSubstring = [];
|
||||||
attributes.forEach(element => {
|
attributes.forEach(element => {
|
||||||
if (searchOptions[element]) {
|
if (searchOptions[element]) {
|
||||||
if(searchOptions[element] == '*空') {
|
if (searchOptions[element] == '*空') {
|
||||||
if(joinSubstring.includes(element)) {
|
if (joinSubstring.includes(element)) {
|
||||||
where[element] = null;
|
where[element] = null;
|
||||||
} else {
|
} else {
|
||||||
where[element] = [null, ''];
|
where[element] = [null, ''];
|
||||||
}
|
}
|
||||||
} else{
|
} else {
|
||||||
where[element] = { [Op.substring]: searchOptions[element] };
|
where[element] = { [Op.substring]: searchOptions[element] };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user