Class ProfileController
- java.lang.Object
-
- edu.cnm.deepdive.albuquirky.controller.ProfileController
-
@RestController @RequestMapping("/profiles") @ExposesResourceFor(Profile.class) public class ProfileController extends ObjectThe ProfileController class is the @RestController that maps the endpoints of "/profiles" for communication between the server-side and client-side forProfile
-
-
Constructor Summary
Constructors Constructor Description ProfileController(ProfileService profileService)Constructs the instance of ProfileService object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetAddress(org.springframework.security.core.Authentication auth)The Get method which returns the profile address.org.springframework.http.ResponseEntity<org.springframework.core.io.Resource>getImage(org.springframework.security.core.Authentication auth)The Get method which returns the profile image.ProfilegetOrder(Long userId, org.springframework.security.core.Authentication auth)The Get method which returns theProfilematching the ID provided.StringgetUsername(org.springframework.security.core.Authentication auth)The Get method which returns the username for the current user.Profileme(org.springframework.security.core.Authentication auth)The Get method which returns the current authenticated profile.StringupdateAddress(String address, org.springframework.security.core.Authentication auth)The Put method which lets the current user update their address.StringupdateUsername(String name, org.springframework.security.core.Authentication auth)The Put method which allows the profile to update their usernameProfileuploadImage(org.springframework.web.multipart.MultipartFile file, org.springframework.security.core.Authentication auth)The Put method which updates the current user's profile image.
-
-
-
Constructor Detail
-
ProfileController
public ProfileController(ProfileService profileService)
Constructs the instance of ProfileService object.- Parameters:
profileService- TheProfileServiceto be created.
-
-
Method Detail
-
me
@GetMapping(value="/me", produces="application/json") public Profile me(org.springframework.security.core.Authentication auth)The Get method which returns the current authenticated profile.- Parameters:
auth- The user authentication.
-
getOrder
@GetMapping(value="/{userId:\\d+}", produces="application/json") public Profile getOrder(@PathVariable Long userId, org.springframework.security.core.Authentication auth)The Get method which returns theProfilematching the ID provided.
-
getUsername
@GetMapping(value="/me/username", produces="application/json") public String getUsername(org.springframework.security.core.Authentication auth)The Get method which returns the username for the current user.- Parameters:
auth- The user authentication.- Returns:
- The current user's username.
-
updateUsername
@PutMapping(value="/me/username", consumes="application/json", produces="application/json") public String updateUsername(@RequestBody String name, org.springframework.security.core.Authentication auth)The Put method which allows the profile to update their username- Parameters:
name- The new username.auth- The user authentication.- Returns:
- The updated username.
-
getImage
@GetMapping("/me/image") public org.springframework.http.ResponseEntity<org.springframework.core.io.Resource> getImage(org.springframework.security.core.Authentication auth) throws IOExceptionThe Get method which returns the profile image.- Parameters:
auth- The user authentication.- Returns:
- The user's current profile image.
- Throws:
IOException
-
uploadImage
@PutMapping(value="/me/image", produces="application/json") public Profile uploadImage(@RequestBody org.springframework.web.multipart.MultipartFile file, org.springframework.security.core.Authentication auth) throws IOExceptionThe Put method which updates the current user's profile image.- Parameters:
file- The path to the new image.auth- The user authentication.- Returns:
- The updated profile image.
- Throws:
IOException- If the file cannot be accessed from the reference provided.
-
getAddress
@GetMapping(value="/me/address", produces="application/json") public String getAddress(org.springframework.security.core.Authentication auth)The Get method which returns the profile address.- Parameters:
auth- The user authentication.- Returns:
- The user's current address.
-
updateAddress
@PutMapping(value="/me/address", consumes="application/json", produces="application/json") public String updateAddress(@RequestBody String address, org.springframework.security.core.Authentication auth)The Put method which lets the current user update their address.- Parameters:
address- The new user address.auth- The user authentication.- Returns:
- The updated user address.
-
-