-
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.
* add :: create emoji * chore :: add format
- Loading branch information
Showing
6 changed files
with
68 additions
and
22 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
src/application/domain/emoji/controller/emoji.controller.ts
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,22 @@ | ||
import { Body, Controller, Injectable, Post, UseFilters, UseGuards } from "@nestjs/common"; | ||
import { GlobalExceptionFilter } from "../../../../infrastructure/global/filter/global.exception.filter"; | ||
import { EmojiService } from "../service/emoji.service"; | ||
import { CurrentUser } from "../../../../infrastructure/global/decorator/current-user"; | ||
import { UserEntity } from "../../../../infrastructure/domain/user/persistence/user.entity"; | ||
import { CreateEmojiRequest } from "../dto/emoji.dto"; | ||
import { AuthGuard } from "@nestjs/passport"; | ||
|
||
@UseFilters(GlobalExceptionFilter) | ||
@Controller('emoji') | ||
export class EmojiController { | ||
constructor( | ||
private emojiService: EmojiService | ||
) { | ||
} | ||
|
||
@UseGuards(AuthGuard()) | ||
@Post() | ||
async createEmoji(@CurrentUser() user: UserEntity, @Body() request: CreateEmojiRequest) { | ||
await this.emojiService.createEmoji(user, request) | ||
} | ||
} |
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 { IsNotEmpty, IsNumber, IsString, Matches } from "class-validator"; | ||
|
||
export class CreateEmojiRequest { | ||
@IsNotEmpty() | ||
@IsString() | ||
title: string; | ||
@IsNotEmpty() | ||
@IsString() | ||
content: string; | ||
@IsNotEmpty() | ||
@IsString() | ||
imageUrl: string; | ||
@IsNotEmpty() | ||
@IsNumber() | ||
price: 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,19 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import { InjectRepository } from "@nestjs/typeorm"; | ||
import { EmojiEntity } from "../../../../infrastructure/domain/emoji/persistence/emoji.entity"; | ||
import { Repository } from "typeorm"; | ||
import { CreateEmojiRequest } from "../dto/emoji.dto"; | ||
|
||
@Injectable() | ||
export class EmojiService { | ||
constructor( | ||
@InjectRepository(EmojiEntity) | ||
private emojiRepository: Repository<EmojiEntity>, | ||
) { | ||
} | ||
|
||
async createEmoji(req, request: CreateEmojiRequest) { | ||
let { title, content, imageUrl, price } = request | ||
await this.emojiRepository.save({ title: title, content: content, image: imageUrl, price: price, userId: req }) | ||
} | ||
} |
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
15 changes: 0 additions & 15 deletions
15
src/infrastructure/domain/emoji/persistence/emoji.image.entity.ts
This file was deleted.
Oops, something went wrong.
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