wuyi 2 år sedan
förälder
incheckning
0f5862f5f7

+ 7 - 3
src/comment/comment.service.ts

@@ -10,6 +10,7 @@ import { CommentDto } from './dto/comment.dto'
 import { LikesService } from 'src/likes/likes.service'
 import { Likes } from 'src/likes/entities/likes.entity'
 import { Moments } from 'src/moments/entities/moments.entity'
+import { ConditionService } from 'src/condition/condition.service'
 
 @Injectable()
 export class CommentService {
@@ -21,7 +22,8 @@ export class CommentService {
         private readonly likesRepository: Repository<Likes>,
         @InjectRepository(Moments)
         private readonly momentsRepository: Repository<Moments>,
-        private readonly likesService: LikesService
+        private readonly likesService: LikesService,
+        private readonly conditionService: ConditionService
     ) { }
 
 
@@ -140,9 +142,11 @@ export class CommentService {
         moments.commentNum += 1
         await this.momentsRepository.save(moments)
         const newComment = await this.commentRepository.save(commentDto)
-        
 
-        
+        if (false) {
+            await this.conditionService.reply(newComment, moments)
+        }
+
         return newComment
     }
 

+ 11 - 0
src/form/dto/form.dto.ts

@@ -0,0 +1,11 @@
+import { IsNumber, IsString } from "class-validator";
+
+export class FormDto {
+
+    name: string
+
+    text: string
+
+    relId: number
+
+}

+ 22 - 0
src/form/entities/form.entity.ts

@@ -0,0 +1,22 @@
+import { Col } from "sequelize/types/utils";
+import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn } from "typeorm";
+
+@Entity()
+export class Form {
+
+    @PrimaryGeneratedColumn()
+    id: number;
+
+    @Column()
+    name: string
+
+    @Column()
+    text: string
+
+    @Column()
+    relId: number
+
+    @CreateDateColumn()
+    createdAt: Date
+
+}

+ 11 - 0
src/form/form.controller.ts

@@ -0,0 +1,11 @@
+import {
+    Controller
+} from '@nestjs/common'
+import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'
+
+@ApiTags('form')
+@Controller('/form')
+@ApiBearerAuth()
+export class FormController {
+
+}

+ 13 - 0
src/form/form.module.ts

@@ -0,0 +1,13 @@
+import { Module } from '@nestjs/common'
+import { TypeOrmModule } from '@nestjs/typeorm'
+import { FormService } from './form.service'
+import { Form } from './entities/form.entity'
+import { FormController } from './form.controller'
+
+@Module({
+    imports: [TypeOrmModule.forFeature([Form])],
+    controllers: [FormController],
+    providers: [FormService],
+    exports: [FormService]
+})
+export class FormModule { }

+ 41 - 0
src/form/form.service.ts

@@ -0,0 +1,41 @@
+import {
+    Injectable, NotFoundException
+} from '@nestjs/common'
+import { FindManyOptions, FindOptionsOrder, In, Repository, UpdateResult } from 'typeorm'
+import { InjectRepository } from '@nestjs/typeorm'
+import { paginate, Pagination } from 'nestjs-typeorm-paginate'
+import { PageRequest } from '../common/dto/page-request'
+import { Form } from './entities/form.entity'
+import { FormDto } from './dto/form.dto'
+
+@Injectable()
+export class FormService {
+
+    constructor(
+        @InjectRepository(Form)
+        private readonly formRepository: Repository<Form>
+    ) { }
+
+    public async create(formDto: FormDto) {
+        return await this.formRepository.save(formDto)
+    }
+
+    public async createAll(list: Form[]) {
+
+    }
+
+    public async findById(id: number): Promise<Form> {
+        const form = await this.formRepository.findOneBy({
+            id: +id
+        })
+
+        if (!form) {
+            throw new NotFoundException(`Form #${id} not found`)
+        }
+
+        return form
+    }
+
+
+
+}