Skip to content

Commit

Permalink
[#28] CounterService: increaseHit 메소드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
chaiminwoo0223 committed Jun 14, 2024
1 parent e6e6987 commit 8047e01
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
7 changes: 0 additions & 7 deletions src/main/java/skhu/jijijig/domain/Counter.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,4 @@ public class Counter {

@Column(nullable = false)
private int hit;

public Counter increaseHit() {
return Counter.builder()
.id(this.id)
.hit(this.hit + 1)
.build();
}
}
5 changes: 4 additions & 1 deletion src/main/java/skhu/jijijig/service/CounterService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ public class CounterService {
@Transactional
public CounterDTO increaseHit() {
Counter counter = counterRepository.findById(1L).orElse(Counter.builder().hit(0).build());
Counter increasedCounter = counter.increaseHit();
Counter increasedCounter = Counter.builder()
.id(counter.getId())
.hit(counter.getHit() + 1)
.build();
counterRepository.save(increasedCounter);
return CounterDTO.fromEntity(increasedCounter);
}
Expand Down

0 comments on commit 8047e01

Please sign in to comment.