-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Refactor #106 기수 테이블 분리
- Loading branch information
Showing
28 changed files
with
527 additions
and
124 deletions.
There are no files selected for viewing
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
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
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
10 changes: 10 additions & 0 deletions
10
src/main/java/leets/weeth/domain/user/application/dto/request/CardinalSaveRequest.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,10 @@ | ||
package leets.weeth.domain.user.application.dto.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record CardinalSaveRequest ( | ||
@NotNull Integer cardinalNumber, | ||
@NotNull Integer year, | ||
@NotNull Integer semester | ||
){ | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/leets/weeth/domain/user/application/dto/response/CardinalResponse.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,13 @@ | ||
package leets.weeth.domain.user.application.dto.response; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public record CardinalResponse( | ||
Long id, | ||
Integer cardinalNumber, | ||
Integer year, | ||
Integer semester, | ||
LocalDateTime createdAt, | ||
LocalDateTime modifiedAt | ||
) { | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/leets/weeth/domain/user/application/dto/response/UserCardinalDto.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 leets.weeth.domain.user.application.dto.response; | ||
|
||
import leets.weeth.domain.user.domain.entity.User; | ||
import leets.weeth.domain.user.domain.entity.UserCardinal; | ||
|
||
import java.util.List; | ||
|
||
public record UserCardinalDto( | ||
User user, | ||
List<UserCardinal> cardinals | ||
) { | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/leets/weeth/domain/user/application/exception/DuplicateCardinalException.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,9 @@ | ||
package leets.weeth.domain.user.application.exception; | ||
|
||
import leets.weeth.global.common.exception.BusinessLogicException; | ||
|
||
public class DuplicateCardinalException extends BusinessLogicException { | ||
public DuplicateCardinalException() { | ||
super(400, "이미 존재하는 기수 입니다."); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/leets/weeth/domain/user/application/mapper/CardinalMapper.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,23 @@ | ||
package leets.weeth.domain.user.application.mapper; | ||
|
||
import leets.weeth.domain.user.application.dto.request.CardinalSaveRequest; | ||
import leets.weeth.domain.user.application.dto.response.CardinalResponse; | ||
import leets.weeth.domain.user.application.dto.response.UserCardinalDto; | ||
import leets.weeth.domain.user.domain.entity.Cardinal; | ||
import leets.weeth.domain.user.domain.entity.User; | ||
import leets.weeth.domain.user.domain.entity.UserCardinal; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.MappingConstants; | ||
import org.mapstruct.ReportingPolicy; | ||
|
||
import java.util.List; | ||
|
||
@Mapper(componentModel = MappingConstants.ComponentModel.SPRING, unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
public interface CardinalMapper { | ||
|
||
Cardinal from(CardinalSaveRequest dto); | ||
|
||
CardinalResponse to(Cardinal cardinal); | ||
|
||
UserCardinalDto toUserCardinalDto(User user, List<UserCardinal> userCardinals); | ||
} |
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
38 changes: 38 additions & 0 deletions
38
src/main/java/leets/weeth/domain/user/application/usecase/CardinalUseCase.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,38 @@ | ||
package leets.weeth.domain.user.application.usecase; | ||
|
||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import leets.weeth.domain.user.application.dto.request.CardinalSaveRequest; | ||
import leets.weeth.domain.user.application.dto.response.CardinalResponse; | ||
import leets.weeth.domain.user.application.mapper.CardinalMapper; | ||
import leets.weeth.domain.user.domain.entity.Cardinal; | ||
import leets.weeth.domain.user.domain.service.CardinalGetService; | ||
import leets.weeth.domain.user.domain.service.CardinalSaveService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class CardinalUseCase { | ||
|
||
private final CardinalGetService cardinalGetService; | ||
private final CardinalSaveService cardinalSaveService; | ||
|
||
private final CardinalMapper cardinalMapper; | ||
|
||
@Transactional | ||
public void save(CardinalSaveRequest dto) { | ||
cardinalGetService.validateCardinal(dto.cardinalNumber()); | ||
|
||
cardinalSaveService.save(cardinalMapper.from(dto)); | ||
} | ||
|
||
public List<CardinalResponse> findAll() { | ||
List<Cardinal> cardinals = cardinalGetService.findAll(); | ||
return cardinals.stream() | ||
.map(cardinalMapper::to) | ||
.toList(); | ||
} | ||
} |
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
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
Oops, something went wrong.