Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ public void createRecord(UserPrincipal userPrincipal, CreateRecordReq createReco
// User user = userRepository.findById(5L).orElseThrow(UserNotFoundException::new);
validateCreateRecordReq(createRecordReq);

String recordImgUrl = s3Util.uploadToRecordFolder(img);
log.info("recordImgUrl: {}", recordImgUrl);
String recordImgUrl;
if(img != null){
recordImgUrl = s3Util.uploadToRecordFolder(img);
log.info("recordImgUrl: {}", recordImgUrl);
}
else{
recordImgUrl = null;
}

String verb = createRecordReq.getVerbType();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
Expand All @@ -25,6 +26,7 @@
@RestController
@RequestMapping("api/v1/record")
@RequiredArgsConstructor
@Slf4j
public class RecordController {
private final RecordService recordService;
@Operation(summary = "기록 추가 API", description = "기록을 추가하는 API입니다.")
Expand All @@ -42,6 +44,11 @@ public ResponseEntity<?> createRecord(
@Parameter(description = "Schemas의 CreateRecordReq를 참고해주세요.", required = true) @RequestPart CreateRecordReq createRecordReq,
@RequestPart(value = "img", required = false) MultipartFile img
) {
// 이미지 null 체크
log.info("img: {}", img.isEmpty());
if(img.isEmpty()) {
img = null;
}
recordService.createRecord(userPrincipal, createRecordReq, img);
return ResponseEntity.ok(ApiResponseUtil.success(Message.builder().message("기록이 생성되었습니다.").build()));
}
Expand Down