xiongzhu 2 лет назад
Родитель
Сommit
7f02fa9fd9

+ 3 - 1
src/app.module.ts

@@ -14,6 +14,7 @@ import { UserBalanceModule } from './user-balance/user-balance.module'
 import { SysConfigModule } from './sys-config/sys-config.module'
 import { AllExceptionsFilter } from './filters/all-exceptions-filter.filter'
 import { DownloadModule } from './download/download.module';
+import { GalleryModule } from './gallery/gallery.module';
 @Module({
     imports: [
         DevtoolsModule.register({
@@ -65,7 +66,8 @@ import { DownloadModule } from './download/download.module';
         FileModule,
         UserBalanceModule,
         SysConfigModule,
-        DownloadModule
+        DownloadModule,
+        GalleryModule,
     ],
     controllers: [],
     providers: [

+ 31 - 0
src/gallery/entities/gallery.entity.ts

@@ -0,0 +1,31 @@
+import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'
+
+@Entity()
+export class Gallery {
+    @PrimaryGeneratedColumn()
+    id: number
+
+    @Column({ type: 'varchar' })
+    parody: string[]
+
+    @Column({ type: 'varchar' })
+    charactor: string[]
+
+    @Column({ type: 'varchar' })
+    tag: string[]
+
+    @Column()
+    artist: string
+
+    @Column()
+    group: string
+
+    @Column()
+    language: string
+
+    @Column()
+    category: string
+
+    @Column({ type: 'text' })
+    details: string[]
+}

+ 20 - 0
src/gallery/gallery.controller.ts

@@ -0,0 +1,20 @@
+import { Body, Controller, Get, Post, Put } from '@nestjs/common'
+import { Public } from '../auth/public.decorator'
+import { GalleryService } from './gallery.service'
+import { Gallery } from './entities/gallery.entity'
+
+@Controller('gallery')
+@Public()
+export class GalleryController {
+    constructor(private galleryService: GalleryService) {}
+
+    @Get()
+    async findAll() {
+        return await this.galleryService.findAll()
+    }
+
+    @Put()
+    async save(@Body() gallery: Gallery) {
+        return await this.galleryService.save(gallery)
+    }
+}

+ 12 - 0
src/gallery/gallery.module.ts

@@ -0,0 +1,12 @@
+import { Module } from '@nestjs/common'
+import { GalleryController } from './gallery.controller'
+import { GalleryService } from './gallery.service'
+import { TypeOrmModule } from '@nestjs/typeorm'
+import { Gallery } from './entities/gallery.entity'
+
+@Module({
+    imports: [TypeOrmModule.forFeature([Gallery])],
+    controllers: [GalleryController],
+    providers: [GalleryService]
+})
+export class GalleryModule {}

+ 20 - 0
src/gallery/gallery.service.ts

@@ -0,0 +1,20 @@
+import { Injectable } from '@nestjs/common'
+import { Repository } from 'typeorm'
+import { Gallery } from './entities/gallery.entity'
+import { InjectRepository } from '@nestjs/typeorm'
+
+@Injectable()
+export class GalleryService {
+    constructor(
+        @InjectRepository(Gallery)
+        private readonly galleryRepository: Repository<Gallery>
+    ) {}
+
+    async findAll(): Promise<Gallery[]> {
+        return await this.galleryRepository.find()
+    }
+
+    async save(gallery: Gallery): Promise<Gallery> {
+        return await this.galleryRepository.save(gallery)
+    }
+}