Class PhotoController


  • @RestController
    @RequestMapping("/photos")
    @ExposesResourceFor(Photo.class)
    public class PhotoController
    extends Object
    This Class is a @RestController which handles the endpoints for communication between the client side to the serverside.
    • Constructor Detail

      • PhotoController

        @Autowired
        public PhotoController​(PhotoService photoService)
        This Constructor creates a PhotoService object.
        Parameters:
        photoService - is a PhotoService object.
    • Method Detail

      • post

        @PostMapping(consumes="application/json",
                     produces="application/json")
        public Photo post​(@RequestBody
                          Photo photo,
                          Event event)
        Creates a new Photo in the PicMe database with the Event associated.
        Parameters:
        photo - is a Photo object.
        event - is a Event object.
        Returns:
        A saved photo.
      • delete

        @DeleteMapping(value="/{id}",
                       consumes="application/json")
        public void delete​(@RequestBody
                           Photo photo,
                           long id)
        Deletes a photo associated with a specific primary key.
        Parameters:
        photo - is a Photo object.
        id - is a Photo objects primary key.
      • getAllPhotosByUser

        @GetMapping(value="/{user}",
                    produces="application/json")
        public List<Photo> getAllPhotosByUser​(@PathVariable
                                              User user)
        Gets the photos associated with a User.
        Parameters:
        user - is a User object.
        Returns:
        A Collection of photos associated with a user