Skip to content

Commit

Permalink
Merge pull request #169 from 9uttery/fix/qa-#167
Browse files Browse the repository at this point in the history
[QA] QA-44 (남의 앨범 저장 시 내부 소확행 전부 북마크 활성화)
  • Loading branch information
hojeong2747 authored Apr 13, 2024
2 parents aa7632d + 849d045 commit 3465b96
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ public AlbumGetDetailResponse getAlbumDetail(Long albumId, UserPrincipal userPri
joyInfoList = albumQueryDslRepository.getMyAlbumJoys(albumId);
albumGetDetailResponse = new AlbumGetDetailResponse(album.getAlbumStatus().getIsOfficial(), album.getAlbumInfo().getAlbumIconNum(), album.getAlbumInfo().getAlbumColorNum(), null, album.getName(), null, album.getDescription(), joyInfoList);
} else { // 남 앨범
joyInfoList = albumQueryDslRepository.getAlbumJoys(albumId, user.getUserId());
Boolean isAlbumSaved = albumQueryDslRepository.getIsAlbumSaved(albumId, user.getUserId());
if (isAlbumSaved) { // 저장 -> joyInfoList 속 isJoySaved 전부 true
joyInfoList = albumQueryDslRepository.getSavedAlbumJoys(albumId, user.getUserId());
} else {
joyInfoList = albumQueryDslRepository.getAlbumJoys(albumId, user.getUserId());
}
albumGetDetailResponse = new AlbumGetDetailResponse(album.getAlbumStatus().getIsOfficial(), album.getAlbumInfo().getAlbumIconNum(), album.getAlbumInfo().getAlbumColorNum(), isAlbumSaved, album.getName(), album.getUser().getUserProfile().getNickname(), album.getDescription(), joyInfoList);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ public interface AlbumQueryDslRepository {

List<AlbumGetOthersResponse> getOtherAlbums(Long albumId, Long userId);


List<JoyGetInfo> getSavedAlbumJoys(Long albumId, Long userId);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.guttery.madii.domain.albums.infrastructure;

import com.guttery.madii.domain.albums.application.dto.*;
import com.guttery.madii.domain.albums.domain.model.QSavingJoy;
import com.guttery.madii.domain.albums.domain.repository.AlbumQueryDslRepository;
import com.querydsl.core.types.NullExpression;
import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.jpa.JPAExpressions;
import com.querydsl.jpa.JPQLQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
Expand Down Expand Up @@ -60,7 +60,6 @@ public List<JoyGetInfo> getMyAlbumJoys(Long albumId) {
@Override
public List<JoyGetInfo> getAlbumJoys(Long albumId, Long userId) {
// 사용자의 앨범에 저장된 joys
QSavingJoy userSavedJoys = new QSavingJoy("userSavedJoy");
JPQLQuery<Boolean> isJoySavedSubQuery = JPAExpressions
.select(savingJoy.isNotNull())
.from(savingJoy)
Expand All @@ -81,6 +80,26 @@ public List<JoyGetInfo> getAlbumJoys(Long albumId, Long userId) {
.fetch();
}

@Override
public List<JoyGetInfo> getSavedAlbumJoys(Long albumId, Long userId) {

// Boolean isJoySavedValue = true; // 고정된 값(true) 설정

return queryFactory
.select(Projections.constructor(JoyGetInfo.class,
joy.joyId,
joy.joyIconNum,
joy.contents,
Expressions.asBoolean(true)))
// new Expression<>(Boolean.class)))
.from(joy)
.join(savingJoy)
.on(savingJoy.joy.joyId.eq(joy.joyId)
.and(savingJoy.album.albumId.eq(albumId)))
.orderBy(savingJoy.createdAt.desc())
.fetch();
}

@Override
public Boolean getIsAlbumSaved(Long albumId, Long userId) {
long count = queryFactory
Expand Down

0 comments on commit 3465b96

Please sign in to comment.