mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-28 02:16:07 +08:00
修复openapi认证,环境变量排序
This commit is contained in:
parent
96b111b894
commit
410dd2ecdc
|
@ -50,7 +50,10 @@ export enum CrontabStatus {
|
||||||
interface CronInstance extends Model<Crontab, Crontab>, Crontab {}
|
interface CronInstance extends Model<Crontab, Crontab>, Crontab {}
|
||||||
export const CrontabModel = sequelize.define<CronInstance>('Crontab', {
|
export const CrontabModel = sequelize.define<CronInstance>('Crontab', {
|
||||||
name: DataTypes.STRING,
|
name: DataTypes.STRING,
|
||||||
command: DataTypes.STRING,
|
command: {
|
||||||
|
unique: 'command',
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
},
|
||||||
schedule: DataTypes.STRING,
|
schedule: DataTypes.STRING,
|
||||||
timestamp: DataTypes.STRING,
|
timestamp: DataTypes.STRING,
|
||||||
saved: DataTypes.BOOLEAN,
|
saved: DataTypes.BOOLEAN,
|
||||||
|
|
|
@ -31,6 +31,12 @@ export default class CronService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async insert(payload: Crontab): Promise<Crontab> {
|
public async insert(payload: Crontab): Promise<Crontab> {
|
||||||
|
const cron = await CrontabModel.findOne({
|
||||||
|
where: { command: payload.command },
|
||||||
|
});
|
||||||
|
if (cron) {
|
||||||
|
return cron;
|
||||||
|
}
|
||||||
return await CrontabModel.create(payload, { returning: true });
|
return await CrontabModel.create(payload, { returning: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,15 +108,18 @@ export default class EnvService {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const result = await this.find(condition);
|
const result = await this.find(condition, [['position', 'DESC']]);
|
||||||
return result as any;
|
return result as any;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async find(query: any, sort?: any): Promise<Env[]> {
|
private async find(query: any, sort: any = []): Promise<Env[]> {
|
||||||
const docs = await EnvModel.findAll({ where: { ...query } });
|
const docs = await EnvModel.findAll({
|
||||||
|
where: { ...query },
|
||||||
|
order: [...sort],
|
||||||
|
});
|
||||||
return docs;
|
return docs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,14 +12,15 @@ export default class OpenService {
|
||||||
constructor(@Inject('logger') private logger: winston.Logger) {}
|
constructor(@Inject('logger') private logger: winston.Logger) {}
|
||||||
|
|
||||||
public async findTokenByValue(token: string): Promise<App | null> {
|
public async findTokenByValue(token: string): Promise<App | null> {
|
||||||
const doc = await this.getDb({
|
const doc = await this.getDb(
|
||||||
where: sequelize.fn(
|
sequelize.fn(
|
||||||
'JSON_CONTAINS',
|
'JSON_CONTAINS',
|
||||||
sequelize.col('tokens'),
|
sequelize.col('tokens'),
|
||||||
JSON.stringify({ value: token }),
|
JSON.stringify({ value: token }),
|
||||||
),
|
),
|
||||||
});
|
);
|
||||||
return doc;
|
return doc;
|
||||||
|
AppModel.upsert;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async create(payload: App): Promise<App> {
|
public async create(payload: App): Promise<App> {
|
||||||
|
@ -50,7 +51,7 @@ export default class OpenService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getDb(query: any): Promise<App> {
|
public async getDb(query: any): Promise<App> {
|
||||||
const doc: any = await AppModel.findOne({ where: { ...query } });
|
const doc: any = await AppModel.findOne({ where: query });
|
||||||
return doc && (doc.get({ plain: true }) as App);
|
return doc && (doc.get({ plain: true }) as App);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user