Coder Social home page Coder Social logo

gojohnny-rest-api's People

Contributors

fedosovmax avatar luckyloker avatar omgkanamikun avatar podolian avatar remezenkos avatar shryhus avatar shtramak avatar svlugovoy avatar tboychuk avatar yura-jt avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gojohnny-rest-api's Issues

Fix flyway scripts naming

Current naming convention for SQL migration scripts is potentially dangerous. Flyway checks the latest version in the flyway_schema_version and applies all migrations with larger versions. It means that if two developers started working on tickets #14 and #18 at the same time, and ticket #18 was released before the other one, then migration of ticket #14 will be ignored which is incorrect.

Starting from now use the following simple naming convention: Vx.y__Description, every time you submit new migration, you should use the latest value of x, and y will be used for major db changes.

Suppose current database version is 1.8, and you need to create a migration to add new column photoUrl to Place. Your migration name should be V1.9__Add_photo_url_to_place.

  • replace all current SQL migrations with a single file
  • start using new convention starting from version 1.0
  • update README file
  • notify team to recreate local databases

Configure new "testing" profile

Create and configure new profile testing that will be used to run Spring tests.

For this profile:

  • configure in memory H2 datasource
  • enable schema generation

Create integration test for Place endpoints

Create SpringBoot integration test that will call a REST API endpoints and verify results.
Test at least the following scenarios:

  • saving new place
  • getting place by id
  • searching place by name
  • searching place in bounds

Use Spring testing profile.

Add Place type

Add new field type to class Place.

  • create enum PlaceType with values PEAK, CAMP, SOURCE, and UNKNOWN - default
  • create mandatory field with corresponding JPA mapping
  • create migration script

Implement endpoint to search place by name

REST API should provide a GET endpoint by url ../places/search/name that receives one string parameter called query and returns a list of places found by query. Query represents a piece of name.

Use Rest Repository to implement that endpoint. E.g. your PlaceRepository should have one more custom method that is implemented using @Query and JPQL.

Investigate Open Streep Map API

Investigate OSM API and create a working example.

We are going to build our own database of places and other spatial data. Most of the content that we are going to store will be produces by users of our system, hence will be unique. However, information like place name, altitude or location is not unique. It means that we should found some open API that allows to get required geographical data. The larges open resource is Open Street Map (OSM). Mapbox is also using OSM.

At some point, we are going to use OSM API and copy some data into our own database. Therefore, we need to know the API, and the format of the data.

Focus on places only. You should be able to answer questions like how to load places by name, by type or by location.

Create endpoint GET ../places/osm, that takes five parameters:

  • mitLat
  • maxLat
  • minLng
  • maxLng
  • type - optional

it should use provided parameters, load data from OSM and return the response.

Extend Place entity with photo URL

In class Place create new String field named photoUrl. This field should be optional. All database schema changes should done using migration scripts.

Add place description

  • add new String description field to class Place.
  • configure JPA mapping, make field optional
  • implement db migration script, see ticket #5

Configure proper text encoding

Configure proper encoding so we can store and retrieve Ukrainian words.

Cover this case with a proper integration test. E.g. store new place with a Ukrainian name, and then retrieve it from the database using REST API.

Create new PhotoComment entity

Create new entity PhotoComment that will represent comments added to Photo. Add the following mandatory fields:

  • id - auto generated
  • text
  • creationTime
  • photo - a reference to a Photo
  • author - reference to User, which added a comment

Create corresponding JPA repository and the migration script.

Create integration test for User

Create a Spring Boot integration test that will verify CRUD endpoints for User entity.
You should use testing profile for that.

Wrong mapping on Place entity

Place entity contain wrong mapping on place type.

It is @Column(nullable = false, columnDefinition = "UNKNOWN")

but should be

@Column(nullable = false, columnDefinition = "VARCHAR (255) DEFAULT UNKNOWN")

Place entity does not correspond to migration script

JPA entity Place has different constraint that database table.

See class Place and migration script V5_2_2018.10.06__Create_table_place.sql.

Update entity and create new migration script to fix database table. Place requirements that should be updated:

  • location is mandatory
  • altitude is NOT mandatory

Create User entity

Create new User entity with the following fields mandatory fields:

  • id - autogenerated using db sequence
  • firstName
  • lastName
  • email
  • password
  • creationTime

Add corresponding JPA repository and migration script.

Extend Place with OSM id

Since we are going to implement integration with OSM, it's better to have store OSM id for each place.

  • create new field osm_id
  • implement migration script

Create registration form

Create a registration form that allows to create a new user account. From should consists of four required fields:

  • first name
  • last name
  • email
  • password

Implement integration with OSM for getting place data

Check out how to use OSM API. See ticket #31.

Create new endpoint POST ../places/osm that takes five parameters:

  • mitLat
  • maxLat
  • minLng
  • maxLng
  • type - optional

Implement corresponding service logic. It should call OSM API and using the following parameters load places. All new places should be stored in our database according to our own format.

Create new Photo entity

Create new Photo entity with the following mandatory fields:

  • id - auto generated
  • url - a valid URL where photo is located
  • creationTime
  • author - a reference to User that posted a photo

Add corresponding JPA repository and the migration script.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.