47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { PrismaService } from '../prisma/prisma.service';
|
|
|
|
@Injectable()
|
|
export class SettingsService {
|
|
constructor(private prisma: PrismaService) {}
|
|
|
|
async getUiTexts() {
|
|
return this.prisma.uiText.findMany();
|
|
}
|
|
|
|
async updateUiText(key: string, value: string) {
|
|
return this.prisma.uiText.upsert({
|
|
where: { key },
|
|
update: { value },
|
|
create: { key, value },
|
|
});
|
|
}
|
|
|
|
async getScientificTerms() {
|
|
return this.prisma.scientificTerm.findMany();
|
|
}
|
|
|
|
async upsertScientificTerm(key: string, data: any) {
|
|
return this.prisma.scientificTerm.upsert({
|
|
where: { key },
|
|
update: {
|
|
term: data.term,
|
|
definition: data.definition,
|
|
wikiId: data.wikiId || 'general',
|
|
},
|
|
create: {
|
|
key,
|
|
term: data.term,
|
|
definition: data.definition,
|
|
wikiId: data.wikiId || 'general',
|
|
},
|
|
});
|
|
}
|
|
|
|
async deleteScientificTerm(key: string) {
|
|
return this.prisma.scientificTerm.delete({
|
|
where: { key },
|
|
});
|
|
}
|
|
}
|