Skip to content

Commit

Permalink
Merge pull request #45 from Kusitms-29th-Meetup-TeamE/feat/44/experie…
Browse files Browse the repository at this point in the history
…nce-detail

Feat: 마이페이지 - 배움내역보기 api 구현
  • Loading branch information
Jeongho427 authored May 17, 2024
2 parents 2787804 + 777deb6 commit dd79f5b
Show file tree
Hide file tree
Showing 18 changed files with 249 additions and 214 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import static java.time.format.DateTimeFormatter.ofPattern;

@RequiredArgsConstructor
@AllArgsConstructor
@Getter
@Builder
Expand All @@ -29,7 +28,7 @@ public class ActivitySummaryRes {

private String activityThumbnail;

private boolean isLiked = false;
private boolean isLiked;

public static ActivitySummaryRes of(Activity activity, boolean isLiked) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
import com.meetup.teame.backend.domain.chatroom.entity.GroupChatRoom;
import com.meetup.teame.backend.domain.chatroom.repository.DirectChatRoomRepository;
import com.meetup.teame.backend.domain.chatroom.repository.GroupChatRoomRepository;
import com.meetup.teame.backend.domain.review.entity.Review;
import com.meetup.teame.backend.domain.review.repository.ReviewRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
Expand All @@ -19,17 +22,26 @@
public class LastAppointmentScheduler {
private final DirectChatRoomRepository directChatRoomRepository;
private final GroupChatRoomRepository groupChatRoomRepository;
private final ReviewRepository reviewRepository;

@Scheduled(cron = "0 0 0 * * *")
@Transactional
public void updateLastAppointment() {
log.info("-----updateLastAppointment-----");

List<Review> reviews = new ArrayList<>();
List<DirectChatRoom> directChatRooms = directChatRoomRepository.findUpdatableRooms();
for (DirectChatRoom directChatRoom : directChatRooms) {
reviews.add(Review.of(
directChatRoom.getExperience(),
directChatRoom.getExperience().getUser(),
directChatRoom.getMentee(),
directChatRoom.getNextAppointment()
));
directChatRoom.setLastAppointment(directChatRoom.getNextAppointment());
directChatRoom.setNextAppointment(null);
}
reviewRepository.saveAll(reviews);

List<GroupChatRoom> groupChatRooms = groupChatRoomRepository.findUpdatableRooms();
for (GroupChatRoom groupChatRoom : groupChatRooms) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public class Experience {
@Comment("경험 설명")
private String description;

@Comment("경험 상세 내용")
private String detail;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.meetup.teame.backend.domain.review.controller;

import com.meetup.teame.backend.domain.review.dto.request.CreateReviewReq;
import com.meetup.teame.backend.domain.review.dto.response.ReviewRes;
import com.meetup.teame.backend.domain.review.dto.response.ReadReviewsByMeRes;
import com.meetup.teame.backend.domain.review.dto.response.ReviewByMeRes;
import com.meetup.teame.backend.domain.review.service.ReviewService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand All @@ -12,35 +13,50 @@
@RequiredArgsConstructor
@RestController
@Tag(name = "review", description = "후기 관련 api")
@RequestMapping("/reviews")
public class ReviewController {

private final ReviewService reviewService;

@Operation(summary = "후기 보내기", description = """
후기 보내기 api 입니다.
후기 내용, 멘토 id, 멘티 id를 입력하셔야합니다.
후기보내기가 정상적으로 요청되면 후기 id, 후기 내용, 멘토 id, 멘티 id을 반환해줍니다.
request body에 리뷰 내용을 입력해 전달해주세요.
""")
//후기 보내기
@PostMapping("/review")
public ResponseEntity<ReviewRes> sendReview(@RequestBody CreateReviewReq request) {
ReviewRes response = reviewService.createReview(request);
return ResponseEntity.ok().body(response);
@PostMapping("/{reviewId}")
public ResponseEntity<Void> sendReview(@RequestBody CreateReviewReq request, @PathVariable Long reviewId) {
reviewService.sendReview(request,reviewId);
return ResponseEntity.ok().build();
}

@Operation(summary = "후기 조회하기", description = """
후기 조회하기 api 입니다.
후기 id로 후기에 대한 내용을 볼 수 있습니다.
후기 id, 후기 내용, 멘토 id, 멘티 id을 반환해줍니다.
@Operation(summary = "후기 보내기 페이지에서 해당 배움 정보 보기", description = """
후기 보내기 페이지에서 해당 배움 정보 보기 api 입니다.
""")
@GetMapping("/{reviewId}")
public ResponseEntity<ReviewByMeRes> readReview(@PathVariable Long reviewId) {
return ResponseEntity
.ok(reviewService.readReview(reviewId));
}

@Operation(summary = "나의 배움 내역 보기", description = """
나의 배움 내역 보기 api 입니다.
""")
//후기 조회하기
@GetMapping("/review/{reviewId}")
public ResponseEntity<ReviewRes> getReview(@PathVariable long reviewId) {
ReviewRes response = reviewService.findReview(reviewId);
return ResponseEntity.ok().body(response);
@GetMapping("/byme")
public ResponseEntity<ReadReviewsByMeRes> readReviewsByMe() {
return ResponseEntity
.ok(reviewService.readReviewsByMe());
}


// @Operation(summary = "나의 후기 보기", description = """
// 나의 후기 보기 api 입니다.
// """)
// @GetMapping("/aboutme")
// public ResponseEntity<ReadReviewsAboutMeRes> readReviewsAboutMe() {
// //todo api 작성
// return null;
//// return ResponseEntity
//// .ok(reviewService.readReviewsAboutMe());
// }
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package com.meetup.teame.backend.domain.review.dto.request;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
public class CreateReviewReq {

private String description;

private Long mentorId;

private Long menteeId;
private String content;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.meetup.teame.backend.domain.review.dto.response;

import com.meetup.teame.backend.domain.review.entity.Review;
import lombok.*;

import java.util.List;

@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
@Builder
public class ReadReviewsByMeRes {
private List<ReviewByMeRes> reviews;

public static ReadReviewsByMeRes of(List<Review> reviews) {
return ReadReviewsByMeRes.builder()
.reviews(reviews.stream()
.map(ReviewByMeRes::of)
.toList())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
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.Gender;
import lombok.*;

import java.time.LocalDate;

@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
@Builder
public class ReviewByMeRes {
private Long id;

private String type;

private String title;

private String appointmentLocation;

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd")
private LocalDate appointmentDate;

private String imageUrl;

private String name;

private Long age;

private String gender;

private String location;

private String experienceDetail;

private String review;

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd")
private LocalDate reviewDate;

private Boolean isWritten;

public static ReviewByMeRes of(Review review) {
return ReviewByMeRes.builder()
.id(review.getId())
.type(review.getAppointmentType().getDescription())
.title(review.getAppointmentTitle())
.appointmentLocation(review.getAppointment().getAppointmentLocation())
.appointmentDate(review.getAppointment().getAppointmentDate())
.imageUrl(review.getMentor().getImageUrl())
.name(review.getMentor().getName())
.age(review.getMentor().getAge())
.gender(review.getMentor().getGender().getDescription())
.location(review.getMentor().getLocation())
.experienceDetail(review.getAppointmentDetail())
.review(review.getContent())
.reviewDate(review.getReviewDate())
.isWritten(review.getIsWritten())
.build();
}
}

This file was deleted.

Loading

0 comments on commit dd79f5b

Please sign in to comment.