-
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 pull request #80 from tukcomCD2024/feat#78/unify-response
- Loading branch information
Showing
45 changed files
with
856 additions
and
614 deletions.
There are no files selected for viewing
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
49 changes: 30 additions & 19 deletions
49
...etory/src/main/java/com/example/memetory/domain/comment/controller/CommentController.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 |
---|---|---|
@@ -1,36 +1,47 @@ | ||
package com.example.memetory.domain.comment.controller; | ||
|
||
import static com.example.memetory.global.response.ResultCode.*; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
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; | ||
|
||
import com.example.memetory.domain.comment.dto.CommentServiceDto; | ||
import com.example.memetory.domain.comment.dto.request.GenerateCommentRequest; | ||
import com.example.memetory.domain.comment.service.CommentService; | ||
import com.example.memetory.global.annotation.LoginMemberEmail; | ||
import com.example.memetory.global.response.ResultResponse; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequestMapping("/comments") | ||
@RequiredArgsConstructor | ||
public class CommentController implements CommentApi{ | ||
public class CommentController implements CommentApi { | ||
|
||
private final CommentService commentService; | ||
private final CommentService commentService; | ||
|
||
@PostMapping | ||
@Override | ||
public ResponseEntity<HttpStatus> register(@LoginMemberEmail String email, @RequestBody GenerateCommentRequest generateCommentRequest) { | ||
CommentServiceDto newCommentServiceDto = generateCommentRequest.toServiceDto(email); | ||
commentService.register(newCommentServiceDto); | ||
@PostMapping | ||
@Override | ||
public ResponseEntity<ResultResponse> register(@LoginMemberEmail String email, | ||
@RequestBody GenerateCommentRequest generateCommentRequest) { | ||
CommentServiceDto newCommentServiceDto = generateCommentRequest.toServiceDto(email); | ||
commentService.register(newCommentServiceDto); | ||
|
||
return ResponseEntity.status(HttpStatus.CREATED).build(); | ||
} | ||
return ResponseEntity.status(HttpStatus.CREATED).body(ResultResponse.of(CREATE_COMMENT_SUCCESS)); | ||
} | ||
|
||
@DeleteMapping("/{commentId}") | ||
@Override | ||
public ResponseEntity<HttpStatus> delete(@PathVariable Long commentId) { | ||
CommentServiceDto newCommentServiceDto = CommentServiceDto.create(commentId); | ||
commentService.delete(newCommentServiceDto); | ||
@DeleteMapping("/{commentId}") | ||
@Override | ||
public ResponseEntity<ResultResponse> delete(@PathVariable Long commentId) { | ||
CommentServiceDto newCommentServiceDto = CommentServiceDto.create(commentId); | ||
commentService.delete(newCommentServiceDto); | ||
|
||
return ResponseEntity.status(HttpStatus.OK).build(); | ||
} | ||
return ResponseEntity.ok(ResultResponse.of(DELETE_COMMENT_SUCCESS)); | ||
} | ||
} |
14 changes: 5 additions & 9 deletions
14
...src/main/java/com/example/memetory/domain/comment/exception/NotFoundCommentException.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 |
---|---|---|
@@ -1,14 +1,10 @@ | ||
package com.example.memetory.domain.comment.exception; | ||
|
||
import com.example.memetory.global.exception.BusinessException; | ||
import com.example.memetory.global.response.ErrorCode; | ||
|
||
public class NotFoundCommentException extends RuntimeException { | ||
public NotFoundCommentException() {} | ||
|
||
public NotFoundCommentException(String message) { | ||
super(message); | ||
} | ||
|
||
public NotFoundCommentException(String message, Throwable cause) { | ||
super(message, cause); | ||
public class NotFoundCommentException extends BusinessException { | ||
public NotFoundCommentException() { | ||
super(ErrorCode.COMMENT_NOT_FOUND); | ||
} | ||
} |
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
57 changes: 34 additions & 23 deletions
57
...ory/src/main/java/com/example/memetory/domain/complain/controller/ComplainController.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 |
---|---|---|
@@ -1,35 +1,46 @@ | ||
package com.example.memetory.domain.complain.controller; | ||
|
||
import static com.example.memetory.global.response.ResultCode.*; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
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; | ||
|
||
import com.example.memetory.domain.complain.dto.ComplainServiceDto; | ||
import com.example.memetory.domain.complain.dto.request.GenerateComplainRequest; | ||
import com.example.memetory.domain.complain.service.ComplainService; | ||
import com.example.memetory.global.annotation.LoginMemberEmail; | ||
import com.example.memetory.global.response.ResultResponse; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/complains") | ||
public class ComplainController implements ComplainApi{ | ||
private final ComplainService complainService; | ||
|
||
@PostMapping | ||
@Override | ||
public ResponseEntity<HttpStatus> register(@LoginMemberEmail String email, @RequestBody GenerateComplainRequest generateComplainRequest) { | ||
ComplainServiceDto newComplainServiceDto = generateComplainRequest.toServiceDto(email); | ||
complainService.register(newComplainServiceDto); | ||
|
||
return ResponseEntity.status(HttpStatus.CREATED).build(); | ||
} | ||
|
||
@DeleteMapping("/{complainId}") | ||
@Override | ||
public ResponseEntity<HttpStatus> delete(@PathVariable Long complainId) { | ||
ComplainServiceDto newComplainServiceDto = ComplainServiceDto.create(complainId); | ||
complainService.delete(newComplainServiceDto); | ||
|
||
return ResponseEntity.status(HttpStatus.OK).build(); | ||
} | ||
public class ComplainController implements ComplainApi { | ||
private final ComplainService complainService; | ||
|
||
@PostMapping | ||
@Override | ||
public ResponseEntity<ResultResponse> register(@LoginMemberEmail String email, | ||
@RequestBody GenerateComplainRequest generateComplainRequest) { | ||
ComplainServiceDto newComplainServiceDto = generateComplainRequest.toServiceDto(email); | ||
complainService.register(newComplainServiceDto); | ||
|
||
return ResponseEntity.status(HttpStatus.CREATED).body(ResultResponse.of(CREATE_COMPLAIN_SUCCESS)); | ||
} | ||
|
||
@DeleteMapping("/{complainId}") | ||
@Override | ||
public ResponseEntity<ResultResponse> delete(@PathVariable Long complainId) { | ||
ComplainServiceDto newComplainServiceDto = ComplainServiceDto.create(complainId); | ||
complainService.delete(newComplainServiceDto); | ||
|
||
return ResponseEntity.ok(ResultResponse.of(DELETE_COMMENT_SUCCESS)); | ||
} | ||
} |
13 changes: 5 additions & 8 deletions
13
...c/main/java/com/example/memetory/domain/complain/exception/NotFoundComplainException.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 |
---|---|---|
@@ -1,13 +1,10 @@ | ||
package com.example.memetory.domain.complain.exception; | ||
|
||
public class NotFoundComplainException extends RuntimeException{ | ||
public NotFoundComplainException() {} | ||
import com.example.memetory.global.exception.BusinessException; | ||
import com.example.memetory.global.response.ErrorCode; | ||
|
||
public NotFoundComplainException(String message) { | ||
super(message); | ||
} | ||
|
||
public NotFoundComplainException(String message, Throwable cause) { | ||
super(message, cause); | ||
public class NotFoundComplainException extends BusinessException { | ||
public NotFoundComplainException() { | ||
super(ErrorCode.COMPLAIN_NOT_FOUND); | ||
} | ||
} |
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
45 changes: 27 additions & 18 deletions
45
...nd/memetory/src/main/java/com/example/memetory/domain/like/controller/LikeController.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 |
---|---|---|
@@ -1,34 +1,43 @@ | ||
package com.example.memetory.domain.like.controller; | ||
|
||
import static com.example.memetory.global.response.ResultCode.*; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.example.memetory.domain.like.dto.LikeServiceDto; | ||
import com.example.memetory.domain.like.service.LikeService; | ||
import com.example.memetory.global.annotation.LoginMemberEmail; | ||
import com.example.memetory.global.response.ResultResponse; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/memes") | ||
public class LikeController implements LikeApi { | ||
private final LikeService likeService; | ||
private final LikeService likeService; | ||
|
||
@PostMapping("/{memesId}/like") | ||
@Override | ||
public ResponseEntity<String> register(@LoginMemberEmail String email, @PathVariable Long memesId) { | ||
LikeServiceDto likeServiceDto = LikeServiceDto.create(email, memesId); | ||
likeService.register(likeServiceDto); | ||
@PostMapping("/{memesId}/like") | ||
@Override | ||
public ResponseEntity<ResultResponse> register(@LoginMemberEmail String email, @PathVariable Long memesId) { | ||
LikeServiceDto likeServiceDto = LikeServiceDto.create(email, memesId); | ||
likeService.register(likeServiceDto); | ||
|
||
return ResponseEntity.status(HttpStatus.CREATED).build(); | ||
} | ||
return ResponseEntity.status(HttpStatus.CREATED).body(ResultResponse.of(CREATE_LIKE_SUCCESS)); | ||
} | ||
|
||
@DeleteMapping("/{memesId}/like") | ||
@Override | ||
public ResponseEntity<String> cancel(@LoginMemberEmail String email, @PathVariable Long memesId) { | ||
LikeServiceDto likeServiceDto = LikeServiceDto.create(email, memesId); | ||
likeService.cancel(likeServiceDto); | ||
@DeleteMapping("/{memesId}/like") | ||
@Override | ||
public ResponseEntity<ResultResponse> cancel(@LoginMemberEmail String email, @PathVariable Long memesId) { | ||
LikeServiceDto likeServiceDto = LikeServiceDto.create(email, memesId); | ||
likeService.cancel(likeServiceDto); | ||
|
||
return ResponseEntity.status(HttpStatus.OK).build(); | ||
} | ||
return ResponseEntity.ok(ResultResponse.of(DELETE_LIKE_SUCCESS)); | ||
} | ||
} |
15 changes: 6 additions & 9 deletions
15
...etory/src/main/java/com/example/memetory/domain/like/exception/NotFoundLikeException.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 |
---|---|---|
@@ -1,13 +1,10 @@ | ||
package com.example.memetory.domain.like.exception; | ||
|
||
public class NotFoundLikeException extends RuntimeException { | ||
public NotFoundLikeException(){} | ||
import com.example.memetory.global.exception.BusinessException; | ||
import com.example.memetory.global.response.ErrorCode; | ||
|
||
public NotFoundLikeException(String message) { | ||
super(message); | ||
} | ||
|
||
public NotFoundLikeException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
public class NotFoundLikeException extends BusinessException { | ||
public NotFoundLikeException() { | ||
super(ErrorCode.LIKE_NOT_FOUND); | ||
} | ||
} |
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
Oops, something went wrong.