Skip to content

Commit

Permalink
Merge pull request #121 from Mojacknong/feature_120/미션-인증-관련-이슈
Browse files Browse the repository at this point in the history
Feature 120/미션 인증 관련 이슈
  • Loading branch information
Ryeolee authored Sep 11, 2024
2 parents 3ac31cd + 1963a88 commit 22547dc
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ public BaseResponseDto<?> getMissionPostList(

@GetMapping("/{farmClubId}/user")
public BaseResponseDto<?> getFarmClubUserList(
@AuthenticationPrincipal CustomUser user,
@PathVariable Long farmClubId
) {
return BaseResponseDto.of(SuccessCode.SUCCESS, farmClubService.getFarmClubUserList(farmClubId));
return BaseResponseDto.of(SuccessCode.SUCCESS, farmClubService.getFarmClubUserList(user.getUserId(), farmClubId));
}

@GetMapping("/mission/{missionPostId}")
Expand Down Expand Up @@ -198,4 +199,20 @@ public BaseResponseDto<?> reportMissionPostComment(
missionPostService.reportMissionPostComment(user.getUserId(), requestDto);
return BaseResponseDto.of(SuccessCode.SUCCESS, null);
}

@DeleteMapping("/mission/{missionPostId}")
public BaseResponseDto<?> deleteMissionPost(
@PathVariable Long missionPostId
) {
missionPostService.deleteMissionPost(missionPostId);
return BaseResponseDto.of(SuccessCode.SUCCESS, null);
}

@DeleteMapping("/mission/comment/{missionPostCommentId}")
public BaseResponseDto<?> deleteMissionPostComment(
@PathVariable Long missionPostCommentId
) {
missionPostService.deleteMissionPostComment(missionPostCommentId);
return BaseResponseDto.of(SuccessCode.SUCCESS, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public List<GetMyFarmClubListResponseDto> getUserFarmClubList(Long userId) {
return farmClubRepository.findMyFarmClubList(userId);
}

public GetFarmClubUserListResponseDto getFarmClubUserList(Long farmClubId) {
return GetFarmClubUserListResponseDto.of(farmClubRepository.findFarmClubUserList(farmClubId));
public GetFarmClubUserListResponseDto getFarmClubUserList(Long userId, Long farmClubId) {
return GetFarmClubUserListResponseDto.of(farmClubRepository.findFarmClubUserList(userId, farmClubId));
}

public List<FarmClub> getRecommendedFarmClubList(String level) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public interface FarmClubRepositoryCustom {
List<GetMyFarmClubListResponseDto> findMyFarmClubList(Long userId);
GetMyFarmClubVo findMyFarmClub(Long farmClubId, Long userId);
HistoryDetailVo getFarmClubDetail(Long userFarmClubId);
List<GetFarmClubUserVo> findFarmClubUserList(Long farmClubId);
List<GetFarmClubUserVo> findFarmClubUserList(Long userId, Long farmClubId);
List<FarmClub> getRecommendedFarmClubList(String level);
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,40 @@ public GetMyFarmClubVo findMyFarmClub(Long farmClubId, Long userId) {
}

@Override
public List<GetFarmClubUserVo> findFarmClubUserList(Long farmClubId) {
public List<GetFarmClubUserVo> findFarmClubUserList(Long userId, Long farmClubId) {
JPAQueryFactory queryFactory = new JPAQueryFactory(em);

return queryFactory
// 내 유저 정보
List<GetFarmClubUserVo> userList = queryFactory
.select(Projections.constructor(
GetFarmClubUserVo.class,
user.id,
user.nickname,
user.profileImage))
.from(user)
.where(user.id.in(
JPAExpressions
.select(userFarmClub.userId)
.from(userFarmClub)
.join(userFarmClub.farmClub, farmClub)
.where(farmClub.id.eq(farmClubId))
))
.where(user.id.eq(userId)) // 내 유저 id를 먼저 조회
.fetch();

// 나머지 유저 정보
userList.addAll(
queryFactory
.select(Projections.constructor(
GetFarmClubUserVo.class,
user.id,
user.nickname,
user.profileImage))
.from(user)
.where(user.id.in(
JPAExpressions
.select(userFarmClub.userId)
.from(userFarmClub)
.join(userFarmClub.farmClub, farmClub)
.where(farmClub.id.eq(farmClubId))
).and(user.id.ne(userId))) // 내 유저 id를 제외하고 조회
.fetch()
);

return userList;
}

public HistoryDetailVo getFarmClubDetail(Long userFarmClubId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ public List<GetMyFarmClubListResponseDto> getMyFarmClubList(Long userId) {
return farmClubHelper.getUserFarmClubList(userId);
}

public GetFarmClubUserListResponseDto getFarmClubUserList(Long farmClubId) {
return farmClubHelper.getFarmClubUserList(farmClubId);
public GetFarmClubUserListResponseDto getFarmClubUserList(Long userId, Long farmClubId) {
return farmClubHelper.getFarmClubUserList(userId, farmClubId);
}

public GetMyVeggieResponseDto getMyVeggieForRegister(Long userId, String veggieInfoId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ public void reportMissionPostComment(Long userId, CreateMissionPostCommentReport
}
}

public void deleteMissionPost(Long missionPostId) {
MissionPost missionPost = missionPostHelper.getMissionPost(missionPostId);
missionPostHelper.deleteMissionPost(missionPost);
}

public void deleteMissionPostComment(Long missionPostCommentId) {
MissionPostComment missionPostComment = missionPostHelper.getMissionPostComment(missionPostCommentId);
missionPostHelper.deleteMissionPostComment(missionPostComment);
}

private MissionPost saveMissionPost(MissionPost missionPost) {
return missionPostRepository.save(missionPost);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

@Builder(access = AccessLevel.PRIVATE)
public record GetFarmClubUserVo(
Long userId,
String nickname,
String profileImage
) {
public static GetFarmClubUserVo of(String nickname, String profileImage) {
public static GetFarmClubUserVo of(Long userId, String nickname, String profileImage) {
return GetFarmClubUserVo.builder()
.userId(userId)
.nickname(nickname)
.profileImage(profileImage)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

public record MissionPostVo(
Long missionPostId,
Long userId,
int stepNum,
String nickname,
String profileImage,
Expand All @@ -23,6 +24,7 @@ public MissionPostVo(MissionPost missionPost, User user, Long likeCount, Long co
{
this(
missionPost.getId(),
user.getId(),
missionPost.getStepNum(),
user.getNickname(),
user.getProfileImage(),
Expand Down

0 comments on commit 22547dc

Please sign in to comment.