ntrip-caster服务后端

This commit is contained in:
2026-05-12 17:43:03 +08:00
commit 6e761f3727
45 changed files with 3125 additions and 0 deletions

50
app/core/base_service.js Normal file
View File

@@ -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;