Skip to content

Commit

Permalink
[#92]feat: myPage pagenation 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Arios67 committed Mar 31, 2022
1 parent f5cd383 commit 9ed1d9b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
14 changes: 7 additions & 7 deletions ars/src/apis/art/art.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,8 @@ export class ArtResolver {

// 작품id로 해당 작가의 모든 작품 조회
@Query(() => [Art])
async fetchArtistWorks(
@Args('page') page: number,
@Args('artId') artId: string,
) {
return await this.artService.findArtistWorks(artId, page);
async fetchArtistWorks(@Args('artId') artId: string) {
return await this.artService.findArtistWorks(artId);
}

@UseGuards(GqlAuthAccessGuard)
Expand Down Expand Up @@ -115,7 +112,10 @@ export class ArtResolver {

@UseGuards(GqlAuthAccessGuard)
@Query(() => [Art])
async fetchLikeArt(@CurrentUser() currentUser: ICurrentUser) {
return await this.likeArtService.find(currentUser.id);
async fetchLikeArt(
@Args('page') page: number,
@CurrentUser() currentUser: ICurrentUser,
) {
return await this.likeArtService.find(currentUser.id, page);
}
}
4 changes: 1 addition & 3 deletions ars/src/apis/art/art.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,14 @@ export class ArtService {
}

// 작품Id로 해당 작가 모든 작품검색
async findArtistWorks(artId, page) {
async findArtistWorks(artId) {
const art = await this.artRepository.findOne({
withDeleted: true,
where: { id: artId },
});
const user = art.user;
return await this.artRepository.find({
withDeleted: true,
take: 10,
skip: 10 * (page - 1),
where: { user: user },
});
}
Expand Down
4 changes: 2 additions & 2 deletions ars/src/apis/auth/auth.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export class AuthResolver {
const user = await this.userService.findOne(email);
if (!user)
// 이메일 체크
throw new UnprocessableEntityException();
throw new UnprocessableEntityException('이메일이 올바르지 않습니다.');
const isAuth = await bcrypt.compare(password, user.password);
if (!isAuth) throw new UnauthorizedException();
if (!isAuth) throw new UnauthorizedException('비밀번호가 틀렸습니다.');

this.authService.setRefreshToken({ user, res: context.res });

Expand Down
8 changes: 6 additions & 2 deletions ars/src/apis/likeArt/likeArt.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ export class LikeArtService {
private readonly likeArtRepository: Repository<LikeArt>,
) {}

async find(userId) {
const arts = await this.likeArtRepository.find({ userId: userId });
async find(userId, page) {
const arts = await this.likeArtRepository.find({
take: 10,
skip: 10 * (page - 1),
where: { userId: userId },
});
return arts.map((ele) => ele.art);
}

Expand Down
7 changes: 1 addition & 6 deletions ars/src/apis/pointTransaction/pointTransaction.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,7 @@ export class PointTransactionServive {
},
);
// 유저 누적 포인트 업데이트
// const updatedUser = this.userRepository.create({
// ...user,
// point: user.point + charge_amount,
// });

const updatedUser = await queryRunner.manager.save({
const updatedUser = await queryRunner.manager.save(User, {
...user,
point: user.point + charge_amount,
});
Expand Down

0 comments on commit 9ed1d9b

Please sign in to comment.