-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Users 도메인에 대한 내 정보 조회, 수정 API 개발
- Loading branch information
Showing
7 changed files
with
163 additions
and
9 deletions.
There are no files selected for viewing
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
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
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
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
5 changes: 5 additions & 0 deletions
5
src/main/java/com/seniors/domain/users/repository/UsersRepositoryCustom.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 |
---|---|---|
@@ -1,11 +1,16 @@ | ||
package com.seniors.domain.users.repository; | ||
|
||
|
||
import com.seniors.domain.users.dto.UsersDto.GetUserDetailRes; | ||
import com.seniors.domain.users.dto.UsersDto.SetUserDto; | ||
import com.seniors.domain.users.entity.Users; | ||
|
||
|
||
public interface UsersRepositoryCustom { | ||
|
||
Users getOneUsers(Long userId); | ||
|
||
GetUserDetailRes getUserDetails(Long userId, String snsId, String nickname, String profileImageUrl, String email, String gender); | ||
|
||
void modifyUser(Long userId, SetUserDto setUserDto, String profileImageUrl); | ||
} |
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
30 changes: 30 additions & 0 deletions
30
src/main/java/com/seniors/domain/users/service/UsersService.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 |
---|---|---|
@@ -1,13 +1,43 @@ | ||
package com.seniors.domain.users.service; | ||
|
||
import com.seniors.config.S3Uploader; | ||
import com.seniors.domain.users.dto.UsersDto.GetUserDetailRes; | ||
import com.seniors.domain.users.dto.UsersDto.SetUserDto; | ||
import com.seniors.domain.users.repository.UsersRepository; | ||
import jakarta.transaction.Transactional; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import java.io.IOException; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class UsersService { | ||
|
||
private final UsersRepository usersRepository; | ||
private final S3Uploader s3Uploader; | ||
|
||
public GetUserDetailRes findOneUsers(Long userId, String snsId, String nickname, String profileImageUrl, String email, String gender) { | ||
|
||
return usersRepository.getUserDetails(userId, | ||
snsId, | ||
nickname, | ||
profileImageUrl, | ||
email, | ||
gender); | ||
} | ||
|
||
@Transactional | ||
public void modifyUsers(Long userId, String curProfileImage, SetUserDto setUserDto, MultipartFile profileImage) throws IOException { | ||
String dirName = "users/profileImage/" + userId.toString(); | ||
String uploadImagePath = curProfileImage; | ||
if (profileImage != null) { | ||
// 기존 미디어 파일 삭제 | ||
s3Uploader.deleteS3Object(dirName); | ||
uploadImagePath = s3Uploader.upload(profileImage, dirName); | ||
} | ||
|
||
usersRepository.modifyUser(userId, setUserDto, uploadImagePath); | ||
} | ||
} |