commit 90a84079244e5907cbbc670bc27ca2e8c110b9a4 Author: qubiaobiao <3294694717@qq.com> Date: Fri Mar 27 17:51:58 2026 +0800 北斗短报文通信服务平台 diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..4ebc8ae --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +coverage diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..f304bdd --- /dev/null +++ b/.eslintrc @@ -0,0 +1,4 @@ +{ + "extends": "eslint-config-egg", + "root": true +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..652759b --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +logs/ +npm-debug.log +yarn-error.log +node_modules/ +*-lock.json +*-lock.yaml +yarn.lock +coverage/ +.idea/ +run/ +.DS_Store +*.sw* +*.un~ +typings/ +.nyc_output/ diff --git a/.sequelizerc b/.sequelizerc new file mode 100644 index 0000000..01d9847 --- /dev/null +++ b/.sequelizerc @@ -0,0 +1,10 @@ +'use strict'; + +const path = require('path'); + +module.exports = { + "config": path.join(__dirname, 'database/config.json'), + 'migrations-path': path.join(__dirname, 'database/migrations'), + 'seeders-path': path.join(__dirname, 'database/seeders'), + 'models-path': path.join(__dirname, 'app/model'), +}; diff --git a/README.md b/README.md new file mode 100644 index 0000000..fdcfe49 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# bd-short-message-platform + + + +## QuickStart + + + +see [egg docs][egg] for more detail. + +### Development + +```bash +npm i +npm run dev +open http://localhost:7001/ +``` + +### Deploy + +```bash +npm start +npm stop +``` + +### npm scripts + +- Use `npm run lint` to check code style. +- Use `npm test` to run unit test. + +[egg]: https://eggjs.org diff --git a/app/controller/home.js b/app/controller/home.js new file mode 100644 index 0000000..83eb439 --- /dev/null +++ b/app/controller/home.js @@ -0,0 +1,387 @@ +const { Controller } = require('egg'); + +const GBK = require("gbk.js"); + +const decode = (data) => { + let arr = []; + data.match(/..?/g).forEach((element) => { + arr.push(parseInt(element, 16)); + }); + return GBK.decode(arr); +} + +const CryptoJS = require("crypto-js"); + +const KEY = CryptoJS.enc.Utf8.parse('BDQH'); + +const decryptRequest = (body) => { + return CryptoJS.AES.decrypt(body, KEY, { + mode: CryptoJS.mode.ECB, + padding: CryptoJS.pad.Pkcs7 + }).toString(CryptoJS.enc.Utf8); +} + +const checkUid = async (ctx) => { + const uid = ctx.request.body.uid; + const token = ctx.request.header.authorization; + const redis = ctx.app.redis; + let rdmcode; + if (!uid) { + const [buser, cuser, tuser] = await Promise.all([ + redis.get('db0').get(token), + redis.get('db1').get(token), + redis.get('db5').get(token), + ]); + rdmcode = buser || cuser || tuser; + } else { + let decryptUid = decryptRequest(uid).split('?')[0]; + const redisType = { + "B": "db0", + "C": "db1", + "T": "db5", + }; + const lastCode = decryptUid[decryptUid.length - 1]; + rdmcode = await redis.get(redisType[lastCode]).get(token); + } + if (!rdmcode) { + return false; + } + return rdmcode; +}; + +const fileName = "home"; + +const setResponse = (ctx, code, msg, model, data = {}) => { + const modelType = { + "none": { code, msg }, + "deconstruction": { code, msg, ...data }, + "polymerization": { code, msg, data } + } + ctx.body = modelType[model]; +} + +class HomeController extends Controller { + // 获取卡号 + async getCard() { + const ctx = this.ctx; + try { + let rdmcode = await checkUid(ctx); + if (!rdmcode) { + setResponse(ctx, 401, 'token过期或错误', "none"); + return; + } + const uid = JSON.parse(rdmcode).uid; + const result = await ctx.service.home.getCard(uid); + if(result == "error") { + setResponse(ctx, 500, '服务器错误', "none"); + return; + } + if (result) { + const data = { cardID: result.dataValues.card_id }; + setResponse(ctx, 200, '获取卡号成功', "deconstruction", data); + } else { + setResponse(ctx, 404, '获取卡号失败', "none"); + } + } catch (error) { + const blockName = fileName + "--" + "getCard"; + ctx.app.middleware.utils.log('../../../controllerLog', blockName + ">>>>" + error); + setResponse(ctx, 500, '服务器错误', "none"); + } + } + // 搜索卡号 + async searchCard() { + const ctx = this.ctx; + try { + let rdmcode = await checkUid(ctx); + if (!rdmcode) { + setResponse(ctx, 401, 'token过期或错误', "none"); + return; + } + const uid = JSON.parse(rdmcode).uid; + const { cardID } = ctx.request.body; + const result = await ctx.service.home.searchCard(cardID); + if(result == "error") { + setResponse(ctx, 500, '服务器错误', "none"); + return; + } + if (result) { + if (result.dataValues.cuser == null) { + setResponse(ctx, 201, '此卡未绑定', "none"); + } else if (result.dataValues.cuser == uid) { + setResponse(ctx, 202, '此卡已与当前账号绑定', "none"); + } else { + setResponse(ctx, 203, '此卡已绑定', "none"); + } + } else { + setResponse(ctx, 404, '此卡未注册', "none"); + } + } catch (error) { + const blockName = fileName + "--" + "searchCard"; + ctx.app.middleware.utils.log('../../../controllerLog', blockName + ">>>>" + error); + setResponse(ctx, 500, '服务器错误', "none"); + } + } + + // 绑卡 + async bindCard() { + const ctx = this.ctx; + try { + let rdmcode = await checkUid(ctx); + if (!rdmcode) { + setResponse(ctx, 401, 'token过期或错误', "none"); + return; + } + const uid = JSON.parse(rdmcode).uid; + const body = ctx.request.body; + const result = await ctx.service.home.bindCard(uid, body); + if(result == "error") { + setResponse(ctx, 500, '服务器错误', "none"); + return; + } + if (result) { + setResponse(ctx, 200, '绑卡成功', "none"); + } else { + setResponse(ctx, 404, '绑卡失败', "none"); + } + } catch (error) { + const blockName = fileName + "--" + "bindCard"; + ctx.app.middleware.utils.log('../../../controllerLog', blockName + ">>>>" + error); + setResponse(ctx, 500, '服务器错误', "none"); + } + } + + // 解绑 + async unBindingCard() { + const ctx = this.ctx; + try { + let rdmcode = await checkUid(ctx); + if (!rdmcode) { + setResponse(ctx, 401, 'token过期或错误', "none"); + return; + } + const uid = JSON.parse(rdmcode).uid; + const body = ctx.request.body; + const result = await ctx.service.home.unBindingCard(uid, body); + if(result == "error") { + setResponse(ctx, 500, '服务器错误', "none"); + return; + } + if (result) { + setResponse(ctx, 200, '解绑成功', "none"); + } else { + setResponse(ctx, 404, '解绑失败', "none"); + } + } catch (error) { + const blockName = fileName + "--" + "unBindingCard"; + ctx.app.middleware.utils.log('../../../controllerLog', blockName + ">>>>" + error); + setResponse(ctx, 500, '服务器错误', "none"); + } + } + + // B端单位管理员解绑 + async unBindManager() { + const ctx = this.ctx; + try { + let rdmcode = await checkUid(ctx); + if (!rdmcode) { + setResponse(ctx, 401, 'token过期或错误', "none"); + 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 result = await ctx.service.home.unBindManager(uid, model, password, requestMsg); + if(result == "error") { + setResponse(ctx, 500, '服务器错误', "none"); + return; + } + if (result) { + setResponse(ctx, 200, '解绑成功', "none"); + } else { + setResponse(ctx, 404, '解绑失败', "none"); + } + } catch (error) { + const blockName = fileName + "--" + "unBindManager"; + ctx.app.middleware.utils.log('../../../controllerLog', blockName + ">>>>" + error); + setResponse(ctx, 500, '服务器错误', "none"); + } + } + + // 获取绑定记录 + async getRecord() { + const ctx = this.ctx; + try { + let rdmcode = await checkUid(ctx); + if (!rdmcode) { + setResponse(ctx, 401, 'token过期或错误', "none"); + return; + } + const uid = JSON.parse(rdmcode).uid; + const body = ctx.request.body; + const result = await ctx.service.home.getRecord(uid, body); + if(result == "error") { + setResponse(ctx, 500, '服务器错误', "none"); + return; + } + if (result) { + let recordMsg = []; + result.rows.forEach(element => { + recordMsg.push(element.dataValues); + }); + const data = { + recordMsg: recordMsg, + count: result.count + }; + setResponse(ctx, 200, '绑定记录查询成功', "deconstruction", data); + } else { + setResponse(ctx, 404, '绑定记录查询失败', "none"); + } + } catch (error) { + const blockName = fileName + "--" + "getRecord"; + ctx.app.middleware.utils.log('../../../controllerLog', blockName + ">>>>" + error); + setResponse(ctx, 500, '服务器错误', "none"); + } + } + + // 存储消息记录 + async shortMsg() { + const ctx = this.ctx; + try { + const body = ctx.request.body; + const { card_id, receiver_address, original_msg, send_type, encode_type, msg_data, created_at } = body; + const form = { + card_id: card_id, + receiver_address: receiver_address, + original_msg: original_msg, + send_type: Number(send_type), + encode_type: Number(encode_type), + msg_data: Number(encode_type) == 0 ? decode(msg_data) : msg_data, + created_at: created_at + }; + const result = await ctx.service.home.shortMsg(form); + if(result == "error") { + setResponse(ctx, 500, '服务器错误', "none"); + return; + } + if (result) { + setResponse(ctx, 200, '消息记录存储成功', "none"); + } else { + setResponse(ctx, 404, '消息记录存储失败', "none"); + } + } catch (error) { + const blockName = fileName + "--" + "shortMsg"; + ctx.app.middleware.utils.log('../../../controllerLog', blockName + ">>>>" + error); + setResponse(ctx, 500, '服务器错误', "none"); + } + } + + // 获取历史消息 + async getHistoryMsg() { + const ctx = this.ctx; + try { + let rdmcode = await checkUid(ctx); + if (!rdmcode) { + setResponse(ctx, 401, 'token过期或错误', "none"); + return; + } + const uid = JSON.parse(rdmcode).uid; + const body = ctx.request.body; + const result = await ctx.service.home.getHistoryMsg(uid, body); + if(result == "error") { + setResponse(ctx, 500, '服务器错误', "none"); + return; + } + if (result) { + let historyMsg = []; + result.rows.forEach(element => { + historyMsg.push(element.dataValues); + }); + const data = { + historyMsg: historyMsg, + count: result.count + }; + setResponse(ctx, 200, '历史消息查找成功', "deconstruction", data); + } else { + setResponse(ctx, 404, '历史消息查找失败', "none"); + } + } catch (error) { + const blockName = fileName + "--" + "getHistoryMsg"; + ctx.app.middleware.utils.log('../../../controllerLog', blockName + ">>>>" + error); + setResponse(ctx, 500, '服务器错误', "none"); + } + } + + // 删除历史消息 + async delHistoryMsg() { + const ctx = this.ctx; + try { + let rdmcode = await checkUid(ctx); + if (!rdmcode) { + setResponse(ctx, 401, 'token过期或错误', "none"); + 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"); + } + } + + // 获取单位用户 + async bsideManager() { + const ctx = this.ctx; + try { + let rdmcode = await checkUid(ctx); + if (!rdmcode) { + setResponse(ctx, 401, 'token过期或错误', "none"); + return; + } + const uid = JSON.parse(rdmcode).uid; + let result; + if(uid[uid.length - 1] == 'B') { + const body = ctx.request.body; + result = await ctx.service.home.bsideManager(uid, body); + } + if(result == "error") { + setResponse(ctx, 500, '服务器错误', "none"); + return; + } + if (result) { + let bsideUsers = []; + result.rows.forEach(element => { + bsideUsers.push(element.dataValues); + }); + const data = { + bsideUsers: bsideUsers, + count: result.count + }; + setResponse(ctx, 200, '获取单位用户成功', "deconstruction", data); + } else { + setResponse(ctx, 404, '获取单位用户失败', "none"); + } + } catch (error) { + const blockName = fileName + "--" + "bsideManager"; + ctx.app.middleware.utils.log('../../../controllerLog', blockName + ">>>>" + error); + setResponse(ctx, 500, '服务器错误', "none"); + } + } +} + +module.exports = HomeController; diff --git a/app/core/base_service.js b/app/core/base_service.js new file mode 100644 index 0000000..8a79e50 --- /dev/null +++ b/app/core/base_service.js @@ -0,0 +1,50 @@ +const { Service } = require('egg'); + +const sha256 = require("crypto-js/sha256"); + +const CryptoJS = require("crypto-js"); + +const KEY = CryptoJS.enc.Utf8.parse('BDQH'); + +class BaseService extends Service { + shaForm = (body, salt) => { + return sha256(sha256(body).toString() + salt).toString(); + } + + encryptRequest = (body) => { + return CryptoJS.AES.encrypt(body, KEY, { + mode: CryptoJS.mode.ECB, + padding: CryptoJS.pad.Pkcs7 + }).toString(); + } + + decryptRequest = (body) => { + return CryptoJS.AES.decrypt(body, KEY, { + mode: CryptoJS.mode.ECB, + padding: CryptoJS.pad.Pkcs7 + }).toString(CryptoJS.enc.Utf8); + } + + opOptions = (attributes, searchOptions, substring, key, between, sortOptions) => { + let where = {}, order = []; + attributes.forEach(element => { + if (searchOptions[element]) { + if (substring.includes(element)) { + where[element] = { [Op.substring]: searchOptions[element] }; + } else if (key.includes(element)) { + where[element] = searchOptions[element]; + } else if (between.includes(element)) { + where[element] = { [Op.between]: [searchOptions[element][0], searchOptions[element][1]] }; + } + } + if (!sortOptions[element]) { + order.push([element, 'DESC']); + } else if (sortOptions[element]) { + order.push([element, 'ASC']); + } + }); + return { where, order } + } +} + +module.exports = BaseService; \ No newline at end of file diff --git a/app/middleware/packageBuild/buildXFType100.js b/app/middleware/packageBuild/buildXFType100.js new file mode 100644 index 0000000..12ee1a9 --- /dev/null +++ b/app/middleware/packageBuild/buildXFType100.js @@ -0,0 +1,9 @@ +// 构造集团客户认证请求信息的数据部分 +// 将token中的每一位字符转为ascii码后再转为十六进制字符串,最后重新拼接起来 +module.exports = (token) => { + let code = ''; + for (let i = 0; i < token.length; i++) { + code = code + token.charCodeAt(i).toString(16); + } + return code; +}; \ No newline at end of file diff --git a/app/middleware/packageBuild/packageBuild.js b/app/middleware/packageBuild/packageBuild.js new file mode 100644 index 0000000..77f3bfb --- /dev/null +++ b/app/middleware/packageBuild/packageBuild.js @@ -0,0 +1,26 @@ +// 构造发送包,传入参数nowData和resendData +// nowData为当前数据段,resendData为重发数据段 +// nowData和resendData都为数组,数组元素的内容为:信息类型编号 + 信息内容长度 + 信息内容 +module.exports = (app, nowData, resendData) => { + const utils = app.middleware.utils; + utils.intrinsic.packageNumber++; + let now = new Date(); + let sendTime = utils.packageItem(2, now.getFullYear()) + + utils.packageItem(1, now.getMonth() + 1) + + utils.packageItem(1, now.getDate()); + let packageMsg = utils.packageItem(2, app.config.socketClient.id) + + utils.packageItem(2, app.config.socketClient.destination) + + utils.packageItem(4, utils.intrinsic.packageNumber) + + utils.packageItem(1, nowData.length) + + utils.packageItem(2, utils.arrItemLength(nowData)) + + (resendData ? '01' : '00') + + (resendData ? utils.packageItem(1, resendData.length) : '00') + + (resendData ? utils.packageItem(2, utils.arrItemLength(resendData)) : '0000') + + sendTime + + utils.arrTotalItem(nowData) + + (resendData ? sendTime : '') + + (resendData ? utils.arrTotalItem(resendData) : '') + + utils.intrinsic.separateIdentifiers; + const buffer = Buffer.from(packageMsg, 'hex'); + return buffer; +}; \ No newline at end of file diff --git a/app/middleware/parseDataPackage/parseDataPackage.js b/app/middleware/parseDataPackage/parseDataPackage.js new file mode 100644 index 0000000..2417d31 --- /dev/null +++ b/app/middleware/parseDataPackage/parseDataPackage.js @@ -0,0 +1,32 @@ +// 解析数据包 +module.exports = (middleware, data) => { + const utils = middleware.utils; + const shunt = middleware.shunt; + let msg; + if (data == 'e5bf83e8b7b3') { + msg = 'e5bf83e8b7b37878787888888888'; + } else { + let regex = /..?/g, + arr = data.match(regex), + baseArr = utils.getArr(arr, 0, 14), + baseObj = { + infoSource: { label: "信源", data: parseInt(baseArr[0] + baseArr[1], 16) }, + destination: { label: "信宿", data: parseInt(baseArr[2] + baseArr[3], 16) }, + packageNumber: { label: "包序号", data: parseInt(baseArr[4] + baseArr[5] + baseArr[6] + baseArr[7], 16) }, + dataItem: { label: "当前数据项", data: parseInt(baseArr[8], 16) }, + dataLength: { label: "当前数据段总长度", data: parseInt(baseArr[9] + baseArr[10], 16) }, + resendFlag: { label: "重发标志", data: parseInt(baseArr[11], 16) }, + resendItem: { label: "重发数据项", data: parseInt(baseArr[12], 16) }, + resendLength: { label: "重发数据段总长度", data: parseInt(baseArr[13] + baseArr[14], 16) }, + dataContent: { label: "数据段", } + }; + if (baseObj.dataItem.data !== 0) { + shunt.selectXFType(middleware, 'now', baseObj, arr); + } + if (baseObj.resendFlag.data !== 0) { + shunt.selectXFType(middleware, 'resend', baseObj, arr); + } + msg = baseObj; + } + return msg; +}; \ No newline at end of file diff --git a/app/middleware/parseDataPackage/parseMsg.js b/app/middleware/parseDataPackage/parseMsg.js new file mode 100644 index 0000000..c28bf2b --- /dev/null +++ b/app/middleware/parseDataPackage/parseMsg.js @@ -0,0 +1,24 @@ +// 解析通信服务的通信数据 +module.exports = (type, msg) => { + let regex, arr, result = ''; + if (type == '0000') { + // 0000, 汉字编码,按14bit区位编码,前7位为区码,后7位为位码 + // 区号和位号分别加上160,再分别转换成十六进制数,就成为四位的十六进制GB2312国家标准编码 + regex = /.......?/g; + arr = msg.match(regex); + for (let t = 0; t < arr.length; t += 2) { + result = result + (parseInt(arr[t], 2) + 160).toString(16) + (parseInt(arr[t + 1], 2) + 160).toString(16); + } + } else if (type == '0001') { + // 0001,BCD码,按4bit编码,将每4bit二进制转换为一个十进制数,再拼接成字符串 + regex = /....?/g; + arr = msg.match(regex); + arr.forEach(element => { + result = result + parseInt(element, 2); + }); + } else { + // 保留,二进制转为十进制 + result = parseInt(msg, 2); + } + return result; +}; \ No newline at end of file diff --git a/app/middleware/parseDataPackage/parseXFType004.js b/app/middleware/parseDataPackage/parseXFType004.js new file mode 100644 index 0000000..4d874c1 --- /dev/null +++ b/app/middleware/parseDataPackage/parseXFType004.js @@ -0,0 +1,125 @@ +// 解析通信服务信息 +module.exports = (middleware, dataArr, objCtx) => { + const utils = middleware.utils; + const parseDataPackage = middleware.parseDataPackage; + let informationFieldString = utils.hexToBinary(utils.getString(dataArr, 0, dataArr.length - 1)); + objCtx.msgContent = { + originalMsg: utils.getString(dataArr, 0, dataArr.length - 1), + outboundTypeIdentification: { label: "出站类型标识", data: parseInt(informationFieldString.slice(0, 8), 2) }, + receiverType: { label: "收方类型", data: parseInt(informationFieldString.slice(8, 16), 2) }, + receiverAddress: { label: "收方地址", data: parseInt(informationFieldString.slice(parseInt(informationFieldString.slice(8, 16), 2) == 0 ? 40 : 16, 64), 2) }, + msgLength: { label: "信息长度", data: parseInt(informationFieldString.slice(64, 80), 2) }, + msgCategory: { + label: "信息类别", + retain: { label: "保留", data: informationFieldString.slice(80, 81) }, + outboundFrameCategory: { label: "出站帧类别", data: informationFieldString.slice(81, 83) }, + typeOfCommunication: { label: "通信类型", }, + }, + }; + informationFieldString = informationFieldString.slice(83, objCtx.msgContent.msgLength.data + 80); + switch (informationFieldString.slice(0, 2)) { + case '00': + objCtx.msgContent.msgCategory.typeOfCommunication.shortMsg = { label: "短报文", data: informationFieldString.slice(0, 2) }; + objCtx.msgContent.msgCategory.typeOfCommunication.senderType = { label: "发方类型", data: informationFieldString.slice(2, 3) }; + objCtx.msgContent.msgCategory.typeOfCommunication.packetID = { + label: "报文标识", + instantMessages: { label: "是否为即时报文出站", data: informationFieldString.slice(3, 4) }, + acknowledgmentOfReceipt: { label: "是否需要收方用户自动回执", data: informationFieldString.slice(4, 5) }, + }; + break; + case '01': + if (informationFieldString.slice(2, 3) == '0') { + objCtx.msgContent.msgCategory.typeOfCommunication.onDemandCommunications = { label: "点播通信", data: informationFieldString.slice(0, 3) }; + objCtx.msgContent.msgCategory.typeOfCommunication.senderType = { label: "发方类型", data: informationFieldString.slice(3, 4) }; + objCtx.msgContent.msgCategory.typeOfCommunication.realTimeIdentification = { label: "实时标识", data: informationFieldString.slice(4, 5) }; + } else { + objCtx.msgContent.msgCategory.typeOfCommunication.retain = { label: "保留", data: informationFieldString.slice(0, 5) }; + } + break; + case '10': + if (informationFieldString.slice(0, 5) == '10000') { + objCtx.msgContent.msgCategory.typeOfCommunication.receiptQueryResults = { label: "回执查询结果", data: informationFieldString.slice(0, 5) }; + } else { + objCtx.msgContent.msgCategory.typeOfCommunication.retain = { label: "保留", data: informationFieldString.slice(0, 5) }; + } + break; + case '11': + if (informationFieldString.slice(0, 5) == '11000') { + objCtx.msgContent.msgCategory.typeOfCommunication.multicastCommunication = { label: "组播通信", data: informationFieldString.slice(0, 5) }; + } else if (informationFieldString.slice(0, 5) == '11010') { + objCtx.msgContent.msgCategory.typeOfCommunication.broadcastCommunications = { label: "通播通信", data: informationFieldString.slice(0, 5) }; + } else { + objCtx.msgContent.msgCategory.typeOfCommunication.retain = { label: "保留", data: informationFieldString.slice(0, 5) }; + } + break; + default: + break; + }; + if (informationFieldString.slice(0, 2) == '00' || informationFieldString.slice(0, 3) == '010' || informationFieldString.slice(0, 5) == '11000' || informationFieldString.slice(0, 5) == '11010') { + let typeMsg = informationFieldString.slice(0, 5); + objCtx.msgContent.outboundMsg = { + label: "出站信息段", + firstFrame: { label: "是否首帧", data: informationFieldString.slice(5, 6) }, + resumeFrame: { label: "有无续帧", data: informationFieldString.slice(6, 7) }, + senderAddress: { label: "发方地址", }, + }; + if (typeMsg.slice(0, 3) == '001' || typeMsg.slice(0, 4) == '0101') { + objCtx.msgContent.outboundMsg.senderAddress.data = parseInt(informationFieldString.slice(7, 55), 2); + informationFieldString = informationFieldString.slice(55, informationFieldString.length); + } else { + objCtx.msgContent.outboundMsg.senderAddress.data = parseInt(informationFieldString.slice(7, 31), 2); + informationFieldString = informationFieldString.slice(31, informationFieldString.length); + }; + objCtx.msgContent.outboundMsg.sendMsgTime = { + label: "发信时间", + weeklyInstructions: { label: "周指示", data: parseInt(informationFieldString.slice(0, 1), 2) }, + intraWeekSeconds: { label: "周内秒", data: parseInt(informationFieldString.slice(1, 21), 2) }, + }; + if (typeMsg.slice(0, 2) == '00' && objCtx.msgContent.receiverAddress.data == '通播地址') { + objCtx.msgContent.outboundMsg.ancillaryInformation = { + label: "辅助信息", + msgNumber: { label: "信息编号", data: parseInt(informationFieldString.slice(21, 29), 2) }, + }; + informationFieldString = informationFieldString.slice(29, informationFieldString.length); + } else if (typeMsg.slice(0, 2) == '00' && objCtx.msgContent.receiverAddress.data == '组播地址') { + objCtx.msgContent.outboundMsg.ancillaryInformation = { + label: "辅助信息", + totalGroupMembers: { label: "编组组员总数", data: parseInt(informationFieldString.slice(21, 28), 2) }, + onlineGroupMembers: { label: "在线组员数", data: parseInt(informationFieldString.slice(28, 35), 2) }, + msgNumber: { label: "信息编号", data: parseInt(informationFieldString.slice(35, 43), 2) }, + }; + informationFieldString = informationFieldString.slice(43, informationFieldString.length); + } else if (typeMsg.slice(0, 5) == '11000') { + objCtx.msgContent.outboundMsg.multicastAncillaryInformation = { + label: "组播辅助信息", + totalGroupMembers: { label: "编组组员总数", data: parseInt(informationFieldString.slice(21, 28), 2) }, + onlineGroupMembers: { label: "在线组员数", data: parseInt(informationFieldString.slice(28, 35), 2) }, + }; + informationFieldString = informationFieldString.slice(35, informationFieldString.length); + } else { + informationFieldString = informationFieldString.slice(21, informationFieldString.length); + } + objCtx.msgContent.outboundMsg.encodingCategory = { label: "编码类别", data: informationFieldString.slice(0, 4) } + objCtx.msgContent.outboundMsg.msgData = { label: "通信数据", data: parseDataPackage.parseMsg(objCtx.msgContent.outboundMsg.encodingCategory.data, informationFieldString.slice(4, informationFieldString.length)) } + } else if (informationFieldString.slice(0, 5) == '10000') { + objCtx.msgContent.receiptQueryResults = { + label: "回执查询结果", + communicationRecipientAddress: { label: "通信收方地址", data: parseInt(informationFieldString.slice(5, 29), 2), }, + receiptsNumber: { label: "回执数", data: parseInt(informationFieldString.slice(29, 32), 2), }, + } + if (objCtx.msgContent.receiptQueryResults.receiptsNumber.data !== 0) { + informationFieldString = informationFieldString.slice(32, informationFieldString.length); + for (let k = 0; k < objCtx.msgContent.receiptQueryResults.receiptsNumber.data; k++) { + let communicationTime = "communicationTime" + (k + 1); + objCtx.msgContent.receiptQueryResults[communicationTime] = { + label: "通信发信时间" + (k + 1), + weeklyInstructions: { label: "周指示", data: parseInt(informationFieldString.slice(0, 1), 2) }, + intraWeekSeconds: { label: "周内秒", data: parseInt(informationFieldString.slice(1, 21), 2) }, + } + informationFieldString = informationFieldString.slice(21, informationFieldString.length); + } + } + } else { + objCtx.msgContent.retain = { label: "保留", data: informationFieldString.slice(5, informationFieldString.length), } + }; +}; \ No newline at end of file diff --git a/app/middleware/parseDataPackage/parseXFType005.js b/app/middleware/parseDataPackage/parseXFType005.js new file mode 100644 index 0000000..bedd933 --- /dev/null +++ b/app/middleware/parseDataPackage/parseXFType005.js @@ -0,0 +1,52 @@ +// 解析广播服务信息 +module.exports = (middleware, dataArr, objCtx) => { + const utils = middleware.utils; + let fixedFieldString = utils.hexToBinary(utils.getString(dataArr, 0, 15).slice(0, 16)), + informationFieldString = utils.hexToBinary(utils.getString(dataArr, 17, objCtx.contentLength.data + 3)); + objCtx.msgContent = { + fixedField: { + label: "固定域", + satelliteNumber: { label: "卫星号", data: parseInt(fixedFieldString.slice(0, 6), 2) }, + beamNumber: { label: "波束号", data: parseInt(fixedFieldString.slice(6, 10), 2) }, + hyperframeCount: { label: "超帧计数", data: parseInt(fixedFieldString.slice(10, 27), 2) }, + weeklyCount: { label: "周计数", data: parseInt(fixedFieldString.slice(27, 40), 2) }, + frequencyDynamicControl: { label: "频度动态控制", data: parseInt(fixedFieldString.slice(40, 44), 2) }, + outboundDelayForecast: { label: "出站时延预报", data: parseInt(fixedFieldString.slice(44, 48), 2) }, + integrityInformation: { label: "完好性信息", data: parseInt(fixedFieldString.slice(48, 50), 2) }, + reserved1: { label: "保留1", data: parseInt(fixedFieldString.slice(50, 55), 2) }, + reserved2: { label: "保留2", data: parseInt(fixedFieldString.slice(55, 64), 2) }, + repeat: { label: "重复" }, + }, + msgType: { label: "MsgType", data: parseInt(utils.hexToBinary(dataArr[16]), 2) }, + informationField: { label: "类别信息域", }, + } + objCtx.msgContent.informationField.satellitesNumber = { label: "本帧电文包括卫星数", data: parseInt(informationFieldString.slice(0, 3), 2) }; + informationFieldString = informationFieldString.slice(3, informationFieldString.length); + if (objCtx.msgContent.informationField.satellitesNumber.data !== 0) { + for (let j = 0; j < objCtx.msgContent.informationField.satellitesNumber.data; j++) { + let satellitesObj = "satellitesObj" + (j + 1); + objCtx.msgContent.informationField[satellitesObj] = { + label: "卫星" + (j + 1), + PRNNumber: { label: "导航PRN号", data: parseInt(informationFieldString.slice(0, 6), 2) }, + beamsNumber: { label: "出站波束数量", data: parseInt(informationFieldString.slice(6, 10), 2) }, + reserved1: { label: "保留1", data: parseInt(informationFieldString.slice(10, 16), 2) }, + reserved2: { label: "保留2", data: parseInt(informationFieldString.slice(16, 22), 2) }, + } + informationFieldString = informationFieldString.slice(22, informationFieldString.length); + if (objCtx.msgContent.informationField[satellitesObj].beamsNumber.data !== 0) { + for (let l = 0; l < objCtx.msgContent.informationField[satellitesObj].beamsNumber.data; l++) { + let CenterObj = "CenterObj" + (l + 1); + objCtx.msgContent.informationField[satellitesObj][CenterObj] = { + label: "波束" + (l + 1) + "中心经纬度", + longitude: { label: "经度", data: parseInt(informationFieldString.slice(0, 1), 2) == 0 ? parseInt(informationFieldString.slice(1, 9), 2) : '-' + parseInt(informationFieldString.slice(1, 9), 2) }, + latitude: { label: "纬度", data: parseInt(informationFieldString.slice(9, 10), 2) == 0 ? parseInt(informationFieldString.slice(10, 17), 2) : '-' + parseInt(informationFieldString.slice(10, 17), 2) }, + } + informationFieldString = informationFieldString.slice(17, informationFieldString.length); + } + } + } + objCtx.msgContent.informationField.reserved = { label: "保留", data: informationFieldString }; + } else { + objCtx.msgContent.informationField.reserved = { label: "保留", data: informationFieldString }; + } +}; \ No newline at end of file diff --git a/app/middleware/parseDataPackage/parseXFType099.js b/app/middleware/parseDataPackage/parseXFType099.js new file mode 100644 index 0000000..5eb13d3 --- /dev/null +++ b/app/middleware/parseDataPackage/parseXFType099.js @@ -0,0 +1,16 @@ +// 解析集团客户认证结果信息 +module.exports = (dataArr, objCtx) => { + let authCoed = parseInt(dataArr.pop(), 16); + if (authCoed == 1) { + let token = ''; + dataArr.forEach(element => { + token = token + String.fromCodePoint(parseInt(element, 16)); + }); + objCtx.token = token; + objCtx.authStatus = '1'; + objCtx.resultMsg = '认证成功'; + } else if (authCoed == 0) { + objCtx.authStatus = '0'; + objCtx.resultMsg = '认证失败'; + } +}; \ No newline at end of file diff --git a/app/middleware/shunt/selectXFType.js b/app/middleware/shunt/selectXFType.js new file mode 100644 index 0000000..56dd44e --- /dev/null +++ b/app/middleware/shunt/selectXFType.js @@ -0,0 +1,50 @@ +// 解析服务信息类型 +module.exports = (middleware, item, baseObj, arr) => { + const utils = middleware.utils; + const parseDataPackage = middleware.parseDataPackage; + let dataCtx = baseObj.dataContent, objName, labelString, dataArr, itemLength, itemType; + if (item == 'now') { + objName = 'nowData'; + labelString = '当前'; + itemLength = baseObj.dataLength.data; + dataArr = utils.getArr(arr, 15, 15 + itemLength - 1); + itemType = baseObj.dataItem.data; + } else if (item == 'resend') { + objName = 'resendData'; + labelString = '重发'; + itemLength = baseObj.resendLength.data; + dataArr = utils.getArr(arr, 15 + baseObj.dataLength.data, 15 + baseObj.dataLength.data + itemLength - 1); + itemType = baseObj.resendItem.data; + } + dataCtx[objName] = { + label: labelString + "数据段", + timeObj: { + year: { label: "年", data: parseInt(dataArr[0] + dataArr[1], 16) }, + month: { label: "月", data: parseInt(dataArr[2], 16) }, + day: { label: "日", data: parseInt(dataArr[3], 16) }, + } + } + dataArr = utils.getArr(dataArr, 4, itemLength - 1); + for (let i = 0; i < itemType; i++) { + let contentObj = "contentObj" + (i + 1); + dataCtx[objName][contentObj] = { + label: labelString + "数据内容" + (i + 1), + typeNumber: { label: "信息类型编号", data: parseInt(dataArr[0] + dataArr[1], 16) }, + contentLength: { label: "信息内容长度", data: parseInt(dataArr[2] + dataArr[3], 16) }, + } + if (dataCtx[objName][contentObj].contentLength.data !== 0) { + dataArr = utils.getArr(dataArr, 4, itemLength - 5); + switch (dataCtx[objName][contentObj].typeNumber.data) { + case 4: parseDataPackage.parseXFType004(middleware, dataArr, dataCtx[objName][contentObj]); + break; + case 5: parseDataPackage.parseXFType005(middleware, dataArr, dataCtx[objName][contentObj]); + break; + case 99: parseDataPackage.parseXFType099(dataArr, dataCtx[objName][contentObj]); + break; + default: + break; + } + } + dataArr = utils.getArr(dataArr, dataCtx[objName][contentObj].contentLength.data, itemLength - 1); + } +}; \ No newline at end of file diff --git a/app/middleware/shunt/socketEmitter.js b/app/middleware/shunt/socketEmitter.js new file mode 100644 index 0000000..815eca4 --- /dev/null +++ b/app/middleware/shunt/socketEmitter.js @@ -0,0 +1,8 @@ +// socket事件监听器 +const EventEmitter = require('events'); + +const socketEmitter = new EventEmitter(); + +module.exports = () => { + return socketEmitter; +}; \ No newline at end of file diff --git a/app/middleware/shunt/socketResult.js b/app/middleware/shunt/socketResult.js new file mode 100644 index 0000000..a808a1b --- /dev/null +++ b/app/middleware/shunt/socketResult.js @@ -0,0 +1,14 @@ +// 对数据包解析结果做类型判断,并根据不同类型返回不同结果 +module.exports = (data) => { + for (let item in data) { + if (data[item].typeNumber) { + if (data[item].typeNumber.data == 4) { + return { type: 4, data: data[item] }; + } else if (data[item].typeNumber.data == 5) { + return { type: 5, data: data[item] }; + } else if (data[item].typeNumber.data == 99) { + return { type: 99, data: data[item].authStatus }; + } + } + } +}; \ No newline at end of file diff --git a/app/middleware/socket/socketClient.js b/app/middleware/socket/socketClient.js new file mode 100644 index 0000000..0b1fc9e --- /dev/null +++ b/app/middleware/socket/socketClient.js @@ -0,0 +1,135 @@ +// socket客户端 +const net = require('net'); + +module.exports = (app) => { + const { middleware } = app; + const packageBuild = middleware.packageBuild; + const utils = middleware.utils; + const parseDataPackage = middleware.parseDataPackage; + const shunt = middleware.shunt; + + const client = new net.Socket(); + + let times, connectSwitch = true, reconnectSwitch = false; + + setTimeout(() => { + reconnectSwitch = true; + }, 66000); + + const createClient = () => { + if(connectSwitch) { + connectSwitch = false; + client.connect(app.config.socketClient.port, app.config.socketClient.ip, () => { + console.log(`socket: 连接到服务端: ${app.config.socketClient.ip + ':' + app.config.socketClient.port}`); + client.setKeepAlive(true, 60000); + reconnectSwitch = true; + }); + } + }; + + createClient(); + + // 重连服务端 + const reconnect = () => { + if (reconnectSwitch) { + reconnectSwitch = false; + setTimeout(() => { + connectSwitch = true; + createClient(); + }, 66000); + } + }; + + client.on('connectTimeout', () => { + reconnect(); + }); + + client.on('timeout', () => { + reconnect(); + }); + + client.on('end', () => { + reconnect(); + }); + + client.on('close', () => { + reconnect(); + }); + + client.on('error', (err) => { + utils.log('../../../socketLog', err); + reconnect(); + }); + + client.on('connect', () => { + // 连接成功后的逻辑... + client.write(packageBuild.packageBuild(app, [utils.packageItem(2, 100) + utils.packageItem(2, packageBuild.buildXFType100(app.config.socketClient.token).length / 2) + packageBuild.buildXFType100(app.config.socketClient.token)])); + }); + + client.on('data', async (data) => { + // 在这里可以处理从服务器接收到的数据 + // utils.log('../../../socketLog', data); + let msg = parseDataPackage.parseDataPackage(middleware, data.toString('hex').slice(0, data.toString('hex').length - 16)); + if (msg == utils.intrinsic.heart) { + clearTimeout(times); + times = setTimeout(() => { + client.write(Buffer.from(msg, 'hex')); + }, 10000); + } else { + let nowResult = shunt.socketResult(msg.dataContent.nowData); + let resendResult = shunt.socketResult(msg.dataContent.resendData); + // 当前消息处理 + if (nowResult.type == 99) { + // token验证处理程序 + if (nowResult.data == '1') { + client.write(Buffer.from(utils.intrinsic.heart, 'hex')); + } else { + reconnect(); + } + } else if (nowResult.type == 4) { + const { msgContent } = nowResult.data; + const { outboundMsg, receiverAddress, originalMsg } = msgContent; + const { senderAddress, msgData, encodingCategory } = outboundMsg; + // socket接收消息后触发事件监听器,将消息发送给websocket客户端并存储在数据库中 + 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', { + dataType: 'json', + contentType: 'application/x-www-form-urlencoded', + method: 'POST', + timeout: 3000, + data: { + card_id: senderAddress.data, + receiver_address: receiverAddress.data, + original_msg: originalMsg, + send_type: 0, + encode_type: parseInt(encodingCategory.data), + msg_data: msgData.data, + created_at: new Date() + }, + }); + } + // 重发消息处理 + if (resendResult && resendResult.type == 4) { + const { msgContent } = resendResult.data; + const { outboundMsg, receiverAddress } = msgContent; + const { senderAddress, msgData, encodingCategory } = outboundMsg; + // socket接收消息后触发事件监听器,将消息发送给websocket客户端并存储在数据库中 + shunt.socketEmitter().emit(senderAddress.data, msgData.data); + await app.curl('http://127.0.0.1:' + app.server.address().port + '/shortMsg', { + dataType: 'json', + contentType: 'application/x-www-form-urlencoded', + method: 'POST', + timeout: 3000, + data: { + card_id: senderAddress.data, + receiver_address: receiverAddress.data, + msg: data.toString(), + send_type: 1, + encode_type: parseInt(encodingCategory.data), + msg_data: msgData.data, + }, + }); + } + } + }); +}; \ No newline at end of file diff --git a/app/middleware/utils/arrItemLength.js b/app/middleware/utils/arrItemLength.js new file mode 100644 index 0000000..889d1ad --- /dev/null +++ b/app/middleware/utils/arrItemLength.js @@ -0,0 +1,8 @@ +// 计算数组中十六进制数据的总字节数,并在最终结果中加上时间信息的4字节长度 +module.exports = (arr) => { + let length = 0; + arr.forEach(element => { + length = length + (element.length / 2); + }); + return length + 4; +}; \ No newline at end of file diff --git a/app/middleware/utils/arrTotalItem.js b/app/middleware/utils/arrTotalItem.js new file mode 100644 index 0000000..360085d --- /dev/null +++ b/app/middleware/utils/arrTotalItem.js @@ -0,0 +1,8 @@ +// 将数组中的所有元素按下标顺序拼接成字符串 +module.exports = (arr) => { + let total = ''; + arr.forEach(element => { + total = total + element; + }); + return total; +}; \ No newline at end of file diff --git a/app/middleware/utils/getArr.js b/app/middleware/utils/getArr.js new file mode 100644 index 0000000..59b41e4 --- /dev/null +++ b/app/middleware/utils/getArr.js @@ -0,0 +1,10 @@ +// 截取数组元素,组成新数组并返回 +module.exports = (arr, start, end) => { + let newArr = []; + arr.forEach((element, index) => { + if (index >= start && index <= end) { + newArr.push(element); + } + }); + return newArr; +}; \ No newline at end of file diff --git a/app/middleware/utils/getString.js b/app/middleware/utils/getString.js new file mode 100644 index 0000000..89ab003 --- /dev/null +++ b/app/middleware/utils/getString.js @@ -0,0 +1,10 @@ +// 截取数组元素,拼接成字符串并返回 +module.exports = (arr, start, end) => { + let newString = ''; + arr.forEach((element, index) => { + if (index >= start && index <= end) { + newString = newString + element; + } + }); + return newString; +}; \ No newline at end of file diff --git a/app/middleware/utils/getTimes.js b/app/middleware/utils/getTimes.js new file mode 100644 index 0000000..2be633d --- /dev/null +++ b/app/middleware/utils/getTimes.js @@ -0,0 +1,13 @@ +// 返回时间对象 +module.exports = () => { + let now = new Date(), + times = { + year: now.getFullYear(), + month: now.getMonth() + 1, + day: now.getDate(), + hour: now.getHours(), + minute: now.getMinutes(), + second: now.getSeconds() + }; + return times; +}; \ No newline at end of file diff --git a/app/middleware/utils/hexToBinary.js b/app/middleware/utils/hexToBinary.js new file mode 100644 index 0000000..6feb181 --- /dev/null +++ b/app/middleware/utils/hexToBinary.js @@ -0,0 +1,15 @@ +// 十六进制转二进制 +module.exports = (hex) => { + let hexChars = '0123456789ABCDEF'; + let binaryString = ''; + for (let i = 0; i < hex.length; i++) { + let hexIndex = hexChars.indexOf(hex[i].toUpperCase()); + let binaryDigit = hexIndex.toString(2); + // 确保每个十六进制数字转换为四位二进制数字 + while (binaryDigit.length < 4) { + binaryDigit = '0' + binaryDigit; + } + binaryString += binaryDigit; + } + return binaryString; +}; \ No newline at end of file diff --git a/app/middleware/utils/intrinsic.js b/app/middleware/utils/intrinsic.js new file mode 100644 index 0000000..2db8c15 --- /dev/null +++ b/app/middleware/utils/intrinsic.js @@ -0,0 +1,8 @@ +module.exports = { + // 数据包最后固定十六进制串作为TCP流的分隔识别符 + separateIdentifiers: '7878787888888888', + // 心跳检测信息固定格式 + heart: 'e5bf83e8b7b37878787888888888', + // 包序号,从0开始,随程序运行变大 + packageNumber: 0, +}; \ No newline at end of file diff --git a/app/middleware/utils/log.js b/app/middleware/utils/log.js new file mode 100644 index 0000000..6d7323a --- /dev/null +++ b/app/middleware/utils/log.js @@ -0,0 +1,72 @@ +// 错误日志 +const fs = require('fs'); +const os = require('os'); +const path = require('path'); + +const dirCheck = (dirPath) => { + // 检查文件夹是否存在 + fs.access(dirPath, fs.constants.F_OK, (err) => { + if (err) { + // 文件夹不存在 + console.log('文件夹不存在,正在创建...'); + fs.mkdir(dirPath, { recursive: true }, (err) => { + if (err) throw err; + console.log('文件夹已创建'); + }); + } else { + // 文件夹存在 + console.log('文件夹已存在'); + } + }); +} + +module.exports = (filePath, msg) => { + // 获取时间 + let now = new Date(), + times = { + year: now.getFullYear(), + month: now.getMonth() + 1, + day: now.getDate(), + hour: now.getHours(), + minute: now.getMinutes(), + second: now.getSeconds() + }; + // 获取操作系统类型 + const type = os.type(); + console.log(`操作系统类型: ${type}`); + filePath = path.join(__dirname, filePath); + dirCheck(filePath); + const yearPath = filePath + '/' + times.year; + dirCheck(yearPath); + const monthPath = yearPath + '/' + times.month; + dirCheck(monthPath); + const dayPath = monthPath + '/' + times.day + '.txt'; + const logTime = '[' + times.year + '-' + times.month + '-' + times.day + '>>>' + times.hour + ':' + times.minute + ':' + times.second + ']' + '>>>'; + let crlf; + // 判断操作系统类型,设置换行符 + if (type === 'Windows_NT') { + crlf = '\n'; + } else { + crlf = '\r\n'; + } + // 读取文件内容 + fs.readFile(dayPath, 'utf8', (err, data) => { + if (err) { + if (err.code === 'ENOENT') { + // 文件不存在,直接写入新内容(这里实际上还是使用了覆盖的方式) + fs.writeFile(dayPath, logTime + msg + crlf, (err) => { + if (err) throw err; + console.log('文件已创建并写入新内容'); + }); + } else { + throw err; + } + } else { + // 文件存在,追加新内容 + fs.appendFile(dayPath, logTime + msg + crlf, (err) => { + if (err) throw err; + console.log('新内容已追加到文件'); + }); + } + }); +}; \ No newline at end of file diff --git a/app/middleware/utils/packageItem.js b/app/middleware/utils/packageItem.js new file mode 100644 index 0000000..dd6a291 --- /dev/null +++ b/app/middleware/utils/packageItem.js @@ -0,0 +1,8 @@ +// 判断十六进制数据的长度,若长度不满足条件,则在左侧补0,直至长度满足条件 +module.exports = (length, data) => { + let item = data.toString(16); + for (let i = 0; i < (length * 2) - data.toString(16).length; i++) { + item = '0' + item; + } + return item; +}; \ No newline at end of file diff --git a/app/middleware/webSocket/webSocketServer.js b/app/middleware/webSocket/webSocketServer.js new file mode 100644 index 0000000..3e6e149 --- /dev/null +++ b/app/middleware/webSocket/webSocketServer.js @@ -0,0 +1,47 @@ +// webSocket服务端 +const http = require('http'); +const { Server } = require('socket.io'); + +module.exports = (app) => { + // 创建HTTP服务器并监听8010端口 + const server = http.createServer(function (req, res) { + if (req.url === '/') { + res.writeHead(200, {'Content-Type': 'text/plain'}); + res.end('Hello World!'); + } + }).listen(app.config.webSocketServer.port); + + let io = new Server(server, { + cors: { + origin: "http://127.0.0.1", // 生产环境应指定具体域名 + methods: ["GET", "POST"] + }, + // path: app.config.webSocketServer.path, + transports: ['websocket', 'polling'], + connectionStateRecovery: {} + }); + + console.log(`websocket: ${ app.config.webSocketServer.ip }服务器已启动,监听端口:${ app.config.webSocketServer.port }`); + + const socketEmitter = app.middleware.shunt.socketEmitter(); + const utils = app.middleware.utils; + + io.on('connection', (socket) => { + socket.on('message', (cardID) => { + if(socketEmitter.listeners(cardID).length !== 0) { + socketEmitter.removeAllListeners(cardID); + }; + socketEmitter.on(cardID, (msg) => { + socket.emit(cardID, msg); + }); + }); + }); + + io.on('error', (err) => { + utils.log('../../webSocketLog', err); + io = new Server(app.config.webSocketServer.port, { + cors: true, + connectionStateRecovery: {} + }); + }); +}; \ No newline at end of file diff --git a/app/model/BShortMsg.js b/app/model/BShortMsg.js new file mode 100644 index 0000000..0a7cee8 --- /dev/null +++ b/app/model/BShortMsg.js @@ -0,0 +1,24 @@ +'use strict'; + +module.exports = (app) => { + const { INTEGER, CHAR, TEXT, DATE } = app.Sequelize; + + const BShortMsg = app.model.define('bshort-msg', { + id: { type: INTEGER(11), primaryKey: true, autoIncrement: true }, + user_uid: CHAR(15), + card_id: CHAR(8), + receiver_address: CHAR(8), + original_msg: TEXT, + send_type: INTEGER(1), + encode_type: INTEGER(1), + msg_data: TEXT, + created_at: DATE, + },{ + freezeTableName: true, + timestamp: true, + createdAt: true, + updatedAt: false, + }); + + return BShortMsg; +}; \ No newline at end of file diff --git a/app/model/BSide.js b/app/model/BSide.js new file mode 100644 index 0000000..726431c --- /dev/null +++ b/app/model/BSide.js @@ -0,0 +1,30 @@ +'use strict'; + +module.exports = (app) => { + const { INTEGER, CHAR, STRING, DATE } = app.Sequelize; + + const BSide = app.model.define('b-side', { + id: { type: INTEGER(8), primaryKey: true, autoIncrement: true }, + uid: CHAR(15), + salt: CHAR(24), + status: INTEGER(3), + role: INTEGER(3), + account_name: STRING(20), + password: CHAR(64), + organization: CHAR(16), + user_name: STRING(20), + phone: CHAR(11), + msg: STRING(300), + created_at: DATE, + updated_at: DATE, + login_at: DATE, + login_status: INTEGER(3) + },{ + freezeTableName: true, + timestamp: true, + createdAt: true, + updatedAt: true, + }); + + return BSide; +}; \ No newline at end of file diff --git a/app/model/BindBrecord.js b/app/model/BindBrecord.js new file mode 100644 index 0000000..a9e5cad --- /dev/null +++ b/app/model/BindBrecord.js @@ -0,0 +1,20 @@ +'use strict'; + +module.exports = (app) => { + const { INTEGER, CHAR, DATE } = app.Sequelize; + + const BindBrecord = app.model.define('bind-brecord', { + id: { type: INTEGER(11), primaryKey: true, autoIncrement: true }, + user_uid: CHAR(15), + card_id: CHAR(8), + type: INTEGER(1), + created_at: DATE, + },{ + freezeTableName: true, + timestamp: true, + createdAt: true, + updatedAt: false, + }); + + return BindBrecord; +}; \ No newline at end of file diff --git a/app/model/BuserBind.js b/app/model/BuserBind.js new file mode 100644 index 0000000..86bc0f2 --- /dev/null +++ b/app/model/BuserBind.js @@ -0,0 +1,18 @@ +'use strict'; + +module.exports = (app) => { + const { INTEGER, CHAR } = app.Sequelize; + + const BuserBind = app.model.define('buser-bind', { + id: { type: INTEGER(8), primaryKey: true, autoIncrement: true }, + card_id: CHAR(8), + user_uid: CHAR(15), + },{ + freezeTableName: true, + timestamp: false, + createdAt: false, + updatedAt: false, + }); + + return BuserBind; +}; \ No newline at end of file diff --git a/app/model2/BindCrecord.js b/app/model2/BindCrecord.js new file mode 100644 index 0000000..f12dfa3 --- /dev/null +++ b/app/model2/BindCrecord.js @@ -0,0 +1,20 @@ +'use strict'; + +module.exports = (app) => { + const { INTEGER, CHAR, DATE } = app.Sequelize; + + const BindCrecord = app.model2.define('bind-crecord', { + id: { type: INTEGER(11), primaryKey: true, autoIncrement: true }, + user_uid: CHAR(15), + card_id: CHAR(8), + type: INTEGER(1), + created_at: DATE, + },{ + freezeTableName: true, + timestamp: true, + createdAt: true, + updatedAt: false, + }); + + return BindCrecord; +}; \ No newline at end of file diff --git a/app/model2/CShortMsg.js b/app/model2/CShortMsg.js new file mode 100644 index 0000000..ddc4dc3 --- /dev/null +++ b/app/model2/CShortMsg.js @@ -0,0 +1,24 @@ +'use strict'; + +module.exports = (app) => { + const { INTEGER, CHAR, TEXT, DATE } = app.Sequelize; + + const CShortMsg = app.model2.define('cshort-msg', { + id: { type: INTEGER(11), primaryKey: true, autoIncrement: true }, + user_uid: CHAR(15), + card_id: CHAR(8), + receiver_address: CHAR(8), + original_msg: TEXT, + send_type: INTEGER(1), + encode_type: INTEGER(1), + msg_data: TEXT, + created_at: DATE, + },{ + freezeTableName: true, + timestamp: true, + createdAt: true, + updatedAt: false, + }); + + return CShortMsg; +}; \ No newline at end of file diff --git a/app/model2/CSide.js b/app/model2/CSide.js new file mode 100644 index 0000000..373eec9 --- /dev/null +++ b/app/model2/CSide.js @@ -0,0 +1,34 @@ +'use strict'; + +module.exports = (app) => { + const { INTEGER, CHAR, STRING, DATE } = app.Sequelize; + + const CSide = app.model2.define('c-side', { + id: { type: INTEGER(8), primaryKey: true, autoIncrement: true }, + uid: CHAR(15), + salt: CHAR(24), + status: INTEGER(3), + role: INTEGER(3), + avatar: CHAR(15), + account_name: STRING(20), + password: CHAR(64), + user_name: STRING(20), + phone: CHAR(11), + gender: INTEGER(1), + age: INTEGER(3), + email: STRING(254), + address: STRING(300), + post_code: CHAR(6), + created_at: DATE, + updated_at: DATE, + login_at: DATE, + login_status: INTEGER(3) + },{ + freezeTableName: true, + timestamp: true, + createdAt: true, + updatedAt: true, + }); + + return CSide; +}; \ No newline at end of file diff --git a/app/model2/CuserBind.js b/app/model2/CuserBind.js new file mode 100644 index 0000000..dab636a --- /dev/null +++ b/app/model2/CuserBind.js @@ -0,0 +1,18 @@ +'use strict'; + +module.exports = (app) => { + const { INTEGER, CHAR } = app.Sequelize; + + const CuserBind = app.model2.define('cuser-bind', { + id: { type: INTEGER(8), primaryKey: true, autoIncrement: true }, + user_uid: CHAR(15), + card_id: CHAR(8), + },{ + freezeTableName: true, + timestamp: false, + createdAt: false, + updatedAt: false, + }); + + return CuserBind; +}; \ No newline at end of file diff --git a/app/model3/BDCard.js b/app/model3/BDCard.js new file mode 100644 index 0000000..414352d --- /dev/null +++ b/app/model3/BDCard.js @@ -0,0 +1,22 @@ +'use strict'; + +module.exports = (app) => { + const { INTEGER, CHAR, DATE } = app.Sequelize; + + const BDCard = app.model3.define('bd-card', { + id: { type: INTEGER(8), primaryKey: true, autoIncrement: true }, + card_id: CHAR(8), + card_imsi: CHAR(18), + type: INTEGER(3), + status: INTEGER(3), + created_at: DATE, + updated_at: DATE, + },{ + freezeTableName: true, + timestamp: true, + createdAt: true, + updatedAt: true, + }); + + return BDCard; +}; \ No newline at end of file diff --git a/app/model4/Account.js b/app/model4/Account.js new file mode 100644 index 0000000..1aaf39b --- /dev/null +++ b/app/model4/Account.js @@ -0,0 +1,24 @@ +'use strict'; + +module.exports = (app) => { + const { INTEGER, CHAR, STRING, DATE } = app.Sequelize; + + const Account = app.model4.define('account', { + id: { type: INTEGER(8), primaryKey: true, autoIncrement: true }, + uid: CHAR(15), + salt: CHAR(24), + contest_uid: CHAR(15), + account_name: STRING(20), + password: CHAR(64), + status: INTEGER(3), + created_at: DATE, + login_status: INTEGER(3) + },{ + freezeTableName: true, + timestamp: true, + createdAt: true, + updatedAt: false, + }); + + return Account; +}; \ No newline at end of file diff --git a/app/model4/TShortMsg.js b/app/model4/TShortMsg.js new file mode 100644 index 0000000..ae1d7a7 --- /dev/null +++ b/app/model4/TShortMsg.js @@ -0,0 +1,24 @@ +'use strict'; + +module.exports = (app) => { + const { INTEGER, CHAR, TEXT, DATE } = app.Sequelize; + + const TShortMsg = app.model4.define('tshort-msg', { + id: { type: INTEGER(8), primaryKey: true, autoIncrement: true }, + user_uid: CHAR(15), + card_id: CHAR(8), + receiver_address: CHAR(8), + original_msg: TEXT, + send_type: INTEGER(1), + encode_type: INTEGER(1), + msg_data: TEXT, + created_at: DATE, + },{ + freezeTableName: true, + timestamp: true, + createdAt: true, + updatedAt: false, + }); + + return TShortMsg; +}; \ No newline at end of file diff --git a/app/model4/TuserBind.js b/app/model4/TuserBind.js new file mode 100644 index 0000000..97a9f1c --- /dev/null +++ b/app/model4/TuserBind.js @@ -0,0 +1,18 @@ +'use strict'; + +module.exports = (app) => { + const { INTEGER, CHAR } = app.Sequelize; + + const TuserBind = app.model4.define('tuser-bind', { + id: { type: INTEGER(8), primaryKey: true, autoIncrement: true }, + card_id: CHAR(8), + user_uid: CHAR(15), + },{ + freezeTableName: true, + timestamp: false, + createdAt: false, + updatedAt: false, + }); + + return TuserBind; +}; \ No newline at end of file diff --git a/app/router.js b/app/router.js new file mode 100644 index 0000000..2e2d349 --- /dev/null +++ b/app/router.js @@ -0,0 +1,41 @@ +/** + * @param {Egg.Application} app - egg application +*/ + +// const { Server } = require('socket.io'); + +// const net = require('net'); + +// const EventEmitter = require('events'); + +module.exports = app => { + const { router, controller, middleware } = app; + + setTimeout(() => { + // 启动socket客户端 + middleware.socket.socketClient(app); + // 启动webSocket服务端 + middleware.webSocket.webSocketServer(app); + }, 10000); + + // 获取卡号 + router.post('/getCard', controller.home.getCard); + // 搜索卡号 + router.post('/searchCard', controller.home.searchCard); + // 绑卡 + router.post('/bindCard', controller.home.bindCard); + // 解绑 + router.post('/unBindingCard', controller.home.unBindingCard); + // B端单位管理员解绑 + router.post('/unBindManager', controller.home.unBindManager); + // 获取绑定记录 + router.post('/getRecord', controller.home.getRecord); + // 存储消息记录 + router.post('/shortMsg', controller.home.shortMsg); + // 获取历史消息 + router.post('/getHistoryMsg', controller.home.getHistoryMsg); + // 删除历史消息 + router.post('/delHistoryMsg', controller.home.delHistoryMsg); + // 获取单位用户 + router.post('/bsideManager', controller.home.bsideManager); +}; diff --git a/app/service/home.js b/app/service/home.js new file mode 100644 index 0000000..46f9ecf --- /dev/null +++ b/app/service/home.js @@ -0,0 +1,403 @@ +'use strict'; + +const Service = require('../core/base_service'); + +const { Op } = require('sequelize'); + +const shunt = (uid) => { + return uid[uid.length - 1]; +}; + +const fileName = 'home'; + +class HomeService extends Service { + // 获取卡号 + async getCard(uid) { + const { ctx } = this; + try { + const where = { user_uid: uid }; + const uidLastCode = shunt(uid); + const model = { + "B": ctx.model.BuserBind, + "C": ctx.model2.CuserBind, + "T": ctx.model4.TuserBind, + }; + const result = await model[uidLastCode].findOne({ where }); + return result || false; + } catch (error) { + const blockName = fileName + "--" + "getCard"; + ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error); + return 'error'; + } + } + + // 搜索卡号 + async searchCard(cardID) { + const { ctx } = this; + try { + const where = { card_id: cardID }; + const result = await ctx.model3.BDCard.findOne({ where }); + return result || false; + } catch (error) { + const blockName = fileName + "--" + "searchCard"; + ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error); + return 'error'; + } + } + + // 绑卡 + async bindCard(uid, body) { + const { ctx } = this; + try { + const { cardID, IMSI } = body; + const where = { + card_id: cardID, + card_imsi: IMSI + }; + const status = shunt(uid) == 'B' ? 1 : 2; + const defaults = { + card_id: cardID, + card_imsi: IMSI, + type: 0, + status, + created_at: new Date(), + updated_at: new Date() + }; + const [card] = await ctx.model3.BDCard.findOrCreate({ where, defaults }); + const model = { + "B": ctx.model.BuserBind, + "C": ctx.model2.CuserBind, + "T": ctx.model4.TuserBind + }; + const uidLastCode = shunt(uid); + const bindCheck = await model[uidLastCode].findOne({ where: { user_uid: uid } }); + if (card.status !== 0 || bindCheck.value) { + return false; + } else { + const cardResult = await ctx.model3.BDCard.update({ status }, { where }); + const bindForm = { + user_uid: uid, + card_id: cardID + }; + const resultForm = { + user_uid: uid, + card_id: cardID, + type: 1, + created_at: new Date() + }; + const modelName = { + "B": ctx.model.BindBrecord, + "C": ctx.model2.BindCrecord + }; + const bindResult = await model[uidLastCode].create(bindForm); + const recordResult = await modelName[uidLastCode].create(resultForm); + return cardResult[0] && bindResult && recordResult ? true : false; + } + } catch (error) { + const blockName = fileName + "--" + "bindCard"; + ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error); + return 'error'; + } + } + + // 解绑 + async unBindingCard(uid, body) { + const { ctx } = this; + try { + const { cardID, IMSI } = body; + const cardWhere = { + card_id: cardID, + card_imsi: IMSI + }; + const cardResult = await ctx.model3.BDCard.update({ status: 0 }, { where: cardWhere }); + if (cardResult[0] !== 0) { + const where = { + user_uid: uid, + card_id: cardID + }; + const form = { + user_uid: uid, + card_id: cardID, + type: 0, + created_at: new Date() + }; + const uidLastCode = shunt(uid); + const model = { + "B": ctx.model.BuserBind, + "C": ctx.model2.CuserBind, + }; + const modelName = { + "B": ctx.model.BindBrecord, + "C": ctx.model2.BindCrecord + }; + const bindResult = await model[uidLastCode].destroy({ where }); + const recordResult = await modelName[uidLastCode].create(form); + return bindResult && recordResult ? true : false; + } else { + return false; + } + } catch (error) { + const blockName = fileName + "--" + "unBindingCard"; + ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error); + return 'error'; + } + } + + // B端单位管理员解绑 + async unBindManager(uid, modelType, password, requestMsg) { + const { ctx } = this; + try { + const result = await ctx.model.BSide.findOne({ where: { uid, status: { [Op.not]: 2 }, role: 1 } }); + if (!result || result.dataValues.password !== this.shaForm(password, this.decryptRequest(result.dataValues.salt))) return false; + let where = {}; + let attributes = ['uid']; + if (modelType == "single") { + where = requestMsg; + } else if (modelType == "multiple") { + let account_name = [], user_name = [], phone = []; + for (const key in requestMsg) { + requestMsg[key].forEach(element => { + account_name.push(element.account_name), + user_name.push(element.user_name), + phone.push(element.phone) + }); + } + where = { account_name, user_name, phone }; + } else if (modelType == "all") { + const role = { [Op.not]: 1 }; + where = { organization: result.dataValues.organization, role }; + } + + const userResult = await ctx.model.BSide.findAll({ attributes, where }); + if (!userResult[0]) return false; + let user_uid = []; + userResult.forEach(element => { + user_uid.push(element.dataValues.uid); + }); + attributes = ['card_id']; + where = { user_uid }; + const bindResult = await ctx.model.BuserBind.findAll({ attributes, where }); + if (!bindResult[0]) return false; + let card_id = [], recordForm = []; + bindResult.forEach((element, index) => { + card_id.push(element.dataValues.card_id); + recordForm.push({ user_uid: user_uid[index], card_id: card_id[index], type: 0, created_at: new Date() }); + }); + where = { user_uid, card_id }; + const unbindResult = await ctx.model.BuserBind.destroy({ where }); + const recordResult = await ctx.model.BindBrecord.bulkCreate(recordForm); + where = { card_id }; + const cardResult = await ctx.model3.BDCard.update({ status: 0 }, { where }); + return unbindResult !== 0 && recordResult[0] && cardResult[0] !== 0 ? true : false; + } catch (error) { + const blockName = fileName + "--" + "unBindManager"; + ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error); + return 'error'; + } + } + + // 获取绑定记录 + async getRecord(uid, body) { + const { ctx } = this; + try { + let { offset, limit, searchOptions, sortOptions } = body; + offset = (offset - 1) * limit; + let attributes = ['card_id', 'type', 'created_at'], + where = { user_uid: uid }, order = [], dbOptions, joinSubstring = [], + substring = ['card_id'], key = ['type'], between = ['created_at']; + const uidLastCode = shunt(uid); + attributes.forEach(element => { + if (searchOptions[element]) { + if(searchOptions[element] == '*空') { + if(joinSubstring.includes(element)) { + where[element] = null; + } else { + where[element] = [null, '']; + } + } else if(substring.includes(element)) { + where[element] = { [Op.substring]: searchOptions[element] }; + } else if (key.includes(element)) { + where[element] = searchOptions[element] == "1" ? uidLastCode === 'B' ? 1 : 2 : 0; + } else if (between.includes(element)) { + where[element] = { [Op.between]: [searchOptions[element][0], searchOptions[element][1]] }; + } + } + if (sortOptions[element] == true) { + order.push([element, 'ASC']); + } else if (sortOptions[element] == false) { + order.push([element, 'DESC']); + } + }); + dbOptions = { attributes, offset, limit, where, order }; + const model = { + "B": ctx.model.BindBrecord, + "C": ctx.model2.BindCrecord, + }; + const result = await model[uidLastCode].findAndCountAll(dbOptions); + return result.rows.length == 0 ? false : result; + } catch (error) { + const blockName = fileName + "--" + "getRecord"; + ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error); + return 'error'; + } + } + + // 存储消息记录 + async shortMsg(form) { + const { ctx } = this; + try { + const where = { card_id: form.card_id }; + const card = await ctx.model3.BDCard.findOne({ where }); + if (!card) { + ctx.app.middleware.utils.log('../../../unknownCardLog', form); + return false; + }; + const model = { + 1: ctx.model.BuserBind, + 2: ctx.model2.CuserBind, + 3: ctx.model4.TuserBind, + }; + const bind = await model[card.dataValues.status].findOne({ where }); + if (!bind) return false; + form.user_uid = bind.dataValues.user_uid; + const uidLastCode = shunt(form.user_uid); + const modelName = { + "B": ctx.model.BShortMsg, + "C": ctx.model2.CShortMsg, + "T": ctx.model4.TShortMsg, + }; + const result = await modelName[uidLastCode].create(form); + return result || false; + } catch (error) { + const blockName = fileName + "--" + "shortMsg"; + ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error); + return 'error'; + } + } + + // 获取历史消息 + async getHistoryMsg(uid, body) { + const { ctx } = this; + try { + let { offset, limit, searchOptions, sortOptions } = body; + offset = (offset - 1) * limit; + let attributes = ['card_id', 'encode_type', 'msg_data', 'created_at'], + where = { user_uid: uid }, order = [], dbOptions, joinSubstring = [], + substring = ['card_id', 'msg_data'], key = ['encode_type'], between = ['created_at']; + attributes.forEach(element => { + if (searchOptions[element]) { + if(searchOptions[element] == '*空') { + if(joinSubstring.includes(element)) { + where[element] = null; + } else { + where[element] = [null, '']; + } + } else if (substring.includes(element)) { + where[element] = { [Op.substring]: searchOptions[element] }; + } else if (key.includes(element)) { + where[element] = searchOptions[element] == "1" ? true : false; + } else if (between.includes(element)) { + where[element] = { [Op.between]: [searchOptions[element][0], searchOptions[element][1]] }; + } + } + if (sortOptions[element] == true) { + order.push([element, 'ASC']); + } else if (sortOptions[element] == false) { + order.push([element, 'DESC']); + } + }); + dbOptions = { attributes, offset, limit, where, order }; + const uidLastCode = shunt(uid); + const model = { + "B": ctx.model.BShortMsg, + "C": ctx.model2.CShortMsg, + "T": ctx.model4.TShortMsg, + }; + const result = await model[uidLastCode].findAndCountAll(dbOptions); + return result.rows.length == 0 ? false : result; + } catch (error) { + const blockName = fileName + "--" + "getHistoryMsg"; + ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error); + return 'error'; + } + } + + // 删除历史消息 + async delHistoryMsg(uid, modelType, password, requestMsg) { + const { ctx } = this; + try { + const uidLastCode = shunt(uid); + const model = { + "B": ctx.model.BSide, + "C": ctx.model2.CSide, + "T": ctx.model4.Account, + }; + const result = await model[uidLastCode].findOne({ where: { uid } }); + if (!result || result.dataValues.password !== this.shaForm(password, this.decryptRequest(result.dataValues.salt))) return false; + let where = {}; + if (modelType == "single") { + const { card_id, encode_type, msg_data, origin_time } = requestMsg; + where = { user_uid: uid, card_id, encode_type, msg_data, created_at: origin_time }; + } else if (modelType == "multiple") { + let card_id = [], encode_type = [], msg_data = [], created_at = []; + for (const key in requestMsg) { + requestMsg[key].forEach(element => { + card_id.push(element.card_id), + encode_type.push(element.encode_type), + msg_data.push(element.msg_data), + created_at.push(element.origin_time) + }); + } + where = { user_uid: uid, card_id, encode_type, msg_data, created_at }; + } else if (modelType == "all") { + where = { user_uid: uid }; + } + const modelName = { + "B": ctx.model.BShortMsg, + "C": ctx.model2.CShortMsg, + "T": ctx.model4.TShortMsg, + }; + const resetList = await modelName[uidLastCode].destroy({ where }); + return resetList.length == 0 ? false : resetList; + } catch (error) { + const blockName = fileName + "--" + "delHistoryMsg"; + ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error); + return 'error'; + } + } + + // 获取单位用户 + async bsideManager(uid, body) { + const { ctx } = this; + try { + const result = await ctx.model.BSide.findOne({ where: { uid, status: { [Op.not]: 2 }, role: 1 } }); + if (!result || result.organization == null) return false; + let { offset, limit, searchOptions } = body; + offset = (offset - 1) * limit; + let attributes = ['account_name', 'user_name', 'phone'], + where = { organization: result.organization, role: { [Op.not]: 1 } }, dbOptions, joinSubstring = []; + attributes.forEach(element => { + if (searchOptions[element]) { + if(searchOptions[element] == '*空') { + if(joinSubstring.includes(element)) { + where[element] = null; + } else { + where[element] = [null, '']; + } + } else{ + where[element] = { [Op.substring]: searchOptions[element] }; + } + } + }); + dbOptions = { attributes, offset, limit, where }; + const userList = await ctx.model.BSide.findAndCountAll(dbOptions); + return userList.rows.length == 0 ? false : userList; + } catch (error) { + const blockName = fileName + "--" + "bsideManager"; + ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error); + return 'error'; + } + } +} + +module.exports = HomeService; \ No newline at end of file diff --git a/config/config.default.js b/config/config.default.js new file mode 100644 index 0000000..d8fcab5 --- /dev/null +++ b/config/config.default.js @@ -0,0 +1,243 @@ +/* eslint valid-jsdoc: "off" */ + +/** + * @param {Egg.EggAppInfo} appInfo app info + */ + +const process = require('process'), + path = require('path'); + +module.exports = appInfo => { + /** + * built-in config + * @type {Egg.EggAppConfig} + **/ + const config = exports = {}; + + // use for cookie sign key, should change to your own and keep security + config.keys = appInfo.name + '_1715070366856_4575'; + + // add your middleware config here + // config.middleware = [] + + // 修改Egg.js的public路径配置到运行路径下 + config.static = { + prefix: '/', + dir: process.cwd() + '/public', + }; + + // 配置执行时临时文件的路径到运行路径 + config.rundir = process.cwd() + '/run'; + + // 配置普通日志文件地址 + config.logger = { + dir: path.join(process.cwd(), 'logs'), + }; + + // 配置定时任务日志文件地址 + config.customLogger = { + scheduleLogger: { + file: path.join(process.cwd(), 'logs', 'egg-schedule.log'), + }, + }; + + config.security = { + csrf: { + enable: false + }, + }; + + // socket客户端配置 + // 开发/测试环境 + config.socketClient = { + ip: '127.0.0.1', + port: 9004, + // id即信源 + id: 989, + destination: 20, + token: '8613987248fdba01f8fb0e7aa0423ca5' + }; + // 生产环境 + // config.socketClient = { + // ip: '36.110.64.122', + // port: 9004, + // // id即信源 + // id: 989, + // destination: 20, + // token: '8613987248fdba01f8fb0e7aa0423ca5' + // }; + + // webSocket服务端配置 + config.webSocketServer = { + ip: '127.0.0.1', + port: 8010, + // path: '/bdShortMessage/' + // path: '/bdrdWebSocket/' + path: '/socket.io/' + }; + + config.redis = { + // 开发/测试环境 + clients: { + db0: { + port: 6379, + host: '127.0.0.1', + password: '74191221', + db: 0, + }, + db1: { + port: 6379, + host: '127.0.0.1', + password: '74191221', + db: 1, + }, + db2: { + port: 6379, + host: '127.0.0.1', + password: '74191221', + db: 2, + }, + db3: { + port: 6379, + host: '127.0.0.1', + password: '74191221', + db: 3, + }, + db5: { + port: 6379, + host: '127.0.0.1', + password: '74191221', + db: 5, + }, + } + // 生产环境 + // clients: { + // db0: { + // port: 6379, + // host: '127.0.0.1', + // password: 'bd3@htcc2023', + // db: 2, + // }, + // db1: { + // port: 6379, + // host: '127.0.0.1', + // password: 'bd3@htcc2023', + // db: 3, + // }, + // db2: { + // port: 6379, + // host: '127.0.0.1', + // password: 'bd3@htcc2023', + // db: 4, + // }, + // db3: { + // port: 6379, + // host: '127.0.0.1', + // password: 'bd3@htcc2023', + // db: 5, + // } + // db5: { + // port: 6379, + // host: '127.0.0.1', + // password: 'bd3@htcc2023', + // db: 7, + // }, + // } + }; + + config.sequelize = { + // 开发/测试环境 + datasources: [ + { + dialect: 'mariadb', + host: 'localhost', + port: 3306, + username: 'root', + password: '74191221', + database: 'bside', + }, + { + dialect: 'mariadb', + host: 'localhost', + port: 3306, + username: 'root', + password: '74191221', + database: 'cside', + delegate: 'model2', + baseDir: 'model2', + }, + { + dialect: 'mariadb', + host: 'localhost', + port: 3306, + username: 'root', + password: '74191221', + database: 'insiders', + delegate: 'model3', + baseDir: 'model3', + }, + { + dialect: 'mariadb', + host: 'localhost', + port: 3306, + username: 'root', + password: '74191221', + database: 'bdContest', + delegate: 'model4', + baseDir: 'model4', + } + ] + // 生产环境 + // datasources: [ + // { + // dialect: 'mariadb', + // host: 'localhost', + // port: 3306, + // username: 'bdqh_platform', + // password: '124689@XXxx', + // database: 'bside', + // }, + // { + // dialect: 'mariadb', + // host: 'localhost', + // port: 3306, + // username: 'bdqh_platform', + // password: '124689@XXxx', + // database: 'cside', + // delegate: 'model2', + // baseDir: 'model2', + // }, + // { + // dialect: 'mariadb', + // host: 'localhost', + // port: 3306, + // username: 'bdqh_platform', + // password: '124689@XXxx', + // database: 'insiders', + // delegate: 'model3', + // baseDir: 'model3', + // }, + // { + // dialect: 'mariadb', + // host: 'localhost', + // port: 3306, + // username: 'bdqh_platform', + // password: '124689@XXxx', + // database: 'bdContest', + // delegate: 'model4', + // baseDir: 'model4', + // } + // ] + }; + + // add your user config here + const userConfig = { + // myAppName: 'egg', + salt: 'shortMessage' + }; + + return { + ...config, + ...userConfig, + }; +}; diff --git a/config/config.test.js b/config/config.test.js new file mode 100644 index 0000000..b09d8d7 --- /dev/null +++ b/config/config.test.js @@ -0,0 +1,140 @@ +/* eslint valid-jsdoc: "off" */ + +/** + * @param {Egg.EggAppInfo} appInfo app info + */ + +const process = require('process'), + path = require('path'); + +module.exports = appInfo => { + /** + * built-in config + * @type {Egg.EggAppConfig} + **/ + const config = exports = {}; + + // use for cookie sign key, should change to your own and keep security + config.keys = appInfo.name + '_1715070366856_4575'; + + // add your middleware config here + // config.middleware = [] + + // 修改Egg.js的public路径配置到运行路径下 + config.static = { + prefix: '/', + dir: process.cwd() + '/public', + }; + + // 配置执行时临时文件的路径到运行路径 + config.rundir = process.cwd() + '/run'; + + // 配置普通日志文件地址 + config.logger = { + dir: path.join(process.cwd(), 'logs'), + }; + + // 配置定时任务日志文件地址 + config.customLogger = { + scheduleLogger: { + file: path.join(process.cwd(), 'logs', 'egg-schedule.log'), + }, + }; + + config.security = { + csrf: { + enable: false + }, + }; + + // socket客户端配置 + config.socketClient = { + port: 9004, + ip: '127.0.0.1', + // id即信源 + id: 989, + destination: 20, + token: '8613987248fdba01f8fb0e7aa0423ca5' + }; + + // webSocket服务端配置 + config.webSocketServer = { + port: 8010, + ip: '127.0.0.1' + }; + + config.redis = { + // 开发/测试环境 + clients: { + db0: { + port: 6379, + host: '127.0.0.1', + password: '74191221', + db: 0, + }, + db1: { + port: 6379, + host: '127.0.0.1', + password: '74191221', + db: 1, + }, + db2: { + port: 6379, + host: '127.0.0.1', + password: '74191221', + db: 2, + }, + db3: { + port: 6379, + host: '127.0.0.1', + password: '74191221', + db: 3, + } + } + }; + + config.sequelize = { + // 开发/测试环境 + datasources: [ + { + dialect: 'mariadb', + host: 'localhost', + port: 3306, + username: 'root', + password: '74191221', + database: 'bside', + }, + { + dialect: 'mariadb', + host: 'localhost', + port: 3306, + username: 'root', + password: '74191221', + database: 'cside', + delegate: 'model2', + baseDir: 'model2', + }, + { + dialect: 'mariadb', + host: 'localhost', + port: 3306, + username: 'root', + password: '74191221', + database: 'insiders', + delegate: 'model3', + baseDir: 'model3', + } + ] + }; + + // add your user config here + const userConfig = { + // myAppName: 'egg', + salt: 'shortMessage' + }; + + return { + ...config, + ...userConfig, + }; +}; \ No newline at end of file diff --git a/config/env b/config/env new file mode 100644 index 0000000..c23f7a8 --- /dev/null +++ b/config/env @@ -0,0 +1 @@ +prod \ No newline at end of file diff --git a/config/plugin.js b/config/plugin.js new file mode 100644 index 0000000..47d52b6 --- /dev/null +++ b/config/plugin.js @@ -0,0 +1,27 @@ +/** @type Egg.EggPlugin */ +module.exports = { + // had enabled by egg + // static: { + // enable: true, + // } + + CryptoJS : { + enable: true, + package: 'crypto-js', + }, + + redis : { + enable: true, + package: 'egg-redis', + }, + + sequelize : { + enable: true, + package: 'egg-sequelize', + }, + + validate : { + enable: true, + package: 'egg-validate', + }, +}; diff --git a/controllerLog/2024/10/17.txt b/controllerLog/2024/10/17.txt new file mode 100644 index 0000000..3bb8c5d --- /dev/null +++ b/controllerLog/2024/10/17.txt @@ -0,0 +1,5 @@ +[2024-10-17>>>11:45:17]>>>home--bsideManager>>>>TypeError: result.forEach is not a function +[2024-10-17>>>11:46:24]>>>home--bsideManager>>>>TypeError: result.forEach is not a function +[2024-10-17>>>11:46:24]>>>home--bsideManager>>>>TypeError: result.forEach is not a function +[2024-10-17>>>11:48:10]>>>home--bsideManager>>>>TypeError: result.forEach is not a function +[2024-10-17>>>11:48:10]>>>home--bsideManager>>>>TypeError: result.forEach is not a function diff --git a/controllerLog/2024/8/16.txt b/controllerLog/2024/8/16.txt new file mode 100644 index 0000000..28796b9 --- /dev/null +++ b/controllerLog/2024/8/16.txt @@ -0,0 +1,6 @@ +[2024-8-16>>>16:8:56]>>>SequelizeUniqueConstraintError: Validation error +[2024-8-16>>>16:9:47]>>>SequelizeUniqueConstraintError: Validation error +[2024-8-16>>>16:12:27]>>>SequelizeUniqueConstraintError: Validation error +[2024-8-16>>>16:12:49]>>>SequelizeUniqueConstraintError: Validation error +[2024-8-16>>>16:13:49]>>>SequelizeUniqueConstraintError: Validation error +[2024-8-16>>>16:14:27]>>>SequelizeUniqueConstraintError: Validation error diff --git a/controllerLog/2025/6/27.txt b/controllerLog/2025/6/27.txt new file mode 100644 index 0000000..e4ef1ac --- /dev/null +++ b/controllerLog/2025/6/27.txt @@ -0,0 +1,89 @@ +[2025-6-27>>>11:48:36]>>>home--getCard>>>>TypeError: Cannot read properties of undefined (reading 'get') +et') + +[2025-6-27>>>11:48:36]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:48:36]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:48:43]>>>home--getRecord>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:50:51]>>>home--getCard>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:50:51]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:50:51]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:50:51]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:50:51]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:51:18]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:51:18]>>>home--getCard>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:51:18]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:51:19]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:51:19]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:52:59]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:52:59]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:52:59]>>>home--getCard>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:52:59]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:52:59]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:56:52]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:56:52]>>>home--getCard>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:56:52]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:56:52]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>11:56:52]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:2:33]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:2:33]>>>home--getCard>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:2:33]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:2:34]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:2:34]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:3:17]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:3:17]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:3:19]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:3:19]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:3:19]>>>home--getCard>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:3:20]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:3:20]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:20:20]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:20:20]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:20:24]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:20:24]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:20:24]>>>home--getCard>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:20:25]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:20:25]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:35:14]>>>home--getCard>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:35:14]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:35:14]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:35:14]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:35:14]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:41:20]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:41:20]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:41:20]>>>home--getCard>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:41:20]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:41:20]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:45:56]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:45:56]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:45:56]>>>home--getCard>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:45:56]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:45:56]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:48:20]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:48:20]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:48:23]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:48:23]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:48:23]>>>home--getCard>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:48:23]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>15:48:23]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:7:4]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:7:4]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:7:6]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:7:6]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:7:6]>>>home--getCard>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:7:6]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:7:6]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:9:4]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:9:4]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:9:4]>>>home--getCard>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:9:4]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:9:4]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:22:16]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:22:16]>>>home--getCard>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:22:16]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:22:16]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:22:16]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:42:11]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:42:11]>>>home--getCard>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:42:11]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:42:11]>>>home--bsideManager>>>>TypeError: Cannot read properties of undefined (reading 'get') +[2025-6-27>>>16:42:11]>>>home--getHistoryMsg>>>>TypeError: Cannot read properties of undefined (reading 'get') diff --git a/database/config.json b/database/config.json new file mode 100644 index 0000000..28abf0a --- /dev/null +++ b/database/config.json @@ -0,0 +1,23 @@ +{ + "development": { + "username": "root", + "password": 74191221, + "database": "vm_centos", + "host": "127.0.0.1", + "dialect": "mariadb" + }, + "test": { + "username": "root", + "password": 74191221, + "database": "vm_centos", + "host": "127.0.0.1", + "dialect": "mariadb" + }, + "production": { + "username": "root", + "password": 74191221, + "database": "vm_centos", + "host": "127.0.0.1", + "dialect": "mariadb" + } +} \ No newline at end of file diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..1bbed3f --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,5 @@ +{ + "include": [ + "**/*" + ] +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..dda93ef --- /dev/null +++ b/package.json @@ -0,0 +1,70 @@ +{ + "name": "bd-short-message-platform", + "version": "1.0.0", + "description": "", + "private": true, + "egg": { + "declarations": true + }, + "dependencies": { + "bd-short-message-platform": "file:", + "crypto-js": "^4.2.0", + "egg": "^3.17.5", + "egg-redis": "^2.6.0", + "egg-scripts": "^3.0.1", + "egg-sequelize": "^6.0.0", + "egg-validate": "^2.0.2", + "gbk.js": "^0.3.0", + "ioredis": "^5.4.1", + "mariadb": "^3.3.0", + "mysql2": "^3.9.7", + "sequelize": "^6.37.3", + "socket.io": "^4.7.5" + }, + "devDependencies": { + "egg-bin": "6", + "egg-mock": "5", + "eslint": "8", + "eslint-config-egg": "13", + "sequelize-cli": "^6.6.2" + }, + "engines": { + "node": ">=16.0.0" + }, + "pkg": { + "scripts": [ + "./app/**/*.js", + "./app.js", + "./agent.js", + "./config/**/*.js", + "./config/*.js", + "./config/*" + ], + "assets": [ + "./app/view/**/*", + "./app/public/**/*", + "./static/**/*", + "./node_modules/**/*" + ] + }, + "bin": "./build.js", + "scripts": { + "reload": "egg-scripts stop --title=egg-server-bd-short-message-platform && egg-scripts start --port=8090 --workers=1 --daemon --title=egg-server-bd-short-message-platform --ignore-stderr", + "start": "egg-scripts start --port=8090 --workers=1 --daemon --title=egg-server-bd-short-message-platform --ignore-stderr", + "stop": "egg-scripts stop --title=egg-server-bd-short-message-platform", + "dev": "egg-bin dev --port=8090", + "test": "egg-scripts start --env=test --daemon --port=8090", + "test:local": "egg-bin test", + "cov": "egg-bin cov", + "lint": "eslint .", + "ci": "npm run lint && npm run cov", + "build:win": "pkg . --targets win --out-path ./dist", + "build:linux": "pkg . --targets linux --out-path /usr/dist" + }, + "repository": { + "type": "git", + "url": "" + }, + "author": "", + "license": "MIT" +} diff --git a/serviceLog/2024/10/17.txt b/serviceLog/2024/10/17.txt new file mode 100644 index 0000000..3571c8b --- /dev/null +++ b/serviceLog/2024/10/17.txt @@ -0,0 +1 @@ +[2024-10-17>>>11:44:4]>>>home--bsideManager>>>>TypeError: ctx.model.BSide.findAndCount is not a function diff --git a/serviceLog/2024/8/16.txt b/serviceLog/2024/8/16.txt new file mode 100644 index 0000000..da04aa9 --- /dev/null +++ b/serviceLog/2024/8/16.txt @@ -0,0 +1,9 @@ +[2024-8-16>>>15:48:55]>>>SequelizeUniqueConstraintError: Validation error +[2024-8-16>>>15:49:26]>>>SequelizeUniqueConstraintError: Validation error +[2024-8-16>>>15:50:55]>>>SequelizeUniqueConstraintError: Validation error +[2024-8-16>>>15:54:34]>>>SequelizeUniqueConstraintError: Validation error +[2024-8-16>>>15:55:13]>>>SequelizeUniqueConstraintError: Validation error +[2024-8-16>>>16:0:58]>>>SequelizeUniqueConstraintError: Validation error +[2024-8-16>>>16:6:40]>>>SequelizeUniqueConstraintError: Validation error +[2024-8-16>>>16:7:26]>>>SequelizeUniqueConstraintError: Validation error +[2024-8-16>>>16:8:16]>>>SequelizeUniqueConstraintError: Validation error diff --git a/serviceLog/2024/9/23.txt b/serviceLog/2024/9/23.txt new file mode 100644 index 0000000..c8bbf63 --- /dev/null +++ b/serviceLog/2024/9/23.txt @@ -0,0 +1,8 @@ +[2024-9-23>>>16:28:21]>>>SequelizeDatabaseError: (conn:88, no: 1054, SQLState: 42S22) Unknown column 'buser-bind.uid' in 'where clause' +sql: SELECT `id`, `card_id`, `user_uid` FROM `buser-bind` AS `buser-bind` WHERE `buser-bind`.`uid` IN ('20240613698222B', '20240613698200B', '20240613698202B', '20240613698220B', '20240613698210B', '20240613698240B'); - parameters:[] +[2024-9-23>>>16:36:34]>>>SequelizeDatabaseError: (conn:89, no: 1054, SQLState: 42S22) Unknown column 'buser-bind.uid' in 'where clause' +sql: SELECT `id`, `card_id`, `user_uid` FROM `buser-bind` AS `buser-bind` WHERE `buser-bind`.`uid` IN ('20240613698222B'); - parameters:[] +[2024-9-23>>>16:39:13]>>>SequelizeDatabaseError: (conn:90, no: 1054, SQLState: 42S22) Unknown column 'buser-bind.uid' in 'where clause' +sql: SELECT `id`, `card_id`, `user_uid` FROM `buser-bind` AS `buser-bind` WHERE `buser-bind`.`uid` IN ('20240613698222B'); - parameters:[] +[2024-9-23>>>17:7:52]>>>SequelizeDatabaseError: (conn:176, no: 1364, SQLState: HY000) Field 'type' doesn't have a default value +sql: INSERT INTO `bind-brecord` (`id`,`user_uid`,`card_id`,`created_at`) VALUES (NULL,'20240613698222B','15590602','2024-09-23 09:07:52.892'); - parameters:[] diff --git a/serviceLog/2024/9/29.txt b/serviceLog/2024/9/29.txt new file mode 100644 index 0000000..c08d832 --- /dev/null +++ b/serviceLog/2024/9/29.txt @@ -0,0 +1,10 @@ +[2024-9-29>>>16:9:35]>>>Error: WHERE parameter "card_id" has invalid "undefined" value +[2024-9-29>>>16:12:57]>>>Error: WHERE parameter "card_id" has invalid "undefined" value +[2024-9-29>>>16:16:47]>>>Error: WHERE parameter "card_id" has invalid "undefined" value +[2024-9-29>>>16:20:51]>>>Error: WHERE parameter "card_id" has invalid "undefined" value +[2024-9-29>>>16:21:29]>>>Error: WHERE parameter "card_id" has invalid "undefined" value +[2024-9-29>>>16:23:58]>>>Error: WHERE parameter "card_id" has invalid "undefined" value +[2024-9-29>>>16:24:15]>>>Error: WHERE parameter "card_id" has invalid "undefined" value +[2024-9-29>>>16:25:1]>>>Error: WHERE parameter "card_id" has invalid "undefined" value +[2024-9-29>>>16:34:39]>>>Error: WHERE parameter "card_id" has invalid "undefined" value +[2024-9-29>>>16:35:4]>>>Error: WHERE parameter "card_id" has invalid "undefined" value diff --git a/socketLog/2024/10/12.txt b/socketLog/2024/10/12.txt new file mode 100644 index 0000000..06ddce1 --- /dev/null +++ b/socketLog/2024/10/12.txt @@ -0,0 +1,5 @@ +[2024-10-12>>>13:51:25]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-12>>>13:51:35]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-12>>>17:34:34]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-12>>>17:34:44]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-12>>>17:55:2]>>>Error: read ECONNRESET diff --git a/socketLog/2024/10/14.txt b/socketLog/2024/10/14.txt new file mode 100644 index 0000000..4a9a0b4 --- /dev/null +++ b/socketLog/2024/10/14.txt @@ -0,0 +1,2 @@ +[2024-10-14>>>11:37:5]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-14>>>11:37:15]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/10/17.txt b/socketLog/2024/10/17.txt new file mode 100644 index 0000000..9c6cabe --- /dev/null +++ b/socketLog/2024/10/17.txt @@ -0,0 +1,2 @@ +[2024-10-17>>>11:6:16]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-17>>>11:6:26]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/10/18.txt b/socketLog/2024/10/18.txt new file mode 100644 index 0000000..ee4c185 --- /dev/null +++ b/socketLog/2024/10/18.txt @@ -0,0 +1,2 @@ +[2024-10-18>>>9:17:53]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-18>>>9:18:3]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/10/21.txt b/socketLog/2024/10/21.txt new file mode 100644 index 0000000..8a5e6d3 --- /dev/null +++ b/socketLog/2024/10/21.txt @@ -0,0 +1,2 @@ +[2024-10-21>>>10:19:58]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-21>>>10:20:8]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/10/24.txt b/socketLog/2024/10/24.txt new file mode 100644 index 0000000..0c365be --- /dev/null +++ b/socketLog/2024/10/24.txt @@ -0,0 +1,2 @@ +[2024-10-24>>>14:11:56]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-24>>>14:12:6]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/10/29.txt b/socketLog/2024/10/29.txt new file mode 100644 index 0000000..067e4ea --- /dev/null +++ b/socketLog/2024/10/29.txt @@ -0,0 +1,12 @@ +[2024-10-29>>>17:26:43]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-29>>>17:26:53]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-29>>>17:32:49]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-29>>>17:32:59]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-29>>>17:34:35]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-29>>>17:34:45]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-29>>>17:35:26]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-29>>>17:35:36]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-29>>>17:36:28]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-29>>>17:36:38]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-29>>>17:39:1]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-29>>>17:39:11]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/10/31.txt b/socketLog/2024/10/31.txt new file mode 100644 index 0000000..51b696c --- /dev/null +++ b/socketLog/2024/10/31.txt @@ -0,0 +1,2 @@ +[2024-10-31>>>15:15:20]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-10-31>>>15:15:30]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/11/13.txt b/socketLog/2024/11/13.txt new file mode 100644 index 0000000..f55e9d9 --- /dev/null +++ b/socketLog/2024/11/13.txt @@ -0,0 +1,2 @@ +[2024-11-13>>>14:9:14]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-11-13>>>14:9:24]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/11/14.txt b/socketLog/2024/11/14.txt new file mode 100644 index 0000000..f6dd3ad --- /dev/null +++ b/socketLog/2024/11/14.txt @@ -0,0 +1,2 @@ +[2024-11-14>>>9:18:30]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-11-14>>>9:18:40]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/11/15.txt b/socketLog/2024/11/15.txt new file mode 100644 index 0000000..fe4a610 --- /dev/null +++ b/socketLog/2024/11/15.txt @@ -0,0 +1,14 @@ +[2024-11-15>>>9:55:48]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-11-15>>>9:55:58]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-11-15>>>9:59:16]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-11-15>>>9:59:26]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-11-15>>>11:11:49]>>>Error: read ECONNRESET +[2024-11-15>>>11:12:47]>>>Error: read ECONNRESET +[2024-11-15>>>11:14:7]>>>Error: read ECONNRESET +[2024-11-15>>>11:14:25]>>>Error: read ECONNRESET +[2024-11-15>>>11:18:5]>>>Error: read ECONNRESET +[2024-11-15>>>11:18:16]>>>Error: read ECONNRESET +[2024-11-15>>>14:39:38]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-11-15>>>14:40:14]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-11-15>>>16:52:34]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-11-15>>>17:11:10]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/11/25.txt b/socketLog/2024/11/25.txt new file mode 100644 index 0000000..69f7c8e --- /dev/null +++ b/socketLog/2024/11/25.txt @@ -0,0 +1 @@ +[2024-11-25>>>9:37:31]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/11/26.txt b/socketLog/2024/11/26.txt new file mode 100644 index 0000000..ab66c03 --- /dev/null +++ b/socketLog/2024/11/26.txt @@ -0,0 +1 @@ +[2024-11-26>>>15:38:58]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/11/29.txt b/socketLog/2024/11/29.txt new file mode 100644 index 0000000..c909cbe --- /dev/null +++ b/socketLog/2024/11/29.txt @@ -0,0 +1,3 @@ +[2024-11-29>>>16:58:24]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-11-29>>>17:2:41]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-11-29>>>17:3:27]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/11/5.txt b/socketLog/2024/11/5.txt new file mode 100644 index 0000000..8fadff8 --- /dev/null +++ b/socketLog/2024/11/5.txt @@ -0,0 +1,2 @@ +[2024-11-5>>>10:55:57]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-11-5>>>10:56:7]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/12/18.txt b/socketLog/2024/12/18.txt new file mode 100644 index 0000000..2611334 --- /dev/null +++ b/socketLog/2024/12/18.txt @@ -0,0 +1 @@ +[2024-12-18>>>11:41:15]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/12/3.txt b/socketLog/2024/12/3.txt new file mode 100644 index 0000000..c2c8630 --- /dev/null +++ b/socketLog/2024/12/3.txt @@ -0,0 +1 @@ +[2024-12-3>>>15:46:12]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/12/5.txt b/socketLog/2024/12/5.txt new file mode 100644 index 0000000..28766d9 --- /dev/null +++ b/socketLog/2024/12/5.txt @@ -0,0 +1 @@ +[2024-12-5>>>9:37:36]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/12/6.txt b/socketLog/2024/12/6.txt new file mode 100644 index 0000000..73c703d --- /dev/null +++ b/socketLog/2024/12/6.txt @@ -0,0 +1 @@ +[2024-12-6>>>9:25:30]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/12/9.txt b/socketLog/2024/12/9.txt new file mode 100644 index 0000000..c69e234 --- /dev/null +++ b/socketLog/2024/12/9.txt @@ -0,0 +1 @@ +[2024-12-9>>>9:36:57]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/8/20.txt b/socketLog/2024/8/20.txt new file mode 100644 index 0000000..4a9fce9 --- /dev/null +++ b/socketLog/2024/8/20.txt @@ -0,0 +1,2 @@ +[2024-8-20>>>9:10:21]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-20>>>9:10:31]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/8/21.txt b/socketLog/2024/8/21.txt new file mode 100644 index 0000000..c54bd4d --- /dev/null +++ b/socketLog/2024/8/21.txt @@ -0,0 +1,21 @@ +[2024-8-21>>>9:27:43]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>9:27:53]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:0:32]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:0:42]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:1:49]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:1:59]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:2:11]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:2:21]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:3:32]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:3:42]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:4:28]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:4:41]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:4:51]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:11:29]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:11:39]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:11:47]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:11:57]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:14:0]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:14:10]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:18:29]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-21>>>11:18:39]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/8/22.txt b/socketLog/2024/8/22.txt new file mode 100644 index 0000000..3593bbf --- /dev/null +++ b/socketLog/2024/8/22.txt @@ -0,0 +1,10 @@ +[2024-8-22>>>9:23:22]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-22>>>9:23:32]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-22>>>15:12:20]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-22>>>15:12:30]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-22>>>15:13:14]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-22>>>15:13:24]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-22>>>16:21:23]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-22>>>16:21:33]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-22>>>16:27:15]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-22>>>16:27:25]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/8/27.txt b/socketLog/2024/8/27.txt new file mode 100644 index 0000000..84fa5ba --- /dev/null +++ b/socketLog/2024/8/27.txt @@ -0,0 +1,2 @@ +[2024-8-27>>>15:6:48]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-27>>>15:6:58]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/8/28.txt b/socketLog/2024/8/28.txt new file mode 100644 index 0000000..0a0ec0b --- /dev/null +++ b/socketLog/2024/8/28.txt @@ -0,0 +1,2 @@ +[2024-8-28>>>14:31:43]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-28>>>14:31:53]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/8/30.txt b/socketLog/2024/8/30.txt new file mode 100644 index 0000000..66ed3b2 --- /dev/null +++ b/socketLog/2024/8/30.txt @@ -0,0 +1,2 @@ +[2024-8-30>>>10:19:35]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-8-30>>>10:19:45]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/9/12.txt b/socketLog/2024/9/12.txt new file mode 100644 index 0000000..6c7a788 --- /dev/null +++ b/socketLog/2024/9/12.txt @@ -0,0 +1,2 @@ +[2024-9-12>>>14:30:28]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-9-12>>>14:30:38]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/9/13.txt b/socketLog/2024/9/13.txt new file mode 100644 index 0000000..25ea9c5 --- /dev/null +++ b/socketLog/2024/9/13.txt @@ -0,0 +1,2 @@ +[2024-9-13>>>11:40:6]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-9-13>>>11:40:16]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/9/14.txt b/socketLog/2024/9/14.txt new file mode 100644 index 0000000..97e4d13 --- /dev/null +++ b/socketLog/2024/9/14.txt @@ -0,0 +1,2 @@ +[2024-9-14>>>9:17:51]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-9-14>>>9:18:1]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/9/18.txt b/socketLog/2024/9/18.txt new file mode 100644 index 0000000..726d3e5 --- /dev/null +++ b/socketLog/2024/9/18.txt @@ -0,0 +1,4 @@ +[2024-9-18>>>9:21:50]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-9-18>>>9:22:0]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-9-18>>>11:23:40]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-9-18>>>11:23:50]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/9/19.txt b/socketLog/2024/9/19.txt new file mode 100644 index 0000000..6619204 --- /dev/null +++ b/socketLog/2024/9/19.txt @@ -0,0 +1 @@ +[2024-9-19>>>9:8:38]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/9/2.txt b/socketLog/2024/9/2.txt new file mode 100644 index 0000000..63e8b2b --- /dev/null +++ b/socketLog/2024/9/2.txt @@ -0,0 +1,4 @@ +[2024-9-2>>>9:33:9]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-9-2>>>9:33:19]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-9-2>>>17:56:19]>>>Error: read ECONNRESET +[2024-9-2>>>17:56:29]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/9/24.txt b/socketLog/2024/9/24.txt new file mode 100644 index 0000000..07e1d42 --- /dev/null +++ b/socketLog/2024/9/24.txt @@ -0,0 +1,2 @@ +[2024-9-24>>>9:55:33]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-9-24>>>9:55:43]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/9/26.txt b/socketLog/2024/9/26.txt new file mode 100644 index 0000000..637f91d --- /dev/null +++ b/socketLog/2024/9/26.txt @@ -0,0 +1,2 @@ +[2024-9-26>>>9:28:42]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-9-26>>>9:28:52]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/9/29.txt b/socketLog/2024/9/29.txt new file mode 100644 index 0000000..a32fc8f --- /dev/null +++ b/socketLog/2024/9/29.txt @@ -0,0 +1,2 @@ +[2024-9-29>>>9:37:21]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-9-29>>>9:37:31]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/9/3.txt b/socketLog/2024/9/3.txt new file mode 100644 index 0000000..da9270b --- /dev/null +++ b/socketLog/2024/9/3.txt @@ -0,0 +1,2 @@ +[2024-9-3>>>9:24:46]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-9-3>>>9:24:56]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/9/30.txt b/socketLog/2024/9/30.txt new file mode 100644 index 0000000..01c7fc7 --- /dev/null +++ b/socketLog/2024/9/30.txt @@ -0,0 +1,2 @@ +[2024-9-30>>>17:55:9]>>>Error: read ECONNRESET +[2024-9-30>>>17:55:19]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2024/9/4.txt b/socketLog/2024/9/4.txt new file mode 100644 index 0000000..fb52e30 --- /dev/null +++ b/socketLog/2024/9/4.txt @@ -0,0 +1,2 @@ +[2024-9-4>>>9:8:26]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2024-9-4>>>9:8:36]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2025/2/26.txt b/socketLog/2025/2/26.txt new file mode 100644 index 0000000..293f39c --- /dev/null +++ b/socketLog/2025/2/26.txt @@ -0,0 +1 @@ +[2025-2-26>>>11:50:59]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2025/3/24.txt b/socketLog/2025/3/24.txt new file mode 100644 index 0000000..3802f67 --- /dev/null +++ b/socketLog/2025/3/24.txt @@ -0,0 +1,2 @@ +[2025-3-24>>>11:44:21]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2025-3-24>>>12:11:56]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2025/6/27.txt b/socketLog/2025/6/27.txt new file mode 100644 index 0000000..f153f40 --- /dev/null +++ b/socketLog/2025/6/27.txt @@ -0,0 +1,3 @@ +[2025-6-27>>>9:16:44]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2025-6-27>>>9:23:35]>>>Error: read ECONNRESET +[2025-6-27>>>11:48:31]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2026/2/27.txt b/socketLog/2026/2/27.txt new file mode 100644 index 0000000..ab8d8a2 --- /dev/null +++ b/socketLog/2026/2/27.txt @@ -0,0 +1 @@ +[2026-2-27>>>16:47:2]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2026/2/28.txt b/socketLog/2026/2/28.txt new file mode 100644 index 0000000..a4318ae --- /dev/null +++ b/socketLog/2026/2/28.txt @@ -0,0 +1,11 @@ +[2026-2-28>>>10:28:35]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2026-2-28>>>11:18:30]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2026-2-28>>>11:27:30]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2026-2-28>>>11:46:14]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2026-2-28>>>11:47:47]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2026-2-28>>>14:35:44]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2026-2-28>>>14:41:22]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2026-2-28>>>14:43:51]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2026-2-28>>>14:47:57]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2026-2-28>>>14:50:6]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 +[2026-2-28>>>14:53:43]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2026/3/20.txt b/socketLog/2026/3/20.txt new file mode 100644 index 0000000..354dbf9 --- /dev/null +++ b/socketLog/2026/3/20.txt @@ -0,0 +1 @@ +[2026-3-20>>>10:21:8]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2026/3/4.txt b/socketLog/2026/3/4.txt new file mode 100644 index 0000000..c519cca --- /dev/null +++ b/socketLog/2026/3/4.txt @@ -0,0 +1 @@ +[2026-3-4>>>11:18:35]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/socketLog/2026/3/9.txt b/socketLog/2026/3/9.txt new file mode 100644 index 0000000..9eee148 --- /dev/null +++ b/socketLog/2026/3/9.txt @@ -0,0 +1 @@ +[2026-3-9>>>16:5:17]>>>Error: connect ECONNREFUSED 127.0.0.1:9004 diff --git a/test/app/controller/home.test.js b/test/app/controller/home.test.js new file mode 100644 index 0000000..ea43dbb --- /dev/null +++ b/test/app/controller/home.test.js @@ -0,0 +1,23 @@ +const { strict: assert } = require('node:assert'); +const path = require('node:path'); +const { statSync } = require('node:fs'); +const { app } = require('egg-mock/bootstrap'); + +describe('test/app/controller/home.test.js', () => { + it('should assert', async () => { + const pkg = require('../../../package.json'); + assert(app.config.keys.startsWith(pkg.name)); + }); + + it('should typings exists', async () => { + const typings = path.join(__dirname, '../../../typings'); + assert(statSync(typings)); + }); + + it('should GET /', async () => { + return app.httpRequest() + .get('/') + .expect('hi, egg') + .expect(200); + }); +});