Skip to content

feature/MB-04 #66 : 게시글 좋아요 기능 구현#162

Merged
sete3683 merged 8 commits into
developfrom
feature/MB-04
Apr 13, 2025
Merged

feature/MB-04 #66 : 게시글 좋아요 기능 구현#162
sete3683 merged 8 commits into
developfrom
feature/MB-04

Conversation

@zelly-log
Copy link
Copy Markdown
Collaborator

feature/MB-04 #66 : 게시글 좋아요 기능 구현

🔘 Part

  • BE
  • Infra

🔎 PR Type

  • 새로운 기능 추가
  • 버그 수정
  • 주요 코드 리팩토링(성능 최적화 등)
  • 간단 코드 리팩토링(주석, 코드 컨벤션, 오타 수정 등)
  • 기타 (기타 사항 기입)

🔧 작업 내용 상세 작성

  • [feature/MB-04 [FEAT] MB-04 #66]

  • 메이트 모집 게시글 좋아요 기능 구현


✔️ PR Checklist

  • 커밋 메세지를 컨벤션에 맞게 잘 적용 하였나요?

  • 테스트 코드 작성 / 단위 테스트 or 통합 테스트 진행 하셨나요?

@zelly-log zelly-log added the enhancement 신규 기능 구현 / 기능 향상 label Apr 13, 2025
@zelly-log zelly-log requested a review from sete3683 April 13, 2025 09:19
@zelly-log zelly-log self-assigned this Apr 13, 2025
@zelly-log zelly-log linked an issue Apr 13, 2025 that may be closed by this pull request
2 tasks
zelly-log and others added 5 commits April 13, 2025 18:21
* [Remove] 사용하지 않는 파일 삭제

* [Remove] 예약 내역 전체 조회 및 예약 취소, 내역 삭제 구현

* [Feat] 예약 에러 메시지 추가

* [Feat] 응답 예외 방어/호출오류로그 추가 병합 충돌 해결

* test : Travel Controller, Service 테스트 코드 오류 수정

* 병합 충돌 해결

* [Refactor] @builder.Default/@AuthenticationPrincipal

* [Feat] 이미지-메이트 게시판 연동 (#140)

* refactor : Schedule, ScheduleDay, Travel Response 응답 id 추가 (#144)

* Refactor/CB-01 #129 : 챗봇 로그인 사용자 일정 조회 기능 오류 수정 (#146)

* refactor : 챗봇 대화 중 특정 유저 일정 불러올 때 오류 수정
- 스케줄, 여행 일정 InitData 추가

* refactor : TravelServiceTest 오류 수정

# Conflicts:
#	backend/src/test/java/com/frend/planit/domain/calendar/schedule/travel/service/TravelServiceTest.java

* refactor : 챗봇 특정 유저의 모든 일정 안내 로직 오류 수정 및 Schedule, Travel 샘플 데이터 생성

* [Feat] Accommodation-Filtering

* Feature/U-07 : 내 활동 내역 (메이트 게시판, 댓글) (#148)

* [FEAT] 나의활동 - 메이트 게시판

* [TEST] matepost 테스트 완료

* [FEAT] 내 활동 내역 - 내가 쓴 댓글

* [TEST] 내 활동 내역 - 내가 쓴 댓글 테스트, postman 확인

* [REFACTOR] userid 받아오는거로 통일

* Feature/U-08 : 내 활동 내역 - 캘린더 조회 (#150)

* [FEAT] 내 활동 내역 - 캘린더 조회

* [TEST] 내 활동 내역 - 캘린더 조회

* [FIX] 카카오 네이버 오류 해결 (#152)

* Refactor/S-01 #154 : 전체 조회 일정 기능 구현으로 단일 조회 일정 조회와 역할 구분하도록 리팩토링 (#155)

* Refactor/S-01 #156 : ScheduleController 보안 강화 및 색상 응답 추가 리팩토링 (#159)

* refactor : 로그인 인증된 사용자만 접근 가능하도록 리팩토링
- getIntHour, getIntMinute 메서드명으로 인해 스웨거에서 오류 발생 parseIntHout, parseIntMinute으로 변경

* refactor : CalendarEntity에 저장된 색상코드(lable_color)가 기본값에서 변경되지 않는 오류로 인해 ScheduleResponse에 색상코드(lable_color)를 추가
- ScheduleControllerTest 코드 수정

* [Refactor] 필드명 수정

---------

Co-authored-by: kingyj00 <onshopyj@gmail.com>
Co-authored-by: hellonaeunkim <hellonaeunkim@gmail.com>
Co-authored-by: sete3683 <108328000+sete3683@users.noreply.github.com>
Co-authored-by: NaEun Kim <121096778+hellonaeunkim@users.noreply.github.com>
Co-authored-by: c-hano <wdq0304@naver.com>
# Conflicts:
#	backend/src/main/java/com/frend/planit/global/response/ErrorType.java
.accommodationImage(data.getAccommodationImage())
.checkInDate(data.getCheckIn())
.checkOutDate(data.getCheckOut())
.checkInDate(data.getCheckInDate())
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data.getCheckIn()data.getCheckOut()에서 Date 타입의 필드명이 CheckInDate, CheckOutDate 로 변경된 것으로 보입니다. 변경 사유를 명확히 주석으로 추가해주세요. DTO의 필드명 변경과 일관성을 유지하기 위한 변경인지, 다른 이유가 있는지 명시해주시면 좋겠습니다.

*
* @param mateId 신청할 게시글 ID
* @param userId 현재 로그인한 사용자
* @param matePostId 신청할 게시글 ID
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mateIdmatePostId로 변경되었습니다. 일관성을 위해 mateId를 사용하는 다른 부분도 모두 matePostId로 변경해야 합니다. 변경 사유를 명확히 주석으로 추가해주세요. 예를 들어, "게시글 ID를 나타내는 변수명을 matePostId로 통일" 과 같이 구체적으로 작성해주세요.

* @param userId 현재 로그인한 사용자
*/
@PostMapping("/{mateId}")
@PostMapping("/{matePostId}")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API 엔드포인트에서도 mateIdmatePostId로 변경되었습니다. 이 변경은 위의 주석 변경과 일관성을 유지하기 위한 것으로 보입니다. 잘못된 부분이 없는지 확인해야 합니다.

@ResponseStatus(HttpStatus.CREATED)
public void applyToMate(@PathVariable Long mateId, @AuthenticationPrincipal Long userId) {
mateApplicationService.applyToMate(userId, mateId);
public void applyToMate(@PathVariable Long matePostId, @AuthenticationPrincipal Long userId) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메소드 파라미터 mateIdmatePostId로 변경되었습니다. mateApplicationService.applyToMate 메소드의 파라미터도 일관성 있게 변경되었는지 확인해야 합니다. 만약 변경되지 않았다면, mateApplicationService 메소드도 수정해야 합니다.

*
* @param mateId 신청을 취소할 게시글 ID
* @param userId 현재 로그인한 사용자 (신청자 본인)
* @param matePostId 신청을 취소할 게시글 ID
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mateIdmatePostId로 변경되었습니다. 일관성을 유지하기 위해 다른 부분도 수정해야 합니다. 변경 사유를 주석으로 명확히 기재해주세요.

* @param userId 현재 로그인한 사용자 (신청자 본인)
*/
@DeleteMapping("/{mateId}")
@DeleteMapping("/{matePostId}")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API 엔드포인트에서 mateIdmatePostId로 변경된 것을 확인했습니다. 일관성을 위해 다른 곳도 변경해야 합니다.

@ResponseStatus(HttpStatus.NO_CONTENT)
public void cancelApplication(@PathVariable Long mateId, @AuthenticationPrincipal Long userId) {
mateApplicationService.cancelApplication(userId, mateId);
public void cancelApplication(@PathVariable Long matePostId,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메소드 파라미터 mateIdmatePostId로 변경되었고, 코드 스타일 개선을 위해 줄바꿈이 추가되었습니다. mateApplicationService.cancelApplication 메소드의 파라미터도 일관성 있게 변경되었는지 확인하고, 필요하다면 수정해야 합니다.


/**
* 게시글 작성자가 특정 신청자의 신청을 수락합니다.
*
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mateIdmatePostId로 변경되었습니다. 일관성 있는 명명 규칙을 유지하기 위해서 다른 부분도 확인해야 합니다.

* @param matePostId 게시글 ID
* @param applicantId 수락할 신청자 ID
* @param userId 현재 로그인한 사용자 (게시글 작성자)
*/
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API 엔드포인트에서 mateIdmatePostId로 변경되었습니다. 일관성을 위해 mateId를 사용하는 다른 부분도 모두 matePostId로 변경했는지 확인해야 합니다.

@PutMapping("/{mateId}/accept/{applicantId}")
@PutMapping("/{matePostId}/accept/{applicantId}")
@ResponseStatus(HttpStatus.OK)
public void acceptApplication(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메소드 파라미터 mateIdmatePostId로 변경되었고, mateApplicationService.acceptApplication 메소드의 파라미터도 변경되었는지 확인해야 합니다. 만약 변경되지 않았다면, mateApplicationService 메소드도 수정해야 합니다.


/**
* 게시글 작성자가 특정 신청자의 신청을 거절합니다.
*
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mateIdmatePostId로 변경되었습니다. 일관성 있는 명명 규칙을 유지하기 위해서 다른 부분도 확인해야 합니다.

* @param matePostId 게시글 ID
* @param applicantId 거절할 신청자 ID
* @param userId 현재 로그인한 사용자 (게시글 작성자)
*/
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API 엔드포인트에서 mateIdmatePostId로 변경되었습니다. 일관성을 위해 mateId를 사용하는 다른 부분도 모두 matePostId로 변경했는지 확인해야 합니다.

@PutMapping("/{mateId}/reject/{applicantId}")
@PutMapping("/{matePostId}/reject/{applicantId}")
@ResponseStatus(HttpStatus.OK)
public void rejectApplication(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메소드 파라미터 mateIdmatePostId로 변경되었고, mateApplicationService.rejectApplication 메소드의 파라미터도 변경되었는지 확인해야 합니다. 만약 변경되지 않았다면, mateApplicationService 메소드도 수정해야 합니다.

@@ -0,0 +1,13 @@
package com.frend.planit.domain.mateboard.application.dto.request;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

새로운 DTO 클래스가 추가되었습니다. applicationIdmatePostId 필드의 유효성 검사(validation)를 추가하는 것이 좋습니다. 예를 들어, @NotNull 어노테이션을 사용하여 null 값을 허용하지 않도록 할 수 있습니다.

@@ -0,0 +1,10 @@
package com.frend.planit.domain.mateboard.application.dto.request;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

새로운 DTO 클래스가 추가되었습니다. matePostId 필드에 대한 유효성 검사(validation)를 추가하는 것이 좋습니다. null 값을 허용하지 않도록 @NotNull 어노테이션을 추가하는 것을 고려해 보세요.

@@ -0,0 +1,13 @@
package com.frend.planit.domain.mateboard.application.dto.request;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

새로운 DTO 클래스가 추가되었습니다. applicationIdmatePostId 필드에 대한 유효성 검사(validation)를 추가하는 것이 좋습니다. @NotNull 어노테이션을 사용하는 것을 고려해 보세요.

@@ -0,0 +1,8 @@
package com.frend.planit.domain.mateboard.application.dto.response;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

새로운 DTO 클래스가 추가되었습니다. status 필드의 값이 PENDING, ACCEPTED, REJECTED로 제한되는지 확인하고, 필요하다면 enum 타입을 사용하여 더욱 안전하게 관리하는 것을 고려해 보세요.

@@ -0,0 +1,34 @@
package com.frend.planit.domain.mateboard.post.controller;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

새로운 컨트롤러가 추가되었습니다. 좋아요 기능을 위한 likeunlike 메소드가 정의되어 있습니다. 에러 핸들링을 추가하여 예외 상황을 처리하는 것이 좋습니다. 예를 들어, try-catch 블록을 사용하여 ServiceException을 catch하고, 적절한 HTTP 응답을 반환할 수 있습니다.

@@ -37,6 +37,8 @@ public class MateResponseDto {
private final String bio;
private final String profileImage;
private final Gender authorGender;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DTO에 commentCountlikeCount 필드가 추가되었습니다. 이 변경은 좋아요 기능 추가와 관련이 있는 것으로 보입니다. 필드의 타입과 값이 적절한지 확인해야 합니다. 기존 생성자는 삭제하고, 새로운 필드를 포함하는 생성자만 남겨도 될 것 같습니다. 기존 생성자는 불필요한 중복 코드일 수 있습니다.

@@ -0,0 +1,51 @@
package com.frend.planit.domain.mateboard.post.entity;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋아요 기능을 위한 새로운 엔티티 클래스가 추가되었습니다. matePostuser 필드에 대한 관계 매핑이 정확한지 확인해야 합니다. FetchType.LAZY를 사용했으므로, 필요에 따라 지연 로딩 문제가 발생하지 않도록 주의해야 합니다.

@@ -0,0 +1,17 @@
package com.frend.planit.domain.mateboard.post.repository;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋아요 기능을 위한 새로운 repository 인터페이스가 추가되었습니다. findByUserAndMatePost 메소드는 사용자가 특정 게시글에 좋아요를 했는지 확인하고, countByMatePost 메소드는 특정 게시글의 좋아요 수를 계산합니다. 잘 작동하는지 테스트가 필요합니다.

@@ -0,0 +1,66 @@
package com.frend.planit.domain.mateboard.post.service;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋아요 기능을 위한 새로운 서비스 클래스가 추가되었습니다. like, unLike, getLikeCount 메소드가 정의되어 있으며, @Transactional 어노테이션을 사용하여 트랜잭션 관리를 하고 있습니다. 에러 핸들링이 잘 구현되었는지 확인하고, mateService.findMateOrThrow 메소드가 예외를 적절하게 처리하는지 확인해야 합니다. MateRepository는 사용하지 않고 MateService를 사용하는데 그 이유를 확인해주세요.

@@ -75,6 +75,10 @@ public enum ErrorType {
INVALID_CALENDAR_DATE(HttpStatus.BAD_REQUEST, "종료 시간은 시작 시간보다 빠를 수 없습니다."),
INVALID_ALERT_TIME(HttpStatus.BAD_REQUEST, "알람 시간은 시작 시간보다 늦을 수 없습니다."),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋아요 기능 관련 에러 타입인 ALREADY_LIKEDLIKE_NOT_FOUND가 추가되었습니다. HTTP 상태 코드와 에러 메시지가 명확하게 정의되어 있습니다.

@sete3683 sete3683 merged commit 4aeb12c into develop Apr 13, 2025
1 check passed
@zelly-log zelly-log deleted the feature/MB-04 branch April 13, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement 신규 기능 구현 / 기능 향상

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] MB-04

2 participants