diff --git a/server/src/main/java/com/yogit/server/report/controller/BoardReportController.java b/server/src/main/java/com/yogit/server/report/controller/BoardReportController.java new file mode 100644 index 0000000..0ec3b7a --- /dev/null +++ b/server/src/main/java/com/yogit/server/report/controller/BoardReportController.java @@ -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 createBoardReport(@RequestBody @Validated CreateBoardReportReq dto){ +// return boardReportService.createBoardReport(dto); +// } +} diff --git a/server/src/main/java/com/yogit/server/report/dto/req/CreateBoardReportReq.java b/server/src/main/java/com/yogit/server/report/dto/req/CreateBoardReportReq.java new file mode 100644 index 0000000..66464f2 --- /dev/null +++ b/server/src/main/java/com/yogit/server/report/dto/req/CreateBoardReportReq.java @@ -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; +} diff --git a/server/src/main/java/com/yogit/server/report/dto/res/BoardReportRes.java b/server/src/main/java/com/yogit/server/report/dto/res/BoardReportRes.java new file mode 100644 index 0000000..4cf29df --- /dev/null +++ b/server/src/main/java/com/yogit/server/report/dto/res/BoardReportRes.java @@ -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(); + } +} diff --git a/server/src/main/java/com/yogit/server/report/repository/BoardReportRepository.java b/server/src/main/java/com/yogit/server/report/repository/BoardReportRepository.java new file mode 100644 index 0000000..8ec2f29 --- /dev/null +++ b/server/src/main/java/com/yogit/server/report/repository/BoardReportRepository.java @@ -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 { +} diff --git a/server/src/main/java/com/yogit/server/report/service/boardreport/BoardReportService.java b/server/src/main/java/com/yogit/server/report/service/boardreport/BoardReportService.java new file mode 100644 index 0000000..dd7c0a1 --- /dev/null +++ b/server/src/main/java/com/yogit/server/report/service/boardreport/BoardReportService.java @@ -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 createBoardReport(CreateBoardReportReq createBoardReportReq); +} diff --git a/server/src/main/java/com/yogit/server/report/service/boardreport/BoardReportServiceImpl.java b/server/src/main/java/com/yogit/server/report/service/boardreport/BoardReportServiceImpl.java new file mode 100644 index 0000000..8e8eb1c --- /dev/null +++ b/server/src/main/java/com/yogit/server/report/service/boardreport/BoardReportServiceImpl.java @@ -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 createBoardReport(CreateBoardReportReq createBoardReportReq) { +// +// +// } +}