fix admin note is required in mentor

This commit is contained in:
2024-10-29 19:49:22 +07:00
parent e003bcd634
commit 8631bd935d
5 changed files with 32 additions and 23 deletions

View File

@@ -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,

View File

@@ -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,
})
})
}
}