@Test void getUsersByFilterTest() throws Exception { int pageNumber = 1; int pageSize = 20; Pageable pageable = PageRequest.of(pageNumber, pageSize); String content = "{\n" + " \"searchReg\": \"string\"\n" + "}"; mockMvc.perform(post(userLink + "/filter?page=1") .contentType(MediaType.APPLICATION_JSON) .content(content)) .andExpect(status().isOk()); ObjectMapper mapper = new ObjectMapper(); FilterUserDto filterUserDto = mapper.readValue(content, FilterUserDto.class); verify(userService).getUsersByFilter(eq(filterUserDto), eq(pageable)); }
@ApiOperation(value = "Filter all user by search criteria") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = PageableDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @ApiPageable @PostMapping("filter") public ResponseEntity<PageableDto> getUsersByFilter( @ApiIgnore Pageable pageable, @RequestBody FilterUserDto filterUserDto) { return ResponseEntity.status(HttpStatus.OK).body(userService.getUsersByFilter(filterUserDto, pageable)); }
UserController { @ApiOperation(value = "Filter all user by search criteria") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = PageableDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @ApiPageable @PostMapping("filter") public ResponseEntity<PageableDto> getUsersByFilter( @ApiIgnore Pageable pageable, @RequestBody FilterUserDto filterUserDto) { return ResponseEntity.status(HttpStatus.OK).body(userService.getUsersByFilter(filterUserDto, pageable)); } }
UserController { @ApiOperation(value = "Filter all user by search criteria") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = PageableDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @ApiPageable @PostMapping("filter") public ResponseEntity<PageableDto> getUsersByFilter( @ApiIgnore Pageable pageable, @RequestBody FilterUserDto filterUserDto) { return ResponseEntity.status(HttpStatus.OK).body(userService.getUsersByFilter(filterUserDto, pageable)); }  }
UserController { @ApiOperation(value = "Filter all user by search criteria") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = PageableDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @ApiPageable @PostMapping("filter") public ResponseEntity<PageableDto> getUsersByFilter( @ApiIgnore Pageable pageable, @RequestBody FilterUserDto filterUserDto) { return ResponseEntity.status(HttpStatus.OK).body(userService.getUsersByFilter(filterUserDto, pageable)); }  @ApiOperation(value = "Update status of user") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = UserStatus.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping("status") ResponseEntity<UserStatusDto> updateStatus(
            @Valid @RequestBody UserStatusDto userStatusDto, @ApiIgnore Principal principal); @ApiOperation(value = "Update role of user") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = UserRoleDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping("role") ResponseEntity<UserRoleDto> updateRole(
            @Valid @RequestBody UserRoleDto userRoleDto, @ApiIgnore Principal principal); @ApiOperation(value = "Get users by page") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = PageableDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @ApiPageable @GetMapping("all") ResponseEntity<PageableDto> getAllUsers(@ApiIgnore Pageable pageable); @ApiOperation(value = "Get all available roles") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = RoleDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("roles") ResponseEntity<RoleDto> getRoles(); @ApiOperation(value = "Get all available email notifications statuses") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = EmailNotification[].class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST) }) @GetMapping("emailNotifications") ResponseEntity<List<EmailNotification>> getEmailNotifications(); @ApiOperation(value = "Filter all user by search criteria") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = PageableDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @ApiPageable @PostMapping("filter") ResponseEntity<PageableDto> getUsersByFilter(
            @ApiIgnore Pageable pageable, @RequestBody FilterUserDto filterUserDto); @ApiOperation(value = "Get User dto by principal (email) from access token") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = UserUpdateDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping ResponseEntity<UserUpdateDto> getUserByPrincipal(@ApiIgnore @AuthenticationPrincipal Principal principal); @ApiOperation(value = "Update User") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping ResponseEntity updateUser(@Valid @RequestBody UserUpdateDto dto,
                                     @ApiIgnore @AuthenticationPrincipal Principal principal); @GetMapping("/{userId}/habits") ResponseEntity<List<HabitDto>> getUserHabits(@PathVariable @CurrentUserId Long userId,
                                                        @ApiParam(value = "Code of the needed language.")
                                                        @RequestParam String language); @ApiOperation(value = "Find statistic about user habits.") @GetMapping("/{userId}/habits/statistic") ResponseEntity<CalendarUsefulHabitsDto> findInfoAboutUserHabits(@PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Get goals of current user.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("/{userId}/goals") ResponseEntity<List<UserGoalResponseDto>> getUserGoals(
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId,
            @ApiParam(value = "Code of the needed language.", defaultValue = AppConstant.DEFAULT_LANGUAGE_CODE)
            @RequestParam(required = false, defaultValue = AppConstant.DEFAULT_LANGUAGE_CODE) String language); @ApiOperation(value = "Get all user custom goals.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/{userId}/customGoals") ResponseEntity<List<CustomGoalResponseDto>> findAllByUser(@PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Save one or multiple custom goals for current user.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @PostMapping("/{userId}/customGoals") ResponseEntity<List<CustomGoalResponseDto>> saveUserCustomGoals(
            @Valid @RequestBody BulkSaveCustomGoalDto dto,
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Update user custom goals") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = UserRoleDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping("/{userId}/customGoals") ResponseEntity<List<CustomGoalResponseDto>> updateBulk(@PathVariable @CurrentUserId Long userId,
                                                                  @Valid @RequestBody BulkCustomGoalDto dto); @ApiOperation(value = "Delete user custom goals") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = Long.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @DeleteMapping("/{userId}/customGoals") ResponseEntity<List<Long>> bulkDeleteCustomGoals(
            @ApiParam(value = "Ids of custom goals separated by a comma \n e.g. 1,2", required = true)
            @RequestParam String ids,
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Get available goals for current user.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("/{userId}/goals/available") ResponseEntity<List<GoalDto>> getAvailableGoals(
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId,
            @ApiParam(value = "Code of the needed language.", defaultValue = AppConstant.DEFAULT_LANGUAGE_CODE)
            @RequestParam(required = false, defaultValue = AppConstant.DEFAULT_LANGUAGE_CODE) String language); @ApiOperation(value = "Get available custom goals for current user.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("/{userId}/customGoals/available") ResponseEntity<List<CustomGoalResponseDto>> getAvailableCustomGoals(
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Change status of one of the goals for current user to DONE.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @PatchMapping("/{userId}/goals/{goalId}") ResponseEntity<UserGoalResponseDto> updateUserGoalStatus(
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId,
            @ApiParam("Id of the UserGoal that belongs to current user. Cannot be empty.")
            @PathVariable Long goalId,
            @ApiParam(value = "Code of the needed language.", defaultValue = AppConstant.DEFAULT_LANGUAGE_CODE)
            @RequestParam(required = false, defaultValue = AppConstant.DEFAULT_LANGUAGE_CODE) String language); @ApiOperation(value = "Save one or multiple goals for current user.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @PostMapping("/{userId}/goals") ResponseEntity<List<UserGoalResponseDto>> saveUserGoals(
            @Valid @RequestBody BulkSaveUserGoalDto dto,
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId,
            @ApiParam(value = "Code of the needed language.", defaultValue = AppConstant.DEFAULT_LANGUAGE_CODE)
            @RequestParam(required = false, defaultValue = AppConstant.DEFAULT_LANGUAGE_CODE) String language); @ApiOperation(value = "Get available habit dictionary for current user.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("/{userId}/habit-dictionary/available") ResponseEntity<List<HabitDictionaryDto>> getAvailableHabitDictionary(
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId,
            @ApiParam(value = "Code of the needed language.")
            @RequestParam @ValidLanguage String language); @ApiOperation(value = "Save one or multiple habits for current user.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @PostMapping("/{userId}/habit") ResponseEntity<List<HabitCreateDto>> saveUserHabits(
            @Valid @RequestBody List<HabitIdDto> dto,
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId,
            @ApiParam(value = "Code of the needed language.")
            @RequestParam @ValidLanguage String language); @ApiOperation(value = "Delete habit") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @DeleteMapping("/{userId}/habit/{habitId}") void deleteHabit(
            @ApiParam("Id habit of current user. Cannot be empty.")
            @PathVariable Long habitId,
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Delete user goal") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = Long.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @DeleteMapping("/{userId}/userGoals") ResponseEntity<List<Long>> bulkDeleteUserGoals(
            @ApiParam(value = "Ids of user goals separated by a comma \n e.g. 1,2", required = true)
            @Pattern(regexp = "^\\d+(,\\d+)*$", message = ValidationConstants.BAD_COMMA_SEPARATED_NUMBERS)
            @RequestParam String ids,
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Get all activated users amount") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = Long.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/activatedUsersAmount") ResponseEntity<Long> getActivatedUsersAmount(); @ApiOperation(value = "Update user profile picture") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping(path = "/profilePicture", consumes = {MediaType.APPLICATION_JSON_UTF8_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) ResponseEntity<HttpStatus> updateUserProfilePicture(@ApiParam(value = "Profile picture")
                                                               @ImageValidation
                                                               @RequestPart(required = false) MultipartFile image,
                                                               @ApiIgnore
                                                               @AuthenticationPrincipal Principal principal); @ApiOperation(value = "Delete user friend") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @DeleteMapping("/{userId}/userFriend/{friendId}") ResponseEntity<Object> deleteUserFriend(
            @ApiParam("Id friend of current user. Cannot be empty.")
            @PathVariable Long friendId,
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Add new user friend") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @PostMapping("/{userId}/userFriend/{friendId}") ResponseEntity<Object> addNewFriend(
            @ApiParam("Id friend of current user. Cannot be empty.")
            @PathVariable Long friendId,
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Get six friends profile picture with the highest rating") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("/{userId}/sixUserFriends/") ResponseEntity<List<UserProfilePictureDto>> getSixFriendsWithTheHighestRating(
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Save user profile information") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED, response = UserProfileDtoResponse.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @PutMapping(path = "/profile", consumes = {MediaType.APPLICATION_JSON_UTF8_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) ResponseEntity<UserProfileDtoResponse> save(
            @ApiParam(value = "User Profile Request", required = true)
            @RequestPart UserProfileDtoRequest userProfileDtoRequest,
            @ApiParam(value = "User Profile Image")
            @ImageValidation
            @RequestPart(required = false) MultipartFile image,
            @ApiIgnore Principal principal); @ApiOperation(value = "Get user profile information by id") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("/{userId}/profile/") ResponseEntity<UserProfileDtoResponse> getUserProfileInformation(
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Check by id if the user is online") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("isOnline/{userId}/") ResponseEntity<Boolean> checkIfTheUserIsOnline(
            @ApiParam("Id of the user. Cannot be empty.")
            @PathVariable Long userId); @ApiOperation(value = "Get user profile statistics by id") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("/{userId}/profileStatistics/") ResponseEntity<UserProfileStatisticsDto> getUserProfileStatistics(
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId); @MessageMapping("/userAndSixFriendsWithOnlineStatus") @SendTo("/topic/sixUsersOnlineStatus") UserAndFriendsWithOnlineStatusDto getUserAndSixFriendsWithOnlineStatus(
            Long userId); @MessageMapping("/userAndAllFriendsWithOnlineStatus") @SendTo("/topic/userAndAllFriendsOnlineStatus") UserAndAllFriendsWithOnlineStatusDto getUserAndAllFriendsWithOnlineStatus(
            Long userId, Pageable pageable); }
UserController { @ApiOperation(value = "Filter all user by search criteria") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = PageableDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @ApiPageable @PostMapping("filter") public ResponseEntity<PageableDto> getUsersByFilter( @ApiIgnore Pageable pageable, @RequestBody FilterUserDto filterUserDto) { return ResponseEntity.status(HttpStatus.OK).body(userService.getUsersByFilter(filterUserDto, pageable)); }  @ApiOperation(value = "Update status of user") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = UserStatus.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping("status") ResponseEntity<UserStatusDto> updateStatus(
            @Valid @RequestBody UserStatusDto userStatusDto, @ApiIgnore Principal principal); @ApiOperation(value = "Update role of user") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = UserRoleDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping("role") ResponseEntity<UserRoleDto> updateRole(
            @Valid @RequestBody UserRoleDto userRoleDto, @ApiIgnore Principal principal); @ApiOperation(value = "Get users by page") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = PageableDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @ApiPageable @GetMapping("all") ResponseEntity<PageableDto> getAllUsers(@ApiIgnore Pageable pageable); @ApiOperation(value = "Get all available roles") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = RoleDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("roles") ResponseEntity<RoleDto> getRoles(); @ApiOperation(value = "Get all available email notifications statuses") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = EmailNotification[].class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST) }) @GetMapping("emailNotifications") ResponseEntity<List<EmailNotification>> getEmailNotifications(); @ApiOperation(value = "Filter all user by search criteria") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = PageableDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @ApiPageable @PostMapping("filter") ResponseEntity<PageableDto> getUsersByFilter(
            @ApiIgnore Pageable pageable, @RequestBody FilterUserDto filterUserDto); @ApiOperation(value = "Get User dto by principal (email) from access token") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = UserUpdateDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping ResponseEntity<UserUpdateDto> getUserByPrincipal(@ApiIgnore @AuthenticationPrincipal Principal principal); @ApiOperation(value = "Update User") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping ResponseEntity updateUser(@Valid @RequestBody UserUpdateDto dto,
                                     @ApiIgnore @AuthenticationPrincipal Principal principal); @GetMapping("/{userId}/habits") ResponseEntity<List<HabitDto>> getUserHabits(@PathVariable @CurrentUserId Long userId,
                                                        @ApiParam(value = "Code of the needed language.")
                                                        @RequestParam String language); @ApiOperation(value = "Find statistic about user habits.") @GetMapping("/{userId}/habits/statistic") ResponseEntity<CalendarUsefulHabitsDto> findInfoAboutUserHabits(@PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Get goals of current user.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("/{userId}/goals") ResponseEntity<List<UserGoalResponseDto>> getUserGoals(
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId,
            @ApiParam(value = "Code of the needed language.", defaultValue = AppConstant.DEFAULT_LANGUAGE_CODE)
            @RequestParam(required = false, defaultValue = AppConstant.DEFAULT_LANGUAGE_CODE) String language); @ApiOperation(value = "Get all user custom goals.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/{userId}/customGoals") ResponseEntity<List<CustomGoalResponseDto>> findAllByUser(@PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Save one or multiple custom goals for current user.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @PostMapping("/{userId}/customGoals") ResponseEntity<List<CustomGoalResponseDto>> saveUserCustomGoals(
            @Valid @RequestBody BulkSaveCustomGoalDto dto,
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Update user custom goals") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = UserRoleDto.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping("/{userId}/customGoals") ResponseEntity<List<CustomGoalResponseDto>> updateBulk(@PathVariable @CurrentUserId Long userId,
                                                                  @Valid @RequestBody BulkCustomGoalDto dto); @ApiOperation(value = "Delete user custom goals") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = Long.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @DeleteMapping("/{userId}/customGoals") ResponseEntity<List<Long>> bulkDeleteCustomGoals(
            @ApiParam(value = "Ids of custom goals separated by a comma \n e.g. 1,2", required = true)
            @RequestParam String ids,
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Get available goals for current user.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("/{userId}/goals/available") ResponseEntity<List<GoalDto>> getAvailableGoals(
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId,
            @ApiParam(value = "Code of the needed language.", defaultValue = AppConstant.DEFAULT_LANGUAGE_CODE)
            @RequestParam(required = false, defaultValue = AppConstant.DEFAULT_LANGUAGE_CODE) String language); @ApiOperation(value = "Get available custom goals for current user.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("/{userId}/customGoals/available") ResponseEntity<List<CustomGoalResponseDto>> getAvailableCustomGoals(
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Change status of one of the goals for current user to DONE.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @PatchMapping("/{userId}/goals/{goalId}") ResponseEntity<UserGoalResponseDto> updateUserGoalStatus(
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId,
            @ApiParam("Id of the UserGoal that belongs to current user. Cannot be empty.")
            @PathVariable Long goalId,
            @ApiParam(value = "Code of the needed language.", defaultValue = AppConstant.DEFAULT_LANGUAGE_CODE)
            @RequestParam(required = false, defaultValue = AppConstant.DEFAULT_LANGUAGE_CODE) String language); @ApiOperation(value = "Save one or multiple goals for current user.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @PostMapping("/{userId}/goals") ResponseEntity<List<UserGoalResponseDto>> saveUserGoals(
            @Valid @RequestBody BulkSaveUserGoalDto dto,
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId,
            @ApiParam(value = "Code of the needed language.", defaultValue = AppConstant.DEFAULT_LANGUAGE_CODE)
            @RequestParam(required = false, defaultValue = AppConstant.DEFAULT_LANGUAGE_CODE) String language); @ApiOperation(value = "Get available habit dictionary for current user.") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("/{userId}/habit-dictionary/available") ResponseEntity<List<HabitDictionaryDto>> getAvailableHabitDictionary(
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId,
            @ApiParam(value = "Code of the needed language.")
            @RequestParam @ValidLanguage String language); @ApiOperation(value = "Save one or multiple habits for current user.") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @PostMapping("/{userId}/habit") ResponseEntity<List<HabitCreateDto>> saveUserHabits(
            @Valid @RequestBody List<HabitIdDto> dto,
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId,
            @ApiParam(value = "Code of the needed language.")
            @RequestParam @ValidLanguage String language); @ApiOperation(value = "Delete habit") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @DeleteMapping("/{userId}/habit/{habitId}") void deleteHabit(
            @ApiParam("Id habit of current user. Cannot be empty.")
            @PathVariable Long habitId,
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Delete user goal") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = Long.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @DeleteMapping("/{userId}/userGoals") ResponseEntity<List<Long>> bulkDeleteUserGoals(
            @ApiParam(value = "Ids of user goals separated by a comma \n e.g. 1,2", required = true)
            @Pattern(regexp = "^\\d+(,\\d+)*$", message = ValidationConstants.BAD_COMMA_SEPARATED_NUMBERS)
            @RequestParam String ids,
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Get all activated users amount") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK, response = Long.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @GetMapping("/activatedUsersAmount") ResponseEntity<Long> getActivatedUsersAmount(); @ApiOperation(value = "Update user profile picture") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @PatchMapping(path = "/profilePicture", consumes = {MediaType.APPLICATION_JSON_UTF8_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) ResponseEntity<HttpStatus> updateUserProfilePicture(@ApiParam(value = "Profile picture")
                                                               @ImageValidation
                                                               @RequestPart(required = false) MultipartFile image,
                                                               @ApiIgnore
                                                               @AuthenticationPrincipal Principal principal); @ApiOperation(value = "Delete user friend") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @DeleteMapping("/{userId}/userFriend/{friendId}") ResponseEntity<Object> deleteUserFriend(
            @ApiParam("Id friend of current user. Cannot be empty.")
            @PathVariable Long friendId,
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Add new user friend") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @PostMapping("/{userId}/userFriend/{friendId}") ResponseEntity<Object> addNewFriend(
            @ApiParam("Id friend of current user. Cannot be empty.")
            @PathVariable Long friendId,
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Get six friends profile picture with the highest rating") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("/{userId}/sixUserFriends/") ResponseEntity<List<UserProfilePictureDto>> getSixFriendsWithTheHighestRating(
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Save user profile information") @ApiResponses(value = { @ApiResponse(code = 201, message = HttpStatuses.CREATED, response = UserProfileDtoResponse.class), @ApiResponse(code = 303, message = HttpStatuses.SEE_OTHER), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN), }) @PutMapping(path = "/profile", consumes = {MediaType.APPLICATION_JSON_UTF8_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) ResponseEntity<UserProfileDtoResponse> save(
            @ApiParam(value = "User Profile Request", required = true)
            @RequestPart UserProfileDtoRequest userProfileDtoRequest,
            @ApiParam(value = "User Profile Image")
            @ImageValidation
            @RequestPart(required = false) MultipartFile image,
            @ApiIgnore Principal principal); @ApiOperation(value = "Get user profile information by id") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("/{userId}/profile/") ResponseEntity<UserProfileDtoResponse> getUserProfileInformation(
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId); @ApiOperation(value = "Check by id if the user is online") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("isOnline/{userId}/") ResponseEntity<Boolean> checkIfTheUserIsOnline(
            @ApiParam("Id of the user. Cannot be empty.")
            @PathVariable Long userId); @ApiOperation(value = "Get user profile statistics by id") @ApiResponses(value = { @ApiResponse(code = 200, message = HttpStatuses.OK), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST), @ApiResponse(code = 403, message = HttpStatuses.FORBIDDEN) }) @GetMapping("/{userId}/profileStatistics/") ResponseEntity<UserProfileStatisticsDto> getUserProfileStatistics(
            @ApiParam("Id of current user. Cannot be empty.")
            @PathVariable @CurrentUserId Long userId); @MessageMapping("/userAndSixFriendsWithOnlineStatus") @SendTo("/topic/sixUsersOnlineStatus") UserAndFriendsWithOnlineStatusDto getUserAndSixFriendsWithOnlineStatus(
            Long userId); @MessageMapping("/userAndAllFriendsWithOnlineStatus") @SendTo("/topic/userAndAllFriendsOnlineStatus") UserAndAllFriendsWithOnlineStatusDto getUserAndAllFriendsWithOnlineStatus(
            Long userId, Pageable pageable);  }