Skip to content

Commit

Permalink
Merge pull request #120 from softeerbootcamp4th/feat/#119-upload-image
Browse files Browse the repository at this point in the history
Feat/#119 upload image
  • Loading branch information
wjddn2165 authored Aug 13, 2024
2 parents c45ef28 + 9a6a4fb commit af4c958
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import JGS.CasperEvent.domain.event.dto.RequestDto.AdminRequestDto;
import JGS.CasperEvent.domain.event.dto.RequestDto.lotteryEventDto.LotteryEventRequestDto;
import JGS.CasperEvent.domain.event.dto.RequestDto.rushEventDto.RushEventRequestDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.ImageUrlResponseDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.lotteryEventResponseDto.LotteryEventDetailResponseDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.lotteryEventResponseDto.LotteryEventResponseDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.lotteryEventResponseDto.LotteryEventParticipantsListResponseDto;
Expand Down Expand Up @@ -36,6 +37,16 @@ public ResponseEntity<ResponseDto> postAdmin(@RequestBody @Valid AdminRequestDto
.body(adminService.postAdmin(adminRequestDto));
}

// 이미지 업로드
@PostMapping("/image")
public ResponseEntity<ImageUrlResponseDto> postImage(
@RequestPart(value = "image") MultipartFile image){
return ResponseEntity
.status(HttpStatus.CREATED)
.body(adminService.postImage(image));

}

// 추첨 이벤트 조회
@GetMapping("/event/lottery")
public ResponseEntity<LotteryEventDetailResponseDto> getLotteryEvent() {
Expand Down Expand Up @@ -84,7 +95,6 @@ public ResponseEntity<List<AdminRushEventResponseDto>> getRushEvents() {
.body(adminService.getRushEvents());
}


// 선착순 이벤트 참여자 조회
@GetMapping("/event/rush/{rushEventId}/participants")
public ResponseEntity<RushEventParticipantsListResponseDto> getRushEventParticipants(
Expand All @@ -98,6 +108,17 @@ public ResponseEntity<RushEventParticipantsListResponseDto> getRushEventParticip
.body(adminService.getRushEventParticipants(rushEventId, size, page, option, phoneNumber));
}

// 선착순 이벤트 수정
@PutMapping("/event/rush")
public ResponseEntity<List<AdminRushEventResponseDto>> updateRushEvent(
@RequestPart(name = "json") List<RushEventRequestDto> rushEventListRequestDto,
@RequestPart(name = "images") List<MultipartFile> images
) {
return ResponseEntity
.status(HttpStatus.OK)
.body(adminService.updateRushEvents(rushEventListRequestDto, images));
}

// 추첨 이벤트 삭제
@DeleteMapping("/event/lottery")
public ResponseEntity<Void> deleteLotteryEvent() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package JGS.CasperEvent.domain.event.dto.ResponseDto;

public record ImageUrlResponseDto(String imageUrl) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import JGS.CasperEvent.domain.event.dto.RequestDto.lotteryEventDto.LotteryEventRequestDto;
import JGS.CasperEvent.domain.event.dto.RequestDto.rushEventDto.RushEventOptionRequestDto;
import JGS.CasperEvent.domain.event.dto.RequestDto.rushEventDto.RushEventRequestDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.ImageUrlResponseDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.lotteryEventResponseDto.LotteryEventDetailResponseDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.lotteryEventResponseDto.LotteryEventParticipantsListResponseDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.lotteryEventResponseDto.LotteryEventParticipantsResponseDto;
Expand Down Expand Up @@ -74,6 +75,10 @@ public ResponseDto postAdmin(AdminRequestDto adminRequestDto) {
return ResponseDto.of("관리자 생성 성공");
}

public ImageUrlResponseDto postImage(MultipartFile image){
return new ImageUrlResponseDto(s3Service.upload(image));
}

public LotteryEventResponseDto createLotteryEvent(LotteryEventRequestDto lotteryEventRequestDto) {
if (lotteryEventRepository.count() >= 1) throw new TooManyLotteryEventException();

Expand Down Expand Up @@ -150,7 +155,7 @@ public RushEventResponseDto createRushEvent(RushEventRequestDto rushEventRequest
Position.RIGHT
));

rushEvent.updateOption(leftRushOption, rightRushOption);
rushEvent.addOption(leftRushOption, rightRushOption);

return RushEventResponseDto.of(rushEvent);
}
Expand Down Expand Up @@ -254,4 +259,10 @@ private LotteryEvent getCurrentLotteryEvent() {

return lotteryEventList.get(0);
}

public List<AdminRushEventResponseDto> updateRushEvents(List<RushEventRequestDto> rushEventRequestDtoList, List<MultipartFile> images) {
LocalDateTime now = LocalDateTime.now();

return null;
}
}

0 comments on commit af4c958

Please sign in to comment.