Skip to content

Commit

Permalink
feat: #47 페이지 별로 우연 조회 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ChoiYongWon committed Dec 10, 2022
1 parent 0d438cd commit 7cc9ac0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
18 changes: 10 additions & 8 deletions src/posting/posting.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ export class PostingController {
isArray: true,
})
@Roles([Role.User])
async getAllPost(@Req() req) {
async getAllPost(@Req() req, @Query('page') page: number) {
const user_id = req.user.user_id;
return await this.postingService.getAllPost(user_id).catch((err) => {
return await this.postingService.getAllPost(user_id, page).catch((err) => {
throw new InternalServerErrorException({
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
message: err.message,
Expand All @@ -161,14 +161,16 @@ export class PostingController {
isArray: true,
})
@Roles([Role.User])
async getViewedPost(@Req() req) {
async getViewedPost(@Req() req, @Query('page') page: number) {
const user_id = req.user.user_id;
return await this.postingService.getViewedPost(user_id).catch((err) => {
throw new InternalServerErrorException({
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
message: err.message,
return await this.postingService
.getViewedPost(user_id, page)
.catch((err) => {
throw new InternalServerErrorException({
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
message: err.message,
});
});
});
}

@Get('/near')
Expand Down
8 changes: 6 additions & 2 deletions src/posting/posting.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,16 @@ forFriend = 0 인 게시물 중에
return result;
}

async getViewedPost(user_id: string) {
async getViewedPost(user_id: string, page: number) {
let query = await this.postingRepository
.createQueryBuilder('post')
.leftJoin('post.footprint', 'footprint')
.leftJoinAndSelect('post.image', 'image')
.select('post.post_id')
.addSelect('image.img_url')
.where('footprint.user_id = :user_id', { user_id })
.take(15)
.skip(15 * page)
.getMany();

const result = [];
Expand Down Expand Up @@ -245,14 +247,16 @@ forFriend = 0 인 게시물 중에
return { ...result, emotion: { ...emotion }, distance, owner };
}

async getAllPost(user_id: string) {
async getAllPost(user_id: string, page: number) {
let query = await this.postingRepository
.createQueryBuilder('post')
.leftJoinAndSelect('post.user_id', 'user')
.leftJoinAndSelect('post.image', 'image')
.select('post.post_id')
.addSelect('image.img_url')
.where('user.user_id = :user_id', { user_id })
.take(15)
.skip(15 * page)
.getMany();

// 대표사진만
Expand Down

0 comments on commit 7cc9ac0

Please sign in to comment.