-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: 아카이브 테이블 구조 변경 * chore: flyway 업데이트 * refactor: TEXT 컬럼 옵션 표현 * refactor: template, temporal memo archive 로직 위치 변경 & url 수정
- Loading branch information
1 parent
9a56f0e
commit dc592e9
Showing
37 changed files
with
717 additions
and
727 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/main/java/com/baro/archive/application/ArchiveService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.baro.archive.application; | ||
|
||
import com.baro.archive.domain.ArchiveRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@RequiredArgsConstructor | ||
@Transactional | ||
@Service | ||
public class ArchiveService { | ||
|
||
private final ArchiveRepository archiveRepository; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/com/baro/archive/domain/ArchiveRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.baro.archive.domain; | ||
|
||
import java.util.List; | ||
|
||
public interface ArchiveRepository { | ||
|
||
Archive getById(Long id); | ||
|
||
boolean existsByMemberIdAndTemplateId(Long memberId, Long templateId); | ||
|
||
Archive getByMemberIdAndTemplateId(Long memberId, Long templateId); | ||
|
||
List<Archive> findAll(); | ||
|
||
Archive save(Archive archive); | ||
|
||
void delete(Archive archive); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/baro/archive/exception/ArchiveException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.baro.archive.exception; | ||
|
||
import com.baro.common.exception.RequestException; | ||
import com.baro.common.exception.RequestExceptionType; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public class ArchiveException extends RequestException { | ||
|
||
private final ArchiveExceptionType exceptionType; | ||
|
||
@Override | ||
public RequestExceptionType exceptionType() { | ||
return exceptionType; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/baro/archive/exception/ArchiveExceptionType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.baro.archive.exception; | ||
|
||
import com.baro.common.exception.RequestExceptionType; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@RequiredArgsConstructor | ||
public enum ArchiveExceptionType implements RequestExceptionType { | ||
|
||
NOT_EXIST_ARCHIVE("AR01", "존재하지 않는 아카이브 입니다.", HttpStatus.NOT_FOUND), | ||
ARCHIVED_TEMPLATE("AR02", "이미 저장한 템플릿입니다.", HttpStatus.BAD_REQUEST), | ||
NOT_ARCHIVED_TEMPLATE("AR03", "저장하지 않은 템플릿입니다.", HttpStatus.BAD_REQUEST), | ||
; | ||
|
||
private final String errorCode; | ||
private final String errorMessage; | ||
private final HttpStatus httpStatus; | ||
|
||
@Override | ||
public String errorCode() { | ||
return errorCode; | ||
} | ||
|
||
@Override | ||
public String errorMessage() { | ||
return errorMessage; | ||
} | ||
|
||
@Override | ||
public HttpStatus httpStatus() { | ||
return httpStatus; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/baro/archive/infra/ArchiveJpaRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.baro.archive.infra; | ||
|
||
import com.baro.archive.domain.Archive; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ArchiveJpaRepository extends JpaRepository<Archive, Long> { | ||
|
||
boolean existsByMemberIdAndTemplateId(Long memberId, Long templateId); | ||
|
||
Optional<Archive> findByMemberIdAndTemplateId(Long memberId, Long templateId); | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/com/baro/archive/infra/ArchiveRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.baro.archive.infra; | ||
|
||
import com.baro.archive.domain.Archive; | ||
import com.baro.archive.domain.ArchiveRepository; | ||
import com.baro.archive.exception.ArchiveException; | ||
import com.baro.archive.exception.ArchiveExceptionType; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@RequiredArgsConstructor | ||
@Repository | ||
public class ArchiveRepositoryImpl implements ArchiveRepository { | ||
|
||
private final ArchiveJpaRepository archiveJpaRepository; | ||
|
||
@Override | ||
public Archive getById(Long id) { | ||
return archiveJpaRepository.findById(id) | ||
.orElseThrow(() -> new ArchiveException(ArchiveExceptionType.NOT_EXIST_ARCHIVE)); | ||
} | ||
|
||
@Override | ||
public boolean existsByMemberIdAndTemplateId(Long memberId, Long templateId) { | ||
return archiveJpaRepository.existsByMemberIdAndTemplateId(memberId, templateId); | ||
} | ||
|
||
@Override | ||
public Archive getByMemberIdAndTemplateId(Long memberId, Long templateId) { | ||
return archiveJpaRepository.findByMemberIdAndTemplateId(memberId, templateId) | ||
.orElseThrow(() -> new ArchiveException(ArchiveExceptionType.NOT_ARCHIVED_TEMPLATE)); | ||
} | ||
|
||
@Override | ||
public List<Archive> findAll() { | ||
return archiveJpaRepository.findAll(); | ||
} | ||
|
||
@Override | ||
public Archive save(Archive archive) { | ||
return archiveJpaRepository.save(archive); | ||
} | ||
|
||
@Override | ||
public void delete(Archive archive) { | ||
archiveJpaRepository.delete(archive); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/baro/archive/presentation/ArchiveController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.baro.archive.presentation; | ||
|
||
import com.baro.archive.application.ArchiveService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("/archives") | ||
@RestController | ||
public class ArchiveController { | ||
|
||
private final ArchiveService archiveService; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/main/java/com/baro/memo/application/dto/ArchiveTemporalMemoResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package com.baro.memo.application.dto; | ||
|
||
import com.baro.memo.domain.Memo; | ||
import com.baro.archive.domain.Archive; | ||
|
||
public record ArchiveTemporalMemoResult( | ||
Long id | ||
) { | ||
|
||
public static ArchiveTemporalMemoResult from(Memo memo) { | ||
return new ArchiveTemporalMemoResult(memo.getId()); | ||
public static ArchiveTemporalMemoResult from(Archive archive) { | ||
return new ArchiveTemporalMemoResult(archive.getId()); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
src/main/java/com/baro/memo/infrastructure/MemoJpaRepository.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.