mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
修复下载单文件订阅
This commit is contained in:
parent
1e749f3731
commit
c3908e956f
|
@ -2,13 +2,13 @@ import { sequelize } from '.';
|
|||
import { DataTypes, Model, ModelDefined } from 'sequelize';
|
||||
import { NotificationInfo } from './notify';
|
||||
|
||||
export class AuthInfo {
|
||||
export class SystemInfo {
|
||||
ip?: string;
|
||||
type: AuthDataType;
|
||||
info?: SystemModelInfo;
|
||||
id?: number;
|
||||
|
||||
constructor(options: AuthInfo) {
|
||||
constructor(options: SystemInfo) {
|
||||
this.ip = options.ip;
|
||||
this.info = options.info;
|
||||
this.type = options.type;
|
||||
|
@ -50,7 +50,7 @@ export type SystemModelInfo = SystemConfigInfo &
|
|||
Partial<NotificationInfo> &
|
||||
LoginLogInfo;
|
||||
|
||||
export interface SystemInstance extends Model<AuthInfo, AuthInfo>, AuthInfo { }
|
||||
export interface SystemInstance extends Model<SystemInfo, SystemInfo>, SystemInfo { }
|
||||
export const SystemModel = sequelize.define<SystemInstance>('Auth', {
|
||||
ip: DataTypes.STRING,
|
||||
type: DataTypes.STRING,
|
||||
|
|
|
@ -375,7 +375,10 @@ export default class CronService {
|
|||
|
||||
public async getDb(query: FindOptions<Crontab>['where']): Promise<Crontab> {
|
||||
const doc: any = await CrontabModel.findOne({ where: { ...query } });
|
||||
return doc && (doc.get({ plain: true }) as Crontab);
|
||||
if (!doc) {
|
||||
throw new Error(`${JSON.stringify(query)} not found`);
|
||||
}
|
||||
return doc.get({ plain: true });
|
||||
}
|
||||
|
||||
public async run(ids: number[]) {
|
||||
|
@ -437,7 +440,7 @@ export default class CronService {
|
|||
const cp = spawn(
|
||||
`real_log_path=${logPath} no_delay=true ${this.makeCommand(
|
||||
cron,
|
||||
true
|
||||
true,
|
||||
)}`,
|
||||
{ shell: '/bin/bash' },
|
||||
);
|
||||
|
|
|
@ -63,7 +63,10 @@ export default class CronViewService {
|
|||
query: FindOptions<CrontabView>['where'],
|
||||
): Promise<CrontabView> {
|
||||
const doc: any = await CrontabViewModel.findOne({ where: { ...query } });
|
||||
return doc && (doc.get({ plain: true }) as CrontabView);
|
||||
if (!doc) {
|
||||
throw new Error(`${JSON.stringify(query)} not found`);
|
||||
}
|
||||
return doc.get({ plain: true });
|
||||
}
|
||||
|
||||
public async disabled(ids: number[]) {
|
||||
|
|
|
@ -183,7 +183,10 @@ export default class DependenceService {
|
|||
query: FindOptions<Dependence>['where'],
|
||||
): Promise<Dependence> {
|
||||
const doc: any = await DependenceModel.findOne({ where: { ...query } });
|
||||
return doc && (doc.get({ plain: true }) as Dependence);
|
||||
if (!doc) {
|
||||
throw new Error(`${JSON.stringify(query)} not found`);
|
||||
}
|
||||
return doc.get({ plain: true });
|
||||
}
|
||||
|
||||
private async updateLog(ids: number[], log: string): Promise<void> {
|
||||
|
|
|
@ -165,7 +165,10 @@ export default class EnvService {
|
|||
|
||||
public async getDb(query: FindOptions<Env>['where']): Promise<Env> {
|
||||
const doc: any = await EnvModel.findOne({ where: { ...query } });
|
||||
return doc && (doc.get({ plain: true }) as Env);
|
||||
if (!doc) {
|
||||
throw new Error(`${JSON.stringify(query)} not found`);
|
||||
}
|
||||
return doc.get({ plain: true });
|
||||
}
|
||||
|
||||
public async disabled(ids: string[]) {
|
||||
|
|
|
@ -26,7 +26,7 @@ export default class OpenService {
|
|||
|
||||
public async insert(payload: App): Promise<App> {
|
||||
const doc = await AppModel.create(payload, { returning: true });
|
||||
return doc.get({ plain: true }) as App;
|
||||
return doc.get({ plain: true });
|
||||
}
|
||||
|
||||
public async update(payload: App): Promise<App> {
|
||||
|
@ -45,7 +45,10 @@ export default class OpenService {
|
|||
|
||||
public async getDb(query: any): Promise<App> {
|
||||
const doc: any = await AppModel.findOne({ where: query });
|
||||
return doc && (doc.get({ plain: true }) as App);
|
||||
if (!doc) {
|
||||
throw new Error(`${JSON.stringify(query)} not found`);
|
||||
}
|
||||
return doc.get({ plain: true });
|
||||
}
|
||||
|
||||
public async remove(ids: number[]) {
|
||||
|
|
|
@ -24,7 +24,7 @@ import {
|
|||
import { NotificationInfo } from '../data/notify';
|
||||
import {
|
||||
AuthDataType,
|
||||
AuthInfo,
|
||||
SystemInfo,
|
||||
SystemInstance,
|
||||
SystemModel,
|
||||
SystemModelInfo,
|
||||
|
@ -47,18 +47,21 @@ export default class SystemService {
|
|||
|
||||
public async getSystemConfig() {
|
||||
const doc = await this.getDb({ type: AuthDataType.systemConfig });
|
||||
return doc || ({} as SystemInstance);
|
||||
return doc;
|
||||
}
|
||||
|
||||
private async updateAuthDb(payload: AuthInfo): Promise<SystemInstance> {
|
||||
private async updateAuthDb(payload: SystemInfo): Promise<SystemInfo> {
|
||||
await SystemModel.upsert({ ...payload });
|
||||
const doc = await this.getDb({ type: payload.type });
|
||||
return doc;
|
||||
}
|
||||
|
||||
public async getDb(query: any): Promise<SystemInstance> {
|
||||
const doc: any = await SystemModel.findOne({ where: { ...query } });
|
||||
return doc && doc.get({ plain: true });
|
||||
public async getDb(query: any): Promise<SystemInfo> {
|
||||
const doc = await SystemModel.findOne({ where: { ...query } });
|
||||
if (!doc) {
|
||||
throw new Error(`${JSON.stringify(query)} not found`);
|
||||
}
|
||||
return doc.get({ plain: true });
|
||||
}
|
||||
|
||||
public async updateNotificationMode(notificationInfo: NotificationInfo) {
|
||||
|
|
|
@ -13,7 +13,7 @@ import jwt from 'jsonwebtoken';
|
|||
import { authenticator } from '@otplib/preset-default';
|
||||
import {
|
||||
AuthDataType,
|
||||
AuthInfo,
|
||||
SystemInfo,
|
||||
SystemModel,
|
||||
SystemModelInfo,
|
||||
LoginStatus,
|
||||
|
@ -223,7 +223,7 @@ export default class UserService {
|
|||
return [];
|
||||
}
|
||||
|
||||
private async insertDb(payload: AuthInfo): Promise<AuthInfo> {
|
||||
private async insertDb(payload: SystemInfo): Promise<SystemInfo> {
|
||||
const doc = await SystemModel.create({ ...payload }, { returning: true });
|
||||
return doc;
|
||||
}
|
||||
|
@ -351,10 +351,10 @@ export default class UserService {
|
|||
|
||||
public async getNotificationMode(): Promise<NotificationInfo> {
|
||||
const doc = await this.getDb({ type: AuthDataType.notification });
|
||||
return (doc && doc.info) || {};
|
||||
return doc.info as NotificationInfo;
|
||||
}
|
||||
|
||||
private async updateAuthDb(payload: AuthInfo): Promise<any> {
|
||||
private async updateAuthDb(payload: SystemInfo): Promise<any> {
|
||||
let doc = await SystemModel.findOne({ type: payload.type });
|
||||
if (doc) {
|
||||
const updateResult = await SystemModel.update(payload, {
|
||||
|
@ -368,9 +368,12 @@ export default class UserService {
|
|||
return doc;
|
||||
}
|
||||
|
||||
public async getDb(query: any): Promise<any> {
|
||||
const doc: any = await SystemModel.findOne({ where: { ...query } });
|
||||
return doc && (doc.get({ plain: true }) as any);
|
||||
public async getDb(query: any): Promise<SystemInfo> {
|
||||
const doc = await SystemModel.findOne({ where: { ...query } });
|
||||
if (!doc) {
|
||||
throw new Error(`${JSON.stringify(query)} not found`);
|
||||
}
|
||||
return doc.get({ plain: true });
|
||||
}
|
||||
|
||||
public async updateNotificationMode(notificationInfo: NotificationInfo) {
|
||||
|
|
|
@ -161,7 +161,7 @@ update_raw() {
|
|||
if [[ $url == http:* ]]; then
|
||||
proxyStr="-e \"http_proxy=${proxy}\""
|
||||
elif [[ $url == https:* ]]; then
|
||||
proxyStr="-e \"http_proxy=${proxy};https_proxy=${proxy}\""
|
||||
proxyStr="-e \"https_proxy=${proxy}\""
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -255,7 +255,7 @@ reload_qinglong() {
|
|||
reload_pm2
|
||||
}
|
||||
|
||||
## 更新qinglong
|
||||
## 更新 qinglong
|
||||
update_qinglong() {
|
||||
rm -rf ${dir_tmp}/*
|
||||
local mirror="gitee"
|
||||
|
|
Loading…
Reference in New Issue
Block a user