Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.example.leets7th.domain.comment.domain.Comment;
import com.example.leets7th.domain.comment.domain.CommentRepository;
import com.example.leets7th.domain.comment.exception.CommentException;
import com.example.leets7th.domain.post.exception.PostException;
import com.example.leets7th.domain.post.error.PostException;
import com.example.leets7th.domain.report.domain.ReportContentType;
import com.example.leets7th.domain.report.strategy.ReportStrategy;
import com.example.leets7th.global.code.ErrorCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public List<PostResponseDto.ReadPostList> getPostList() {
}

@Transactional
public PostResponseDto.CreatePost createPost(PostRequestDto.Create request,Long userId) {
public PostResponseDto.CreatePost createPost(PostRequestDto.PostCreateReq request, Long userId) {
Post post = Post.create(request.title(),request.content(),userService.getUser(userId));
postRepository.save(post);

return PostResponseDto.CreatePost.from(post);
}

@Transactional
public PostResponseDto.UpdatePost updatePost(PostRequestDto.Update request,Long postId,Long userId) {
public PostResponseDto.UpdatePost updatePost(PostRequestDto.PostUpdateReq request,Long postId,Long userId) {
Post post = postRepository.findByIdWithUser(postId).orElseThrow(()-> new GlobalException(ErrorCode.POST_NOT_FOUND));

if(!userId.equals(post.getUser().getId())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import com.example.leets7th.domain.post.dto.PostResponseDto;
import com.example.leets7th.global.code.SuccessCode;
import com.example.leets7th.global.response.ApiResponse;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.List;
Expand All @@ -20,8 +22,8 @@ public class PostController implements PostControllerDocs {
@Override
@GetMapping("/{postId}")
public ApiResponse<PostResponseDto.ReadPost> getPost(
Long postId,
Long userId
@PathVariable Long postId,
@RequestParam Long userId
) {
return ApiResponse.success(SuccessCode.POST_READ_OK,postService.getPost(postId));
}
Expand All @@ -35,20 +37,21 @@ public ApiResponse<List<PostResponseDto.ReadPostList>> getPostList() {


@Override
@ResponseStatus(HttpStatus.CREATED)
@PostMapping
public ApiResponse<PostResponseDto.CreatePost> createPost(
PostRequestDto.Create request,
Long userId
@Valid @RequestBody PostRequestDto.PostCreateReq request,
@RequestParam Long userId
) {
return ApiResponse.success(SuccessCode.POST_CREATED,postService.createPost(request,userId));
}

@Override
@PatchMapping("/{postId}")
public ApiResponse<PostResponseDto.UpdatePost> updatePost(
PostRequestDto.Update request,
Long postId,
Long userId
@Valid @RequestBody PostRequestDto.PostUpdateReq request,
@PathVariable Long postId,
@RequestParam Long userId
) {
return ApiResponse.success(SuccessCode.POST_UPDATE_OK,postService.updatePost(request,postId,userId));
}
Expand All @@ -57,8 +60,8 @@ public ApiResponse<PostResponseDto.UpdatePost> updatePost(
@Override
@DeleteMapping("/{postId}")
public ApiResponse<Void> deletePost(
Long postId,
Long userId
@PathVariable Long postId,
@RequestParam Long userId
) {
postService.deletePost(postId,userId);
return ApiResponse.success(SuccessCode.POST_DELETE_OK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,73 +16,57 @@
import java.util.List;

@Tag(name = "Post",description = "게시글 API")
@RequestMapping("/api/posts")
public interface PostControllerDocs {


@Operation(summary = "게시글 상세 조회", description = "특정 게시글의 상세정보를 조회합니다.")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200",description = "게시글 상세 조회에 성공하였습니다."),
})
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200",description = "게시글 상세 조회에 성공하였습니다.")
@ApiErrorResponse({ErrorCode.POST_NOT_FOUND})
@GetMapping("/{postId}")
ApiResponse<PostResponseDto.ReadPost> getPost(
@PathVariable Long postId,
@RequestParam Long userId
Long postId,
Long userId
);

@Operation(summary = "게시글 목록 조회",description = "게시글 전체 목록을 조회합니다.")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200",description = "게시글 목록 조회에 성공하였습니다.")
})
@GetMapping
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200",description = "게시글 목록 조회에 성공하였습니다.")
ApiResponse<List<PostResponseDto.ReadPostList>> getPostList();


@Operation(summary = "게시글 생성",description = "새로운 게시글을 생성합니다.")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(
responseCode = "201",
description = "게시글 작성에 성공하였습니다.")
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "201", description = "게시글 작성에 성공하였습니다.")
@ApiErrorResponse({
ErrorCode.USER_NOT_FOUND,
ErrorCode.POST_INPUT_NO_VALIDATION
})
@ResponseStatus(HttpStatus.CREATED)
@PostMapping
ApiResponse<PostResponseDto.CreatePost> createPost(
@Valid @RequestBody PostRequestDto.Create request,
@RequestParam Long userId
PostRequestDto.PostCreateReq request,
Long userId
);

@Operation(summary = "게시글 수정", description = "게시글 제목과 내용을 수정합니다.")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(
responseCode = "200",
description = "게시글 수정에 성공하였습니다.")
})
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "게시글 수정에 성공하였습니다.")
@ApiErrorResponse({
ErrorCode.POST_UPDATE_NO_PERMISSION,
ErrorCode.POST_NOT_FOUND
ErrorCode.POST_NOT_FOUND,
ErrorCode.POST_INPUT_NO_VALIDATION
})
@PatchMapping("/{postId}")
ApiResponse<PostResponseDto.UpdatePost> updatePost(
@Valid @RequestBody PostRequestDto.Update request,
@PathVariable Long postId,
@RequestParam Long userId
PostRequestDto.PostUpdateReq request,
Long postId,
Long userId
);



@Operation(summary = "게시글 삭제", description = "게시글을 삭제합니다.")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(
responseCode = "200",
description = "게시글 삭제에 성공하였습니다.")
})
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "게시글 삭제에 성공하였습니다.")
@ApiErrorResponse({
ErrorCode.POST_DELETE_NO_PERMISSION,
ErrorCode.POST_NOT_FOUND
})
@DeleteMapping("/{postId}")
ApiResponse<Void> deletePost(
@PathVariable Long postId,
@RequestParam Long userId
Long postId,
Long userId
);


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.example.leets7th.domain.post.dto;

