-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
손보석
authored and
손보석
committed
Aug 31, 2023
1 parent
18c933c
commit 75192ac
Showing
25 changed files
with
197 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { IsArray, IsString } from 'class-validator' | ||
import { IsArray, IsNumber, IsString } from 'class-validator' | ||
|
||
export class UserDto { | ||
@ApiProperty({ | ||
example: 'default.jpg', | ||
description: '프로필 이미지' | ||
}) | ||
@IsString() | ||
readonly img: string | ||
|
||
@ApiProperty({ | ||
required: true, | ||
example: 'gildong', | ||
|
@@ -10,6 +17,14 @@ export class UserDto { | |
@IsString() | ||
readonly name: string | ||
|
||
@ApiProperty({ | ||
required: true, | ||
example: '[email protected]', | ||
description: '이메일' | ||
}) | ||
@IsString() | ||
readonly email: string | ||
|
||
@ApiProperty({ | ||
required: true, | ||
example: 'qwer1234!', | ||
|
@@ -19,10 +34,16 @@ export class UserDto { | |
readonly password: string | ||
|
||
@ApiProperty({ | ||
required: true, | ||
example: '그룹이름', | ||
description: '그룹', | ||
}) | ||
@IsArray() | ||
readonly group: string[] | ||
|
||
@ApiProperty({ | ||
example: '97', | ||
description: '상담, 진담 점수' | ||
}) | ||
@IsNumber() | ||
readonly score: number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Controller, Get, Req, Res } from '@nestjs/common' | ||
import { Request, Response } from 'express' | ||
import { FileService } from './file.service' | ||
|
||
@Controller('upload') | ||
export class FileController { | ||
constructor(private readonly fileService: FileService) {} | ||
|
||
@Get('post/:name') | ||
getPostImgByName( | ||
@Req() req: Request, | ||
@Res() res: Response | ||
) { | ||
return this.fileService.post(req, res) | ||
} | ||
|
||
@Get('profile/:name') | ||
getProfileImgByName( | ||
@Req() req: Request, | ||
@Res() res: Response | ||
) { | ||
return this.fileService.profile(req, res) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Module } from '@nestjs/common' | ||
import { FileService } from './file.service' | ||
import { FileController } from './file.controller' | ||
|
||
@Module({ | ||
controllers: [FileController], | ||
providers: [FileService] | ||
}) | ||
export class FileModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Injectable } from '@nestjs/common' | ||
import { Request, Response } from 'express' | ||
import { join } from 'path' | ||
|
||
@Injectable() | ||
export class FileService { | ||
async post(req: Request, res: Response) { | ||
const name = req.params.name | ||
return res.sendFile(join(process.cwd(), `uploads/post/${name}`)) | ||
} | ||
|
||
async profile(req: Request, res: Response) { | ||
const name = req.params.name | ||
return res.sendFile(join(process.cwd(), `uploads/profile/${name}`)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
import { Injectable } from '@nestjs/common' | ||
import { InjectModel } from '@nestjs/mongoose' | ||
import { Model } from 'mongoose' | ||
import { QuestionDto } from 'src/dto/question.dto' | ||
import { Question } from 'src/schema/question.schema' | ||
|
||
@Injectable() | ||
export class QuestionService { | ||
constructor(@InjectModel('Question') private readonly questionModel: Model<Question>) {} | ||
|
||
async createQuestion(content2: string): Promise<Question> { | ||
const newQuestion = new this.questionModel({ content2 }) | ||
async create(body: QuestionDto): Promise<Question> { | ||
const newQuestion = new this.questionModel(body) | ||
return await newQuestion.save() | ||
} | ||
|
||
async getAllQuestion(): Promise<Question[]> { | ||
async getAll(): Promise<Question[]> { | ||
return await this.questionModel.find().exec() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.