fix: restore wiki to dictionary, create dynamic blog pages and backend wiki CRUD
This commit is contained in:
1 parent
945c007a79
commit
dcfc4acae4
13 files changed
+328
-119
No files matched your search
@@ -0,0 +1 @@
|
||||
export class CreateWikiDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/swagger';
|
||||
import { CreateWikiDto } from './create-wiki.dto';
|
||||
|
||||
export class UpdateWikiDto extends PartialType(CreateWikiDto) {}
|
||||
@@ -0,0 +1 @@
|
||||
export class Wiki {}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
import { WikiService } from './wiki.service';
|
||||
|
||||
@Controller('wiki')
|
||||
export class WikiController {
|
||||
constructor(private readonly wikiService: WikiService) {}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.wikiService.findAll();
|
||||
}
|
||||
|
||||
@Get(':key')
|
||||
findOne(@Param('key') key: string) {
|
||||
return this.wikiService.findOneByKey(key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { WikiService } from './wiki.service';
|
||||
import { WikiController } from './wiki.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [WikiController],
|
||||
providers: [WikiService],
|
||||
})
|
||||
export class WikiModule {}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class WikiService {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
|
||||
async findAll() {
|
||||
return this.prisma.scientificTerm.findMany({
|
||||
orderBy: { term: 'asc' }
|
||||
});
|
||||
}
|
||||
|
||||
async findOneByKey(key: string) {
|
||||
const term = await this.prisma.scientificTerm.findUnique({
|
||||
where: { key }
|
||||
});
|
||||
if (!term) throw new NotFoundException('Wiki term not found');
|
||||
return term;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user