diff --git a/pom.xml b/pom.xml index b925015..c49ea5c 100644 --- a/pom.xml +++ b/pom.xml @@ -130,6 +130,16 @@ elasticsearch-configuration-jar 1.0 + + org.springdoc + springdoc-openapi-ui + 1.7.0 + + + org.springdoc + springdoc-openapi-security + 1.7.0 + diff --git a/src/main/java/com/bloggios/user/configuration/Beans.java b/src/main/java/com/bloggios/user/configuration/Beans.java index 03ae25f..63e26e7 100644 --- a/src/main/java/com/bloggios/user/configuration/Beans.java +++ b/src/main/java/com/bloggios/user/configuration/Beans.java @@ -31,7 +31,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.configuration + * Package - com.bloggios.user.provider.configuration * Created_on - 30 November-2023 * Created_at - 19 : 53 */ diff --git a/src/main/java/com/bloggios/user/configuration/ElasticClientConfiguration.java b/src/main/java/com/bloggios/user/configuration/ElasticClientConfiguration.java index 9e3adf3..98dd893 100644 --- a/src/main/java/com/bloggios/user/configuration/ElasticClientConfiguration.java +++ b/src/main/java/com/bloggios/user/configuration/ElasticClientConfiguration.java @@ -51,7 +51,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.configuration + * Package - com.bloggios.user.provider.configuration * Created_on - 02 December-2023 * Created_at - 13 : 26 */ diff --git a/src/main/java/com/bloggios/user/configuration/RetryConfiguration.java b/src/main/java/com/bloggios/user/configuration/RetryConfiguration.java index 5f95a3f..72858d9 100644 --- a/src/main/java/com/bloggios/user/configuration/RetryConfiguration.java +++ b/src/main/java/com/bloggios/user/configuration/RetryConfiguration.java @@ -35,7 +35,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.configuration + * Package - com.bloggios.user.provider.configuration * Created_on - 02 December-2023 * Created_at - 23 : 17 */ diff --git a/src/main/java/com/bloggios/user/configuration/SwaggerConfiguration.java b/src/main/java/com/bloggios/user/configuration/SwaggerConfiguration.java new file mode 100644 index 0000000..8b6a288 --- /dev/null +++ b/src/main/java/com/bloggios/user/configuration/SwaggerConfiguration.java @@ -0,0 +1,74 @@ +package com.bloggios.user.configuration; + +import com.bloggios.user.properties.SwaggerConfigProperties; +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Contact; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.servers.Server; +import lombok.RequiredArgsConstructor; +import org.springdoc.core.GroupedOpenApi; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * Owner - Rohit Parihar + * Author - rohit + * Project - blog-provider-application + * Package - com.bloggios.user.configuration + * Created_on - August 30 - 2024 + * Created_at - 01:19 + */ + +@Configuration +@RequiredArgsConstructor +public class SwaggerConfiguration { + + private final SwaggerConfigProperties swaggerConfigProperties; + + @Bean + public GroupedOpenApi api() { + return GroupedOpenApi.builder() + .group(swaggerConfigProperties.getGroupName().getDefinition()) + .packagesToScan(swaggerConfigProperties.getGroupName().getScanPackages()) + .build(); + } + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info() + .title(swaggerConfigProperties.getInfo().getTitle()) + .version(swaggerConfigProperties.getInfo().getVersion()) + .description(swaggerConfigProperties.getInfo().getDescription()) + .license(new License().name(swaggerConfigProperties.getInfo().getLicense().getName()).url(swaggerConfigProperties.getInfo().getLicense().getUrl())) + .contact(new Contact().name(swaggerConfigProperties.getInfo().getContact().getName()).email(swaggerConfigProperties.getInfo().getContact().getEmail()).url(swaggerConfigProperties.getInfo().getContact().getUrl()))) + .servers(getServers()) + .components(new Components() + .addSecuritySchemes( + "bearerAuth", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("bearer").bearerFormat("JWT") + .name("bearerAuth") + .type(SecurityScheme.Type.HTTP) + .scheme("bearer") + .bearerFormat("JWT") + .in(SecurityScheme.In.HEADER) + .description("JWT Authentication"))); + } + + public List getServers(){ + Map servers = swaggerConfigProperties.getServers(); + List serversList = new ArrayList<>(); + for (String server : servers.keySet()){ + SwaggerConfigProperties.Server getServer = servers.get(server); + serversList.add(new Server().description(getServer.getName()).url(getServer.getUrl())); + } + return serversList; + } +} diff --git a/src/main/java/com/bloggios/user/configuration/TaskExecutorConfiguration.java b/src/main/java/com/bloggios/user/configuration/TaskExecutorConfiguration.java index 2eeb619..0172ec0 100644 --- a/src/main/java/com/bloggios/user/configuration/TaskExecutorConfiguration.java +++ b/src/main/java/com/bloggios/user/configuration/TaskExecutorConfiguration.java @@ -34,7 +34,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.configuration + * Package - com.bloggios.user.provider.configuration * Created_on - 29 November-2023 * Created_at - 15 : 13 */ diff --git a/src/main/java/com/bloggios/user/constants/BeanConstants.java b/src/main/java/com/bloggios/user/constants/BeanConstants.java index a553c74..1d2a30e 100644 --- a/src/main/java/com/bloggios/user/constants/BeanConstants.java +++ b/src/main/java/com/bloggios/user/constants/BeanConstants.java @@ -29,7 +29,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.constants + * Package - com.bloggios.user.provider.constants * Created_on - 29 November-2023 * Created_at - 15 : 13 */ diff --git a/src/main/java/com/bloggios/user/constants/EndpointConstants.java b/src/main/java/com/bloggios/user/constants/EndpointConstants.java index e3cf858..44d9770 100644 --- a/src/main/java/com/bloggios/user/constants/EndpointConstants.java +++ b/src/main/java/com/bloggios/user/constants/EndpointConstants.java @@ -29,7 +29,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.constants + * Package - com.bloggios.user.provider.constants * Created_on - 28 May-2024 * Created_at - 20 : 34 */ @@ -56,16 +56,13 @@ public static class ProfileAuthController { public static class FollowController { public static final String BASE_PATH = "/follow"; public static final String HANDLE_FOLLOW = "/handle-follow/{userId}"; + public static final String COUNT_FOLLOW = "/count"; } public static class OpenController { public static final String BASE_PATH = "/unauth"; public static final String PROFILE_INTERNAL_RESPONSE = "/profile-internal-response/{userId}"; - public static class Follow { - public static final String COUNT_FOLLOW = "/count-follow"; - } - public static class Profile { public static final String USER_PROFILE = "/user-profile"; public static final String FETCH_PROFILES_USERNAME = "/get-username-profiles-list"; diff --git a/src/main/java/com/bloggios/user/constants/EnvironmentConstants.java b/src/main/java/com/bloggios/user/constants/EnvironmentConstants.java index 6568fbf..1f5f46d 100644 --- a/src/main/java/com/bloggios/user/constants/EnvironmentConstants.java +++ b/src/main/java/com/bloggios/user/constants/EnvironmentConstants.java @@ -29,7 +29,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.constants + * Package - com.bloggios.user.provider.constants * Created_on - 29 November-2023 * Created_at - 00 : 58 */ diff --git a/src/main/java/com/bloggios/user/constants/InternalErrorCodes.java b/src/main/java/com/bloggios/user/constants/InternalErrorCodes.java index 27a5c96..4886ff2 100644 --- a/src/main/java/com/bloggios/user/constants/InternalErrorCodes.java +++ b/src/main/java/com/bloggios/user/constants/InternalErrorCodes.java @@ -29,7 +29,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.constants + * Package - com.bloggios.user.provider.constants * Created_on - 29 November-2023 * Created_at - 13 : 57 */ diff --git a/src/main/java/com/bloggios/user/constants/ResponseMessageConstants.java b/src/main/java/com/bloggios/user/constants/ResponseMessageConstants.java index cdcd179..1e95819 100644 --- a/src/main/java/com/bloggios/user/constants/ResponseMessageConstants.java +++ b/src/main/java/com/bloggios/user/constants/ResponseMessageConstants.java @@ -29,7 +29,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.constants + * Package - com.bloggios.user.provider.constants * Created_on - 07 December-2023 * Created_at - 12 : 30 */ diff --git a/src/main/java/com/bloggios/user/constants/ServiceConstants.java b/src/main/java/com/bloggios/user/constants/ServiceConstants.java index fd8856e..0fe7c03 100644 --- a/src/main/java/com/bloggios/user/constants/ServiceConstants.java +++ b/src/main/java/com/bloggios/user/constants/ServiceConstants.java @@ -29,7 +29,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.constants + * Package - com.bloggios.user.provider.constants * Created_on - 29 November-2023 * Created_at - 23 : 46 */ diff --git a/src/main/java/com/bloggios/user/controller/FollowController.java b/src/main/java/com/bloggios/user/controller/FollowController.java index 6ecf742..5280261 100644 --- a/src/main/java/com/bloggios/user/controller/FollowController.java +++ b/src/main/java/com/bloggios/user/controller/FollowController.java @@ -2,13 +2,24 @@ import com.bloggios.authenticationconfig.payload.AuthenticatedUser; import com.bloggios.user.constants.EndpointConstants; +import com.bloggios.user.payload.response.ExceptionResponse; +import com.bloggios.user.payload.response.FollowCountResponse; import com.bloggios.user.payload.response.FollowResponse; import com.bloggios.user.service.FollowService; import com.bloggios.user.utils.AsyncUtils; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; /** * Owner - Rohit Parihar and Bloggios @@ -22,12 +33,58 @@ @RestController @RequestMapping(EndpointConstants.FollowController.BASE_PATH) @RequiredArgsConstructor +@Tag( + name = "Follow Controller", + description = "Controller responsible for handler user followers, followings, etc" +) public class FollowController { private final FollowService followService; @GetMapping(EndpointConstants.FollowController.HANDLE_FOLLOW) + @Operation( + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = FollowResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + }, + security = { + @SecurityRequirement( + name = "bearerAuth" + ) + } + ) public ResponseEntity handleFollow(@PathVariable String userId, @AuthenticationPrincipal AuthenticatedUser authenticatedUser) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(followService.handleFollow(userId, authenticatedUser))); } + + @GetMapping(EndpointConstants.FollowController.COUNT_FOLLOW) + @Operation( + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = FollowCountResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) + public ResponseEntity followCount(@AuthenticationPrincipal AuthenticatedUser authenticatedUser) { + return ResponseEntity.ok(AsyncUtils.getAsyncResult(followService.countFollowerFollowing(authenticatedUser))); + } } diff --git a/src/main/java/com/bloggios/user/controller/OpenController.java b/src/main/java/com/bloggios/user/controller/OpenController.java index 293dc47..2ed5391 100644 --- a/src/main/java/com/bloggios/user/controller/OpenController.java +++ b/src/main/java/com/bloggios/user/controller/OpenController.java @@ -3,12 +3,16 @@ import com.bloggios.authenticationconfig.payload.AuthenticatedUser; import com.bloggios.elasticsearch.configuration.payload.response.ListResponse; import com.bloggios.user.constants.EndpointConstants; -import com.bloggios.user.payload.response.FollowCountResponse; -import com.bloggios.user.payload.response.ProfileResponse; +import com.bloggios.user.payload.response.ExceptionResponse; import com.bloggios.user.payload.response.ProfileInternalResponse; +import com.bloggios.user.payload.response.ProfileResponse; import com.bloggios.user.service.FollowService; import com.bloggios.user.service.ProfileService; import com.bloggios.user.utils.AsyncUtils; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; @@ -32,21 +36,64 @@ public class OpenController { private final FollowService followService; @GetMapping(EndpointConstants.OpenController.PROFILE_INTERNAL_RESPONSE) + @Operation( + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ProfileInternalResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) public ResponseEntity getProfileInternalResponse(@PathVariable String userId) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(profileService.getProfileInternalResponse(userId))); } - @GetMapping(EndpointConstants.OpenController.Follow.COUNT_FOLLOW) - public ResponseEntity followCount(@AuthenticationPrincipal AuthenticatedUser authenticatedUser) { - return ResponseEntity.ok(AsyncUtils.getAsyncResult(followService.countFollowerFollowing(authenticatedUser))); - } - @GetMapping(EndpointConstants.OpenController.Profile.USER_PROFILE) + @Operation( + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ProfileResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) public ResponseEntity getUserProfile(@RequestParam String username, @AuthenticationPrincipal AuthenticatedUser authenticatedUser) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(profileService.getUserProfile(username, authenticatedUser))); } @GetMapping(EndpointConstants.OpenController.Profile.FETCH_PROFILES_USERNAME) + @Operation( + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ListResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) public ResponseEntity fetchProfilesUsingUsername(@RequestParam String username) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(profileService.fetchProfilesUsingUsername(username))); } diff --git a/src/main/java/com/bloggios/user/controller/ProfileAuthController.java b/src/main/java/com/bloggios/user/controller/ProfileAuthController.java index 7800b5f..4a490cb 100644 --- a/src/main/java/com/bloggios/user/controller/ProfileAuthController.java +++ b/src/main/java/com/bloggios/user/controller/ProfileAuthController.java @@ -4,10 +4,16 @@ import com.bloggios.elasticsearch.configuration.payload.response.ListResponse; import com.bloggios.user.constants.EndpointConstants; import com.bloggios.user.payload.request.ProfileListRequest; +import com.bloggios.user.payload.response.ExceptionResponse; import com.bloggios.user.payload.response.ProfileResponse; import com.bloggios.user.payload.response.ProfileTagResponse; import com.bloggios.user.service.ProfileService; import com.bloggios.user.utils.AsyncUtils; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; @@ -30,16 +36,79 @@ public class ProfileAuthController { private final ProfileService profileService; @GetMapping(EndpointConstants.ProfileAuthController.PROFILE_TAGS) + @Operation( + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ProfileTagResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + }, + security = { + @SecurityRequirement( + name = "bearerAuth" + ) + } + ) public ResponseEntity getProfileTags() { return ResponseEntity.ok(AsyncUtils.getAsyncResult(profileService.getProfileTags())); } @PostMapping + @Operation( + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ListResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + }, + security = { + @SecurityRequirement( + name = "bearerAuth" + ) + } + ) public ResponseEntity getProfileList(@RequestBody ProfileListRequest profileListRequest) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(profileService.getProfileList(profileListRequest))); } @GetMapping + @Operation( + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ProfileResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + }, + security = { + @SecurityRequirement( + name = "bearerAuth" + ) + } + ) public ResponseEntity getMyProfile(@AuthenticationPrincipal AuthenticatedUser authenticatedUser) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(profileService.getMyProfile(authenticatedUser))); } diff --git a/src/main/java/com/bloggios/user/controller/ProfileController.java b/src/main/java/com/bloggios/user/controller/ProfileController.java index 0f471f3..7ca8e45 100644 --- a/src/main/java/com/bloggios/user/controller/ProfileController.java +++ b/src/main/java/com/bloggios/user/controller/ProfileController.java @@ -3,9 +3,15 @@ import com.bloggios.authenticationconfig.payload.AuthenticatedUser; import com.bloggios.user.constants.EndpointConstants; import com.bloggios.user.payload.request.ProfileRequest; +import com.bloggios.user.payload.response.ExceptionResponse; import com.bloggios.user.payload.response.ModuleResponse; import com.bloggios.user.service.ProfileService; import com.bloggios.user.utils.AsyncUtils; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; @@ -35,11 +41,53 @@ public ProfileController( } @PostMapping + @Operation( + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ModuleResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + }, + security = { + @SecurityRequirement( + name = "bearerAuth" + ) + } + ) public ResponseEntity addProfile(@RequestBody ProfileRequest profileRequest, @AuthenticationPrincipal AuthenticatedUser authenticatedUser, HttpServletRequest httpServletRequest) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(profileService.addProfile(profileRequest, authenticatedUser, httpServletRequest))); } @PostMapping(EndpointConstants.ProfileController.ADD_PROFILE_IMAGE) + @Operation( + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ModuleResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + }, + security = { + @SecurityRequirement( + name = "bearerAuth" + ) + } + ) public ResponseEntity addImage( @RequestPart MultipartFile image, @AuthenticationPrincipal AuthenticatedUser authenticatedUser @@ -48,6 +96,27 @@ public ResponseEntity addImage( } @PutMapping + @Operation( + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ModuleResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + }, + security = { + @SecurityRequirement( + name = "bearerAuth" + ) + } + ) public ResponseEntity updateProfile(@RequestBody ProfileRequest profileRequest, @AuthenticationPrincipal AuthenticatedUser authenticatedUser) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(profileService.updateProfile(profileRequest, authenticatedUser))); } diff --git a/src/main/java/com/bloggios/user/dao/EsAbstractDao.java b/src/main/java/com/bloggios/user/dao/EsAbstractDao.java index 4c4d9c7..3ab8230 100644 --- a/src/main/java/com/bloggios/user/dao/EsAbstractDao.java +++ b/src/main/java/com/bloggios/user/dao/EsAbstractDao.java @@ -30,7 +30,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.dao + * Package - com.bloggios.user.provider.dao * Created_on - 28 May-2024 * Created_at - 16 : 47 */ diff --git a/src/main/java/com/bloggios/user/dao/PgAbstractDao.java b/src/main/java/com/bloggios/user/dao/PgAbstractDao.java index e55f0ec..bfac156 100644 --- a/src/main/java/com/bloggios/user/dao/PgAbstractDao.java +++ b/src/main/java/com/bloggios/user/dao/PgAbstractDao.java @@ -34,7 +34,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.dao + * Package - com.bloggios.user.provider.dao * Created_on - 29 November-2023 * Created_at - 23 : 55 */ diff --git a/src/main/java/com/bloggios/user/enums/DaoStatus.java b/src/main/java/com/bloggios/user/enums/DaoStatus.java index e696e62..a4a0e78 100644 --- a/src/main/java/com/bloggios/user/enums/DaoStatus.java +++ b/src/main/java/com/bloggios/user/enums/DaoStatus.java @@ -27,7 +27,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.enums + * Package - com.bloggios.user.provider.enums * Created_on - 29 November-2023 * Created_at - 00 : 52 */ diff --git a/src/main/java/com/bloggios/user/enums/EventType.java b/src/main/java/com/bloggios/user/enums/EventType.java index a21e67f..be93425 100644 --- a/src/main/java/com/bloggios/user/enums/EventType.java +++ b/src/main/java/com/bloggios/user/enums/EventType.java @@ -27,7 +27,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.enums + * Package - com.bloggios.user.provider.enums * Created_on - 22 December-2023 * Created_at - 16 : 09 */ diff --git a/src/main/java/com/bloggios/user/exception/ExceptionProvider.java b/src/main/java/com/bloggios/user/exception/ExceptionProvider.java index fadbcd0..883e405 100644 --- a/src/main/java/com/bloggios/user/exception/ExceptionProvider.java +++ b/src/main/java/com/bloggios/user/exception/ExceptionProvider.java @@ -31,7 +31,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.exception + * Package - com.bloggios.user.provider.exception * Created_on - 29 November-2023 * Created_at - 01 : 55 */ diff --git a/src/main/java/com/bloggios/user/exception/GlobalExceptionHandler.java b/src/main/java/com/bloggios/user/exception/GlobalExceptionHandler.java index 6033164..d465ad0 100644 --- a/src/main/java/com/bloggios/user/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/bloggios/user/exception/GlobalExceptionHandler.java @@ -24,7 +24,6 @@ package com.bloggios.user.exception; import com.bloggios.authenticationconfig.exception.AuthenticationConfigException; -import com.bloggios.elasticsearch.configuration.exception.payloads.ElasticsearchException; import com.bloggios.user.constants.InternalErrorCodes; import com.bloggios.user.constants.ServiceConstants; import com.bloggios.user.exception.payloads.BadRequestException; @@ -50,7 +49,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.exception + * Package - com.bloggios.user.provider.exception * Created_on - 30 November-2023 * Created_at - 01 : 57 */ diff --git a/src/main/java/com/bloggios/user/exception/payloads/BadRequestException.java b/src/main/java/com/bloggios/user/exception/payloads/BadRequestException.java index f32f1bb..619c231 100644 --- a/src/main/java/com/bloggios/user/exception/payloads/BadRequestException.java +++ b/src/main/java/com/bloggios/user/exception/payloads/BadRequestException.java @@ -31,7 +31,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.exception.payloads + * Package - com.bloggios.user.provider.exception.payloads * Created_on - 29 November-2023 * Created_at - 13 : 48 */ diff --git a/src/main/java/com/bloggios/user/exception/payloads/InitializationException.java b/src/main/java/com/bloggios/user/exception/payloads/InitializationException.java index e737099..d1c445a 100644 --- a/src/main/java/com/bloggios/user/exception/payloads/InitializationException.java +++ b/src/main/java/com/bloggios/user/exception/payloads/InitializationException.java @@ -31,7 +31,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.exception.payloads + * Package - com.bloggios.user.provider.exception.payloads * Created_on - 02 December-2023 * Created_at - 14 : 50 */ diff --git a/src/main/java/com/bloggios/user/feign/implementation/BlogsCountResponseCallFeign.java b/src/main/java/com/bloggios/user/feign/implementation/BlogsCountResponseCallFeign.java index 9ca11fa..b73eb7e 100644 --- a/src/main/java/com/bloggios/user/feign/implementation/BlogsCountResponseCallFeign.java +++ b/src/main/java/com/bloggios/user/feign/implementation/BlogsCountResponseCallFeign.java @@ -2,13 +2,10 @@ import com.bloggios.user.feign.BlogProviderApplicationFeign; import com.bloggios.user.payload.response.BlogCountResponse; -import com.bloggios.user.payload.response.UserProfileResponse; -import com.bloggios.user.utils.TokenExtractor; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; -import javax.servlet.http.HttpServletRequest; import java.util.Optional; /** diff --git a/src/main/java/com/bloggios/user/implementation/FollowServiceImplementation.java b/src/main/java/com/bloggios/user/implementation/FollowServiceImplementation.java index b5847f6..b899dde 100644 --- a/src/main/java/com/bloggios/user/implementation/FollowServiceImplementation.java +++ b/src/main/java/com/bloggios/user/implementation/FollowServiceImplementation.java @@ -2,31 +2,22 @@ import com.bloggios.authenticationconfig.payload.AuthenticatedUser; import com.bloggios.user.constants.DataErrorCodes; -import com.bloggios.user.constants.EnvironmentConstants; -import com.bloggios.user.dao.implementation.esimplementation.FollowDocumentDao; import com.bloggios.user.dao.implementation.pgsqlimplementation.FollowEntityDao; import com.bloggios.user.dao.implementation.pgsqlimplementation.ProfileEntityDao; -import com.bloggios.user.enums.DaoStatus; import com.bloggios.user.exception.payloads.BadRequestException; import com.bloggios.user.modal.FollowEntity; import com.bloggios.user.modal.ProfileEntity; import com.bloggios.user.payload.response.FollowCountResponse; import com.bloggios.user.payload.response.FollowResponse; -import com.bloggios.user.payload.response.ModuleResponse; -import com.bloggios.user.persistence.FollowEntityToDocumentPersistence; import com.bloggios.user.processor.implementation.HandleFollowProcessor; import com.bloggios.user.processor.implementation.HandleUnfollowProcessor; import com.bloggios.user.service.FollowService; import com.bloggios.user.utils.AsyncUtils; import com.bloggios.user.utils.ValueCheckerUtil; import lombok.RequiredArgsConstructor; -import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; -import java.time.Instant; -import java.util.Date; import java.util.Optional; -import java.util.UUID; import java.util.concurrent.CompletableFuture; /** diff --git a/src/main/java/com/bloggios/user/kafka/consumer/ConsumerFactoryConfiguration.java b/src/main/java/com/bloggios/user/kafka/consumer/ConsumerFactoryConfiguration.java index 272d380..4fc7f93 100644 --- a/src/main/java/com/bloggios/user/kafka/consumer/ConsumerFactoryConfiguration.java +++ b/src/main/java/com/bloggios/user/kafka/consumer/ConsumerFactoryConfiguration.java @@ -39,7 +39,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.kafka.consumer + * Package - com.bloggios.user.provider.kafka.consumer * Created_on - 02 December-2023 * Created_at - 21 : 23 */ diff --git a/src/main/java/com/bloggios/user/kafka/consumer/IncomingMessageFactory.java b/src/main/java/com/bloggios/user/kafka/consumer/IncomingMessageFactory.java index 2cc1d68..3abf767 100644 --- a/src/main/java/com/bloggios/user/kafka/consumer/IncomingMessageFactory.java +++ b/src/main/java/com/bloggios/user/kafka/consumer/IncomingMessageFactory.java @@ -40,7 +40,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.kafka.consumer + * Package - com.bloggios.user.provider.kafka.consumer * Created_on - 02 December-2023 * Created_at - 21 : 23 */ diff --git a/src/main/java/com/bloggios/user/kafka/consumer/InitListener.java b/src/main/java/com/bloggios/user/kafka/consumer/InitListener.java index c2f76b5..156bcea 100644 --- a/src/main/java/com/bloggios/user/kafka/consumer/InitListener.java +++ b/src/main/java/com/bloggios/user/kafka/consumer/InitListener.java @@ -36,7 +36,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.kafka.consumer + * Package - com.bloggios.user.provider.kafka.consumer * Created_on - 02 December-2023 * Created_at - 21 : 23 */ diff --git a/src/main/java/com/bloggios/user/kafka/consumer/KafkaListeners.java b/src/main/java/com/bloggios/user/kafka/consumer/KafkaListeners.java index 749d3d4..addca4c 100644 --- a/src/main/java/com/bloggios/user/kafka/consumer/KafkaListeners.java +++ b/src/main/java/com/bloggios/user/kafka/consumer/KafkaListeners.java @@ -35,7 +35,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.kafka.consumer + * Package - com.bloggios.user.provider.kafka.consumer * Created_on - 02 December-2023 * Created_at - 21 : 23 */ diff --git a/src/main/java/com/bloggios/user/kafka/producer/MessageProducer.java b/src/main/java/com/bloggios/user/kafka/producer/MessageProducer.java index c70fdea..db2d040 100644 --- a/src/main/java/com/bloggios/user/kafka/producer/MessageProducer.java +++ b/src/main/java/com/bloggios/user/kafka/producer/MessageProducer.java @@ -39,7 +39,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.kafka.producer + * Package - com.bloggios.user.provider.kafka.producer * Created_on - 03 December-2023 * Created_at - 00 : 26 */ diff --git a/src/main/java/com/bloggios/user/kafka/producer/PublishingPayload.java b/src/main/java/com/bloggios/user/kafka/producer/PublishingPayload.java index 9d96658..ddbf240 100644 --- a/src/main/java/com/bloggios/user/kafka/producer/PublishingPayload.java +++ b/src/main/java/com/bloggios/user/kafka/producer/PublishingPayload.java @@ -31,7 +31,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.kafka.producer + * Package - com.bloggios.user.provider.kafka.producer * Created_on - 03 December-2023 * Created_at - 00 : 27 */ diff --git a/src/main/java/com/bloggios/user/payload/OutgoingMessageData.java b/src/main/java/com/bloggios/user/payload/OutgoingMessageData.java index 405bc44..7b8c98a 100644 --- a/src/main/java/com/bloggios/user/payload/OutgoingMessageData.java +++ b/src/main/java/com/bloggios/user/payload/OutgoingMessageData.java @@ -30,7 +30,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.payload + * Package - com.bloggios.user.provider.payload * Created_on - 03 December-2023 * Created_at - 00 : 29 */ diff --git a/src/main/java/com/bloggios/user/payload/request/MustNotQueryListRequest.java b/src/main/java/com/bloggios/user/payload/request/MustNotQueryListRequest.java index 85f6573..2d71712 100644 --- a/src/main/java/com/bloggios/user/payload/request/MustNotQueryListRequest.java +++ b/src/main/java/com/bloggios/user/payload/request/MustNotQueryListRequest.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.*; -import org.springframework.stereotype.Component; import java.util.Collection; diff --git a/src/main/java/com/bloggios/user/payload/response/BlogCountResponse.java b/src/main/java/com/bloggios/user/payload/response/BlogCountResponse.java index bb1eead..b2a8eaa 100644 --- a/src/main/java/com/bloggios/user/payload/response/BlogCountResponse.java +++ b/src/main/java/com/bloggios/user/payload/response/BlogCountResponse.java @@ -7,7 +7,7 @@ * Owner - Rohit Parihar and Bloggios * Author - rohit * Project - blog-provider-application - * Package - com.bloggios.blog.payload.response + * Package - com.bloggios.user.payload.response * Created_on - June 14 - 2024 * Created_at - 19:34 */ diff --git a/src/main/java/com/bloggios/user/payload/response/ExceptionResponse.java b/src/main/java/com/bloggios/user/payload/response/ExceptionResponse.java index 5025ffe..7b451aa 100644 --- a/src/main/java/com/bloggios/user/payload/response/ExceptionResponse.java +++ b/src/main/java/com/bloggios/user/payload/response/ExceptionResponse.java @@ -31,7 +31,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.payload.response + * Package - com.bloggios.user.provider.payload.response * Created_on - 11 December-2023 * Created_at - 23 : 22 */ diff --git a/src/main/java/com/bloggios/user/payload/response/ExistResponse.java b/src/main/java/com/bloggios/user/payload/response/ExistResponse.java index d12ce0f..a564973 100644 --- a/src/main/java/com/bloggios/user/payload/response/ExistResponse.java +++ b/src/main/java/com/bloggios/user/payload/response/ExistResponse.java @@ -30,7 +30,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.payload.response + * Package - com.bloggios.user.provider.payload.response * Created_on - 28 May-2024 * Created_at - 13 : 05 */ diff --git a/src/main/java/com/bloggios/user/payload/response/ModuleResponse.java b/src/main/java/com/bloggios/user/payload/response/ModuleResponse.java index ffdaf37..d51fc0b 100644 --- a/src/main/java/com/bloggios/user/payload/response/ModuleResponse.java +++ b/src/main/java/com/bloggios/user/payload/response/ModuleResponse.java @@ -30,7 +30,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.payload.response + * Package - com.bloggios.user.provider.payload.response * Created_on - 29 November-2023 * Created_at - 00 : 09 */ diff --git a/src/main/java/com/bloggios/user/payload/response/ProfileInternalResponse.java b/src/main/java/com/bloggios/user/payload/response/ProfileInternalResponse.java index a33a8de..6102b8a 100644 --- a/src/main/java/com/bloggios/user/payload/response/ProfileInternalResponse.java +++ b/src/main/java/com/bloggios/user/payload/response/ProfileInternalResponse.java @@ -25,4 +25,6 @@ public class ProfileInternalResponse { private String profileTag; private String profileImage; private boolean isBadge; + private long followers; + private long following; } diff --git a/src/main/java/com/bloggios/user/payload/response/UserProfileResponse.java b/src/main/java/com/bloggios/user/payload/response/UserProfileResponse.java index ff7d529..ed0b77b 100644 --- a/src/main/java/com/bloggios/user/payload/response/UserProfileResponse.java +++ b/src/main/java/com/bloggios/user/payload/response/UserProfileResponse.java @@ -31,7 +31,7 @@ * Owner - Rohit Parihar and Bloggios * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.payload.response + * Package - com.bloggios.user.provider.payload.response * Created_on - May 22 - 2024 * Created_at - 22:33 */ diff --git a/src/main/java/com/bloggios/user/processor/Process.java b/src/main/java/com/bloggios/user/processor/Process.java index d2d3c16..ddc42d8 100644 --- a/src/main/java/com/bloggios/user/processor/Process.java +++ b/src/main/java/com/bloggios/user/processor/Process.java @@ -27,7 +27,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.processor + * Package - com.bloggios.user.provider.processor * Created_on - 02 December-2023 * Created_at - 22 : 51 */ diff --git a/src/main/java/com/bloggios/user/processor/fetch/FetchUserFollowFollowingCount.java b/src/main/java/com/bloggios/user/processor/fetch/FetchUserFollowFollowingCount.java new file mode 100644 index 0000000..95b69df --- /dev/null +++ b/src/main/java/com/bloggios/user/processor/fetch/FetchUserFollowFollowingCount.java @@ -0,0 +1,38 @@ +package com.bloggios.user.processor.fetch; + +import com.bloggios.user.constants.DataErrorCodes; +import com.bloggios.user.dao.implementation.pgsqlimplementation.ProfileEntityDao; +import com.bloggios.user.exception.payloads.BadRequestException; +import com.bloggios.user.modal.ProfileEntity; +import com.bloggios.user.payload.response.FollowCountResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +/** + * Owner - Rohit Parihar + * Author - rohit + * Project - user-provider-application + * Package - com.bloggios.user.processor.implementation + * Created_on - August 31 - 2024 + * Created_at - 16:45 + */ + +@Component +@RequiredArgsConstructor +public class FetchUserFollowFollowingCount { + + private final ProfileEntityDao profileEntityDao; + + public FollowCountResponse fetch(String userId) { + ProfileEntity profileEntity = profileEntityDao.findByUserId(userId) + .orElseThrow(() -> new BadRequestException(DataErrorCodes.PROFILE_NOT_FOUND)); + int followers = profileEntity.getFollowTo().size(); + int following = profileEntity.getFollowedBy().size(); + return FollowCountResponse + .builder() + .followers(followers) + .following(following) + .userId(userId) + .build(); + } +} diff --git a/src/main/java/com/bloggios/user/processor/implementation/HandleFollowProcessor.java b/src/main/java/com/bloggios/user/processor/implementation/HandleFollowProcessor.java index d683aa6..06f3328 100644 --- a/src/main/java/com/bloggios/user/processor/implementation/HandleFollowProcessor.java +++ b/src/main/java/com/bloggios/user/processor/implementation/HandleFollowProcessor.java @@ -8,7 +8,6 @@ import com.bloggios.user.modal.FollowEntity; import com.bloggios.user.modal.ProfileEntity; import com.bloggios.user.payload.response.FollowResponse; -import com.bloggios.user.payload.response.ModuleResponse; import com.bloggios.user.persistence.FollowEntityToDocumentPersistence; import lombok.RequiredArgsConstructor; import org.springframework.core.env.Environment; diff --git a/src/main/java/com/bloggios/user/processor/implementation/HandleUnfollowProcessor.java b/src/main/java/com/bloggios/user/processor/implementation/HandleUnfollowProcessor.java index 29f64c4..6fb3666 100644 --- a/src/main/java/com/bloggios/user/processor/implementation/HandleUnfollowProcessor.java +++ b/src/main/java/com/bloggios/user/processor/implementation/HandleUnfollowProcessor.java @@ -6,7 +6,6 @@ import com.bloggios.user.modal.FollowEntity; import com.bloggios.user.modal.ProfileEntity; import com.bloggios.user.payload.response.FollowResponse; -import com.bloggios.user.payload.response.ModuleResponse; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; diff --git a/src/main/java/com/bloggios/user/properties/FetchErrorProperties.java b/src/main/java/com/bloggios/user/properties/FetchErrorProperties.java index b690cc2..09a6eac 100644 --- a/src/main/java/com/bloggios/user/properties/FetchErrorProperties.java +++ b/src/main/java/com/bloggios/user/properties/FetchErrorProperties.java @@ -37,7 +37,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.properties + * Package - com.bloggios.user.provider.properties * Created_on - 11 December-2023 * Created_at - 23 : 20 */ diff --git a/src/main/java/com/bloggios/user/properties/SwaggerConfigProperties.java b/src/main/java/com/bloggios/user/properties/SwaggerConfigProperties.java new file mode 100644 index 0000000..c8a2ec8 --- /dev/null +++ b/src/main/java/com/bloggios/user/properties/SwaggerConfigProperties.java @@ -0,0 +1,69 @@ +package com.bloggios.user.properties; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import java.util.Map; + +/** + * Owner - Rohit Parihar + * Author - rohit + * Project - blog-provider-application + * Package - com.bloggios.user.properties + * Created_on - August 30 - 2024 + * Created_at - 01:35 + */ + +@Getter +@Setter +@ConfigurationProperties(prefix = "swagger-properties") +@Configuration +public class SwaggerConfigProperties { + + private Info info; + private Map servers; + private Group groupName; + + + @Getter + @Setter + public static class Info{ + private String title; + private String description; + private String summary; + private String version; + private Contact contact; + private License license; + } + + @Getter + @Setter + public static class Contact{ + private String name; + private String email; + private String url; + } + + @Getter + @Setter + public static class License{ + private String name; + private String url; + } + + @Getter + @Setter + public static class Server{ + private String name; + private String url; + } + + @Getter + @Setter + public static class Group{ + private String definition; + private String scanPackages; + } +} diff --git a/src/main/java/com/bloggios/user/service/FollowService.java b/src/main/java/com/bloggios/user/service/FollowService.java index 711f452..49c21d4 100644 --- a/src/main/java/com/bloggios/user/service/FollowService.java +++ b/src/main/java/com/bloggios/user/service/FollowService.java @@ -3,7 +3,6 @@ import com.bloggios.authenticationconfig.payload.AuthenticatedUser; import com.bloggios.user.payload.response.FollowCountResponse; import com.bloggios.user.payload.response.FollowResponse; -import com.bloggios.user.payload.response.ModuleResponse; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/com/bloggios/user/service/ProfileService.java b/src/main/java/com/bloggios/user/service/ProfileService.java index 5e73bfa..29b981f 100644 --- a/src/main/java/com/bloggios/user/service/ProfileService.java +++ b/src/main/java/com/bloggios/user/service/ProfileService.java @@ -28,8 +28,8 @@ import com.bloggios.user.payload.request.ProfileListRequest; import com.bloggios.user.payload.request.ProfileRequest; import com.bloggios.user.payload.response.ModuleResponse; -import com.bloggios.user.payload.response.ProfileResponse; import com.bloggios.user.payload.response.ProfileInternalResponse; +import com.bloggios.user.payload.response.ProfileResponse; import com.bloggios.user.payload.response.ProfileTagResponse; import org.springframework.web.multipart.MultipartFile; @@ -40,7 +40,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-write-service - * Package - com.bloggios.auth.provider.write.service + * Package - com.bloggios.user.provider.write.service * Created_on - 30 December-2023 * Created_at - 16 : 23 */ diff --git a/src/main/java/com/bloggios/user/transformer/Transform.java b/src/main/java/com/bloggios/user/transformer/Transform.java index 5aefc62..91ca432 100644 --- a/src/main/java/com/bloggios/user/transformer/Transform.java +++ b/src/main/java/com/bloggios/user/transformer/Transform.java @@ -27,7 +27,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.transformer + * Package - com.bloggios.user.provider.transformer * Created_on - 29 November-2023 * Created_at - 14 : 57 */ diff --git a/src/main/java/com/bloggios/user/transformer/implementation/ProfileDocumentToProfileInternalResponseTransformer.java b/src/main/java/com/bloggios/user/transformer/implementation/ProfileDocumentToProfileInternalResponseTransformer.java index 00245f2..89e4d67 100644 --- a/src/main/java/com/bloggios/user/transformer/implementation/ProfileDocumentToProfileInternalResponseTransformer.java +++ b/src/main/java/com/bloggios/user/transformer/implementation/ProfileDocumentToProfileInternalResponseTransformer.java @@ -1,8 +1,11 @@ package com.bloggios.user.transformer.implementation; import com.bloggios.user.document.ProfileDocument; +import com.bloggios.user.payload.response.FollowCountResponse; import com.bloggios.user.payload.response.ProfileInternalResponse; +import com.bloggios.user.processor.fetch.FetchUserFollowFollowingCount; import com.bloggios.user.transformer.Transform; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import java.util.Objects; @@ -17,10 +20,14 @@ */ @Component +@RequiredArgsConstructor public class ProfileDocumentToProfileInternalResponseTransformer implements Transform { + private final FetchUserFollowFollowingCount fetchUserFollowFollowingCount; + @Override public ProfileInternalResponse transform(ProfileDocument profileDocument) { + FollowCountResponse followCountResponse = fetchUserFollowFollowingCount.fetch(profileDocument.getUserId()); return ProfileInternalResponse .builder() .name(profileDocument.getName()) @@ -28,6 +35,8 @@ public ProfileInternalResponse transform(ProfileDocument profileDocument) { .profileImage(profileDocument.getProfileImage()) .profileTag(Objects.nonNull(profileDocument.getProfileTag()) ? profileDocument.getProfileTag().getValue() : null) .isBadge(profileDocument.isBadge()) + .followers(followCountResponse.getFollowers()) + .following(followCountResponse.getFollowing()) .build(); } } diff --git a/src/main/java/com/bloggios/user/transformer/implementation/ProfileDocumentToUsernameProfileListTransformer.java b/src/main/java/com/bloggios/user/transformer/implementation/ProfileDocumentToUsernameProfileListTransformer.java index 558344a..e186655 100644 --- a/src/main/java/com/bloggios/user/transformer/implementation/ProfileDocumentToUsernameProfileListTransformer.java +++ b/src/main/java/com/bloggios/user/transformer/implementation/ProfileDocumentToUsernameProfileListTransformer.java @@ -2,7 +2,6 @@ import com.bloggios.user.document.ProfileDocument; import com.bloggios.user.payload.response.ProfileResponse; -import com.bloggios.user.payload.response.UserProfileResponse; import com.bloggios.user.transformer.Transform; import org.springframework.stereotype.Component; diff --git a/src/main/java/com/bloggios/user/utils/AsyncUtils.java b/src/main/java/com/bloggios/user/utils/AsyncUtils.java index 9e23a3b..ec94fe2 100644 --- a/src/main/java/com/bloggios/user/utils/AsyncUtils.java +++ b/src/main/java/com/bloggios/user/utils/AsyncUtils.java @@ -35,7 +35,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.utils + * Package - com.bloggios.user.provider.utils * Created_on - 29 November-2023 * Created_at - 16 : 19 */ diff --git a/src/main/java/com/bloggios/user/utils/DateUtil.java b/src/main/java/com/bloggios/user/utils/DateUtil.java index 5149b46..118529a 100644 --- a/src/main/java/com/bloggios/user/utils/DateUtil.java +++ b/src/main/java/com/bloggios/user/utils/DateUtil.java @@ -32,7 +32,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.utils + * Package - com.bloggios.user.provider.utils * Created_on - 07 December-2023 * Created_at - 13 : 46 */ diff --git a/src/main/java/com/bloggios/user/utils/IpUtils.java b/src/main/java/com/bloggios/user/utils/IpUtils.java index ecd917a..e7bef57 100644 --- a/src/main/java/com/bloggios/user/utils/IpUtils.java +++ b/src/main/java/com/bloggios/user/utils/IpUtils.java @@ -33,7 +33,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.utils + * Package - com.bloggios.user.provider.utils * Created_on - 01 March-2024 * Created_at - 20 : 44 */ diff --git a/src/main/java/com/bloggios/user/utils/LinkGenerator.java b/src/main/java/com/bloggios/user/utils/LinkGenerator.java index ccbfe65..d3b8e8d 100644 --- a/src/main/java/com/bloggios/user/utils/LinkGenerator.java +++ b/src/main/java/com/bloggios/user/utils/LinkGenerator.java @@ -24,10 +24,8 @@ package com.bloggios.user.utils; import com.bloggios.user.constants.EnvironmentConstants; -import com.bloggios.user.constants.ServiceConstants; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; import java.util.Objects; diff --git a/src/main/java/com/bloggios/user/utils/MessageDataDeserializer.java b/src/main/java/com/bloggios/user/utils/MessageDataDeserializer.java index 771d5a1..d4ca150 100644 --- a/src/main/java/com/bloggios/user/utils/MessageDataDeserializer.java +++ b/src/main/java/com/bloggios/user/utils/MessageDataDeserializer.java @@ -34,7 +34,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.utils + * Package - com.bloggios.user.provider.utils * Created_on - 02 December-2023 * Created_at - 14 : 44 */ diff --git a/src/main/java/com/bloggios/user/utils/WordsCounter.java b/src/main/java/com/bloggios/user/utils/WordsCounter.java index d67923a..ca1bf62 100644 --- a/src/main/java/com/bloggios/user/utils/WordsCounter.java +++ b/src/main/java/com/bloggios/user/utils/WordsCounter.java @@ -31,7 +31,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.utils + * Package - com.bloggios.user.provider.utils * Created_on - 30 December-2023 * Created_at - 16 : 47 */ diff --git a/src/main/java/com/bloggios/user/validator/BusinessValidator.java b/src/main/java/com/bloggios/user/validator/BusinessValidator.java index 2f9fad8..dd7c395 100644 --- a/src/main/java/com/bloggios/user/validator/BusinessValidator.java +++ b/src/main/java/com/bloggios/user/validator/BusinessValidator.java @@ -27,7 +27,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.validator.service + * Package - com.bloggios.user.provider.validator.service * Created_on - 29 November-2023 * Created_at - 23 : 44 */ diff --git a/src/main/java/com/bloggios/user/validator/Exhibitor.java b/src/main/java/com/bloggios/user/validator/Exhibitor.java index cbd20c9..38ee6ae 100644 --- a/src/main/java/com/bloggios/user/validator/Exhibitor.java +++ b/src/main/java/com/bloggios/user/validator/Exhibitor.java @@ -27,7 +27,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.validator.service + * Package - com.bloggios.user.provider.validator.service * Created_on - 11 December-2023 * Created_at - 00 : 04 */ diff --git a/src/main/java/com/bloggios/user/validator/implementation/businessvalidator/EmailValidationProvider.java b/src/main/java/com/bloggios/user/validator/implementation/businessvalidator/EmailValidationProvider.java index d5a2408..e5a4b81 100644 --- a/src/main/java/com/bloggios/user/validator/implementation/businessvalidator/EmailValidationProvider.java +++ b/src/main/java/com/bloggios/user/validator/implementation/businessvalidator/EmailValidationProvider.java @@ -33,7 +33,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.validator.validators + * Package - com.bloggios.user.provider.validator.validators * Created_on - 29 November-2023 * Created_at - 23 : 43 */ diff --git a/src/main/java/com/bloggios/user/ymlparser/ImportErrorMessages.java b/src/main/java/com/bloggios/user/ymlparser/ImportErrorMessages.java index fb2cf94..420afaa 100644 --- a/src/main/java/com/bloggios/user/ymlparser/ImportErrorMessages.java +++ b/src/main/java/com/bloggios/user/ymlparser/ImportErrorMessages.java @@ -41,7 +41,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.ymlparser + * Package - com.bloggios.user.provider.ymlparser * Created_on - 11 December-2023 * Created_at - 23 : 13 */ diff --git a/src/main/java/com/bloggios/user/ymlparser/factory/YmlFileMapParserFactory.java b/src/main/java/com/bloggios/user/ymlparser/factory/YmlFileMapParserFactory.java index ba234c8..2df5056 100644 --- a/src/main/java/com/bloggios/user/ymlparser/factory/YmlFileMapParserFactory.java +++ b/src/main/java/com/bloggios/user/ymlparser/factory/YmlFileMapParserFactory.java @@ -37,7 +37,7 @@ * Owner - Rohit Parihar * Author - rohit * Project - auth-provider-application - * Package - com.bloggios.auth.provider.ymlparser.factory + * Package - com.bloggios.user.provider.ymlparser.factory * Created_on - 28 May-2024 * Created_at - 13 : 39 */ diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 8f5edfb..bdedca0 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -80,6 +80,17 @@ security-config: paths: - /actuator/** - /unauth/** + - /api/v1/auth/**" + - /v2/api-docs + - /swagger-resources + - /swagger-resources/** + - /configuration/ui + - /configuration/security + - /swagger-ui/** + - /webjars/** + - /swagger-ui.html + - /v3/api-docs + - /v3/api-docs/** cookie: cookie-name: bloggios-cookie-mgmt-token refresh-cookie-name: ${ACTIVE_PROFILE:local}.bg-refresh-mgmt @@ -90,4 +101,28 @@ security-config: private-key: classpath:security/privkey.pem user-files: - profile-photo: /files/user-provider/profile \ No newline at end of file + profile-photo: /files/user-provider/profile + +swagger-properties: + group-name: + definition: ${spring.application.name} + scan-packages: com.bloggios.user + info: + title: Bloggios - User Provider Application + version: @version@ + description: API Documentation for blog-provider-application + summary: The User Provider Application, developed with Java 17 and Spring Boot, is a critical microservice responsible for managing user data. This microservice handles all user-related activities, including profiles, settings, and follow-following functionalities. It is essential for maintaining comprehensive and user management within the system. + contact: + name: Bloggios + email: support@bloggios.com + url: https://www.bloggios.com + license: + name: Apache 2 License + url: https://github.com/Bloggios/user-provider-application/blob/main/LICENSE + servers: + local: + name: Local Port + url: http://localhost:${server.port}/user-provider + production: + name: Hosted Port + url: https://api.bloggios.com/user-provider \ No newline at end of file