-
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.
#70 feat: BoardReport controller-service-repository 구조 구현
- Loading branch information
Showing
6 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
server/src/main/java/com/yogit/server/report/controller/BoardReportController.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,41 @@ | ||
package com.yogit.server.report.controller; | ||
|
||
import com.yogit.server.global.dto.ApplicationResponse; | ||
import com.yogit.server.report.dto.req.CreateBoardReportReq; | ||
import com.yogit.server.report.dto.res.BoardReportRes; | ||
import com.yogit.server.report.service.boardreport.BoardReportService; | ||
import io.swagger.annotations.ApiOperation; | ||
import io.swagger.annotations.ApiResponse; | ||
import io.swagger.annotations.ApiResponses; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.validation.annotation.Validated; | ||
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; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequiredArgsConstructor // private final DI의존주입 | ||
@RequestMapping("/boardreports") | ||
public class BoardReportController { | ||
|
||
private final BoardReportService boardReportService; | ||
|
||
// /** | ||
// * 게시글 신고 생성 | ||
// * @author 토마스 | ||
// */ | ||
// @ApiOperation(value = "게시글 신고 생성", notes = "게시글 신고 생성 요청.") | ||
// @ApiResponses({ | ||
// @ApiResponse(code= 201, message = "요청에 성공하였습니다."), | ||
// @ApiResponse(code= 404, message = "존재하지 않는 유저입니다."), | ||
// @ApiResponse(code= 404, message = "존재하지 않는 보드입니다."), | ||
// @ApiResponse(code = 4000 , message = "서버 오류입니다.") | ||
// }) | ||
// @PostMapping | ||
// public ApplicationResponse<BoardReportRes> createBoardReport(@RequestBody @Validated CreateBoardReportReq dto){ | ||
// return boardReportService.createBoardReport(dto); | ||
// } | ||
} |
32 changes: 32 additions & 0 deletions
32
server/src/main/java/com/yogit/server/report/dto/req/CreateBoardReportReq.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.yogit.server.report.dto.req; | ||
|
||
import com.yogit.server.report.enums.ReportType; | ||
import io.swagger.annotations.ApiModelProperty; | ||
import io.swagger.annotations.ApiParam; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
public class CreateBoardReportReq { | ||
|
||
@ApiModelProperty(example = "음란물이 있습니다.") | ||
@ApiParam(value = "신고 세부 내용", required = false) | ||
private String content; | ||
|
||
@ApiModelProperty(example = "1") | ||
@ApiParam(value = "신고하는 유저 ID", required = true) | ||
private Long reportingUserId; | ||
|
||
@ApiModelProperty(example = "1") | ||
@ApiParam(value = "신고당하는 유저 ID", required = true) | ||
private Long reportedUserId; | ||
|
||
@ApiModelProperty(example = "PORNOGRAPHY") | ||
@ApiParam(value = "신고 이유 타입", required = true) | ||
private ReportType reportType; | ||
|
||
@ApiModelProperty(example = "1") | ||
@ApiParam(value = "신고당하는 보드 ID", required = true) | ||
private Long reportedBoardId; | ||
} |
31 changes: 31 additions & 0 deletions
31
server/src/main/java/com/yogit/server/report/dto/res/BoardReportRes.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.yogit.server.report.dto.res; | ||
|
||
import com.yogit.server.report.entity.BoardReport; | ||
import io.swagger.annotations.ApiModelProperty; | ||
import io.swagger.annotations.ApiParam; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
public class BoardReportRes { | ||
|
||
@ApiModelProperty(example = "1") | ||
@ApiParam(value = "신고 ID") | ||
private Long boardReportId; | ||
|
||
/* | ||
연관관계 편의 메서드 | ||
*/ | ||
@Builder | ||
public BoardReportRes(Long boardReportId) { | ||
this.boardReportId = boardReportId; | ||
} | ||
|
||
public static BoardReportRes toDto(BoardReport boardReport){ | ||
return BoardReportRes.builder() | ||
.boardReportId(boardReport.getId()) | ||
.build(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
server/src/main/java/com/yogit/server/report/repository/BoardReportRepository.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.yogit.server.report.repository; | ||
|
||
import com.yogit.server.report.entity.BoardReport; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface BoardReportRepository extends JpaRepository<BoardReport, Long> { | ||
} |
10 changes: 10 additions & 0 deletions
10
server/src/main/java/com/yogit/server/report/service/boardreport/BoardReportService.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,10 @@ | ||
package com.yogit.server.report.service.boardreport; | ||
|
||
import com.yogit.server.global.dto.ApplicationResponse; | ||
import com.yogit.server.report.dto.req.CreateBoardReportReq; | ||
import com.yogit.server.report.dto.res.BoardReportRes; | ||
|
||
public interface BoardReportService { | ||
|
||
// ApplicationResponse<BoardReportRes> createBoardReport(CreateBoardReportReq createBoardReportReq); | ||
} |
25 changes: 25 additions & 0 deletions
25
server/src/main/java/com/yogit/server/report/service/boardreport/BoardReportServiceImpl.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.yogit.server.report.service.boardreport; | ||
|
||
import com.yogit.server.board.service.BoardService; | ||
import com.yogit.server.global.dto.ApplicationResponse; | ||
import com.yogit.server.report.dto.req.CreateBoardReportReq; | ||
import com.yogit.server.report.dto.res.BoardReportRes; | ||
import com.yogit.server.report.repository.BoardReportRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor | ||
public class BoardReportServiceImpl implements BoardReportService { | ||
|
||
private final BoardReportRepository boardReportRepository; | ||
|
||
// @Override | ||
// @Transactional(readOnly = false) | ||
// public ApplicationResponse<BoardReportRes> createBoardReport(CreateBoardReportReq createBoardReportReq) { | ||
// | ||
// | ||
// } | ||
} |