-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/main/java/daybyquest/user/application/DeleteUserImageService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package daybyquest.user.application; | ||
|
||
import daybyquest.image.vo.BaseImageProperties; | ||
import daybyquest.image.vo.Image; | ||
import daybyquest.user.domain.User; | ||
import daybyquest.user.domain.UserImages; | ||
import daybyquest.user.domain.UserRepository; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
public class DeleteUserImageService { | ||
|
||
private final UserRepository userRepository; | ||
|
||
private final UserImages userImages; | ||
|
||
private final BaseImageProperties baseImageProperties; | ||
|
||
public DeleteUserImageService(final UserRepository userRepository, final UserImages userImages, | ||
final BaseImageProperties baseImageProperties) { | ||
this.userRepository = userRepository; | ||
this.userImages = userImages; | ||
this.baseImageProperties = baseImageProperties; | ||
} | ||
|
||
@Transactional | ||
public void invoke(final Long loginId) { | ||
final User user = userRepository.getById(loginId); | ||
userImages.remove(user.getImageIdentifier()); | ||
user.updateImage(new Image(baseImageProperties.getUserIdentifier())); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters