-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
43 additions
and
27 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
server/src/main/java/org/cecd/server/controller/EnergyDataController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.cecd.server.controller; | ||
|
||
import org.cecd.server.dto.EnergyUsageResponse; | ||
import org.cecd.server.service.EnergyDataService; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/energy-usage") | ||
public class EnergyDataController { | ||
|
||
private final EnergyDataService energyDataService; | ||
|
||
public EnergyDataController(EnergyDataService energyDataService) { | ||
this.energyDataService = energyDataService; | ||
} | ||
|
||
@GetMapping | ||
public List<EnergyUsageResponse> getEnergyUsage() { | ||
return energyDataService.getAllEnergyUsages(); | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
server/src/main/java/org/cecd/server/domain/EnergyUsage.java
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
server/src/main/java/org/cecd/server/dto/EnergyUsageResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.cecd.server.dto; | ||
|
||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
public class EnergyUsageResponse { | ||
private String sensorNumber; | ||
private LocalDateTime dateTime; | ||
private double result; | ||
private double percentage; | ||
} |