import com.example.leets7th.domain.post.domain.Post;
import com.example.leets7th.domain.user.domain.User;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;

Expand All @@ -13,7 +10,7 @@ public class PostRequestDto {



public record Create(
public record PostCreateReq(
@NotBlank(message = "제목을 입력해주세요.")
@Size(max = 255,message = "제목은 최대 255자까지 가능합니다.")
String title,
Expand All @@ -24,7 +21,7 @@ public record Create(
}


public record Update(
public record PostUpdateReq(

@NotBlank(message = "제목을 입력해주세요.")
@Size(max = 255, message = "제목은 최대 255자까지 가능합니다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.leets7th.domain.post.exception;
package com.example.leets7th.domain.post.error;

import com.example.leets7th.global.common.BaseCode;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.example.leets7th.domain.post.domain.Post;
import com.example.leets7th.domain.post.domain.PostRepository;
import com.example.leets7th.domain.post.exception.PostException;
import com.example.leets7th.domain.post.error.PostException;
import com.example.leets7th.domain.report.domain.ReportContentType;
import com.example.leets7th.domain.report.strategy.ReportStrategy;
import com.example.leets7th.global.code.ErrorCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
@RequestMapping("/api/admin/reports")
@RestController
@RequiredArgsConstructor
public class ReportAdminController {
public class ReportAdminController implements ReportAdminControllerDocs{
private final ReportAdminService reportAdminService;

//신고 목록 조회 API
@Override
@GetMapping
public ApiResponse<List<ReportResponseDto.ReportListRes>> getReportList(
@RequestParam ReportStatus status
Expand All @@ -27,6 +28,7 @@ public ApiResponse<List<ReportResponseDto.ReportListRes>> getReportList(
}

//신고 승인 API
@Override
@PostMapping("/{reportId}/approve")
public ApiResponse<Void> approveReport(@PathVariable Long reportId) {
reportAdminService.approveReport(reportId);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.example.leets7th.domain.report.controller;


import com.example.leets7th.domain.report.domain.ReportStatus;
import com.example.leets7th.domain.report.dto.ReportResponseDto;
import com.example.leets7th.global.annotation.ApiErrorResponse;
import com.example.leets7th.global.code.ErrorCode;
import com.example.leets7th.global.response.ApiResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;


import java.util.List;

@Tag(name = "ReportAdmin" ,description = "신고 관리자 API")
public interface ReportAdminControllerDocs {


@Operation(summary = "신고 목록 조회",description = "상태별 신고 목록을 확인합니다.")
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "신고 목록 조회를 성공하였습니다.")
ApiResponse<List<ReportResponseDto.ReportListRes>> getReportList(ReportStatus status);



@Operation(summary = "신고 승인",description = "접수된 신고를 승인합니다.")
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200",description = "신고가 승인되었습니다.")
@ApiErrorResponse({
ErrorCode.REPORT_NOT_FOUND,
ErrorCode.UNSUPPORTED_CONTENT_TYPE
})
ApiResponse<Void> approveReport(Long reportId);



@Operation(summary = "신고 반려",description = "접수된 신고를 반려합니다.")
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200",description = "신고가 반려되었습니다.")
@ApiErrorResponse({
ErrorCode.REPORT_NOT_FOUND
})
ApiResponse<Void> rejectReport(Long reportId);



}
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@
import com.example.leets7th.domain.report.service.ReportService;
import com.example.leets7th.global.code.SuccessCode;
import com.example.leets7th.global.response.ApiResponse;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/reports")
public class ReportController {
public class ReportController implements ReportControllerDocs {

private final ReportService reportService;

//신고 접수 API
@Override
@ResponseStatus(HttpStatus.CREATED)
@PostMapping
public ApiResponse<ReportResponseDto.ReportCreateRes> createReport(
@RequestBody ReportRequestDto.ReportCreateReq request,
@Valid @RequestBody ReportRequestDto.ReportCreateReq request,
@RequestParam Long userId
) {
ReportResponseDto.ReportCreateRes response = reportService.createReport(request,userId);
Expand All @@ -31,6 +33,7 @@ public ApiResponse<ReportResponseDto.ReportCreateRes> createReport(


//신고 취소 API
@Override
@DeleteMapping("/{reportId}")
public ApiResponse<Void> deleteReport(
@PathVariable Long reportId,
Expand Down
Loading