-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add REST CRUD APIs for Chargebox, Reservation, and User #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * SteVe - SteckdosenVerwaltung - https://github.com/steve-community/steve | ||
| * Copyright (C) 2013-2025 SteVe Community Team | ||
| * All Rights Reserved. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
| package de.rwth.idsg.steve.service; | ||
|
|
||
| import de.rwth.idsg.steve.repository.ChargePointRepository; | ||
| import de.rwth.idsg.steve.repository.dto.ChargePoint; | ||
| import de.rwth.idsg.steve.web.dto.ChargePointForm; | ||
| import de.rwth.idsg.steve.web.dto.ChargePointQueryForm; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class ChargeboxService { | ||
|
|
||
| private final ChargePointRepository chargePointRepository; | ||
|
|
||
| public List<ChargePoint.Overview> getOverview(ChargePointQueryForm form) { | ||
| return chargePointRepository.getOverview(form); | ||
| } | ||
|
|
||
| public ChargePoint.Details getDetails(int chargeBoxPk) { | ||
| return chargePointRepository.getDetails(chargeBoxPk); | ||
| } | ||
|
|
||
| public int addChargePoint(ChargePointForm form) { | ||
| return chargePointRepository.addChargePoint(form); | ||
| } | ||
|
|
||
| public void updateChargePoint(ChargePointForm form) { | ||
| chargePointRepository.updateChargePoint(form); | ||
| } | ||
|
|
||
| public void deleteChargePoint(int chargeBoxPk) { | ||
| chargePointRepository.deleteChargePoint(chargeBoxPk); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package de.rwth.idsg.steve.service; | ||
|
|
||
| import de.rwth.idsg.steve.repository.ReservationRepository; | ||
| import de.rwth.idsg.steve.repository.dto.InsertReservationParams; | ||
| import de.rwth.idsg.steve.repository.dto.Reservation; | ||
| import de.rwth.idsg.steve.web.dto.ReservationForm; | ||
| import de.rwth.idsg.steve.web.dto.ReservationQueryForm; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class ReservationService { | ||
|
|
||
| private final ReservationRepository reservationRepository; | ||
|
|
||
| public List<Reservation> getReservations(ReservationQueryForm form) { | ||
| return reservationRepository.getReservations(form); | ||
| } | ||
|
|
||
| public int addReservation(ReservationForm form) { | ||
| InsertReservationParams params = InsertReservationParams.builder() | ||
| .idTag(form.getIdTag()) | ||
| .chargeBoxId(form.getChargeBoxId()) | ||
| .connectorId(form.getConnectorId()) | ||
| .startTimestamp(form.getStartTimestamp()) | ||
| .expiryTimestamp(form.getExpiryTimestamp()) | ||
| .build(); | ||
| return reservationRepository.insert(params); | ||
| } | ||
|
|
||
| public void deleteReservation(int reservationId) { | ||
| reservationRepository.delete(reservationId); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,37 @@ | ||||||||||||||
| package de.rwth.idsg.steve.service; | ||||||||||||||
|
|
||||||||||||||
| import de.rwth.idsg.steve.repository.UserRepository; | ||||||||||||||
| import de.rwth.idsg.steve.repository.dto.User; | ||||||||||||||
| import de.rwth.idsg.steve.web.dto.UserForm; | ||||||||||||||
| import de.rwth.idsg.steve.web.dto.UserQueryForm; | ||||||||||||||
| import lombok.RequiredArgsConstructor; | ||||||||||||||
| import org.springframework.stereotype.Service; | ||||||||||||||
|
|
||||||||||||||
| import java.util.List; | ||||||||||||||
|
|
||||||||||||||
| @Service | ||||||||||||||
| @RequiredArgsConstructor | ||||||||||||||
| public class UserService { | ||||||||||||||
|
|
||||||||||||||
| private final UserRepository userRepository; | ||||||||||||||
|
|
||||||||||||||
| public List<User.Overview> getUsers(UserQueryForm form) { | ||||||||||||||
| return userRepository.getOverview(form); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| public User.Details getUser(int userPk) { | ||||||||||||||
| return userRepository.getDetails(userPk); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| public void addUser(UserForm form) { | ||||||||||||||
| userRepository.add(form); | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Return inserted PK from Other services return the generated PK ( - public void addUser(UserForm form) {
- userRepository.add(form);
- }
+ public int addUser(UserForm form) {
+ return userRepository.add(form);
+ }Additionally, consider marking write methods transactional (see next comment). 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| public void updateUser(UserForm form) { | ||||||||||||||
| userRepository.update(form); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| public void deleteUser(int userPk) { | ||||||||||||||
| userRepository.delete(userPk); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing license header (fails license-maven-plugin)
Add the standard project license header.
📝 Committable suggestion
🧰 Tools
🪛 GitHub Actions: analyze and review code
[warning] 1-1: Missing license header.
🤖 Prompt for AI Agents