Skip to content

Commit

Permalink
Merge pull request #102 from tukcomCD2024/feat#94/integration-testing
Browse files Browse the repository at this point in the history
Feat#94/integration testing
  • Loading branch information
ggamD00 authored Jun 13, 2024
2 parents 4298ef0 + 6924929 commit edd1d1b
Show file tree
Hide file tree
Showing 9 changed files with 578 additions and 577 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,45 +33,6 @@ ResponseEntity<ResultResponse> registerMemes(
GenerateMemesRequest generateMemesRequest
);

@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 삭제",
Expand Down Expand Up @@ -115,38 +76,4 @@ ResponseEntity<ResultResponse> findMemesResponse(
)
})
ResponseEntity<ResultResponse> findMemesInfoSliceResponse(Pageable pageable);

@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
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import static com.example.memetory.global.response.ResultCode.*;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -15,11 +13,8 @@
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.MemesServiceDto;
import com.example.memetory.domain.memes.dto.request.GenerateMemesRequest;
import com.example.memetory.domain.memes.dto.response.MemesInfoResponse;
import com.example.memetory.domain.memes.dto.response.MemesInfoSliceResponse;
import com.example.memetory.domain.memes.dto.response.MemesResponse;
import com.example.memetory.domain.memes.service.MemesService;
Expand All @@ -33,7 +28,6 @@
@RequestMapping("/memes")
public class MemesController implements MemesApi {
private final MemesService memesService;
private final LikeService likeService;

@GetMapping
@Override
Expand Down Expand Up @@ -68,43 +62,4 @@ public ResponseEntity<ResultResponse> deleteMemes(@LoginMemberEmail String email
memesService.deleteMemes(memesServiceDto);
return ResponseEntity.ok(ResultResponse.of(DELETE_MEMES_SUCCESS));
}

@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));
}
}
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
);
}
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));
}
}
Loading

0 comments on commit edd1d1b

Please sign in to comment.