add content
This commit is contained in:
parent
57c0318bda
commit
2e03eca42d
@ -2,9 +2,10 @@ import { Module } from '@nestjs/common';
|
|||||||
|
|
||||||
import { AppController } from './app.controller';
|
import { AppController } from './app.controller';
|
||||||
import { AppService } from './app.service';
|
import { AppService } from './app.service';
|
||||||
|
import { ContentModule } from './modules/content/content.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [],
|
imports: [ContentModule],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
providers: [AppService],
|
providers: [AppService],
|
||||||
})
|
})
|
||||||
|
8
src/modules/content/content.module.ts
Normal file
8
src/modules/content/content.module.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
|
import { PostController } from './controllers/post.controller';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [PostController],
|
||||||
|
})
|
||||||
|
export class ContentModule {}
|
20
src/modules/content/controllers/post.controller.ts
Normal file
20
src/modules/content/controllers/post.controller.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { Controller, Get } from '@nestjs/common';
|
||||||
|
|
||||||
|
import { PostEntity } from '../types';
|
||||||
|
|
||||||
|
const posts: PostEntity[] = [
|
||||||
|
{ title: '第一篇文章标题', body: '第一篇文章内容' },
|
||||||
|
{ title: '第二篇文章标题', body: '第二篇文章内容' },
|
||||||
|
{ title: '第三篇文章标题', body: '第三篇文章内容' },
|
||||||
|
{ title: '第四篇文章标题', body: '第四篇文章内容' },
|
||||||
|
{ title: '第五篇文章标题', body: '第五篇文章内容' },
|
||||||
|
{ title: '第六篇文章标题', body: '第六篇文章内容' },
|
||||||
|
].map((v, id) => ({ ...v, id }));
|
||||||
|
|
||||||
|
@Controller('posts')
|
||||||
|
export class PostController {
|
||||||
|
@Get()
|
||||||
|
async index() {
|
||||||
|
return posts;
|
||||||
|
}
|
||||||
|
}
|
6
src/modules/content/types.ts
Normal file
6
src/modules/content/types.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export interface PostEntity {
|
||||||
|
id: number;
|
||||||
|
title: string;
|
||||||
|
summary?: string;
|
||||||
|
body: string;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user