Skip to content

Commit

Permalink
Merge pull request #127 from Modagbul/feat/alarm_minsu
Browse files Browse the repository at this point in the history
�소모임 조회할 때 프로필 이미지 추가
  • Loading branch information
minsu20 authored Dec 10, 2023
2 parents 5edc09e + c762362 commit aa1606d
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void readBoard() {
public void deleteMember() {
if(Boolean.TRUE.equals(writerIsDeleted)) {
this.writerNickName = "(알 수 없음)";
this.writerProfileImage = "undef";
this.writerProfileImage = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ public Board toBoard(Member member, TeamMember teamMember, Team team, CreateBoar

public GetBoardDetailResponse toBoardDetail(Board board, boolean isWriter, boolean writerIsDeleted) {
String nickName = writerIsDeleted ? "(알 수 없음)" : board.getWriterNickName();
String writerProfileImage = writerIsDeleted ? null : board.getWriterProfileImage();
return GetBoardDetailResponse.builder()
.boardId(board.getBoardId())
.title(board.getTitle())
.content(board.getContent())
.writerNickName(nickName)
.writerIsLeader(board.isLeader())
.writerProfileImage(board.getWriterProfileImage())
.writerProfileImage(writerProfileImage)
.createdDate(getFormattedDate(board.getCreatedDate()))
.isWriter(isWriter)
.isNotice(board.isNotice())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.moing.backend.domain.board.application.dto.response.BoardBlocks;
import com.moing.backend.domain.board.application.dto.response.GetAllBoardResponse;
import com.moing.backend.domain.board.domain.entity.Board;
import com.moing.backend.domain.teamMember.domain.entity.QTeamMember;
import com.querydsl.jpa.impl.JPAQueryFactory;

import javax.persistence.EntityManager;
Expand All @@ -24,12 +25,16 @@ public BoardCustomRepositoryImpl(EntityManager em) {
public GetAllBoardResponse findBoardAll(Long teamId, Long memberId) {
// 전체 게시글 보기
List<Board> allBoards = queryFactory.selectFrom(board)
.distinct()
.leftJoin(board.teamMember, QTeamMember.teamMember).fetchJoin() // TeamMember를 함께 로드
.where(board.team.teamId.eq(teamId))
.orderBy(board.createdDate.desc())
.fetch();

// 읽은 게시글 보기
List<Board> readBoards = queryFactory.selectFrom(board)
.distinct()
.leftJoin(board.teamMember, QTeamMember.teamMember).fetchJoin() // TeamMember를 함께 로드
.join(boardRead).on(boardRead.board.eq(board))
.where(board.team.teamId.eq(teamId))
.where(boardRead.member.memberId.eq(memberId))
Expand Down Expand Up @@ -57,6 +62,7 @@ public GetAllBoardResponse findBoardAll(Long teamId, Long memberId) {
if (isRead) {
boardBlocks.readBoard();
}

return boardBlocks;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Getter
@Builder
@AllArgsConstructor
Expand All @@ -24,10 +27,30 @@ public class CommentBlocks {

private Boolean writerIsDeleted;

private String createdDate;

@QueryProjection
public CommentBlocks(Long boardCommentId, String content, String writerNickName, Boolean writerIsLeader, String writerProfileImage, Boolean isWriter, Boolean writerIsDeleted, LocalDateTime createdDate) {
this.boardCommentId = boardCommentId;
this.writerNickName = writerNickName;
this.writerIsLeader = writerIsLeader;
this.writerProfileImage = writerProfileImage;
this.content = content;
this.isWriter = isWriter;
this.writerIsDeleted=writerIsDeleted;
this.createdDate = getFormattedDate(createdDate);
deleteMember();
}

public void deleteMember() {
if (Boolean.TRUE.equals(writerIsDeleted)) {
this.writerNickName = "(알 수 없음)";
this.writerProfileImage = "undef";
this.writerProfileImage = null;
}
}

public String getFormattedDate(LocalDateTime localDateTime) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm");
return localDateTime.format(formatter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.moing.backend.domain.boardComment.application.dto.response.CommentBlocks;
import com.moing.backend.domain.boardComment.application.dto.response.GetBoardCommentResponse;
import com.moing.backend.domain.boardComment.application.dto.response.QCommentBlocks;
import com.moing.backend.domain.teamMember.domain.entity.QTeamMember;
import com.moing.backend.domain.teamMember.domain.entity.TeamMember;
import com.querydsl.core.types.ExpressionUtils;
Expand All @@ -26,7 +27,7 @@ public BoardCommentCustomRepositoryImpl(EntityManager em) {
@Override
public GetBoardCommentResponse findBoardCommentAll(Long boardId, TeamMember teamMember) {
List<CommentBlocks> commentBlocks = queryFactory
.select(Projections.constructor(CommentBlocks.class,
.select(new QCommentBlocks(
boardComment.boardCommentId,
boardComment.content,
boardComment.writerNickName,
Expand All @@ -38,14 +39,13 @@ public GetBoardCommentResponse findBoardCommentAll(Long boardId, TeamMember team
.where(QTeamMember.teamMember.eq(teamMember)
.and(QTeamMember.teamMember.eq(boardComment.teamMember)))
.exists(), "isWriter"),
boardComment.teamMember.isDeleted))
boardComment.teamMember.isDeleted,
boardComment.createdDate))
.from(boardComment)
.where(boardComment.board.boardId.eq(boardId))
.orderBy(boardComment.createdDate.asc())
.fetch();

commentBlocks.forEach(CommentBlocks::deleteMember);

return new GetBoardCommentResponse(commentBlocks);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class SaveSingleAlarmHistoryUseCase {
private final AlarmHistorySaveService alarmHistorySaveService;

@Async
public void saveAlarmHistory(String fcmToken, Long memberId, String idInfo, String title, String body, String name, AlarmType alarmType, String path) {
public void saveAlarmHistory(Long memberId, String idInfo, String title, String body, String name, AlarmType alarmType, String path) {
AlarmHistory alarmHistory = alarmHistoryMapper.toAlarmHistory(alarmType, path, idInfo, memberId, title, body, name);
alarmHistorySaveService.saveAlarmHistory(alarmHistory);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public class GetMyPageTeamBlock {
private Long teamId;
private String teamName;
private Category category;
private String profileImgUrl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
Expand All @@ -27,9 +26,10 @@ public class TeamBlock {
private String category;
private String startDate;
private LocalDateTime deletionTime;
private String profileImgUrl;

@QueryProjection
public TeamBlock(Long teamId, LocalDateTime approvalTime, Integer levelOfFire, String teamName, Integer numOfMember, Category category, LocalDateTime deletionTime){
public TeamBlock(Long teamId, LocalDateTime approvalTime, Integer levelOfFire, String teamName, Integer numOfMember, Category category, LocalDateTime deletionTime, String profileImgUrl) {
this.teamId=teamId;
this.duration=calculateDuration(approvalTime);
this.levelOfFire=levelOfFire;
Expand All @@ -38,6 +38,7 @@ public TeamBlock(Long teamId, LocalDateTime approvalTime, Integer levelOfFire, S
this.category=category.getMessage();
this.startDate=approvalTime.toLocalDate().format(DateTimeFormatter.ofPattern("yyyy.MM.dd"));
this.deletionTime=deletionTime;
this.profileImgUrl = profileImgUrl;
}

public Long calculateDuration(LocalDateTime approvalTime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public List<Long> findTeamIdByMemberId(Long memberId){
public List<GetMyPageTeamBlock> findMyPageTeamByMemberId(Long memberId) {
return queryFactory
.select(Projections.constructor(GetMyPageTeamBlock.class,
team.teamId, team.name, team.category))
team.teamId, team.name, team.category, team.profileImgUrl))
.from(teamMember)
.innerJoin(teamMember.team, team)
.on(teamMember.member.memberId.eq(memberId))
Expand All @@ -91,7 +91,8 @@ private List<TeamBlock> getTeamBlock(Long memberId) {
team.name,
team.numOfMember,
team.category,
team.deletionTime))
team.deletionTime,
team.profileImgUrl))
.from(teamMember)
.innerJoin(teamMember.team, team)
.on(teamMember.member.memberId.eq(memberId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class FcmService {

private final FirebaseMessaging firebaseMessaging;


@Retryable(value = FirebaseMessagingException.class, maxAttempts = 3, backoff = @Backoff(delay = 1000))
public SingleResponse sendSingleDevice(SingleRequest toSingleRequest) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public void get_board_comment_all() throws Exception {
.writerProfileImage("작성자 프로필 이미지")
.writerIsDeleted(false)
.isWriter(true)
.createdDate("2023/12/05 23:29")
.build();

commentBlocks.add(commentBlock);
Expand Down Expand Up @@ -174,13 +175,14 @@ public void get_board_comment_all() throws Exception {
responseFields(
fieldWithPath("isSuccess").description("true"),
fieldWithPath("message").description("댓글 목록을 모두 조회했습니다."),
fieldWithPath("data.commentBlocks[0].boardCommentId").description("댓글 아이디"),
fieldWithPath("data.commentBlocks[0].content").description("댓글 내용"),
fieldWithPath("data.commentBlocks[0].writerIsLeader").description("작성자 소모임장 여부"),
fieldWithPath("data.commentBlocks[0].writerNickName").description("작성자 닉네임"),
fieldWithPath("data.commentBlocks[0].writerProfileImage").description("작성자 프로필 이미지"),
fieldWithPath("data.commentBlocks[0].writerIsDeleted").description("작성자 삭제 여부"),
fieldWithPath("data.commentBlocks[0].isWriter").description("댓글 작성자 여부")
fieldWithPath("data.commentBlocks[].boardCommentId").description("댓글 아이디"),
fieldWithPath("data.commentBlocks[].content").description("댓글 내용"),
fieldWithPath("data.commentBlocks[].writerIsLeader").description("작성자 소모임장 여부"),
fieldWithPath("data.commentBlocks[].writerNickName").description("작성자 닉네임"),
fieldWithPath("data.commentBlocks[].writerProfileImage").description("작성자 프로필 이미지"),
fieldWithPath("data.commentBlocks[].writerIsDeleted").description("작성자 삭제 여부"),
fieldWithPath("data.commentBlocks[].isWriter").description("댓글 작성자 여부"),
fieldWithPath("data.commentBlocks[].createdDate").description("생성 시간")
)

)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public void get_mypage() throws Exception{
.teamId(1L)
.teamName("소모임이름")
.category(Category.SPORTS)
.profileImgUrl("프로필 이미지 url")
.build();
getMyPageTeamBlocks.add(blocks);

Expand Down Expand Up @@ -160,10 +161,11 @@ public void get_mypage() throws Exception{
fieldWithPath("data.profileImage").description("프로필 이미지 URL"),
fieldWithPath("data.nickName").description("닉네임"),
fieldWithPath("data.introduction").description("한줄 소개"),
fieldWithPath("data.categories[0]").description("내 열정의 불 해시태그"),
fieldWithPath("data.getMyPageTeamBlocks[0].teamId").description("소모임 아이디"),
fieldWithPath("data.getMyPageTeamBlocks[0].teamName").description("소모임 이름"),
fieldWithPath("data.getMyPageTeamBlocks[0].category").description("소모임 카테고리")
fieldWithPath("data.categories[]").description("내 열정의 불 해시태그"),
fieldWithPath("data.getMyPageTeamBlocks[].teamId").description("소모임 아이디"),
fieldWithPath("data.getMyPageTeamBlocks[].teamName").description("소모임 이름"),
fieldWithPath("data.getMyPageTeamBlocks[].category").description("소모임 카테고리"),
fieldWithPath("data.getMyPageTeamBlocks[].profileImgUrl").description("소모임 프로필 이미지 URL")
)
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public void get_team() throws Exception {
.category("ETC")
.startDate("2023.09.05")
.deletionTime(LocalDateTime.now().withNano(0))
.profileImgUrl("프로필 사진 url")
.build();

TeamBlock teamBlock2=TeamBlock.builder()
Expand All @@ -123,6 +124,7 @@ public void get_team() throws Exception {
.category("SPORTS")
.startDate("2023.09.01")
.deletionTime(LocalDateTime.now().withNano(0))
.profileImgUrl("프로필 사진 url")
.build();

teamBlocks.add(teamBlock1);
Expand Down Expand Up @@ -158,14 +160,15 @@ public void get_team() throws Exception {
fieldWithPath("message").description("홈 화면에서 내 소모임을 모두 조회했습니다."),
fieldWithPath("data.numOfTeam").description("소모임 개수(최대 3개)"),
fieldWithPath("data.memberNickName").description("유저 닉네임"),
fieldWithPath("data.teamBlocks[0].teamId").description("소모임 아이디"),
fieldWithPath("data.teamBlocks[0].duration").description("소모임과 함께한 시간"),
fieldWithPath("data.teamBlocks[0].levelOfFire").description("불꽃 레벨"),
fieldWithPath("data.teamBlocks[0].teamName").description("소모임 이름"),
fieldWithPath("data.teamBlocks[0].numOfMember").description("소모임원 명 수"),
fieldWithPath("data.teamBlocks[0].category").description("소모임 카테고리"),
fieldWithPath("data.teamBlocks[0].startDate").description("소모임 시작일"),
fieldWithPath("data.teamBlocks[0].deletionTime").description("소모임 삭제 시간 (삭제 안했으면 null)")
fieldWithPath("data.teamBlocks[].teamId").description("소모임 아이디"),
fieldWithPath("data.teamBlocks[].duration").description("소모임과 함께한 시간"),
fieldWithPath("data.teamBlocks[].levelOfFire").description("불꽃 레벨"),
fieldWithPath("data.teamBlocks[].teamName").description("소모임 이름"),
fieldWithPath("data.teamBlocks[].numOfMember").description("소모임원 명 수"),
fieldWithPath("data.teamBlocks[].category").description("소모임 카테고리"),
fieldWithPath("data.teamBlocks[].startDate").description("소모임 시작일"),
fieldWithPath("data.teamBlocks[].deletionTime").description("소모임 삭제 시간 (삭제 안했으면 null)"),
fieldWithPath("data.teamBlocks[].profileImgUrl").description("프로필 사진 url")
)

)
Expand Down

0 comments on commit aa1606d

Please sign in to comment.