Skip to content

Commit

Permalink
[FEAT] Conflict 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunw9 committed Dec 26, 2024
1 parent af66545 commit 0fa024f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import lombok.RequiredArgsConstructor;
import lombok.val;

import org.sopt.makers.operation.code.success.web.BannerSuccessCode;
import org.sopt.makers.operation.dto.BaseResponse;
import org.sopt.makers.operation.util.ApiResponseUtil;
import org.sopt.makers.operation.web.banner.dto.request.BannerRequest;
import org.sopt.makers.operation.web.banner.dto.request.BannerRequest.BannerCreate;
import org.sopt.makers.operation.web.banner.service.BannerService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand All @@ -15,60 +17,68 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import static org.sopt.makers.operation.code.success.web.BannerSuccessCode.SUCCESS_CREATE_BANNER;
import static org.sopt.makers.operation.code.success.web.BannerSuccessCode.SUCCESS_DELETE_BANNER;
import static org.sopt.makers.operation.code.success.web.BannerSuccessCode.SUCCESS_GET_BANNER_DETAIL;
import static org.sopt.makers.operation.code.success.web.BannerSuccessCode.SUCCESS_GET_BANNER_IMAGE_PRE_SIGNED_URL;
import static org.sopt.makers.operation.code.success.web.BannerSuccessCode.SUCCESS_GET_EXTERNAL_BANNERS;

import org.springframework.web.bind.annotation.*;

import static org.sopt.makers.operation.code.success.web.BannerSuccessCode.SUCCESS_CREATE_BANNER;
import static org.sopt.makers.operation.code.success.web.BannerSuccessCode.SUCCESS_GET_BANNER_DETAIL;
import static org.sopt.makers.operation.code.success.web.BannerSuccessCode.SUCCESS_GET_BANNER_IMAGE_PRE_SIGNED_URL;

@RestController
@RequestMapping("/api/v1/banners")
@RequiredArgsConstructor
public class BannerApiController implements BannerApi {
private final BannerService bannerService;

@Override
@GetMapping("/{bannerId}")
public ResponseEntity<BaseResponse<?>> getBannerDetail(
@PathVariable("bannerId") Long bannerId
) {
val response = bannerService.getBannerDetail(bannerId);
return ApiResponseUtil.success(SUCCESS_GET_BANNER_DETAIL, response);
}
private final BannerService bannerService;

@Override
@GetMapping("/{bannerId}")
public ResponseEntity<BaseResponse<?>> getBannerDetail(
@PathVariable("bannerId") Long bannerId
) {
val response = bannerService.getBannerDetail(bannerId);
return ApiResponseUtil.success(SUCCESS_GET_BANNER_DETAIL, response);
}

@Override
@DeleteMapping("/{bannerId}")
public ResponseEntity<BaseResponse<?>> deleteBanner(
@PathVariable("bannerId") Long bannerId
) {
bannerService.deleteBanner(bannerId);
return ApiResponseUtil.success(SUCCESS_DELETE_BANNER);
}
@Override
@DeleteMapping("/{bannerId}")
public ResponseEntity<BaseResponse<?>> deleteBanner(
@PathVariable("bannerId") Long bannerId
) {
bannerService.deleteBanner(bannerId);
return ApiResponseUtil.success(SUCCESS_DELETE_BANNER);
}

@Override
@GetMapping("/images")
public ResponseEntity<BaseResponse<?>> getExternalBanners(
@RequestParam("image_type") String imageType,
@RequestParam("location") String location
) {
return ApiResponseUtil.success(SUCCESS_GET_EXTERNAL_BANNERS, bannerService.getExternalBanners(imageType, location));
@Override
@GetMapping("/images")
public ResponseEntity<BaseResponse<?>> getExternalBanners(
@RequestParam("image_type") String imageType,
@RequestParam("location") String location
) {
return ApiResponseUtil.success(SUCCESS_GET_EXTERNAL_BANNERS,
bannerService.getExternalBanners(imageType, location));
}

@Override
@GetMapping("/img/pre-signed")
public ResponseEntity<BaseResponse<?>> getIssuedPreSignedUrlForPutImage(@RequestParam("content-name") String contentName, @RequestParam("image-type") String imageType,
@RequestParam("image-extension") String imageExtension, @RequestParam("content-type") String contentType) {
val response = bannerService.getIssuedPreSignedUrlForPutImage(contentName, imageType, imageExtension, contentType);
return ApiResponseUtil.success(SUCCESS_GET_BANNER_IMAGE_PRE_SIGNED_URL, response);
}
@Override
@GetMapping("/img/pre-signed")
public ResponseEntity<BaseResponse<?>> getIssuedPreSignedUrlForPutImage(
@RequestParam("content-name") String contentName,
@RequestParam("image-type") String imageType,
@RequestParam("image-extension") String imageExtension,
@RequestParam("content-type") String contentType
) {
val response = bannerService.getIssuedPreSignedUrlForPutImage(contentName, imageType,
imageExtension, contentType);
return ApiResponseUtil.success(SUCCESS_GET_BANNER_IMAGE_PRE_SIGNED_URL, response);
}

@PostMapping
@Override
public ResponseEntity<BaseResponse<?>> createBanner(@RequestBody BannerRequest.BannerCreate request) {
val response = bannerService.createBanner(request);
return ApiResponseUtil.success(SUCCESS_CREATE_BANNER, response);
}
@PostMapping
@Override
public ResponseEntity<BaseResponse<?>> createBanner(
@RequestBody BannerRequest.BannerCreate request
) {
val response = bannerService.createBanner(request);
return ApiResponseUtil.success(SUCCESS_CREATE_BANNER, response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
Expand Down Expand Up @@ -66,7 +67,7 @@ void getBannerDetail() throws Exception {
this.mockMvc.perform(
// when
get("/api/v1/banners/" + MOCK_BANNER_ID)
.contentType(MediaType.APPLICATION_JSON)
.contentType(APPLICATION_JSON)
.principal(mock(Principal.class)))
// then
.andExpect(status().isOk())
Expand All @@ -93,7 +94,7 @@ void deleteBanner() throws Exception {
this.mockMvc.perform(
//when
delete("/api/v1/banners/" + MOCK_BANNER_ID)
.contentType(MediaType.APPLICATION_JSON)
.contentType(APPLICATION_JSON)
.principal(mock(Principal.class)))

//then
Expand All @@ -112,8 +113,8 @@ void getExternalBanners() throws Exception {
this.mockMvc.perform(
// when
get("/api/v1/banners/images")
.contentType(MediaType.APPLICATION_JSON)
.param("platform", imageType)
.contentType(APPLICATION_JSON)
.param("image_type", imageType)
.param("location", location)
.principal(mock(Principal.class)))
// then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public enum BannerSuccessCode implements SuccessCode {
SUCCESS_GET_BANNER_DETAIL(HttpStatus.OK, "배너 상세 정보 조회 성공"),
SUCCESS_DELETE_BANNER(HttpStatus. NO_CONTENT, "배너 삭제 성공"),
SUCCESS_GET_EXTERNAL_BANNERS(HttpStatus.OK, "외부 배너 조회 성공")
SUCCESS_GET_EXTERNAL_BANNERS(HttpStatus.OK, "외부 배너 조회 성공"),
SUCCESS_GET_BANNER_IMAGE_PRE_SIGNED_URL(HttpStatus.OK, "이미지 업로드 pre signed url 조회에 성공했습니다"),
SUCCESS_CREATE_BANNER(HttpStatus.CREATED, "배너 생성에 성공했습니다")
;
Expand Down

0 comments on commit 0fa024f

Please sign in to comment.