-
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 branch 'develop' into Improve/정우진
- Loading branch information
Showing
18 changed files
with
407 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/main/java/com/example/jsgamesbackendmain/Bean/ReportLogBean/ReportLogSaveBean.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.example.jsgamesbackendmain.Bean.ReportLogBean; | ||
|
||
import com.example.jsgamesbackendmain.Bean.SmallBean.LogBean.LogGetByIdSmallBean; | ||
import com.example.jsgamesbackendmain.Bean.SmallBean.ReportLogBean.ReportLogSaveSmallBean; | ||
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserGetByIdSmallBean; | ||
import com.example.jsgamesbackendmain.Model.DAO.LogDAO; | ||
import com.example.jsgamesbackendmain.Model.DAO.ReportLogDAO; | ||
import com.example.jsgamesbackendmain.Model.DAO.UserDAO; | ||
import com.example.jsgamesbackendmain.Model.DTO.ReportLog.Request.ReportLogRequestDTO; | ||
import com.example.jsgamesbackendmain.Model.DTO.ReportLog.Response.ReportLogResponseDTO; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ReportLogSaveBean { | ||
private final UserGetByIdSmallBean userGetByIdSmallBean; | ||
private final LogGetByIdSmallBean logGetByIdSmallBean; | ||
private final ReportLogSaveSmallBean reportLogSaveSmallBean; | ||
|
||
public ReportLogResponseDTO exec(ReportLogRequestDTO request) { | ||
// 사용자있는지 확인 | ||
UserDAO reporter = userGetByIdSmallBean.exec(request.getReporterId()); | ||
// 신고당한 로그가 있는지 확인 | ||
LogDAO reportedLog = logGetByIdSmallBean.exec(request.getReportedLogId()); | ||
|
||
// 신고 로그 저장 | ||
ReportLogDAO savedReportLog = reportLogSaveSmallBean.exec(reportedLog, reporter); | ||
return ReportLogResponseDTO.of(savedReportLog); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/example/jsgamesbackendmain/Bean/ReportReviewBean/ReportReviewSaveBean.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.example.jsgamesbackendmain.Bean.ReportReviewBean; | ||
|
||
import com.example.jsgamesbackendmain.Bean.SmallBean.ReportReviewBean.ReportReviewSaveSmallBean; | ||
import com.example.jsgamesbackendmain.Bean.SmallBean.ReviewBean.ReviewGetByIdSmallBean; | ||
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserGetByIdSmallBean; | ||
import com.example.jsgamesbackendmain.Model.DAO.ReportReviewDAO; | ||
import com.example.jsgamesbackendmain.Model.DAO.ReviewDAO; | ||
import com.example.jsgamesbackendmain.Model.DAO.UserDAO; | ||
import com.example.jsgamesbackendmain.Model.DTO.ReportReview.Request.ReportReviewPostRequestDTO; | ||
import com.example.jsgamesbackendmain.Model.DTO.ReportReview.Response.ReportReviewPostResponseDTO; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ReportReviewSaveBean { | ||
|
||
private final UserGetByIdSmallBean userGetByIdSmallBean; | ||
private final ReviewGetByIdSmallBean reviewGetByIdSmallBean; | ||
private final ReportReviewSaveSmallBean reportReviewSaveSmallBean; | ||
|
||
public ReportReviewPostResponseDTO exec(ReportReviewPostRequestDTO requestDTO) { | ||
// 사용자있는지 확인 | ||
UserDAO reporter = userGetByIdSmallBean.exec(requestDTO.getReporterId()); | ||
// 신고당한 리뷰가 있는지 확인 | ||
ReviewDAO reportedReview = reviewGetByIdSmallBean.exec(requestDTO.getReportedReviewId()); | ||
// 신고 리뷰 저장 | ||
ReportReviewDAO savedReportReview = reportReviewSaveSmallBean.exec(reportedReview, reporter); | ||
return ReportReviewPostResponseDTO.of(savedReportReview); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/example/jsgamesbackendmain/Bean/SmallBean/LogBean/LogGetByIdSmallBean.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,23 @@ | ||
package com.example.jsgamesbackendmain.Bean.SmallBean.LogBean; | ||
|
||
import com.example.jsgamesbackendmain.Model.DAO.LogDAO; | ||
import com.example.jsgamesbackendmain.Repository.LogRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Optional; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class LogGetByIdSmallBean { | ||
private final LogRepository logRepository; | ||
|
||
public LogDAO exec(Long logId) { | ||
Optional<LogDAO> logOpt = logRepository.findById(logId); | ||
if (!logOpt.isPresent()) { | ||
throw new RuntimeException("Log not found for this LogId :: " + logId); | ||
} else { | ||
return logOpt.get(); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...a/com/example/jsgamesbackendmain/Bean/SmallBean/ReportLogBean/ReportLogSaveSmallBean.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,33 @@ | ||
package com.example.jsgamesbackendmain.Bean.SmallBean.ReportLogBean; | ||
|
||
|
||
import com.example.jsgamesbackendmain.Controller.ExceptionControll.InvalidException; | ||
import com.example.jsgamesbackendmain.Model.DAO.LogDAO; | ||
import com.example.jsgamesbackendmain.Model.DAO.ReportLogDAO; | ||
import com.example.jsgamesbackendmain.Model.DAO.UserDAO; | ||
import com.example.jsgamesbackendmain.Repository.ReportLogRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Optional; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ReportLogSaveSmallBean { | ||
private final ReportLogRepository reportLogRepository; | ||
|
||
public ReportLogDAO exec(LogDAO reportedLog, UserDAO reporter) { | ||
Optional<ReportLogDAO> reportLogOpt = reportLogRepository.findByReportedLogAndReporter(reportedLog, reporter); | ||
|
||
if(reportLogOpt.isPresent()) { | ||
throw new InvalidException("이미 신고한 기록 입니다."); | ||
} | ||
|
||
ReportLogDAO newReportLog = ReportLogDAO.builder() | ||
.reporter(reporter) | ||
.reportedLog(reportedLog) | ||
.build(); | ||
|
||
return reportLogRepository.save(newReportLog); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...example/jsgamesbackendmain/Bean/SmallBean/ReportReviewBean/ReportReviewSaveSmallBean.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,33 @@ | ||
package com.example.jsgamesbackendmain.Bean.SmallBean.ReportReviewBean; | ||
|
||
import com.example.jsgamesbackendmain.Controller.ExceptionControll.InvalidException; | ||
import com.example.jsgamesbackendmain.Model.DAO.ReportReviewDAO; | ||
import com.example.jsgamesbackendmain.Model.DAO.ReviewDAO; | ||
import com.example.jsgamesbackendmain.Model.DAO.UserDAO; | ||
import com.example.jsgamesbackendmain.Repository.ReportReviewRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Optional; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ReportReviewSaveSmallBean { | ||
private final ReportReviewRepository reportReviewRepository; | ||
|
||
public ReportReviewDAO exec(ReviewDAO review, UserDAO userDAO) { | ||
Optional<ReportReviewDAO> reportReviewOpt = | ||
reportReviewRepository.findByReportedReviewAndReporter(review, userDAO); | ||
|
||
if (reportReviewOpt.isPresent()) { | ||
throw new InvalidException("이미 신고한 리뷰입니다."); | ||
} | ||
|
||
ReportReviewDAO reportReview = ReportReviewDAO.builder() | ||
.reporter(userDAO) | ||
.reportedReview(review) | ||
.build(); | ||
|
||
return reportReviewRepository.save(reportReview); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/example/jsgamesbackendmain/Controller/ReportLogController.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,22 @@ | ||
package com.example.jsgamesbackendmain.Controller; | ||
|
||
import com.example.jsgamesbackendmain.Model.DTO.ReportLog.Request.ReportLogRequestDTO; | ||
import com.example.jsgamesbackendmain.Model.DTO.ReportLog.Response.ReportLogResponseDTO; | ||
import com.example.jsgamesbackendmain.Service.ReportLogService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/report") | ||
@CrossOrigin("*") | ||
public class ReportLogController { | ||
private final ReportLogService reportLogService; | ||
|
||
@PostMapping("/log") | ||
public ReportLogResponseDTO reportLog( | ||
@RequestBody ReportLogRequestDTO request | ||
) { | ||
return reportLogService.reportLog(request); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/example/jsgamesbackendmain/Controller/ReportReviewController.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,22 @@ | ||
package com.example.jsgamesbackendmain.Controller; | ||
|
||
import com.example.jsgamesbackendmain.Model.DTO.ReportReview.Request.ReportReviewPostRequestDTO; | ||
import com.example.jsgamesbackendmain.Model.DTO.ReportReview.Response.ReportReviewPostResponseDTO; | ||
import com.example.jsgamesbackendmain.Service.ReportReviewService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/report") | ||
@CrossOrigin("*") | ||
public class ReportReviewController { | ||
private final ReportReviewService reportReviewService; | ||
|
||
@PostMapping("/review") | ||
public ReportReviewPostResponseDTO reportReview( | ||
@RequestBody ReportReviewPostRequestDTO request | ||
) { | ||
return reportReviewService.reportReview(request); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/example/jsgamesbackendmain/Model/DAO/ReportLogDAO.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,34 @@ | ||
package com.example.jsgamesbackendmain.Model.DAO; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.CreationTimestamp; | ||
|
||
import javax.persistence.*; | ||
import java.time.LocalDateTime; | ||
|
||
@Entity | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
@Getter | ||
@Table(name = "report_log") | ||
public class ReportLogDAO { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long reportLogId; | ||
|
||
// 신고한 유저 | ||
@OneToOne(fetch = FetchType.LAZY) | ||
private UserDAO reporter; | ||
|
||
// 신고당한 LogDAO | ||
@OneToOne(fetch = FetchType.LAZY) | ||
private LogDAO reportedLog; | ||
|
||
@CreationTimestamp | ||
@Column(updatable = false) | ||
private LocalDateTime createdAt; | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/example/jsgamesbackendmain/Model/DAO/ReportReviewDAO.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,34 @@ | ||
package com.example.jsgamesbackendmain.Model.DAO; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.CreationTimestamp; | ||
|
||
import javax.persistence.*; | ||
import java.time.LocalDateTime; | ||
|
||
@Entity | ||
@AllArgsConstructor | ||
@Getter | ||
@NoArgsConstructor | ||
@Builder | ||
@Table(name = "report_review") | ||
public class ReportReviewDAO { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long reportReviewId; | ||
|
||
// 신고당한 리뷰 | ||
@OneToOne(fetch = FetchType.LAZY) | ||
private ReviewDAO reportedReview; | ||
|
||
// 신고한 유저 | ||
@OneToOne(fetch = FetchType.LAZY) | ||
private UserDAO reporter; | ||
|
||
@CreationTimestamp | ||
@Column(updatable = false) | ||
private LocalDateTime createdAt; | ||
} |
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
15 changes: 15 additions & 0 deletions
15
.../java/com/example/jsgamesbackendmain/Model/DTO/ReportLog/Request/ReportLogRequestDTO.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,15 @@ | ||
package com.example.jsgamesbackendmain.Model.DTO.ReportLog.Request; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
public class ReportLogRequestDTO { | ||
private Long reportedLogId; | ||
private String reporterId; | ||
} |
25 changes: 25 additions & 0 deletions
25
...ava/com/example/jsgamesbackendmain/Model/DTO/ReportLog/Response/ReportLogResponseDTO.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,25 @@ | ||
package com.example.jsgamesbackendmain.Model.DTO.ReportLog.Response; | ||
|
||
import com.example.jsgamesbackendmain.Model.DAO.ReportLogDAO; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
public class ReportLogResponseDTO { | ||
private Long reportLogId; | ||
private LocalDateTime createAt; | ||
|
||
public static ReportLogResponseDTO of(ReportLogDAO reportLog){ | ||
return ReportLogResponseDTO.builder() | ||
.reportLogId(reportLog.getReportLogId()) | ||
.createAt(reportLog.getCreatedAt()) | ||
.build(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...example/jsgamesbackendmain/Model/DTO/ReportReview/Request/ReportReviewPostRequestDTO.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,15 @@ | ||
package com.example.jsgamesbackendmain.Model.DTO.ReportReview.Request; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
@Getter | ||
public class ReportReviewPostRequestDTO { | ||
private Long reportedReviewId; | ||
private String reporterId; | ||
} |
25 changes: 25 additions & 0 deletions
25
...ample/jsgamesbackendmain/Model/DTO/ReportReview/Response/ReportReviewPostResponseDTO.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,25 @@ | ||
package com.example.jsgamesbackendmain.Model.DTO.ReportReview.Response; | ||
|
||
import com.example.jsgamesbackendmain.Model.DAO.ReportReviewDAO; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class ReportReviewPostResponseDTO { | ||
private Long reportReviewId; | ||
private LocalDateTime createAt; | ||
|
||
public static ReportReviewPostResponseDTO of(ReportReviewDAO reportReview){ | ||
return ReportReviewPostResponseDTO.builder() | ||
.reportReviewId(reportReview.getReportReviewId()) | ||
.createAt(reportReview.getCreatedAt()) | ||
.build(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/example/jsgamesbackendmain/Repository/ReportLogRepository.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,15 @@ | ||
package com.example.jsgamesbackendmain.Repository; | ||
|
||
import com.example.jsgamesbackendmain.Model.DAO.LogDAO; | ||
import com.example.jsgamesbackendmain.Model.DAO.ReportLogDAO; | ||
import com.example.jsgamesbackendmain.Model.DAO.UserDAO; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface ReportLogRepository extends JpaRepository<ReportLogDAO, Long> { | ||
|
||
Optional<ReportLogDAO> findByReportedLogAndReporter(LogDAO log, UserDAO reporter); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/example/jsgamesbackendmain/Repository/ReportReviewRepository.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,15 @@ | ||
package com.example.jsgamesbackendmain.Repository; | ||
|
||
import com.example.jsgamesbackendmain.Model.DAO.ReportReviewDAO; | ||
import com.example.jsgamesbackendmain.Model.DAO.ReviewDAO; | ||
import com.example.jsgamesbackendmain.Model.DAO.UserDAO; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface ReportReviewRepository extends JpaRepository<ReportReviewDAO, Long> { | ||
|
||
Optional<ReportReviewDAO> findByReportedReviewAndReporter(ReviewDAO reviewDAO, UserDAO userDAO); | ||
} |
Oops, something went wrong.