Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crud operations #4

Merged
merged 5 commits into from
Dec 30, 2019
Merged

crud operations #4

merged 5 commits into from
Dec 30, 2019

Conversation

abwizeline
Copy link
Owner

Added CRUD operations:

  1. Add new TaxiModel
  2. Updated existing TaxiModel by id
  3. List All Paged
  4. Delete by ID
  5. Search by TaxiID Paged

Moved all operations to separate Service

public interface TaxiTripsRepository extends JpaRepository<TaxiTripsModel, Long> {
@Query(value = "select tableData from TaxiTripsModel tableData where tableData.taxiID = :taxiID",
countQuery = "select count(tableData) from TaxiTripsModel tableData where tableData.taxiID = :taxiID")
Page<TaxiTripsModel> searchByTaxiID(@Param("taxiID") Long taxiID, Pageable pageable);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vanduc1102 I already have findById , i think it's similar to getOne ? Just i receiving Optional instead of null if row not found
This method just searching by other field, not included to JPA Repo

@Autowired
private TaxiTripsService mTaxiTripsService;

@GetMapping(value = "all")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont need to add all or delete
in REST we have a convention to use HTTP verb
eg:
GET / to findAll
GET /{id} getOne
POST / to create an object
PUT / to update an object
DELETE /{id} to detele an object

please go through the article here : https://hackernoon.com/restful-api-designing-guidelines-the-best-practices-60e1d954e7c9

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please push your changes :)


@RestController
@RequestMapping("/v1/taxitrips")
public class CrudAPIController {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be TaxiTripController

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -3,13 +3,11 @@
import com.apac.test.apactakehometest.async.AsyncService;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should move the implementation here into TaxiTripController
under a path

POST /import-csv

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

@vanduc1102 vanduc1102 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update code to compliant with REST guide line
and fineOne method,

@@ -0,0 +1,68 @@
package com.apac.test.apactakehometest.controller;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please prefix commit message with issue number #1
#2

Copy link
Collaborator

@vanduc1102 vanduc1102 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 💣 💥 🚀

@abwizeline abwizeline merged commit 2b5017a into master Dec 30, 2019
@abwizeline abwizeline deleted the feature/CRUD branch December 30, 2019 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants