Skip to content

Commit

Permalink
πŸ”— :: (#717) κ²¨μšΈμΈν„΄ λ©”μ„œλ“œλͺ… 및 둜직 μˆ˜μ •
Browse files Browse the repository at this point in the history
  • Loading branch information
4mjeo authored Sep 3, 2024
2 parents 6df6d97 + 95cf64c commit 7df980a
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,4 @@ public class WinterIntern {

private final boolean isWinterInterned;

public WinterIntern toggle() {
return this.toBuilder()
.isWinterInterned(!this.isWinterInterned)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

public interface QueryWinterInternPort {

boolean getIsWintern();
boolean getIsWinterIntern();

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public class QueryIsWinterInternUseCase {
private final QueryWinterInternPort queryWinterInternPort;

public boolean execute() {
return queryWinterInternPort.getIsWintern();
return queryWinterInternPort.getIsWinterIntern();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ToggleWinterInternUseCase {
private final QueryWinterInternPort queryWinterInternPort;

public void execute() {
boolean toggled = !queryWinterInternPort.getIsWintern();
boolean toggled = !queryWinterInternPort.getIsWinterIntern();

WinterIntern toggledWinterIntern = WinterIntern.builder()
.isWinterInterned(toggled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import team.retum.jobis.domain.intern.model.WinterIntern;
import team.retum.jobis.domain.intern.persistence.mapper.WinterInternMapper;
import team.retum.jobis.domain.intern.persistence.entity.WinterInternEntity;
import team.retum.jobis.domain.intern.persistence.repository.WinterInternJpaRepository;
import team.retum.jobis.domain.intern.spi.WinterInternPort;

Expand All @@ -16,10 +16,9 @@ public class WinterInternPersistenceAdapter implements WinterInternPort {

private final JPAQueryFactory queryFactory;
private final WinterInternJpaRepository winterInternJpaRepository;
private final WinterInternMapper winterInternMapper;

@Override
public boolean getIsWintern() {
public boolean getIsWinterIntern() {
Boolean result = queryFactory
.select(winterInternEntity.isWinterIntern)
.from(winterInternEntity)
Expand All @@ -30,10 +29,11 @@ public boolean getIsWintern() {

@Override
public void save(WinterIntern winterIntern) {
winterInternMapper.toDomain(
winterInternJpaRepository.save(
winterInternMapper.toEntity(winterIntern)
)
);
WinterInternEntity entity = winterInternJpaRepository.findTopByOrderById()
.orElse(new WinterInternEntity(winterIntern.isWinterInterned()));

entity.setWinterIntern(winterIntern.isWinterInterned());

winterInternJpaRepository.save(entity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "tbl_wintern")
@Table(name = "tbl_winter_intern")
@Entity
public class WinterInternEntity {

@Id
@Column(name = "wintern_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import team.retum.jobis.domain.intern.usecase.ToggleWinterInternUseCase;

@RequiredArgsConstructor
@RequestMapping("/winterns")
@RequestMapping("/winter-intern")
@RestController
public class WinterInternWebAdapter {

Expand All @@ -20,12 +20,12 @@ public class WinterInternWebAdapter {

@ResponseStatus(HttpStatus.NO_CONTENT)
@PatchMapping
public void toggleWintern() {
public void toggleWinterIntern() {
toggleWinterInternUseCase.execute();
}

@GetMapping
public boolean getIsWintern() {
public boolean getIsWinterIntern() {
return queryIsWinterInternUseCase.execute();
}
}

0 comments on commit 7df980a

Please sign in to comment.