Skip to content

Commit

Permalink
#29 [FEAT] : 전력량 데이터 반환 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
bbabbi committed Nov 9, 2024
1 parent 2f54abc commit 8541f63
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 27 deletions.
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 server/src/main/java/org/cecd/server/domain/EnergyUsage.java

This file was deleted.

18 changes: 18 additions & 0 deletions server/src/main/java/org/cecd/server/dto/EnergyUsageResponse.java
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;
}

0 comments on commit 8541f63

Please sign in to comment.