diff --git a/src/main/java/code/shubham/commons/tree/service/TreeService.java b/src/main/java/code/shubham/commons/tree/service/TreeService.java index 9a0eefa..1afb0a7 100644 --- a/src/main/java/code/shubham/commons/tree/service/TreeService.java +++ b/src/main/java/code/shubham/commons/tree/service/TreeService.java @@ -5,6 +5,7 @@ import code.shubham.commons.treecommons.ITreeService; import code.shubham.commons.treemodels.TreeNodeDTO; import code.shubham.commons.treemodels.TreePathDTO; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -14,15 +15,11 @@ @Slf4j @Service +@RequiredArgsConstructor public class TreeService implements ITreeService { private final TreeRepository repository; - @Autowired - public TreeService(TreeRepository repository) { - this.repository = repository; - } - @Override public Tree save(final TreeNodeDTO node, final Integer parentId) { final Tree created = this.repository.save(Tree.builder().title(node.getTitle()).parentId(parentId).build()); diff --git a/src/main/java/code/shubham/core/blobstore/services/BlobService.java b/src/main/java/code/shubham/core/blobstore/services/BlobService.java index beeceab..7711c01 100644 --- a/src/main/java/code/shubham/core/blobstore/services/BlobService.java +++ b/src/main/java/code/shubham/core/blobstore/services/BlobService.java @@ -4,6 +4,7 @@ import code.shubham.core.blobstore.dao.entities.Blob; import code.shubham.core.blobstore.dao.repositories.BlobRepository; import code.shubham.core.blobstoremodels.CreateBlobResponse; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -13,6 +14,7 @@ @Slf4j @Service +@RequiredArgsConstructor public class BlobService { private final BlobRepository repository; @@ -20,11 +22,6 @@ public class BlobService { @Value("${aws.default.region}") private String defaultRegion; - @Autowired - public BlobService(final BlobRepository repository) { - this.repository = repository; - } - public CreateBlobResponse getPreSignedUploadUrl(final String owner, final String bucket, final String key, final Map metadata) { final Blob blob = this.repository.save(Blob.builder().bucket(bucket).keyName(key).owner(owner).build()); diff --git a/src/main/java/code/shubham/core/iam/services/RoleService.java b/src/main/java/code/shubham/core/iam/services/RoleService.java index 8fbe321..e6ae21f 100644 --- a/src/main/java/code/shubham/core/iam/services/RoleService.java +++ b/src/main/java/code/shubham/core/iam/services/RoleService.java @@ -3,6 +3,8 @@ import code.shubham.core.iam.dao.entities.Role; import code.shubham.core.iam.dao.repositories.RoleRepository; import jakarta.annotation.PostConstruct; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -10,18 +12,15 @@ import java.util.Map; import java.util.Optional; +@Slf4j @Service +@RequiredArgsConstructor public class RoleService { private final RoleRepository repository; private final Map cache = new HashMap<>(); - @Autowired - public RoleService(RoleRepository repository) { - this.repository = repository; - } - @PostConstruct public void init() { this.repository.findAnyTen().stream().forEach(role -> this.cache.put(role.getName(), role)); diff --git a/src/main/java/code/shubham/core/iam/services/UserRoleService.java b/src/main/java/code/shubham/core/iam/services/UserRoleService.java index d41e567..a920cbc 100644 --- a/src/main/java/code/shubham/core/iam/services/UserRoleService.java +++ b/src/main/java/code/shubham/core/iam/services/UserRoleService.java @@ -3,25 +3,23 @@ import code.shubham.commons.exceptions.InvalidParameterException; import code.shubham.core.iam.dao.entities.UserRole; import code.shubham.core.iam.dao.repositories.UserRoleRepository; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Collection; import java.util.stream.Collectors; +@Slf4j @Service +@RequiredArgsConstructor public class UserRoleService { private final UserRoleRepository repository; private final RoleService roleService; - @Autowired - public UserRoleService(final UserRoleRepository repository, final RoleService roleService) { - this.repository = repository; - this.roleService = roleService; - } - public UserRole setRoleToUser(final String roleName, final Long userId) { return this.roleService.getRoleByName(roleName) .map(role -> this.repository.save(UserRole.builder().role(role).userId(userId).build())) diff --git a/src/main/java/code/shubham/core/iam/services/UserService.java b/src/main/java/code/shubham/core/iam/services/UserService.java index 9cc0aab..4a02e6e 100644 --- a/src/main/java/code/shubham/core/iam/services/UserService.java +++ b/src/main/java/code/shubham/core/iam/services/UserService.java @@ -6,26 +6,24 @@ import code.shubham.core.iammodels.GetOrCreateUser; import code.shubham.core.iammodels.GetUserResponse; import code.shubham.core.iammodels.UserDTO; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.transaction.annotation.Transactional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Optional; +@Slf4j @Transactional @Service +@RequiredArgsConstructor public class UserService implements IUserService { private final UserRepository repository; private final UserRoleService userRoleService; - @Autowired - public UserService(final UserRepository repository, final UserRoleService userRoleService) { - this.repository = repository; - this.userRoleService = userRoleService; - } - @Override public GetUserResponse getOrCreate(final GetOrCreateUser.Request request) { final Optional existing = this.repository.findByEmail(request.getEmail()); diff --git a/src/main/java/code/shubham/core/iam/web/v1/controllers/UserController.java b/src/main/java/code/shubham/core/iam/web/v1/controllers/UserController.java index 1e2db18..2e534a3 100644 --- a/src/main/java/code/shubham/core/iam/web/v1/controllers/UserController.java +++ b/src/main/java/code/shubham/core/iam/web/v1/controllers/UserController.java @@ -5,6 +5,7 @@ import code.shubham.core.iammodels.GetOrCreateUser; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.http.HttpStatus; @@ -16,15 +17,11 @@ @SecurityRequirement(name = "BearerAuth") @Tag(name = "User") @ConditionalOnProperty(prefix = "service", name = "module", havingValue = "web") +@RequiredArgsConstructor public class UserController { private final UserService userService; - @Autowired - public UserController(final UserService userService) { - this.userService = userService; - } - @GetMapping public ResponseEntity getOrCreateUser(@RequestBody GetOrCreateUser.Request request) { return ResponseUtils.getDataResponseEntity(HttpStatus.OK, this.userService.getOrCreate(request)); diff --git a/src/main/java/code/shubham/core/lock/services/LockService.java b/src/main/java/code/shubham/core/lock/services/LockService.java index 52a9396..4c0a938 100644 --- a/src/main/java/code/shubham/core/lock/services/LockService.java +++ b/src/main/java/code/shubham/core/lock/services/LockService.java @@ -3,21 +3,20 @@ import code.shubham.commons.generators.id.implementations.SnowflakeSequenceIdGenerator; import code.shubham.core.lock.dao.entites.Lock; import code.shubham.core.lock.dao.repositories.LockRepository; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Optional; +@Slf4j @Service +@RequiredArgsConstructor public class LockService { private final LockRepository repository; - @Autowired - public LockService(final LockRepository repository) { - this.repository = repository; - } - public boolean lock(final String name, final int previousVersion, final String owner, final long timeToLiveInSeconds) { if (previousVersion == 0) diff --git a/src/main/java/code/shubham/core/lock/web/v1/controllers/LockController.java b/src/main/java/code/shubham/core/lock/web/v1/controllers/LockController.java index 50c0743..11a2d03 100644 --- a/src/main/java/code/shubham/core/lock/web/v1/controllers/LockController.java +++ b/src/main/java/code/shubham/core/lock/web/v1/controllers/LockController.java @@ -14,6 +14,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; +import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.http.HttpStatus; @@ -33,15 +34,11 @@ @SecurityRequirement(name = "BearerAuth") @Tag(name = "Lock") @ConditionalOnProperty(prefix = "service", name = "module", havingValue = "web") +@RequiredArgsConstructor public class LockController { private final LockService service; - @Autowired - public LockController(final LockService service) { - this.service = service; - } - @GetMapping("/{name}") public ResponseEntity getByName(@PathVariable @NotNull @NotEmpty final String name) { this.validateNameOrThrowException(name); diff --git a/src/main/java/code/shubham/core/userprofile/services/UserProfileService.java b/src/main/java/code/shubham/core/userprofile/services/UserProfileService.java index 6d70447..8f674d2 100644 --- a/src/main/java/code/shubham/core/userprofile/services/UserProfileService.java +++ b/src/main/java/code/shubham/core/userprofile/services/UserProfileService.java @@ -3,19 +3,18 @@ import code.shubham.commons.exceptions.InvalidRequestException; import code.shubham.core.userprofile.dao.entities.UserProfile; import code.shubham.core.userprofile.dao.repositories.UserProfileRepository; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +@Slf4j @Service +@RequiredArgsConstructor public class UserProfileService { private final UserProfileRepository repository; - @Autowired - public UserProfileService(final UserProfileRepository repository) { - this.repository = repository; - } - public UserProfile update(final Long userId, final String address) { return this.repository.save(this.repository.findByUserId(userId).map(profile -> { profile.setAddress(address); diff --git a/src/main/java/code/shubham/core/userprofile/web/v1/controllers/UserProfileController.java b/src/main/java/code/shubham/core/userprofile/web/v1/controllers/UserProfileController.java index c4c53f7..792f138 100644 --- a/src/main/java/code/shubham/core/userprofile/web/v1/controllers/UserProfileController.java +++ b/src/main/java/code/shubham/core/userprofile/web/v1/controllers/UserProfileController.java @@ -10,6 +10,7 @@ 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.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.http.HttpStatus; @@ -21,15 +22,11 @@ @SecurityRequirement(name = "BearerAuth") @Tag(name = "User Profiles") @ConditionalOnProperty(prefix = "service", name = "module", havingValue = "web") +@RequiredArgsConstructor public class UserProfileController { private final UserProfileService service; - @Autowired - public UserProfileController(final UserProfileService service) { - this.service = service; - } - @Operation(description = "PUT Profile Information", summary = "Idempotent endpoint for setting user profile information like address etc", responses = { @ApiResponse(description = "Success", responseCode = "200"),