Skip to content

Commit 9de9577

Browse files
committed
2 parents 8a56aa9 + de60944 commit 9de9577

File tree

90 files changed

+1856
-447
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1856
-447
lines changed

back/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,12 @@ dependencies {
6666
implementation ("software.amazon.awssdk:s3:2.25.0")
6767

6868
implementation ("org.springframework.kafka:spring-kafka")
69+
implementation("org.springframework.boot:spring-boot-starter-websocket")
6970

7071
runtimeOnly("com.mysql:mysql-connector-j")
72+
73+
// Sentry
74+
implementation("io.sentry:sentry-spring-boot-starter-jakarta:8.19.1")
7175
}
7276

7377
tasks.withType<Test> {

back/src/main/java/com/back/domain/file/video/controller/VideoController.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.back.global.rsData.RsData;
77
import io.swagger.v3.oas.annotations.Operation;
88
import lombok.RequiredArgsConstructor;
9+
import org.springframework.security.access.prepost.PreAuthorize;
910
import org.springframework.web.bind.annotation.GetMapping;
1011
import org.springframework.web.bind.annotation.RequestParam;
1112
import org.springframework.web.bind.annotation.RestController;
@@ -16,15 +17,16 @@ public class VideoController {
1617
private final FileManager fileManager;
1718

1819
@GetMapping("/videos/upload")
19-
@Operation(summary="업로드용 URL 요청", description="파일 업로드를 위한 Presigned URL을 발급받습니다.")
20+
@PreAuthorize("hasRole('ADMIN')")
21+
@Operation(summary = "업로드용 URL 요청", description = "파일 업로드를 위한 Presigned URL을 발급받습니다.")
2022
public RsData<UploadUrlGetResponse> getUploadUrl() {
2123
PresignedUrlResponse uploadUrl = fileManager.getUploadUrl();
2224
UploadUrlGetResponse response = new UploadUrlGetResponse(uploadUrl.url().toString(), uploadUrl.expiresAt());
2325
return new RsData<>("200", "업로드용 URL 요청완료", response);
2426
}
2527

2628
@GetMapping("/videos/download")
27-
@Operation(summary="다운로드용 URL 요청", description="파일 다운로드를 위한 Presigned URL을 발급받습니다.")
29+
@Operation(summary = "다운로드용 URL 요청", description = "파일 다운로드를 위한 Presigned URL을 발급받습니다.")
2830
public RsData<UploadUrlGetResponse> getDownloadUrls(@RequestParam String objectKey) {
2931
PresignedUrlResponse downloadUrl = fileManager.getDownloadUrl(objectKey);
3032
UploadUrlGetResponse response = new UploadUrlGetResponse(downloadUrl.url().toString(), downloadUrl.expiresAt());

back/src/main/java/com/back/domain/member/member/service/MemberStorage.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.back.domain.member.member.entity.Member;
44
import com.back.domain.member.member.error.MemberErrorCode;
5+
import com.back.domain.member.member.repository.MemberRepository;
56
import com.back.domain.member.mentee.entity.Mentee;
67
import com.back.domain.member.mentee.repository.MenteeRepository;
78
import com.back.domain.member.mentor.entity.Mentor;
@@ -13,7 +14,7 @@
1314
@Component
1415
@RequiredArgsConstructor
1516
public class MemberStorage {
16-
17+
private final MemberRepository memberRepository;
1718
private final MentorRepository mentorRepository;
1819
private final MenteeRepository menteeRepository;
1920

@@ -39,4 +40,9 @@ public Mentee findMenteeByMember(Member member) {
3940
public boolean existsMentorById(Long mentorId) {
4041
return mentorRepository.existsById(mentorId);
4142
}
43+
44+
public Member findMemberByEmail(String email) {
45+
return memberRepository.findByEmail(email)
46+
.orElseThrow(() -> new ServiceException(MemberErrorCode.NOT_FOUND_MEMBER));
47+
}
4248
}

back/src/main/java/com/back/domain/mentoring/mentoring/controller/ReviewController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class ReviewController {
2525
private final ReviewService reviewService;
2626

2727
@GetMapping("/mentorings/{mentoringId}/reviews")
28-
@Operation(summary = "멘토링 리뷰 조회", description = "멘토링 리뷰 목록을 조회합니다.")
28+
@Operation(summary = "멘토링 리뷰 목록 조회", description = "멘토링 리뷰 목록을 조회합니다.")
2929
public RsData<ReviewPagingResponse> getReviews(
3030
@PathVariable Long mentoringId,
3131
@RequestParam(defaultValue = "0") int page,

back/src/main/java/com/back/domain/mentoring/mentoring/dto/MentoringDetailDto.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public record MentoringDetailDto(
1717
String bio,
1818
@Schema(description = "멘토링 썸네일")
1919
String thumb,
20+
@Schema(description = "멘토링 평점")
21+
Double rating,
2022
@Schema(description = "생성일")
2123
LocalDateTime createDate,
2224
@Schema(description = "수정일")
@@ -26,9 +28,10 @@ public static MentoringDetailDto from(Mentoring mentoring) {
2628
return new MentoringDetailDto(
2729
mentoring.getId(),
2830
mentoring.getTitle(),
29-
mentoring.getTags(),
31+
mentoring.getTagNames(),
3032
mentoring.getBio(),
3133
mentoring.getThumb(),
34+
mentoring.getRating(),
3235
mentoring.getCreateDate(),
3336
mentoring.getModifyDate()
3437
);

back/src/main/java/com/back/domain/mentoring/mentoring/dto/MentoringWithTagsDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static MentoringWithTagsDto from(Mentoring mentoring) {
2121
return new MentoringWithTagsDto(
2222
mentoring.getId(),
2323
mentoring.getTitle(),
24-
mentoring.getTags(),
24+
mentoring.getTagNames(),
2525
mentoring.getMentor().getId(),
2626
mentoring.getMentor().getMember().getNickname()
2727
);

back/src/main/java/com/back/domain/mentoring/mentoring/dto/request/MentoringRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
import java.util.List;
88

99
public record MentoringRequest(
10-
@Schema(description = "멘토링 제목")
10+
@Schema(description = "멘토링 제목", example = "title")
1111
@NotNull @Size(max = 100)
1212
String title,
1313

1414
@Schema(description = "멘토링 태그", example = "[\"Java\", \"Spring\"]")
1515
List<String> tags,
1616

17-
@Schema(description = "멘토링 소개")
17+
@Schema(description = "멘토링 소개", example = "bio")
1818
@NotNull
1919
String bio,
2020

21-
@Schema(description = "멘토링 썸네일")
21+
@Schema(description = "멘토링 썸네일", example = "test.png")
2222
String thumb
2323
) {
2424
}

back/src/main/java/com/back/domain/mentoring/mentoring/dto/request/ReviewRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public record ReviewRequest(
1111
Double rating,
1212

1313
@Size(max = 1000)
14-
@Schema(description = "리뷰 내용")
14+
@Schema(description = "리뷰 내용", example = "review content")
1515
String content
1616
) {
1717
}

back/src/main/java/com/back/domain/mentoring/mentoring/entity/Mentoring.java

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.back.domain.mentoring.mentoring.entity;
22

33
import com.back.domain.member.mentor.entity.Mentor;
4-
import com.back.global.converter.StringListConverter;
54
import com.back.global.jpa.BaseEntity;
65
import jakarta.persistence.*;
76
import lombok.Builder;
@@ -25,30 +24,52 @@ public class Mentoring extends BaseEntity {
2524
@Column(columnDefinition = "TEXT")
2625
private String bio;
2726

28-
@Convert(converter = StringListConverter.class)
29-
@Column(columnDefinition = "JSON")
30-
private List<String> tags;
27+
@OneToMany(mappedBy = "mentoring", cascade = CascadeType.ALL, orphanRemoval = true)
28+
private List<MentoringTag> mentoringTags = new ArrayList<>();
3129

3230
@Column(length = 255)
3331
private String thumb;
3432

33+
@Column
34+
private double rating = 0.0;
35+
3536
@Builder
36-
public Mentoring(Mentor mentor, String title, String bio, List<String> tags, String thumb) {
37+
public Mentoring(Mentor mentor, String title, String bio, String thumb) {
3738
this.mentor = mentor;
3839
this.title = title;
3940
this.bio = bio;
40-
this.tags = tags != null ? tags : new ArrayList<>();
4141
this.thumb = thumb;
4242
}
4343

44-
public void update(String title, String bio, List<String> tags, String thumb) {
44+
public void update(String title, String bio, List<Tag> tags, String thumb) {
4545
this.title = title;
4646
this.bio = bio;
47-
this.tags = tags != null ? tags : new ArrayList<>();
4847
this.thumb = thumb;
48+
49+
updateTags(tags);
50+
}
51+
52+
public void updateTags(List<Tag> tags) {
53+
this.mentoringTags.clear();
54+
55+
if (tags != null) {
56+
tags.forEach(tag ->
57+
this.mentoringTags.add(new MentoringTag(this, tag))
58+
);
59+
}
60+
}
61+
62+
public void updateRating(double averageRating) {
63+
this.rating = averageRating;
4964
}
5065

5166
public boolean isOwner(Mentor mentor) {
5267
return this.mentor.equals(mentor);
5368
}
69+
70+
public List<String> getTagNames() {
71+
return mentoringTags.stream()
72+
.map(mentoringTag -> mentoringTag.getTag().getName())
73+
.toList();
74+
}
5475
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.back.domain.mentoring.mentoring.entity;
2+
3+
import com.back.global.jpa.BaseEntity;
4+
import jakarta.persistence.*;
5+
import lombok.Builder;
6+
import lombok.Getter;
7+
import lombok.NoArgsConstructor;
8+
9+
@Entity
10+
@Getter
11+
@NoArgsConstructor
12+
@Table(name = "mentoring_tag")
13+
public class MentoringTag extends BaseEntity {
14+
@ManyToOne(fetch = FetchType.LAZY)
15+
@JoinColumn(name = "mentoring_id")
16+
private Mentoring mentoring;
17+
18+
@ManyToOne(fetch = FetchType.LAZY)
19+
@JoinColumn(name = "tag_id")
20+
private Tag tag;
21+
22+
@Builder
23+
public MentoringTag(Mentoring mentoring, Tag tag) {
24+
this.mentoring = mentoring;
25+
this.tag = tag;
26+
}
27+
}

0 commit comments

Comments
 (0)