-
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.
[feat] 호스트 프로필 수정 API 구현
- Loading branch information
Showing
7 changed files
with
100 additions
and
1 deletion.
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
27 changes: 27 additions & 0 deletions
27
src/main/java/com/pickple/server/api/host/dto/request/HostUpdateRequest.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,27 @@ | ||
package com.pickple.server.api.host.dto.request; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Size; | ||
|
||
public record HostUpdateRequest( | ||
|
||
@NotBlank(message = "이미지가 비어있습니다.") | ||
String profileUrl, | ||
|
||
@Size(max = 50) | ||
@NotBlank(message = "닉네임이 비어있습니다.") | ||
String nickname, | ||
|
||
@Size(max = 50) | ||
@NotBlank(message = "호칭이 비어있습니다.") | ||
String keyword, | ||
|
||
@Size(max = 70) | ||
@NotBlank(message = "소개글이 비어있습니다.") | ||
String description, | ||
|
||
@Size(max = 50) | ||
@NotBlank(message = "소셜 링크가 비어있습니다.") | ||
String socialLink | ||
) { | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/pickple/server/api/host/service/HostCommandService.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,35 @@ | ||
package com.pickple.server.api.host.service; | ||
|
||
|
||
import com.pickple.server.api.guest.repository.GuestRepository; | ||
import com.pickple.server.api.host.domain.Host; | ||
import com.pickple.server.api.host.dto.request.HostUpdateRequest; | ||
import com.pickple.server.api.host.repository.HostRepository; | ||
import com.pickple.server.api.submitter.repository.SubmitterRepository; | ||
import com.pickple.server.global.exception.CustomException; | ||
import com.pickple.server.global.response.enums.ErrorCode; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class HostCommandService { | ||
|
||
private final HostRepository hostRepository; | ||
private final GuestRepository guestRepository; | ||
private final SubmitterRepository submitterRepository; | ||
|
||
public void updateHostProfile(Long hostId, HostUpdateRequest hostUpdateRequest) { | ||
Host host = hostRepository.findHostByIdOrThrow(hostId); | ||
if (hostRepository.existsByNickname(hostUpdateRequest.nickname()) || guestRepository.existsByNickname( | ||
hostUpdateRequest.nickname()) || submitterRepository.existsByNickname(hostUpdateRequest.nickname())) { | ||
throw new CustomException(ErrorCode.DUPLICATION_NICKNAME); | ||
} | ||
host.updateHostProfile(hostUpdateRequest.profileUrl(), hostUpdateRequest.nickname(), | ||
hostUpdateRequest.keyword(), | ||
hostUpdateRequest.description(), hostUpdateRequest.socialLink()); | ||
|
||
} | ||
} |
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