-
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 #102 from tukcomCD2024/feat#94/integration-testing
Feat#94/integration testing
- Loading branch information
Showing
9 changed files
with
578 additions
and
577 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
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
87 changes: 87 additions & 0 deletions
87
...end/memetory/src/main/java/com/example/memetory/domain/memes/controller/MemesLikeApi.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,87 @@ | ||
package com.example.memetory.domain.memes.controller; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
|
||
import com.example.memetory.global.response.ResultResponse; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.enums.ParameterIn; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
|
||
public interface MemesLikeApi { | ||
@Operation( | ||
summary = "meme`s 인기차트 조회", | ||
description = "좋아요 수 많은 순으로 10개 조회", | ||
security = {@SecurityRequirement(name = "access_token")} | ||
) | ||
@ApiResponses(value = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "인기차트 조회" | ||
) | ||
}) | ||
ResponseEntity<ResultResponse> findTopMemesByLike(); | ||
|
||
@Operation( | ||
summary = "meme`s 이달의 인기차트 조회", | ||
description = "최근 한 달 동안 좋아요 수 많은 순으로 10개 조회", | ||
security = {@SecurityRequirement(name = "access_token")} | ||
) | ||
@ApiResponses(value = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "이달의 인기차트 조회" | ||
) | ||
}) | ||
ResponseEntity<ResultResponse> findTopMemesByLikeForMonth(); | ||
|
||
@Operation( | ||
summary = "meme`s 이주의 인기차트 조회", | ||
description = "최근 한 주 동안 좋아요 수 많은 순으로 10개 조회", | ||
security = {@SecurityRequirement(name = "access_token")} | ||
) | ||
@ApiResponses(value = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "이주의 인기차트 조회" | ||
) | ||
}) | ||
ResponseEntity<ResultResponse> findTopMemesByLikeForWeek(); | ||
|
||
@Operation( | ||
summary = "meme`s 좋아요 등록", | ||
description = "공유된 meme`s 게시물에 좋아요를 등록한다.", | ||
security = {@SecurityRequirement(name = "access_token")} | ||
) | ||
@ApiResponses(value = { | ||
@ApiResponse( | ||
responseCode = "201", | ||
description = "좋아요 등록!" | ||
) | ||
}) | ||
ResponseEntity<ResultResponse> registerLike( | ||
@Parameter(hidden = true) String email, | ||
@Parameter(in = ParameterIn.PATH, description = "밈스 아이디", required = true) | ||
Long memesId | ||
); | ||
|
||
@Operation( | ||
summary = "meme`s 좋아요 취소", | ||
description = "공유된 meme`s 게시물에 등록된 좋아요를 취소한다.", | ||
security = {@SecurityRequirement(name = "access_token")} | ||
) | ||
@ApiResponses(value = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "좋아요 취소!" | ||
) | ||
}) | ||
ResponseEntity<ResultResponse> cancelLike( | ||
@Parameter(hidden = true) String email, | ||
@Parameter(in = ParameterIn.PATH, description = "밈스 아이디", required = true) | ||
Long memesId | ||
); | ||
} |
70 changes: 70 additions & 0 deletions
70
...etory/src/main/java/com/example/memetory/domain/memes/controller/MemesLikeController.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,70 @@ | ||
package com.example.memetory.domain.memes.controller; | ||
|
||
import static com.example.memetory.global.response.ResultCode.*; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
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.domain.memes.dto.response.MemesInfoResponse; | ||
import com.example.memetory.domain.memes.service.MemesService; | ||
import com.example.memetory.global.annotation.LoginMemberEmail; | ||
import com.example.memetory.global.response.ResultResponse; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/memes") | ||
public class MemesLikeController implements MemesLikeApi { | ||
private final MemesService memesService; | ||
private final LikeService likeService; | ||
|
||
@GetMapping("/like/all") | ||
@Override | ||
public ResponseEntity<ResultResponse> findTopMemesByLike() { | ||
List<MemesInfoResponse> response = memesService.findTopMemesByLike(); | ||
return ResponseEntity.ok(ResultResponse.of(GET_TOP_TEN_MEMES_SUCCESS, response)); | ||
} | ||
|
||
@GetMapping("/like/month") | ||
@Override | ||
public ResponseEntity<ResultResponse> findTopMemesByLikeForMonth() { | ||
List<MemesInfoResponse> response = memesService.findTopMemesByLikeForMonth(); | ||
return ResponseEntity.ok(ResultResponse.of(GET_MONTH_TOP_TEN_MEMES_SUCCESS, response)); | ||
} | ||
|
||
@GetMapping("/like/week") | ||
@Override | ||
public ResponseEntity<ResultResponse> findTopMemesByLikeForWeek() { | ||
List<MemesInfoResponse> response = memesService.findTopMemesByLikeForWeek(); | ||
return ResponseEntity.ok(ResultResponse.of(GET_WEEK_TOP_TEN_MEMES_SUCCESS, response)); | ||
} | ||
|
||
@PostMapping("/{memesId}/like") | ||
@Override | ||
public ResponseEntity<ResultResponse> registerLike(@LoginMemberEmail String email, @PathVariable Long memesId) { | ||
LikeServiceDto likeServiceDto = LikeServiceDto.fromEmailAndMemesId(email, memesId); | ||
likeService.registerLike(likeServiceDto); | ||
|
||
return ResponseEntity.status(HttpStatus.CREATED).body(ResultResponse.of(CREATE_LIKE_SUCCESS)); | ||
} | ||
|
||
@DeleteMapping("/{memesId}/like") | ||
@Override | ||
public ResponseEntity<ResultResponse> cancelLike(@LoginMemberEmail String email, @PathVariable Long memesId) { | ||
LikeServiceDto likeServiceDto = LikeServiceDto.fromEmailAndMemesId(email, memesId); | ||
likeService.cancelLike(likeServiceDto); | ||
|
||
return ResponseEntity.ok(ResultResponse.of(DELETE_LIKE_SUCCESS)); | ||
} | ||
} |
Oops, something went wrong.