fix admin note is required in mentor
This commit is contained in:
@@ -64,7 +64,7 @@ export class AppConfigSchema extends PothosSchema {
|
||||
type: this.appConfig(),
|
||||
description: 'Get an app config by key',
|
||||
args: this.builder.generator.findUniqueArgs('Config'),
|
||||
resolve: async (query, root, args) => {
|
||||
resolve: async (query, _root, args) => {
|
||||
return await this.prisma.config.findUnique({
|
||||
...query,
|
||||
where: args.where ?? undefined,
|
||||
@@ -84,7 +84,7 @@ export class AppConfigSchema extends PothosSchema {
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
resolve: async (query, root, args) => {
|
||||
resolve: async (query, _root, args) => {
|
||||
return await this.prisma.config.create({
|
||||
...query,
|
||||
data: args.input,
|
||||
@@ -100,7 +100,7 @@ export class AppConfigSchema extends PothosSchema {
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
resolve: async (query, root, args) => {
|
||||
resolve: async (query, _root, args) => {
|
||||
return await this.prisma.config.createManyAndReturn({
|
||||
...query,
|
||||
data: args.input,
|
||||
|
||||
@@ -13,14 +13,16 @@ export class AppConfigService implements OnModuleInit {
|
||||
const configs = await this.prisma.config.findMany()
|
||||
if (configs.length === 0) {
|
||||
Object.entries(ConfigConstants).forEach(async ([_key, value]) => {
|
||||
await this.prisma.config.create({
|
||||
data: {
|
||||
name: value.name,
|
||||
key: value.key,
|
||||
value: value.value,
|
||||
visible: value.visible,
|
||||
},
|
||||
})
|
||||
try {
|
||||
await this.prisma.config.create({
|
||||
data: {
|
||||
name: value.name,
|
||||
key: value.key,
|
||||
value: value.value,
|
||||
visible: value.visible,
|
||||
},
|
||||
})
|
||||
} catch (_error) {}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -50,9 +52,20 @@ export class AppConfigService implements OnModuleInit {
|
||||
})
|
||||
}
|
||||
|
||||
async deleteConfig(key: string) {
|
||||
return await this.prisma.config.delete({
|
||||
async resetConfig(key: string) {
|
||||
// reset config to default value
|
||||
await this.prisma.config.update({
|
||||
where: { key },
|
||||
data: ConfigConstants[key],
|
||||
})
|
||||
}
|
||||
|
||||
async resetAllConfigs() {
|
||||
// reset all configs to default values
|
||||
Object.entries(ConfigConstants).forEach(async ([_key, value]) => {
|
||||
await this.prisma.config.create({
|
||||
data: value,
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user