-
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 remote-tracking branch 'origin/integration' into develop
- Loading branch information
Showing
16 changed files
with
259 additions
and
5 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
31 changes: 31 additions & 0 deletions
31
src/main/java/com/first/flash/account/member/application/BlockService.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,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); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/first/flash/account/member/application/ReportService.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,32 @@ | ||
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 reportRepository; | ||
private final MemberService memberService; | ||
|
||
@Transactional | ||
public MemberReportResponse reportMember(final Long reportedContentId, | ||
final MemberReportRequest request) { | ||
UUID reporterId = AuthUtil.getId(); | ||
Member reporter = memberService.findById(reporterId); | ||
MemberReport memberReport = MemberReport.reportContent(request.reason(), reporter, | ||
reportedContentId); | ||
reportRepository.save(memberReport); | ||
return MemberReportResponse.toDto(reportedContentId, request.reason()); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/first/flash/account/member/application/dto/MemberBlockResponse.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,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()); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/first/flash/account/member/application/dto/MemberReportRequest.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,7 @@ | ||
package com.first.flash.account.member.application.dto; | ||
|
||
import jakarta.validation.constraints.NotEmpty; | ||
|
||
public record MemberReportRequest(@NotEmpty(message = "신고 사유는 필수입니다.") String reason) { | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/first/flash/account/member/application/dto/MemberReportResponse.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,8 @@ | ||
package com.first.flash.account.member.application.dto; | ||
|
||
public record MemberReportResponse(Long reportedContentId, String reason) { | ||
|
||
public static MemberReportResponse toDto(final Long reportedContentId, final String reason) { | ||
return new MemberReportResponse(reportedContentId, reason); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/first/flash/account/member/domain/MemberBlock.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.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); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/first/flash/account/member/domain/MemberReport.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,39 @@ | ||
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; | ||
private Long reportedContentId; | ||
|
||
private MemberReport(final String reason, final Member reporter, final Long reportedContentId) { | ||
this.reason = reason; | ||
this.reporter = reporter; | ||
this.reportedContentId = reportedContentId; | ||
} | ||
|
||
public static MemberReport reportContent(final String reason, final Member reporter, | ||
final Long reportedContentId) { | ||
return new MemberReport(reason, reporter, reportedContentId); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/first/flash/account/member/infrastructure/BlockRepository.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,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, Long> { | ||
|
||
MemberBlock save(final MemberBlock memberBlock); | ||
} |
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
9 changes: 9 additions & 0 deletions
9
src/main/java/com/first/flash/account/member/infrastructure/ReportRepository.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,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, Long> { | ||
|
||
MemberReport save(final MemberReport memberReport); | ||
} |
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
28 changes: 28 additions & 0 deletions
28
src/main/java/com/first/flash/global/domain/BaseEntity.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,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; | ||
} |