source: backend/src/main/java/mk/finki/roomreservation/service/EquipmentService.java

Last change on this file was 09e02d7, checked in by Nikola Sarafimov <sarafimov.nikola12345@…>, 4 days ago

Final room reservation system implementation

  • Property mode set to 100644
File size: 980 bytes
RevLine 
[09e02d7]1package mk.finki.roomreservation.service;
2
3import mk.finki.roomreservation.model.EquipmentOption;
4import org.springframework.jdbc.core.JdbcTemplate;
5import org.springframework.stereotype.Service;
6
7import java.util.List;
8
9@Service
10public 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.