Skip to content

Commit

Permalink
updateById 작성하기
Browse files Browse the repository at this point in the history
Related to: #37
  • Loading branch information
ahyoon99 committed Aug 21, 2024
1 parent 2f3f067 commit bc6c648
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ public List<T> listAll() {
return (List<T>) result;
}

@Override
public void updateById(int index, T entity) {
String updateByIdQuery = "update restaurant set isvisit=?, visitcount=? where index=?";

WishListEntity wishListEntity = (WishListEntity) entity;
jdbcTemplate.update(updateByIdQuery, wishListEntity.isVisit(), wishListEntity.getVisitCount(), index);
}

private RowMapper<WishListEntity> wishListEntityRowMapper(){
return ((rs, rowNum) -> {
WishListEntity wishListEntity = new WishListEntity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public interface MemoryDbRepositoryIfs<T> {
T save(T entity);
void deleteById(int index);
List<T> listAll();
void updateById(int index, T entity);

}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public void addVisit(int index) {
var restaurnatEntity = restaurant.get();
restaurnatEntity.setVisit(true);
restaurnatEntity.setVisitCount(restaurnatEntity.getVisitCount()+1);
wishListRepository.updateById(index, restaurnatEntity);
}
}

Expand Down

0 comments on commit bc6c648

Please sign in to comment.