From 60ee0f75c570cbc80abb67448340d20c81dfae18 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Tue, 13 Aug 2024 16:53:53 +0900 Subject: [PATCH 01/12] =?UTF-8?q?FLASH-207=20feat:=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=9D=BC=EA=B3=BC=20=EC=88=98=EC=A0=95=EC=9D=BC=EC=9D=84=20?= =?UTF-8?q?=EA=B0=80=EC=A7=80=EB=8A=94=20base=20entity=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../first/flash/global/domain/BaseEntity.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/java/com/first/flash/global/domain/BaseEntity.java diff --git a/src/main/java/com/first/flash/global/domain/BaseEntity.java b/src/main/java/com/first/flash/global/domain/BaseEntity.java new file mode 100644 index 00000000..3e530c01 --- /dev/null +++ b/src/main/java/com/first/flash/global/domain/BaseEntity.java @@ -0,0 +1,28 @@ +package com.first.flash.global.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.MappedSuperclass; +import java.time.LocalDateTime; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +public abstract class BaseEntity { + + @CreatedDate + @Column(updatable = false, nullable = false) + private LocalDateTime createdAt; + + @LastModifiedDate + @Column(nullable = false) + private LocalDateTime updatedAt; +} From 2b1bceb8137c52fb3f6a99dc46677171ecdf8554 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Tue, 13 Aug 2024 16:54:28 +0900 Subject: [PATCH 02/12] =?UTF-8?q?FLASH-207=20config:=20datetime=20?= =?UTF-8?q?=EC=9E=90=EB=8F=99=20=EC=83=9D=EC=84=B1=EC=9D=84=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/first/flash/FlashApplication.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/first/flash/FlashApplication.java b/src/main/java/com/first/flash/FlashApplication.java index 55548eba..5ecde314 100644 --- a/src/main/java/com/first/flash/FlashApplication.java +++ b/src/main/java/com/first/flash/FlashApplication.java @@ -4,10 +4,12 @@ import java.util.TimeZone; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication @EnableScheduling +@EnableJpaAuditing public class FlashApplication { public static void main(String[] args) { From 9743043f7031d782728c4919dbbe710ab7275e57 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Tue, 13 Aug 2024 16:54:54 +0900 Subject: [PATCH 03/12] =?UTF-8?q?FLASH-207=20feat:=20=EC=B0=A8=EB=8B=A8=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EC=A0=80=EC=9E=A5=ED=95=A0=20?= =?UTF-8?q?=EC=97=94=ED=8B=B0=ED=8B=B0=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/member/domain/MemberBlock.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/com/first/flash/account/member/domain/MemberBlock.java diff --git a/src/main/java/com/first/flash/account/member/domain/MemberBlock.java b/src/main/java/com/first/flash/account/member/domain/MemberBlock.java new file mode 100644 index 00000000..114d4bb0 --- /dev/null +++ b/src/main/java/com/first/flash/account/member/domain/MemberBlock.java @@ -0,0 +1,40 @@ +package com.first.flash.account.member.domain; + +import com.first.flash.global.domain.BaseEntity; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor +public class MemberBlock extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) + @JoinColumn(name = "blockerId") + private Member blocker; + + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) + @JoinColumn(name = "blockedId") + private Member blocked; + + private MemberBlock(final Member blocker, final Member blocked) { + this.blocker = blocker; + this.blocked = blocked; + } + + public static MemberBlock blockMember(final Member blocker, final Member blocked) { + return new MemberBlock(blocker, blocked); + } +} From 2b17b9708f97e4998c7d8c441aad9bacadf7cdb2 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Tue, 13 Aug 2024 16:55:11 +0900 Subject: [PATCH 04/12] =?UTF-8?q?FLASH-207=20feat:=20=EC=B0=A8=EB=8B=A8=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EC=A0=80=EC=9E=A5=20=EB=A6=AC?= =?UTF-8?q?=ED=8F=AC=EC=A7=80=ED=86=A0=EB=A6=AC=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/infrastructure/BlockRepository.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/com/first/flash/account/member/infrastructure/BlockRepository.java diff --git a/src/main/java/com/first/flash/account/member/infrastructure/BlockRepository.java b/src/main/java/com/first/flash/account/member/infrastructure/BlockRepository.java new file mode 100644 index 00000000..f3604319 --- /dev/null +++ b/src/main/java/com/first/flash/account/member/infrastructure/BlockRepository.java @@ -0,0 +1,11 @@ +package com.first.flash.account.member.infrastructure; + +import com.first.flash.account.member.domain.MemberBlock; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface BlockRepository extends JpaRepository { + + MemberBlock save(final MemberBlock memberBlock); +} From b5565b2f94f643e009b77ebe7cd48c36c3c23996 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Tue, 13 Aug 2024 16:56:07 +0900 Subject: [PATCH 05/12] =?UTF-8?q?FLASH-207=20feat:=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EC=B0=A8=EB=8B=A8=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/application/BlockService.java | 31 +++++++++++++++++++ .../application/dto/MemberBlockResponse.java | 11 +++++++ .../account/member/ui/MemberController.java | 11 +++++++ 3 files changed, 53 insertions(+) create mode 100644 src/main/java/com/first/flash/account/member/application/BlockService.java create mode 100644 src/main/java/com/first/flash/account/member/application/dto/MemberBlockResponse.java diff --git a/src/main/java/com/first/flash/account/member/application/BlockService.java b/src/main/java/com/first/flash/account/member/application/BlockService.java new file mode 100644 index 00000000..e48bac2a --- /dev/null +++ b/src/main/java/com/first/flash/account/member/application/BlockService.java @@ -0,0 +1,31 @@ +package com.first.flash.account.member.application; + +import com.first.flash.account.member.application.dto.MemberBlockResponse; +import com.first.flash.account.member.domain.Member; +import com.first.flash.account.member.domain.MemberBlock; +import com.first.flash.account.member.infrastructure.BlockRepository; +import com.first.flash.global.util.AuthUtil; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class BlockService { + + private final BlockRepository blockRepository; + private final MemberService memberService; + + @Transactional + public MemberBlockResponse blockMember(final UUID blockedUser) { + UUID blockerId = AuthUtil.getId(); + Member blocker = memberService.findById(blockerId); + Member blocked = memberService.findById(blockedUser); + MemberBlock.blockMember(blocker, blocked); + MemberBlock blockResult = blockRepository.save(MemberBlock.blockMember(blocker, blocked)); + blockRepository.save(blockResult); + return MemberBlockResponse.toDto(blocked); + } +} diff --git a/src/main/java/com/first/flash/account/member/application/dto/MemberBlockResponse.java b/src/main/java/com/first/flash/account/member/application/dto/MemberBlockResponse.java new file mode 100644 index 00000000..11d2e710 --- /dev/null +++ b/src/main/java/com/first/flash/account/member/application/dto/MemberBlockResponse.java @@ -0,0 +1,11 @@ +package com.first.flash.account.member.application.dto; + +import com.first.flash.account.member.domain.Member; +import java.util.UUID; + +public record MemberBlockResponse(UUID blockedMemberId, String blockedMemberName) { + + public static MemberBlockResponse toDto(final Member blockedMember) { + return new MemberBlockResponse(blockedMember.getId(), blockedMember.getNickName()); + } +} diff --git a/src/main/java/com/first/flash/account/member/ui/MemberController.java b/src/main/java/com/first/flash/account/member/ui/MemberController.java index bab7f4c9..adad43b5 100644 --- a/src/main/java/com/first/flash/account/member/ui/MemberController.java +++ b/src/main/java/com/first/flash/account/member/ui/MemberController.java @@ -1,8 +1,10 @@ package com.first.flash.account.member.ui; +import com.first.flash.account.member.application.BlockService; import com.first.flash.account.member.application.MemberService; import com.first.flash.account.member.application.dto.ConfirmNickNameRequest; import com.first.flash.account.member.application.dto.ConfirmNickNameResponse; +import com.first.flash.account.member.application.dto.MemberBlockResponse; import com.first.flash.account.member.application.dto.MemberCompleteRegistrationRequest; import com.first.flash.account.member.application.dto.MemberCompleteRegistrationResponse; import com.first.flash.account.member.application.dto.MemberInfoResponse; @@ -14,10 +16,13 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; +import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -29,6 +34,7 @@ public class MemberController { private final MemberService memberService; + private final BlockService blockService; @Operation(summary = "내 정보 조회", description = "특정 회원 정보 조회") @ApiResponses(value = { @@ -81,4 +87,9 @@ public ResponseEntity confirmNickName( @Valid @RequestBody final ConfirmNickNameRequest request) { return ResponseEntity.ok(memberService.confirmNickName(request)); } + + @PostMapping("/blocks/{blockedUserId}") + public ResponseEntity blockMember(@PathVariable final UUID blockedUserId) { + return ResponseEntity.ok(blockService.blockMember(blockedUserId)); + } } From dea7480b2c9849bcc1285c6c9662c90725ab888a Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Tue, 13 Aug 2024 17:02:11 +0900 Subject: [PATCH 06/12] =?UTF-8?q?FLASH-207=20feat:=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EC=B0=A8=EB=8B=A8=20api=20swagger=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../first/flash/account/member/ui/MemberController.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/first/flash/account/member/ui/MemberController.java b/src/main/java/com/first/flash/account/member/ui/MemberController.java index adad43b5..b1bfb822 100644 --- a/src/main/java/com/first/flash/account/member/ui/MemberController.java +++ b/src/main/java/com/first/flash/account/member/ui/MemberController.java @@ -88,6 +88,15 @@ public ResponseEntity confirmNickName( return ResponseEntity.ok(memberService.confirmNickName(request)); } + @Operation(summary = "유저 차단", description = "특정 유저 차단") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "차단 성공", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = MemberBlockResponse.class))), + @ApiResponse(responseCode = "404", description = "리소스를 찾을 수 없음", + content = @Content(mediaType = "application/json", examples = { + @ExampleObject(name = "차단하려는 유저를 찾을 수 없음", value = "{\"error\": \"사용자를 찾을 수 없습니다!\"}"), + })) + }) @PostMapping("/blocks/{blockedUserId}") public ResponseEntity blockMember(@PathVariable final UUID blockedUserId) { return ResponseEntity.ok(blockService.blockMember(blockedUserId)); From ea38424ce9e43fccaea3ed9d4bb57dda2c441ffd Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Tue, 13 Aug 2024 18:05:03 +0900 Subject: [PATCH 07/12] =?UTF-8?q?FLASH-208=20feat:=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EC=8B=A0=EA=B3=A0=20=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=ED=95=A0=20=EC=97=94=ED=8B=B0=ED=8B=B0=20=EA=B0=9D?= =?UTF-8?q?=EC=B2=B4=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/member/domain/MemberReport.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/main/java/com/first/flash/account/member/domain/MemberReport.java diff --git a/src/main/java/com/first/flash/account/member/domain/MemberReport.java b/src/main/java/com/first/flash/account/member/domain/MemberReport.java new file mode 100644 index 00000000..f57435cb --- /dev/null +++ b/src/main/java/com/first/flash/account/member/domain/MemberReport.java @@ -0,0 +1,41 @@ +package com.first.flash.account.member.domain; + +import com.first.flash.global.domain.BaseEntity; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor +public class MemberReport extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private String reason; + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) + @JoinColumn(name = "reporterId") + private Member reporter; + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) + @JoinColumn(name = "reportedId") + private Member reported; + + private MemberReport(final String reason, final Member reporter, final Member reported) { + this.reason = reason; + this.reporter = reporter; + this.reported = reported; + } + + public static MemberReport reportMember(final String reason, final Member reporter, + final Member reported) { + return new MemberReport(reason, reporter, reported); + } +} From 5e7994d47d6f6448d19ac80e8f9ec7c97a1216a6 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Tue, 13 Aug 2024 18:05:45 +0900 Subject: [PATCH 08/12] =?UTF-8?q?FLASH-208=20feat:=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EC=8B=A0=EA=B3=A0=20=EC=A0=95=EB=B3=B4=20=EB=A6=AC=ED=8F=AC?= =?UTF-8?q?=EC=A7=80=ED=86=A0=EB=A6=AC=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/member/infrastructure/ReportRepository.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/com/first/flash/account/member/infrastructure/ReportRepository.java diff --git a/src/main/java/com/first/flash/account/member/infrastructure/ReportRepository.java b/src/main/java/com/first/flash/account/member/infrastructure/ReportRepository.java new file mode 100644 index 00000000..368f760e --- /dev/null +++ b/src/main/java/com/first/flash/account/member/infrastructure/ReportRepository.java @@ -0,0 +1,9 @@ +package com.first.flash.account.member.infrastructure; + +import com.first.flash.account.member.domain.MemberReport; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ReportRepository extends JpaRepository { + + MemberReport save(final MemberReport memberReport); +} From c66c0e058a334dadf17a71e37a54610e6f244d44 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Tue, 13 Aug 2024 18:06:00 +0900 Subject: [PATCH 09/12] =?UTF-8?q?FLASH-208=20feat:=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EC=8B=A0=EA=B3=A0=20api=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/application/ReportService.java | 31 +++++++++++++++++++ .../application/dto/MemberReportRequest.java | 7 +++++ .../application/dto/MemberReportResponse.java | 13 ++++++++ .../account/member/ui/MemberController.java | 10 ++++++ 4 files changed, 61 insertions(+) create mode 100644 src/main/java/com/first/flash/account/member/application/ReportService.java create mode 100644 src/main/java/com/first/flash/account/member/application/dto/MemberReportRequest.java create mode 100644 src/main/java/com/first/flash/account/member/application/dto/MemberReportResponse.java diff --git a/src/main/java/com/first/flash/account/member/application/ReportService.java b/src/main/java/com/first/flash/account/member/application/ReportService.java new file mode 100644 index 00000000..74ec3390 --- /dev/null +++ b/src/main/java/com/first/flash/account/member/application/ReportService.java @@ -0,0 +1,31 @@ +package com.first.flash.account.member.application; + +import com.first.flash.account.member.application.dto.MemberReportRequest; +import com.first.flash.account.member.application.dto.MemberReportResponse; +import com.first.flash.account.member.domain.Member; +import com.first.flash.account.member.domain.MemberReport; +import com.first.flash.account.member.infrastructure.ReportRepository; +import com.first.flash.global.util.AuthUtil; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class ReportService { + + private final ReportRepository repository; + private final MemberService memberService; + + @Transactional + public MemberReportResponse reportMember(final UUID reportedUserId, final MemberReportRequest request) { + UUID reporterId = AuthUtil.getId(); + Member reporter = memberService.findById(reporterId); + Member reportedMember = memberService.findById(reportedUserId); + MemberReport memberReport = MemberReport.reportMember(request.reason(), reporter, reportedMember); + repository.save(memberReport); + return MemberReportResponse.toDto(reportedMember, request.reason()); + } +} diff --git a/src/main/java/com/first/flash/account/member/application/dto/MemberReportRequest.java b/src/main/java/com/first/flash/account/member/application/dto/MemberReportRequest.java new file mode 100644 index 00000000..90ff2035 --- /dev/null +++ b/src/main/java/com/first/flash/account/member/application/dto/MemberReportRequest.java @@ -0,0 +1,7 @@ +package com.first.flash.account.member.application.dto; + +import jakarta.validation.constraints.NotEmpty; + +public record MemberReportRequest(@NotEmpty(message = "신고 사유는 필수입니다.") String reason) { + +} diff --git a/src/main/java/com/first/flash/account/member/application/dto/MemberReportResponse.java b/src/main/java/com/first/flash/account/member/application/dto/MemberReportResponse.java new file mode 100644 index 00000000..827705dd --- /dev/null +++ b/src/main/java/com/first/flash/account/member/application/dto/MemberReportResponse.java @@ -0,0 +1,13 @@ +package com.first.flash.account.member.application.dto; + +import com.first.flash.account.member.domain.Member; +import java.util.UUID; + +public record MemberReportResponse(UUID reportedMemberId, String reportedMemberName, + String reason) { + + public static MemberReportResponse toDto(final Member reportedMember, final String reason) { + return new MemberReportResponse(reportedMember.getId(), + reportedMember.getNickName(), reason); + } +} diff --git a/src/main/java/com/first/flash/account/member/ui/MemberController.java b/src/main/java/com/first/flash/account/member/ui/MemberController.java index b1bfb822..a4f9fe6d 100644 --- a/src/main/java/com/first/flash/account/member/ui/MemberController.java +++ b/src/main/java/com/first/flash/account/member/ui/MemberController.java @@ -2,12 +2,15 @@ import com.first.flash.account.member.application.BlockService; import com.first.flash.account.member.application.MemberService; +import com.first.flash.account.member.application.ReportService; import com.first.flash.account.member.application.dto.ConfirmNickNameRequest; import com.first.flash.account.member.application.dto.ConfirmNickNameResponse; import com.first.flash.account.member.application.dto.MemberBlockResponse; import com.first.flash.account.member.application.dto.MemberCompleteRegistrationRequest; import com.first.flash.account.member.application.dto.MemberCompleteRegistrationResponse; import com.first.flash.account.member.application.dto.MemberInfoResponse; +import com.first.flash.account.member.application.dto.MemberReportRequest; +import com.first.flash.account.member.application.dto.MemberReportResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.ExampleObject; @@ -35,6 +38,7 @@ public class MemberController { private final MemberService memberService; private final BlockService blockService; + private final ReportService reportService; @Operation(summary = "내 정보 조회", description = "특정 회원 정보 조회") @ApiResponses(value = { @@ -101,4 +105,10 @@ public ResponseEntity confirmNickName( public ResponseEntity blockMember(@PathVariable final UUID blockedUserId) { return ResponseEntity.ok(blockService.blockMember(blockedUserId)); } + + @PostMapping("/reports/{reportedUserId}") + public ResponseEntity reportMember( + @PathVariable final UUID reportedUserId, @RequestBody @Valid final MemberReportRequest request) { + return ResponseEntity.ok(reportService.reportMember(reportedUserId, request)); + } } From a60272ddaa64c86486c40457c35c1aaea45d4ec8 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Tue, 13 Aug 2024 18:20:35 +0900 Subject: [PATCH 10/12] =?UTF-8?q?FLASH-208=20fix:=20=EC=9C=A0=EC=A0=80?= =?UTF-8?q?=EA=B0=80=20=EC=95=84=EB=8B=8C=20=EC=BB=A8=ED=85=90=EC=B8=A0?= =?UTF-8?q?=EB=A5=BC=20=EC=8B=A0=EA=B3=A0=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/member/application/ReportService.java | 13 +++++++------ .../application/dto/MemberReportResponse.java | 11 +++-------- .../flash/account/member/domain/MemberReport.java | 14 ++++++-------- .../flash/account/member/ui/MemberController.java | 5 +++-- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/first/flash/account/member/application/ReportService.java b/src/main/java/com/first/flash/account/member/application/ReportService.java index 74ec3390..67892ac8 100644 --- a/src/main/java/com/first/flash/account/member/application/ReportService.java +++ b/src/main/java/com/first/flash/account/member/application/ReportService.java @@ -16,16 +16,17 @@ @Transactional(readOnly = true) public class ReportService { - private final ReportRepository repository; + private final ReportRepository reportRepository; private final MemberService memberService; @Transactional - public MemberReportResponse reportMember(final UUID reportedUserId, final MemberReportRequest request) { + public MemberReportResponse reportMember(final Long reportedContentId, + final MemberReportRequest request) { UUID reporterId = AuthUtil.getId(); Member reporter = memberService.findById(reporterId); - Member reportedMember = memberService.findById(reportedUserId); - MemberReport memberReport = MemberReport.reportMember(request.reason(), reporter, reportedMember); - repository.save(memberReport); - return MemberReportResponse.toDto(reportedMember, request.reason()); + MemberReport memberReport = MemberReport.reportContent(request.reason(), reporter, + reportedContentId); + reportRepository.save(memberReport); + return MemberReportResponse.toDto(reportedContentId, request.reason()); } } diff --git a/src/main/java/com/first/flash/account/member/application/dto/MemberReportResponse.java b/src/main/java/com/first/flash/account/member/application/dto/MemberReportResponse.java index 827705dd..94e916dc 100644 --- a/src/main/java/com/first/flash/account/member/application/dto/MemberReportResponse.java +++ b/src/main/java/com/first/flash/account/member/application/dto/MemberReportResponse.java @@ -1,13 +1,8 @@ package com.first.flash.account.member.application.dto; -import com.first.flash.account.member.domain.Member; -import java.util.UUID; +public record MemberReportResponse(Long reportedContentId, String reason) { -public record MemberReportResponse(UUID reportedMemberId, String reportedMemberName, - String reason) { - - public static MemberReportResponse toDto(final Member reportedMember, final String reason) { - return new MemberReportResponse(reportedMember.getId(), - reportedMember.getNickName(), reason); + public static MemberReportResponse toDto(final Long reportedContentId, final String reason) { + return new MemberReportResponse(reportedContentId, reason); } } diff --git a/src/main/java/com/first/flash/account/member/domain/MemberReport.java b/src/main/java/com/first/flash/account/member/domain/MemberReport.java index f57435cb..be06c4cd 100644 --- a/src/main/java/com/first/flash/account/member/domain/MemberReport.java +++ b/src/main/java/com/first/flash/account/member/domain/MemberReport.java @@ -24,18 +24,16 @@ public class MemberReport extends BaseEntity { @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) @JoinColumn(name = "reporterId") private Member reporter; - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) - @JoinColumn(name = "reportedId") - private Member reported; + private Long reportedContentId; - private MemberReport(final String reason, final Member reporter, final Member reported) { + private MemberReport(final String reason, final Member reporter, final Long reportedContentId) { this.reason = reason; this.reporter = reporter; - this.reported = reported; + this.reportedContentId = reportedContentId; } - public static MemberReport reportMember(final String reason, final Member reporter, - final Member reported) { - return new MemberReport(reason, reporter, reported); + public static MemberReport reportContent(final String reason, final Member reporter, + final Long reportedContentId) { + return new MemberReport(reason, reporter, reportedContentId); } } diff --git a/src/main/java/com/first/flash/account/member/ui/MemberController.java b/src/main/java/com/first/flash/account/member/ui/MemberController.java index a4f9fe6d..a27281f1 100644 --- a/src/main/java/com/first/flash/account/member/ui/MemberController.java +++ b/src/main/java/com/first/flash/account/member/ui/MemberController.java @@ -108,7 +108,8 @@ public ResponseEntity blockMember(@PathVariable final UUID @PostMapping("/reports/{reportedUserId}") public ResponseEntity reportMember( - @PathVariable final UUID reportedUserId, @RequestBody @Valid final MemberReportRequest request) { - return ResponseEntity.ok(reportService.reportMember(reportedUserId, request)); + @PathVariable final Long reportedContentId, + @RequestBody @Valid final MemberReportRequest request) { + return ResponseEntity.ok(reportService.reportMember(reportedContentId, request)); } } From cb976b967082e443daedb3406e800b53fdcbb0fa Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Tue, 13 Aug 2024 18:23:12 +0900 Subject: [PATCH 11/12] =?UTF-8?q?FLASH-208=20feat:=20=EC=8B=A0=EA=B3=A0=20?= =?UTF-8?q?api=20swagger=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../first/flash/account/member/ui/MemberController.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/first/flash/account/member/ui/MemberController.java b/src/main/java/com/first/flash/account/member/ui/MemberController.java index a27281f1..3757bb44 100644 --- a/src/main/java/com/first/flash/account/member/ui/MemberController.java +++ b/src/main/java/com/first/flash/account/member/ui/MemberController.java @@ -106,7 +106,12 @@ public ResponseEntity blockMember(@PathVariable final UUID return ResponseEntity.ok(blockService.blockMember(blockedUserId)); } - @PostMapping("/reports/{reportedUserId}") + @Operation(summary = "컨텐츠 신고", description = "특정 컨텐츠 신고") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "신고 성공", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = MemberReportRequest.class))) + }) + @PostMapping("/reports/{reportedContentId}") public ResponseEntity reportMember( @PathVariable final Long reportedContentId, @RequestBody @Valid final MemberReportRequest request) { From 175fa530ae0de247b758c4dfd817bbca24537bea Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Wed, 14 Aug 2024 16:19:52 +0900 Subject: [PATCH 12/12] =?UTF-8?q?FLASH-244=20fix:=20=EC=9D=B4=EB=A9=94?= =?UTF-8?q?=EC=9D=BC=EC=9D=B4=20=EC=95=84=EB=8B=8C=20social=20Id=EB=A1=9C?= =?UTF-8?q?=20=EC=9C=A0=EC=A0=80=EB=A5=BC=20=EC=B0=BE=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/first/flash/account/auth/application/AuthService.java | 2 +- .../first/flash/account/member/domain/MemberRepository.java | 2 +- .../account/member/infrastructure/MemberJpaRepository.java | 2 +- .../account/member/infrastructure/MemberRepositoryImpl.java | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/first/flash/account/auth/application/AuthService.java b/src/main/java/com/first/flash/account/auth/application/AuthService.java index 51eda7d1..bb204ed5 100644 --- a/src/main/java/com/first/flash/account/auth/application/AuthService.java +++ b/src/main/java/com/first/flash/account/auth/application/AuthService.java @@ -33,7 +33,7 @@ public class AuthService { public LoginResponseDto login(final LoginRequestDto request) { log.info("로그인 요청: {}", request); SocialInfo socialInfo = socialService.getSocialInfo(request.provider(), request.token()); - Optional foundMember = memberRepository.findByEmail(socialInfo.socialId()); + Optional foundMember = memberRepository.findBySocialId(socialInfo.socialId()); Member member = saveOrGetMember(foundMember, socialInfo); String accessToken = tokenManager.createAccessToken(member.getId()); return new LoginResponseDto(accessToken, member.isCompleteRegistration()); diff --git a/src/main/java/com/first/flash/account/member/domain/MemberRepository.java b/src/main/java/com/first/flash/account/member/domain/MemberRepository.java index 43691cdd..31358388 100644 --- a/src/main/java/com/first/flash/account/member/domain/MemberRepository.java +++ b/src/main/java/com/first/flash/account/member/domain/MemberRepository.java @@ -7,6 +7,6 @@ public interface MemberRepository { Member save(final Member member); Optional findById(final UUID id); - Optional findByEmail(final String email); + Optional findBySocialId(final String socialId); boolean existsByNickName(final String nickName); } diff --git a/src/main/java/com/first/flash/account/member/infrastructure/MemberJpaRepository.java b/src/main/java/com/first/flash/account/member/infrastructure/MemberJpaRepository.java index 546cda91..3a0d825a 100644 --- a/src/main/java/com/first/flash/account/member/infrastructure/MemberJpaRepository.java +++ b/src/main/java/com/first/flash/account/member/infrastructure/MemberJpaRepository.java @@ -11,7 +11,7 @@ public interface MemberJpaRepository extends JpaRepository { Optional findById(final UUID id); - Optional findMemberByEmail(final String email); + Optional findMemberBySocialId(final String email); boolean existsByNickName(final String nickName); } diff --git a/src/main/java/com/first/flash/account/member/infrastructure/MemberRepositoryImpl.java b/src/main/java/com/first/flash/account/member/infrastructure/MemberRepositoryImpl.java index c3d90a16..21a68b3e 100644 --- a/src/main/java/com/first/flash/account/member/infrastructure/MemberRepositoryImpl.java +++ b/src/main/java/com/first/flash/account/member/infrastructure/MemberRepositoryImpl.java @@ -24,8 +24,8 @@ public Optional findById(final UUID id) { } @Override - public Optional findByEmail(final String email) { - return jpaRepository.findMemberByEmail(email); + public Optional findBySocialId(final String socialId) { + return jpaRepository.findMemberBySocialId(socialId); } @Override