Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Origin 변경 #37

Closed
wants to merge 14 commits into from
Closed
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
4 changes: 0 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ dependencies {
// slack
implementation 'com.github.maricn:logback-slack-appender:1.4.0'

// Elasticsearch
implementation 'org.springframework.boot:spring-boot-starter-data-elasticsearch'
// implementation 'org.springframework.data:spring-data-elasticsearch:4.2.2'

// actuator
implementation 'org.springframework.boot:spring-boot-starter-actuator'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-11-26T00:28:54+0900",
date = "2024-11-26T02:00:56+0900",
comments = "version: 1.5.3.Final, compiler: javac, environment: Java 17.0.13 (Homebrew)"
)
@Component
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package moodbuddy.moodbuddy.domain.diary.mapper.draft;

import javax.annotation.processing.Generated;
import moodbuddy.moodbuddy.domain.diary.domain.Diary;
import moodbuddy.moodbuddy.domain.diary.dto.response.DiaryResDetailDTO;
import org.springframework.stereotype.Component;

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-11-26T02:00:56+0900",
comments = "version: 1.5.3.Final, compiler: javac, environment: Java 17.0.13 (Homebrew)"
)
@Component
public class DraftDiaryMapperImpl implements DraftDiaryMapper {

@Override
public DiaryResDetailDTO toResDetailDTO(Diary diary) {
if ( diary == null ) {
return null;
}

DiaryResDetailDTO.DiaryResDetailDTOBuilder diaryResDetailDTO = DiaryResDetailDTO.builder();

diaryResDetailDTO.diaryId( diary.getDiaryId() );
diaryResDetailDTO.moodBuddyStatus( diary.getMoodBuddyStatus() );
diaryResDetailDTO.userId( diary.getUserId() );
diaryResDetailDTO.diaryTitle( diary.getDiaryTitle() );
diaryResDetailDTO.diaryDate( diary.getDiaryDate() );
diaryResDetailDTO.diaryContent( diary.getDiaryContent() );
diaryResDetailDTO.diaryWeather( diary.getDiaryWeather() );
diaryResDetailDTO.diaryEmotion( diary.getDiaryEmotion() );
diaryResDetailDTO.diaryStatus( diary.getDiaryStatus() );
diaryResDetailDTO.diarySummary( diary.getDiarySummary() );
diaryResDetailDTO.diarySubject( diary.getDiarySubject() );
diaryResDetailDTO.diaryBookMarkCheck( diary.getDiaryBookMarkCheck() );
diaryResDetailDTO.diaryFont( diary.getDiaryFont() );
diaryResDetailDTO.diaryFontSize( diary.getDiaryFontSize() );

return diaryResDetailDTO.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-11-26T00:28:54+0900",
date = "2024-11-26T02:00:56+0900",
comments = "version: 1.5.3.Final, compiler: javac, environment: Java 17.0.13 (Homebrew)"
)
@Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-11-26T00:28:54+0900",
date = "2024-11-26T02:00:56+0900",
comments = "version: 1.5.3.Final, compiler: javac, environment: Java 17.0.13 (Homebrew)"
)
@Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import moodbuddy.moodbuddy.domain.diary.dto.request.draft.DiaryReqDraftSelectDeleteDTO;
import moodbuddy.moodbuddy.domain.diary.dto.request.DiaryReqUpdateDTO;
import moodbuddy.moodbuddy.domain.diary.dto.request.draft.DraftDiaryReqSelectDeleteDTO;
import moodbuddy.moodbuddy.domain.diary.dto.request.DiaryReqSaveDTO;
import moodbuddy.moodbuddy.domain.diary.dto.response.DiaryResDetailDTO;
import moodbuddy.moodbuddy.domain.diary.dto.response.draft.DiaryResDraftFindAllDTO;
import moodbuddy.moodbuddy.domain.diary.dto.response.draft.DraftDiaryResDetailDTO;
import moodbuddy.moodbuddy.domain.diary.dto.response.draft.DraftDiaryResFindOneDTO;
import moodbuddy.moodbuddy.domain.diary.facade.draft.DraftDiaryFacade;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v2/member/draftDiary")
@Tag(name = "Diary", description = "일기 관련 API")
Expand All @@ -22,24 +26,40 @@ public class DraftDiaryApiController {
/** 구현 완료 **/
@PostMapping("/save")
@Operation(summary = "일기 임시 저장", description = "일기를 임시 저장합니다.")
public ResponseEntity<DiaryResDetailDTO> draftSave(@Parameter(description = "임시 저장 일기 정보를 담고 있는 DTO")
public ResponseEntity<DiaryResDetailDTO> save(@Parameter(description = "임시 저장 일기 정보를 담고 있는 DTO")
@RequestBody DiaryReqSaveDTO requestDTO) {
return ResponseEntity.ok().body(draftDiaryFacade.saveDraftDiary(requestDTO));
return ResponseEntity.ok().body(draftDiaryFacade.save(requestDTO));
}

/** 구현 완료 **/
@PostMapping("/update")
@Operation(summary = "임시 저장 일기 -> 일기 저장으로 변경", description = "임시 저장 일기 -> 일기 저장으로 변경합니다.")
public ResponseEntity<DiaryResDetailDTO> update(@Parameter(description = "변경할 일기 정보를 담고 있는 DTO")
@RequestBody DiaryReqUpdateDTO requestDTO) {
return ResponseEntity.ok().body(draftDiaryFacade.update(requestDTO));
}

/** 구현 완료 **/
@GetMapping("/findOne/{diaryId}")
@Operation(summary = "임시 저장 일기 하나 조회", description = "임시 저장 일기 하나를 조회합니다.")
public ResponseEntity<DraftDiaryResDetailDTO> findOneByDiaryId(@Parameter(description = "일기 고유 식별자")
@PathVariable("diaryId") Long diaryId) {
return ResponseEntity.ok().body(draftDiaryFacade.findOneByDiaryId(diaryId));
}

/** 구현 완료 **/
@GetMapping("/findAll")
@Operation(summary = "임시 저장 일기 목록 조회", description = "임시 저장 일기를 모두 조회합니다.")
public ResponseEntity<DiaryResDraftFindAllDTO> draftFindAll() {
return ResponseEntity.ok().body(draftDiaryFacade.draftFindAll());
public ResponseEntity<List<DraftDiaryResFindOneDTO>> findAll() {
return ResponseEntity.ok().body(draftDiaryFacade.findAll());
}

/** 구현 완료 **/
@PostMapping("/selectDelete")
@Operation(summary = "임시 저장 일기 선택 삭제", description = "임시 저장 일기를 선택해서 삭제합니다.")
public ResponseEntity<?> draftSelectDelete(@Parameter(description = "삭제할 임시 저장 일기 고유 식별자를 담고 있는 DTO")
@RequestBody DiaryReqDraftSelectDeleteDTO requestDTO) {
draftDiaryFacade.draftSelectDelete(requestDTO);
public ResponseEntity<?> selectDelete(@Parameter(description = "삭제할 임시 저장 일기 고유 식별자를 담고 있는 DTO")
@RequestBody DraftDiaryReqSelectDeleteDTO requestDTO) {
draftDiaryFacade.selectDelete(requestDTO);
return ResponseEntity.ok().body("임시 저장 일기 선택 삭제 완료.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/member/diary")
@RequestMapping("/api/v2/member/diary")
@Tag(name = "Diary", description = "일기 감정 관련 API")
@RequiredArgsConstructor
public class DiaryEmotionApiController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ public class DiaryImageApiController {
public ResponseEntity<CompletableFuture<DiaryImageResURLDTO>> upload(@ModelAttribute CloudReqDTO cloudReqDTO) throws IOException {
return ResponseEntity.ok().body(diaryImageFacade.uploadAndSave(cloudReqDTO));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public record DiaryReqSaveDTO (
DiaryFontSize diaryFontSize,
@Schema(description = "일기 사진 URL 리스트", example = "[이미지 URL, 이미지 URL]")
@Nullable
List<String> diaryImageURLs)
List<String> diaryImageURLs )
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import jakarta.validation.constraints.NotNull;
import java.util.List;

public record DiaryReqDraftSelectDeleteDTO (
public record DraftDiaryReqSelectDeleteDTO(
@Schema(description = "삭제하고 싶은 임시 저장 일기 고유 식별자(diaryId)를 담는 List", example = "[1, 2]")
@NotNull List<Long> diaryIdList) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class DiaryResDetailDTO {
@Schema(description = "일기 상태", example = "ACTIVE")
private MoodBuddyStatus moodBuddyStatus;

@JsonInclude(JsonInclude.Include.NON_NULL) // 굳이 필요하지 않은 경우가 있음.
@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(description = "일기 이미지 List", example = "[이미지 URL, 이미지 URL]")
private List<String> diaryImgList;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package moodbuddy.moodbuddy.domain.diary.dto.response.draft;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import moodbuddy.moodbuddy.domain.diary.domain.type.DiaryFont;
import moodbuddy.moodbuddy.domain.diary.domain.type.DiaryFontSize;
import moodbuddy.moodbuddy.domain.diary.domain.type.DiaryStatus;
import moodbuddy.moodbuddy.domain.diary.domain.type.DiaryWeather;
import moodbuddy.moodbuddy.global.common.base.MoodBuddyStatus;
import java.time.LocalDate;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class DraftDiaryResDetailDTO {
private Long diaryId;
private Long userId;
private String diaryTitle;
private LocalDate diaryDate;
private String diaryContent;
private DiaryWeather diaryWeather;
private DiaryStatus diaryStatus;
private DiaryFont diaryFont;
private DiaryFontSize diaryFontSize;
private MoodBuddyStatus moodBuddyStatus;

@JsonInclude(JsonInclude.Include.NON_NULL)
private List<String> diaryImgList;

public DraftDiaryResDetailDTO(Long diaryId, Long userId, String diaryTitle, LocalDate diaryDate, String diaryContent, DiaryWeather diaryWeather, DiaryStatus diaryStatus, DiaryFont diaryFont, DiaryFontSize diaryFontSize, MoodBuddyStatus moodBuddyStatus) {
this.diaryId = diaryId;
this.userId = userId;
this.diaryTitle = diaryTitle;
this.diaryDate = diaryDate;
this.diaryContent = diaryContent;
this.diaryWeather = diaryWeather;
this.diaryStatus = diaryStatus;
this.diaryFont = diaryFont;
this.diaryFontSize = diaryFontSize;
this.moodBuddyStatus = moodBuddyStatus;
this.diaryImgList = List.of();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@

import java.time.LocalDate;

public record DiaryResDraftFindOneDTO(
public record DraftDiaryResFindOneDTO(
@Schema(description = "일기 고유 식별자(diaryId)", example = "1")
Long diaryId,
@Schema(description = "사용자 고유 식별자(userId)", example = "2")
Long userId,
@Schema(description = "일기 날짜", example = "2023-07-02T15:30:00")
LocalDate diaryDate,
@Schema(description = "일기 상태(DRAFT, PUBLISHED)", example = "DRAFT")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,24 @@
import lombok.RequiredArgsConstructor;
import moodbuddy.moodbuddy.domain.bookMark.service.BookMarkService;
import moodbuddy.moodbuddy.domain.diary.domain.Diary;
import moodbuddy.moodbuddy.domain.diary.domain.image.DiaryImage;
import moodbuddy.moodbuddy.domain.diary.dto.request.DiaryReqSaveDTO;
import moodbuddy.moodbuddy.domain.diary.dto.request.DiaryReqUpdateDTO;
import moodbuddy.moodbuddy.domain.diary.dto.response.DiaryResDetailDTO;
import moodbuddy.moodbuddy.domain.diary.mapper.DiaryMapper;
import moodbuddy.moodbuddy.domain.diary.service.image.DiaryImageService;
import moodbuddy.moodbuddy.domain.diary.service.DiaryService;
import moodbuddy.moodbuddy.global.common.elasticSearch.diary.service.DiaryDocumentService;
import moodbuddy.moodbuddy.domain.user.service.UserService;
import moodbuddy.moodbuddy.global.common.gpt.service.GptService;
import moodbuddy.moodbuddy.global.common.util.JwtUtil;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.util.List;

@Component
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class DiaryFacadeImpl implements DiaryFacade {
private final DiaryService diaryService;
private final DiaryDocumentService diaryDocumentService;
private final DiaryImageService diaryImageService;
private final BookMarkService bookMarkService;
private final UserService userService;
Expand All @@ -42,7 +37,7 @@ public DiaryResDetailDTO save(DiaryReqSaveDTO requestDTO) {
if(requestDTO.diaryImageURLs() != null) {
diaryImageService.saveAll(requestDTO.diaryImageURLs(), diary.getDiaryId());
}
diaryDocumentService.save(diary);
// diaryDocumentService.save(diary);
checkTodayDiary(requestDTO.diaryDate(), userId, false);
return diaryMapper.toResDetailDTO(diary);
}
Expand All @@ -56,7 +51,7 @@ public DiaryResDetailDTO update(DiaryReqUpdateDTO requestDTO) {
if(requestDTO.newImageURLs() != null) {
diaryImageService.saveAll(requestDTO.newImageURLs(), diary.getDiaryId());
}
diaryDocumentService.save(diary);
// diaryDocumentService.save(diary);
return diaryMapper.toResDetailDTO(diary);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package moodbuddy.moodbuddy.domain.diary.facade.draft;

import moodbuddy.moodbuddy.domain.diary.dto.request.draft.DiaryReqDraftSelectDeleteDTO;
import moodbuddy.moodbuddy.domain.diary.dto.request.DiaryReqUpdateDTO;
import moodbuddy.moodbuddy.domain.diary.dto.request.draft.DraftDiaryReqSelectDeleteDTO;
import moodbuddy.moodbuddy.domain.diary.dto.request.DiaryReqSaveDTO;
import moodbuddy.moodbuddy.domain.diary.dto.response.DiaryResDetailDTO;
import moodbuddy.moodbuddy.domain.diary.dto.response.draft.DiaryResDraftFindAllDTO;
import moodbuddy.moodbuddy.domain.diary.dto.response.draft.DraftDiaryResDetailDTO;
import moodbuddy.moodbuddy.domain.diary.dto.response.draft.DraftDiaryResFindOneDTO;

import java.util.List;

public interface DraftDiaryFacade {
DiaryResDetailDTO saveDraftDiary(DiaryReqSaveDTO requestDTO);
DiaryResDraftFindAllDTO draftFindAll();
void draftSelectDelete(DiaryReqDraftSelectDeleteDTO requestDTO);
DiaryResDetailDTO save(DiaryReqSaveDTO requestDTO);
DiaryResDetailDTO update(DiaryReqUpdateDTO requestDTO);
List<DraftDiaryResFindOneDTO> findAll();
void selectDelete(DraftDiaryReqSelectDeleteDTO requestDTO);
DraftDiaryResDetailDTO findOneByDiaryId(Long diaryId);
}
Loading