修改 QLAPI 系统通知

This commit is contained in:
whyour 2025-01-12 15:39:28 +08:00
parent 51ef4e7476
commit ad6e08525c
7 changed files with 24 additions and 25 deletions

9
back.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
import 'express';
declare global {
namespace Express {
interface Request {
platform: string;
}
}
}

View File

@ -20,8 +20,8 @@ import {
UpdateEnvRequest,
} from '../protos/api';
import LoggerInstance from '../loaders/logger';
import NotificationService from '../services/notify';
import pick from 'lodash/pick';
import SystemService from '../services/system';
Container.set('logger', LoggerInstance);
@ -165,11 +165,8 @@ export const systemNotify = async (
callback: sendUnaryData<SystemNotifyResponse>,
) => {
try {
const notifyService = Container.get(NotificationService);
const data = await notifyService.notify(
call.request.title,
call.request.content,
);
const systemService = Container.get(SystemService);
const data = await systemService.notify(call.request);
callback(null, { code: 200, data });
} catch (e: any) {
callback(e);

View File

@ -1,15 +1,7 @@
import { Service, Inject } from 'typedi';
import winston from 'winston';
import {
createFile,
createRandomString,
fileExist,
getNetIp,
getPlatform,
safeJSONParse,
} from '../config/util';
import { createRandomString, getNetIp } from '../config/util';
import config from '../config';
import * as fs from 'fs/promises';
import jwt from 'jsonwebtoken';
import { authenticator } from '@otplib/preset-default';
import {

View File

@ -6,10 +6,10 @@
*/
console.log('test scripts');
QLAPI.notify('test scripts', 'test desc');
QLAPI.getEnvs({ searchValue: 'dddd' }).then(x => {
console.log(x)
})
QLAPI.systemNotify({ title: '123', content: '231' }).then(x => {
console.log(x)
})
QLAPI.getEnvs({ searchValue: 'dddd' }).then((x) => {
console.log('getEnvs', x);
});
QLAPI.systemNotify({ title: '123', content: '231' }).then((x) => {
console.log('systemNotify', x);
});
console.log('test desc');

View File

@ -6,7 +6,9 @@ cron: 1 9 * * *
"""
print("test script")
QLAPI.notify("test script", "test desc")
QLAPI.systemNotify({"title": "test script", "content": "dddd"})
print(QLAPI.notify("test script", "test desc"))
print("test systemNotify")
print(QLAPI.systemNotify({"title": "test script", "content": "dddd"}))
print("test getEnvs")
print(QLAPI.getEnvs("1"))
print("test desc")

View File

@ -1,7 +1,6 @@
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
console.log(process.env.QL_DIR);
const PROTO_PATH = `${process.env.QL_DIR}/back/protos/api.proto`;
const options = {
keepCase: true,

View File

@ -18,7 +18,7 @@
"noEmit": false,
"esModuleInterop": true
},
"include": ["./back/**/*"],
"include": ["./back/**/*", "./back.d.ts"],
"exclude": ["node_modules"],
"files": ["./back/index.d.ts"]
}