Skip to content

Commit

Permalink
민기와 동헌이의 역사적인 만남으로 인한 민기의 API 1차 테스트 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
kimm0302 committed May 15, 2024
1 parent 4c8406c commit 4b2659d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 17 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import project.one.auction.domain.Auction;
import project.one.auction.domain.AuctionModifyRequest;
import project.one.auction.service.AuctionService;
import project.one.global.Response.MakeResponse;
import project.one.global.Response.ResponseMessage;

import java.io.IOException;
import java.util.List;

import static project.one.global.Response.MakeResponse.getResponseMessage;
Expand All @@ -23,20 +25,14 @@ public class AuctionController {
private final AuctionService auctionService;

@Operation(summary = "견적 의뢰서 생성", description = "견적 의뢰서 생성 API")
@PostMapping("/{categoryId}")
public ResponseEntity<ResponseMessage<Object>> createAuction(@PathVariable(value = "categoryId") Long categoryId, @RequestBody AuctionModifyRequest request) {
@PostMapping(value = "/{categoryId}")
public ResponseEntity<ResponseMessage<Object>> createAuction(@PathVariable(value = "categoryId") Long categoryId,
@RequestBody AuctionModifyRequest request)
{
Auction createdAuction = auctionService.createAuction(categoryId, request);
return MakeResponse.getResponseMessage(HttpStatus.OK,"경매 생성 성공",createdAuction);
}

@Operation(summary = "견적 의뢰서 이미지 추가", description = "견적 의뢰서 이미지 추가 API")
@PostMapping("/{auctionId}/images")
public ResponseEntity<ResponseMessage<Auction>> addImageToAuction(
@PathVariable Long auctionId,
@RequestParam String imageUrl) {
Auction addImageToAuction = auctionService.addImageToAuction(auctionId, imageUrl);
return MakeResponse.getResponseMessage(HttpStatus.OK,"이미지가 정상적으로 첨부 되었습니다",addImageToAuction);
}

@Operation(summary = "경매 전체 조회", description = "경매 전체 조회 API")
@GetMapping
Expand All @@ -47,24 +43,23 @@ public ResponseEntity<ResponseMessage<List<Auction>>> getAllAuctions() {

@Operation(summary = "경매 ID로 조회", description = "경매 ID로 조회 API")
@GetMapping("/{auctionId}")
public ResponseEntity<ResponseMessage<Auction>> getAuctionById(@PathVariable Long auctionId) {
public ResponseEntity<ResponseMessage<Auction>> getAuctionById(@PathVariable(value = "auctionId") Long auctionId) {
Auction auction = auctionService.getAuctionById(auctionId);
return MakeResponse.getResponseMessage(HttpStatus.OK,"경매 ID로 조회 성공",auction);
}

@Operation(summary = "경매 수정", description = "경매 수정 API")
@PutMapping("/{auctionId}")
public ResponseEntity<ResponseMessage<Auction>> modifyAuction(
@PathVariable Long auctionId,
@RequestParam Long categoryId,
@PathVariable(value = "auctionId") Long auctionId,
@RequestBody AuctionModifyRequest request) {
Auction modifiedAuction = auctionService.modifyAuction(auctionId, categoryId, request);
Auction modifiedAuction = auctionService.modifyAuction(auctionId, request);
return MakeResponse.getResponseMessage(HttpStatus.OK,"경매 수정 완료",modifiedAuction);
}

@Operation(summary = "경매 삭제", description = "경매 삭제 API")
@DeleteMapping("/{auctionId}")
public ResponseEntity<ResponseMessage<Object>> deleteAuction(@PathVariable Long auctionId) {
public ResponseEntity<ResponseMessage<Object>> deleteAuction(@PathVariable(value = "auctionId") Long auctionId) {
auctionService.deleteAuction(auctionId);
return MakeResponse.getResponseMessage(HttpStatus.OK,"경매 삭제 완료");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import project.one.auction.domain.Auction;
import project.one.auction.domain.AuctionModifyRequest;
import project.one.auction.domain.AuctionRepository;
Expand Down Expand Up @@ -59,11 +60,11 @@ public Auction getAuctionById(Long auctionId) {
}

// 사용자 견적 의뢰서 수정
public Auction modifyAuction(Long auctionId, Long categoryId, AuctionModifyRequest request) {
public Auction modifyAuction(Long auctionId, AuctionModifyRequest request) {
Optional<Auction> optionalAuction = auctionRepository.findById(auctionId);
if (optionalAuction.isPresent()) {
Auction auction = optionalAuction.get();
auction.setCategoryId(categoryId);
//auction.setCategoryId(categoryId);
//auction.setUserId(request.getUserId());
auction.setTitle(request.getTitle());
auction.setContent(request.getContent());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package project.one.global.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter;
import org.springframework.stereotype.Component;

import java.lang.reflect.Type;

@Component
public class MultipartConverter extends AbstractJackson2HttpMessageConverter {
public MultipartConverter(ObjectMapper objectMapper) {
super(objectMapper, MediaType.APPLICATION_OCTET_STREAM);
}

@Override
public boolean canWrite(Class<?> clazz, MediaType mediaType) {
return false;
}

@Override
public boolean canWrite(Type type, Class<?> clazz, MediaType mediaType) {
return false;
}

@Override
protected boolean canWrite(MediaType mediaType) {
return false;
}
}

0 comments on commit 4b2659d

Please sign in to comment.