Skip to content

Commit

Permalink
#70 feat: BoardReport controller-service-repository 구조 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
xhaktmchl committed Nov 27, 2022
1 parent 044d131 commit 698c50d
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 0 deletions.
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);
// }
}
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;
}
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();
}
}
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> {
}
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);
}
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) {
//
//
// }
}

0 comments on commit 698c50d

Please sign in to comment.