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,80 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const WIKI_TERMS = [
|
||||
{
|
||||
id: "green-mussel",
|
||||
name: "صدف لبسبز (Perna Canaliculus)",
|
||||
description: "این صدف بومی سواحل بکر نیوزیلند است و تنها منبع طبیعی حاوی گلیکوزآمینگلیکانها (GAG) در غلظت بسیار بالا محسوب میشود.",
|
||||
benefits: [
|
||||
"بازسازی بافت غضروفی تخریب شده",
|
||||
"خواص ضدالتهابی طبیعی برای رباطها",
|
||||
"تامین اسیدهای چرب امگا ۳ خاص",
|
||||
]
|
||||
},
|
||||
{
|
||||
id: "silver",
|
||||
name: "نقره میکروسیلور (Microsilver)",
|
||||
description: "ذرات نقره خالص با ساختار اسفنجی که به دلیل اندازه ذرات درشت، جذب خون نمیشوند اما اثر آنتیباکتریال پایداری بر سطح غشاها دارند.",
|
||||
benefits: [
|
||||
"مبارزه با باکتریهای مقاوم در دهان و پوست",
|
||||
"عدم آسیب به فلور طبیعی بدن",
|
||||
"جایگزین ایمن برای آنتیبیوتیکهای موضعی",
|
||||
]
|
||||
},
|
||||
{
|
||||
id: "colostrum",
|
||||
name: "آغوز (Colostrum)",
|
||||
description: "اولین شیر مادر که حاوی دوز بالایی از ایمونوگلوبولینها، ویتامینها و مواد معدنی برای فعالسازی فوری سیستم ایمنی است.",
|
||||
benefits: [
|
||||
"تقویت سد دفاعی روده",
|
||||
"انتقال مستقیم آنتیبادی به نوزادان",
|
||||
"تسریع نقاهت بعد از جرافی",
|
||||
]
|
||||
},
|
||||
{
|
||||
id: "peat-extract",
|
||||
name: "عصاره پیت (Peat Extract)",
|
||||
description: "مادهای کاملا طبیعی حاصل از تجزیه گیاهان در طول هزاران سال که غنی از اسیدهای هومیک و مواد معدنی است.",
|
||||
benefits: [
|
||||
"جذب سموم در دستگاه گوارش",
|
||||
"تنظیم فلور روده",
|
||||
"بهبود اشتها و هضم"
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
async function main() {
|
||||
console.log('Seeding Scientific Terms (Wiki)...');
|
||||
|
||||
for (const term of WIKI_TERMS) {
|
||||
await prisma.scientificTerm.upsert({
|
||||
where: { key: term.id },
|
||||
update: {
|
||||
term: term.name,
|
||||
definition: term.description,
|
||||
keywords: JSON.stringify(term.benefits),
|
||||
wikiId: term.id,
|
||||
},
|
||||
create: {
|
||||
key: term.id,
|
||||
term: term.name,
|
||||
definition: term.description,
|
||||
keywords: JSON.stringify(term.benefits),
|
||||
wikiId: term.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
console.log('Wiki seeded successfully');
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
@@ -13,6 +13,7 @@ import { MetricsController } from './common/metrics.controller';
|
||||
import { AdminModule } from './admin/admin.module';
|
||||
import { HomeModule } from './home/home.module';
|
||||
import { BlogsModule } from './blogs/blogs.module';
|
||||
import { WikiModule } from './wiki/wiki.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -31,6 +32,7 @@ import { BlogsModule } from './blogs/blogs.module';
|
||||
AdminModule,
|
||||
HomeModule,
|
||||
BlogsModule,
|
||||
WikiModule,
|
||||
],
|
||||
controllers: [MetricsController],
|
||||
providers: [
|
||||
|
||||
@@ -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