|
Last change
on this file since 09e02d7 was 09e02d7, checked in by Nikola Sarafimov <sarafimov.nikola12345@…>, 3 days ago |
|
Final room reservation system implementation
|
-
Property mode
set to
100644
|
|
File size:
980 bytes
|
| Line | |
|---|
| 1 | package mk.finki.roomreservation.service;
|
|---|
| 2 |
|
|---|
| 3 | import mk.finki.roomreservation.model.EquipmentOption;
|
|---|
| 4 | import org.springframework.jdbc.core.JdbcTemplate;
|
|---|
| 5 | import org.springframework.stereotype.Service;
|
|---|
| 6 |
|
|---|
| 7 | import java.util.List;
|
|---|
| 8 |
|
|---|
| 9 | @Service
|
|---|
| 10 | public class EquipmentService {
|
|---|
| 11 |
|
|---|
| 12 | private final JdbcTemplate jdbcTemplate;
|
|---|
| 13 |
|
|---|
| 14 | public EquipmentService(JdbcTemplate jdbcTemplate) {
|
|---|
| 15 | this.jdbcTemplate = jdbcTemplate;
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | public List<EquipmentOption> findAllEquipment() {
|
|---|
| 19 | String sql = """
|
|---|
| 20 | SELECT
|
|---|
| 21 | equipment_id,
|
|---|
| 22 | name,
|
|---|
| 23 | stock_quantity
|
|---|
| 24 | FROM project.equipment
|
|---|
| 25 | ORDER BY name
|
|---|
| 26 | """;
|
|---|
| 27 |
|
|---|
| 28 | return jdbcTemplate.query(sql, (rs, rowNum) ->
|
|---|
| 29 | new EquipmentOption(
|
|---|
| 30 | rs.getInt("equipment_id"),
|
|---|
| 31 | rs.getString("name"),
|
|---|
| 32 | rs.getInt("stock_quantity")
|
|---|
| 33 | )
|
|---|
| 34 | );
|
|---|
| 35 | }
|
|---|
| 36 | } |
|---|
Note:
See
TracBrowser
for help on using the repository browser.