DartExplore / dallas-by-metro-backend

backend services for Dallas by Metro
https://dallasbymetro.com
MIT License
0 stars 0 forks source link

Creation of empty stations. #153

Closed Nightwing52 closed 1 year ago

Nightwing52 commented 1 year ago

When preparing the entity for the PointOfInterest we are creating stations. Instead, in the service layer in addPointOfInterest, we should be checking the station id is in the database, and if so, setting the PointOfInterest Station to it. When checking the station id is in the database throw the appropriate exception if needed.

image

ZaneBartlett1 commented 1 year ago

So for creating stations it makes sense that we would want to have it so that you must provide an ID to a valid station. For PUT statements though it doesn't unless you're updating the station it's attached to. Since we have the @NotNull on the DTO it means that when we update a POI we have to provide the station, same thing for delete, which you mention on Signal.

https://github.com/DartExplore/dallas-by-metro-backend/blob/38d20efa790dd7e3fb3d17aa160cbf071e460b02/src/main/java/com/dart/explore/dto/PointOfInterestDTO.java#L14-L22

Why is your preference this as opposed to doing this check in the service layer or making more DTOs? Personally, I think handling the checks in the service layer makes the most sense to me.

ZaneBartlett1 commented 1 year ago

Also just as a note here as well since I forgot. The other thing we could do is just choose not to validate certain routes, but I don't really care for that option either.