Class PhotoController
- java.lang.Object
-
- edu.cnm.deepdive.picmegallery.controller.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 Summary
Constructors Constructor Description PhotoController(PhotoService photoService)
This Constructor creates a PhotoService object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete(Photo photo, long id)
Deletes a photo associated with a specific primary key.List<Photo>
getAllPhotosByUser(User user)
Gets the photos associated with a User.Photo
post(Photo photo, Event event)
Creates a new Photo in the PicMe database with the Event associated.
-
-
-
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.
-
-