-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from Kusitms-29th-Meetup-TeamE/feat/42/review
Feat: 나의 후기 확인 api
- Loading branch information
Showing
14 changed files
with
209 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/com/meetup/teame/backend/domain/like/controller/LikeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.meetup.teame.backend.domain.like.controller; | ||
|
||
import com.meetup.teame.backend.domain.like.service.LikeService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
public class LikeController { | ||
|
||
private final LikeService likeService; | ||
|
||
@Operation(summary = "활동 좋아요 활성화", description = """ | ||
활동 좋아요를 활성화 하는 api입니다. | ||
활동 id를 받아서 활동 좋아요를 추가합니다. | ||
""") | ||
//활동 좋아요 활성화 | ||
@PostMapping("/activate-like/{activityId}") | ||
public ResponseEntity<Void> activateLike(@PathVariable long activityId) { | ||
likeService.activateLike(activityId); | ||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
@Operation(summary = "활동 좋아요 비활성화", description = """ | ||
활동 좋아요를 비활성화 하는 api입니다. | ||
활동 id를 받아서 활동 좋아요를 삭제합니다. | ||
""") | ||
//활동 좋아요 비활성화 | ||
@PostMapping("/deactivate-like/{activityId}") | ||
public ResponseEntity<Void> deactivateLike(@PathVariable long activityId) { | ||
likeService.deactivateLike(activityId); | ||
return ResponseEntity.ok().build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/com/meetup/teame/backend/domain/like/service/LikeService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.meetup.teame.backend.domain.like.service; | ||
|
||
import com.meetup.teame.backend.domain.activity.entity.Activity; | ||
import com.meetup.teame.backend.domain.activity.repository.ActivityRepository; | ||
import com.meetup.teame.backend.domain.auth.jwt.SecurityContextProvider; | ||
import com.meetup.teame.backend.domain.like.entity.ActivityLike; | ||
import com.meetup.teame.backend.domain.like.repository.ActivityLikeRepository; | ||
import com.meetup.teame.backend.domain.user.entity.User; | ||
import com.meetup.teame.backend.domain.user.repository.UserRepository; | ||
import com.meetup.teame.backend.global.exception.CustomException; | ||
import com.meetup.teame.backend.global.exception.ExceptionContent; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class LikeService { | ||
|
||
private final UserRepository userRepository; | ||
private final ActivityRepository activityRepository; | ||
private final ActivityLikeRepository activityLikeRepository; | ||
|
||
//활동 좋아요 활성화 | ||
public void activateLike(Long activityId) { | ||
Long userId = SecurityContextProvider.getAuthenticatedUserId(); | ||
User user = userRepository.findById(userId) | ||
.orElseThrow(() -> new CustomException(ExceptionContent.NOT_FOUND_USER)); | ||
Activity activity = activityRepository.findById(activityId) | ||
.orElseThrow(() -> new CustomException(ExceptionContent.NOT_FOUND_ACTIVITY)); | ||
|
||
ActivityLike like = ActivityLike.of(activity, user); | ||
activityLikeRepository.save(like); | ||
} | ||
|
||
//활동 좋아요 비활성화 | ||
public void deactivateLike(Long activityId) { | ||
Long userId = SecurityContextProvider.getAuthenticatedUserId(); | ||
User user = userRepository.findById(userId) | ||
.orElseThrow(() -> new CustomException(ExceptionContent.NOT_FOUND_USER)); | ||
Activity activity = activityRepository.findById(activityId) | ||
.orElseThrow(() -> new CustomException(ExceptionContent.NOT_FOUND_ACTIVITY)); | ||
|
||
ActivityLike like = activityLikeRepository.findByActivityAndUser(activity, user); | ||
activityLikeRepository.delete(like); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/meetup/teame/backend/domain/review/dto/response/MyReviewRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.meetup.teame.backend.domain.review.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.meetup.teame.backend.domain.review.entity.Review; | ||
import com.meetup.teame.backend.domain.user.entity.User; | ||
import lombok.*; | ||
|
||
import java.time.LocalDate; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
@Builder | ||
public class MyReviewRes { | ||
|
||
private Long id; | ||
|
||
private String type; | ||
|
||
private String title; | ||
|
||
private String experienceDetail; | ||
|
||
private String name; | ||
|
||
private String imageUrl; | ||
|
||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd") | ||
private LocalDate appointmentDate; | ||
|
||
private String review; | ||
|
||
public static MyReviewRes of(Review review) { | ||
|
||
return MyReviewRes.builder() | ||
.id(review.getId()) | ||
.type(review.getAppointmentType().getDescription()) | ||
.title(review.getAppointmentTitle()) | ||
.experienceDetail(review.getAppointmentDetail()) | ||
.name(review.getMentee().getName()) | ||
.imageUrl(review.getMentee().getImageUrl()) | ||
.appointmentDate(review.getReviewDate()) | ||
.review(review.getContent()) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.