Skip to content

Commit

Permalink
Merge pull request #425 from boostcampwm2023/BE-ChangeBlockPost-#423
Browse files Browse the repository at this point in the history
[BE/#423] 숨긴 게시글 응답 수정
  • Loading branch information
koomin1227 authored Dec 9, 2023
2 parents ac331d7 + 5202021 commit 8a99c51
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
3 changes: 2 additions & 1 deletion BE/src/login/login.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Headers,
HttpException,
Post,
Query,
UseGuards,
} from '@nestjs/common';
import { LoginService, SocialProperties } from './login.service';
Expand Down Expand Up @@ -37,7 +38,7 @@ export class LoginController {
}

@Post('login/admin')
loginAdmin(@Body('user') user) {
loginAdmin(@Query('user') user) {
return this.loginService.loginAdmin(user);
}

Expand Down
11 changes: 9 additions & 2 deletions BE/src/posts-block/posts-block.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Get,
Param,
Post,
Query,
UseGuards,
} from '@nestjs/common';
import { PostsBlockService } from './posts-block.service';
Expand All @@ -23,8 +24,14 @@ export class PostsBlockController {
}

@Get()
async postsBlockList(@UserHash() blockerId: string) {
return await this.postsBlockService.findBlockedPosts(blockerId);
async postsBlockList(
@UserHash() blockerId: string,
@Query('requestFilter') requestFilter,
) {
return await this.postsBlockService.findBlockedPosts(
blockerId,
parseInt(requestFilter),
);
}

@Delete(':id')
Expand Down
14 changes: 13 additions & 1 deletion BE/src/posts-block/posts-block.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ export class PostsBlockService {
await this.blockPostRepository.save(blockPostEntity);
}

async findBlockedPosts(blockerId: string) {
async findBlockedPosts(blockerId: string, requestFilter: number) {
const blockLists = await this.blockPostRepository.find({
where: {
blocker: blockerId,
blockedPost: this.getRequestFilter(requestFilter),
},
relations: ['blockedPost'],
});
Expand All @@ -52,10 +53,21 @@ export class PostsBlockService {
title: blockedPost.title,
post_image: blockedPost.thumbnail,
post_id: blockedPost.id,
start_date: blockedPost.start_date,
end_date: blockedPost.end_date,
is_request: blockedPost.is_request,
price: blockedPost.price,
};
});
}

getRequestFilter(requestFilter: number) {
if (requestFilter === undefined) {
return undefined;
}
return { is_request: requestFilter === 1 };
}

async removeBlockPosts(blockedPostId: number, userId: string) {
const blockedPost = await this.blockPostRepository.findOne({
where: { blocked_post: blockedPostId, blocker: userId },
Expand Down

0 comments on commit 8a99c51

Please sign in to comment.