mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
修复更新环境变量
This commit is contained in:
parent
647ed3b66c
commit
e5b35273f9
|
@ -20,7 +20,7 @@ export class Env {
|
|||
this.timestamp = new Date().toString();
|
||||
this.position = options.position;
|
||||
this.name = options.name;
|
||||
this.remarks = options.remarks;
|
||||
this.remarks = options.remarks || '';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import {
|
|||
} from '../protos/api';
|
||||
import LoggerInstance from '../loaders/logger';
|
||||
import NotificationService from '../services/notify';
|
||||
import pick from 'lodash/pick';
|
||||
|
||||
Container.set('logger', LoggerInstance);
|
||||
|
||||
|
@ -63,7 +64,9 @@ export const updateEnv = async (
|
|||
) => {
|
||||
try {
|
||||
const envService = Container.get(EnvService);
|
||||
const data = await envService.update(call.request.env as EnvItem);
|
||||
const data = await envService.update(
|
||||
pick(call.request.env, ['id', 'name', 'value', 'remark']) as EnvItem,
|
||||
);
|
||||
callback(null, { code: 200, data });
|
||||
} catch (e: any) {
|
||||
callback(e);
|
||||
|
@ -148,7 +151,10 @@ export const getEnvById = async (
|
|||
try {
|
||||
const envService = Container.get(EnvService);
|
||||
const data = await envService.getDb({ id: call.request.id });
|
||||
callback(null, { code: 200, data });
|
||||
callback(null, {
|
||||
code: 200,
|
||||
data: { ...data, remarks: data.remarks || '' },
|
||||
});
|
||||
} catch (e: any) {
|
||||
callback(e);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ export default class EnvService {
|
|||
}
|
||||
|
||||
public async insert(payloads: Env[]): Promise<Env[]> {
|
||||
const result = [];
|
||||
const result: Env[] = [];
|
||||
for (const env of payloads) {
|
||||
const doc = await EnvModel.create(env, { returning: true });
|
||||
result.push(doc);
|
||||
|
|
Loading…
Reference in New Issue
Block a user