-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [FEAT] 센서 데이터 api 구현 * FEAT : 다이나모 기본 설정 * FEAT : gitignore 추가 * FEAT : 센서 데이터 api * FEAT : build.gradle 수정 * Feat/#9 혼잡도 조회 * FEAT : 다이나모 기본 설정 * FEAT : gitignore 추가 * FEAT : 센서 데이터 api * FEAT : build.gradle 수정 * FEAT : 혼잡도 조회 구현 * FIX : 혼잡도 조회 수정 * FIX : 예상 대기 시간 수정
- Loading branch information
1 parent
c018a0e
commit 0a59576
Showing
8 changed files
with
170 additions
and
20 deletions.
There are no files selected for viewing
Submodule config
updated
from 512b98 to 6ab88b
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
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
29 changes: 29 additions & 0 deletions
29
src/main/java/com/cloudcomputing/ohhanahana/entity/SensorData.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,29 @@ | ||
package com.cloudcomputing.ohhanahana.entity; | ||
|
||
|
||
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute; | ||
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey; | ||
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBRangeKey; | ||
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable; | ||
import com.amazonaws.services.dynamodbv2.model.AttributeValue; | ||
import java.util.Map; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@DynamoDBTable(tableName = "inha-team-project-03-dynamodb") | ||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class SensorData { | ||
@DynamoDBHashKey(attributeName = "DeviceID") | ||
private String deviceId; | ||
|
||
@DynamoDBRangeKey(attributeName = "Timestamp") | ||
private Long timestamp; | ||
|
||
@DynamoDBAttribute(attributeName = "payload") | ||
private Map<String, AttributeValue> payload; | ||
} |
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
28 changes: 26 additions & 2 deletions
28
src/main/java/com/cloudcomputing/ohhanahana/repository/SensorDataRepository.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 |
---|---|---|
@@ -1,13 +1,37 @@ | ||
package com.cloudcomputing.ohhanahana.repository; | ||
|
||
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper; | ||
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression; | ||
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression; | ||
import com.cloudcomputing.ohhanahana.dto.response.SensorDataResponse; | ||
import com.cloudcomputing.ohhanahana.entity.SensorData; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class SensorDataRepository { | ||
|
||
public void findLatest() { | ||
//TODO - 다이나모 디비에서 최신값 불러오기 | ||
private final DynamoDBMapper dynamoDBMapper; | ||
|
||
public List<SensorData> findAll() { | ||
return dynamoDBMapper.scan(SensorData.class, new DynamoDBScanExpression()); | ||
} | ||
|
||
public SensorData findLatestByDeviceId(String deviceId) { | ||
DynamoDBQueryExpression<SensorData> queryExpression = new DynamoDBQueryExpression<SensorData>() | ||
.withHashKeyValues(SensorData.builder().deviceId(deviceId).build()) | ||
.withScanIndexForward(true) //오름차순 | ||
.withLimit(50); //가장 최신값 하나만 가져오기 | ||
|
||
List<SensorData> result = dynamoDBMapper.query(SensorData.class, queryExpression); | ||
|
||
if(result.isEmpty()) { | ||
return null; | ||
} | ||
else { | ||
return result.get(0); | ||
} | ||
} | ||
} |
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
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