-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[server] 게시글 북마크 on 기능 구현 #348
Merged
Merged
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d5cb830
id,date 별 학생식당 메뉴 api
2dcfa11
chore: 불필요 주석 삭제
8003671
chore: 불필요 코드 삭제
7529947
chore: root package 와 server package 구분
c46fc80
practice
347774b
Merge branch 'dev' of https://github.com/CMI-OSS/cbnu-alrami into ser…
275f684
chore: 식당메뉴 추가
eda5d2e
chore: 식당메뉴 추가
cfaa637
chore: swagger 문서 추가
1ef6057
chore: 게시글 북마트 ON API 개발
fa1a6c0
chore: 게시글 북마트 ON API 개발
465ed27
chore: 게시글 북마트 ON API 개발
5fb3baa
Merge branch 'dev' into server/i314
fa1e604
feature: 게시글 bookmark on api 개발
80a89b0
Merge branch 'dev' into server/i314
653f512
chore: package.json 수정
c980a07
chore: ApiTags 문구 수정
4c4c5a5
♻️ Remove unused modules for bookmark module
jaryapp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Controller, Param, Post, Req, UseGuards } from "@nestjs/common"; | ||
import { ApiHeader, ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; | ||
import { Public } from "src/commons/decorators/public.decorator"; | ||
import { UserAuthGuard } from "src/commons/guards/user-auth.guard"; | ||
|
||
import { BookmarkService } from "./bookmark.service"; | ||
|
||
@Public() | ||
@Controller({ | ||
path: "bookmark", | ||
}) | ||
@ApiTags("[subscribe] 게시글 북마크 ON API") | ||
export class BookmarkControlelr { | ||
constructor(private readonly bookmarkService: BookmarkService) {} | ||
|
||
@Post("articles/:articleId") | ||
@ApiOperation({ | ||
summary: "게시글 북마트 ON API", | ||
description: "특정 유저가 북마크한 게시글을 저장합니다.", | ||
}) | ||
@ApiResponse({ | ||
status: 200, | ||
description: "성공 여부", | ||
}) | ||
@ApiHeader({ | ||
name: "uuid", | ||
description: "user uuid", | ||
}) | ||
@UseGuards(UserAuthGuard) | ||
async create(@Req() req, @Param("articleId") articleId: number) { | ||
const { user } = req; | ||
return this.bookmarkService.create(user, articleId); | ||
} | ||
} |
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,13 +1,52 @@ | ||
import { Module } from "@nestjs/common"; | ||
import { TypeOrmModule } from "@nestjs/typeorm"; | ||
import { AdminService } from "src/admin/admin.service"; | ||
import { AdminRepository } from "src/admin/repository/admin.repository"; | ||
import { ArticleRepository } from "src/article/article.repository"; | ||
import { ArticleService } from "src/article/article.service"; | ||
import { ArticleImageRepository } from "src/articleImage/articleImage.repository"; | ||
import { ArticleImageService } from "src/articleImage/articleImage.service"; | ||
import { BoardRepository } from "src/board/board.repository"; | ||
import { BoardService } from "src/board/board.service"; | ||
import { BoardTreeRepository } from "src/boardTree/boardTree.repository"; | ||
import { BoardTreeService } from "src/boardTree/boardTree.service"; | ||
import { HitRepository } from "src/hit/hit.repository"; | ||
import { AwsService } from "src/image/aws.service"; | ||
import { ImageRepository } from "src/image/image.repository"; | ||
import { ImageService } from "src/image/image.service"; | ||
import { SubscribeRepository } from "src/subscribe/subscribe.repository"; | ||
import { SubscribeService } from "src/subscribe/subscribe.service"; | ||
|
||
import { BookmarkControlelr } from "./bookmark.controller"; | ||
import { BookmarkRepository } from "./bookmark.repository"; | ||
import { BookmarkService } from "./bookmark.service"; | ||
|
||
@Module({ | ||
imports: [ TypeOrmModule.forFeature([ BookmarkRepository ]) ], | ||
providers: [ BookmarkService ], | ||
exports: [ BookmarkService ], | ||
imports: [ | ||
TypeOrmModule.forFeature([ | ||
ArticleRepository, | ||
BookmarkRepository, | ||
HitRepository, | ||
BoardRepository, | ||
AdminRepository, | ||
BoardTreeRepository, | ||
ArticleImageRepository, | ||
ImageRepository, | ||
SubscribeRepository, | ||
]), | ||
], | ||
controllers: [ BookmarkControlelr ], | ||
providers: [ | ||
BookmarkService, | ||
ArticleService, | ||
BoardService, | ||
AdminService, | ||
BoardTreeService, | ||
ArticleImageService, | ||
ImageService, | ||
SubscribeService, | ||
AwsService, | ||
ImageService, | ||
], | ||
}) | ||
|
||
export class BookmarkModule {} | ||
export class BookmarkModule {} |
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,8 +1,29 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import { ArticleService } from "src/article/article.service"; | ||
import { User } from "src/commons/entities/user.entity"; | ||
import { Errors } from "src/commons/exception/exception.global"; | ||
|
||
import { BookmarkRepository } from "./bookmark.repository"; | ||
|
||
const { ALREADY_SUBSCRIBE_BOOKMARK } = Errors; | ||
|
||
@Injectable() | ||
export class BookmarkService { | ||
constructor(private readonly bookmarkRepository: BookmarkRepository) {} | ||
constructor( | ||
private readonly bookmarkRepository: BookmarkRepository, | ||
private readonly articleService: ArticleService, | ||
) {} | ||
|
||
async create(user: User, articleId: number) { | ||
const article = await this.articleService.findById(articleId); | ||
|
||
// DESCRIBE: 요청한 유저가 article을 이미 구독 중인지 확인 | ||
if ( | ||
await this.bookmarkRepository.existsByUserAndArticle(user.id, articleId) | ||
) | ||
throw ALREADY_SUBSCRIBE_BOOKMARK; | ||
|
||
await this.bookmarkRepository.save(article); | ||
return "success"; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -33,6 +33,8 @@ export class SubscribeControlelr { | |
}) | ||
@UseGuards(UserAuthGuard) | ||
async create(@Req() req, @Param("boardId") boardId: number) { | ||
console.log("req 객체", req); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. console.log는 지우고 올리는게 좋을 것 같습니다! |
||
console.log("============================"); | ||
const { user } = req; | ||
return this.subscribeService.create(user, boardId); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
북마크 모듈에서 필요한것만 import하는게 좋을것 같아요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4c4c5a5
수정했음다~~