This repository uses Java, SpringBoot with DynamoDB You can user swagger to test the REST APIS as well as can run unit/integration test.
Swagger Link: localhost:8082/swagger-ui.html
-
Run
mvn verify
-
Test can be run with a local in-memory DynamoDB
-
To use a DynamoDb is necessary to update the aws properties in the file
src/main/resources/applications.properties
server.port=8082
and fix as per your requirements in com.example.zorodemo.zorodemo.config.DynamoDbConf.java :
private static final String DYNAMODB_URL = "http://localhost:*YOUR PORT*";
private static final String SIGNINGREGION = *REGION*;
private static final String ACCESSKEY =*ACACCESSKEY*;
private static final String SECRETKEY = *SECRETKEY*;
-
Rest endpoints
- POST: http://localhost:8082/pirate/: Add a new pirate
Sample JSON for this request:{ "crewid": "1", "firstname": "Roronoa", "lastname": "Zoro", "weaponType": "Katana", "specialAttack": "Santoryu", "devilFruit": "False", "devilFruitName": "N/A", "damage": { "damageid": 1, "moveName": "Onigiri", "crewid": "1", "damagePerMove": 123566 } }
- GET: http://localhost:8082/pirate/{id}: Get a pirate by id
- DELETE: http://localhost:8082/pirate/{id}: Delete pirate by id
- PUT: http://localhost:8082/pirate/{id}: Update pirate by id
- GET: http://localhost:8082/pirate/damage/{id}/{count}: Get pirate's top {count}s damage information by the pirate's {id}
To be updated
- GET: http://localhost:8082/damage/{id}: Get damage by id
- POST: http://localhost:8082/move/: Add a new move
Sample JSON for this request:{ "damageid": 1, "moveName": "Onigiri", "crewid": "1", "damagePerMove": 123566 }
- DELETE: http://localhost:8082/damage/{id}: Delete move by id
- PUT: http://localhost:8082/damage/{id}: Update move by id
- GET: http://localhost:8082/damage/{count}: Get top moves information of the respective pirates.
to be updated
- POST: http://localhost:8082/pirate/: Add a new pirate
In this repository to use DynamoDb in Java, it is necessary to add some dependencies, create a DynamoDB Configuration class, and use annotations in the entity classes
com.amazonaws::aws-java-sdk-dynamodb
spring-data-dynamodb
com.amazonaws::DynamoDBLocal
A bean with the name amazonDynamoDB
is required, this bean manages the connection with the DynamoDB instance.
@Bean(name= "dynamoDB")
public DynamoDBMapper dynamoDBMapper() {
return new DynamoDBMapper(buildAmazonDynamoDB());
}
The class is annotated to define it as a DynamoDB table
@DynamoDBTable(tableName = "strawhats")
public class Pirates {
Then, a key
@DynamoDBHashKey
@DynamoDBAutoGeneratedKey
private String crewid
And finally, each attribute
@DynamoDBAttribute(attributeName = "firstname")
private String firstname
The class is annotated to define it as a DynamoDB table
@DynamoDBTable(tableName = "damage")
public class Damage {
Then, a key
@DynamoDBHashKey
@DynamoDBAutoGeneratedKey
private String moveid
And finally, each attribute
@DynamoDBAttribute(attributeName = "movename")
private String movename