-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 parent
ea2a357
commit ae811e9
Showing
5 changed files
with
208 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
31 changes: 31 additions & 0 deletions
31
...n/java/gg/agenda/api/user/agendaprofile/controller/request/AgendaProfileChangeReqDto.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,31 @@ | ||
package gg.agenda.api.user.agendaprofile.controller.request; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.NotNull; | ||
import javax.validation.constraints.Size; | ||
|
||
import org.hibernate.validator.constraints.URL; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) | ||
public class AgendaProfileChangeReqDto { | ||
|
||
@NotNull | ||
@NotBlank | ||
@Size(max = 50, message = "userContent의 길이가 허용된 범위를 초과합니다.") | ||
private String userContent; | ||
|
||
@URL | ||
@Size(max = 100, message = "userGithub의 길이가 허용된 범위를 초과합니다.") | ||
private String userGithub; | ||
|
||
@Builder | ||
public AgendaProfileChangeReqDto(String userContent, String userGithub) { | ||
this.userContent = userContent; | ||
this.userGithub = userGithub; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...pi/src/main/java/gg/agenda/api/user/agendaprofile/service/AgendaProfileModifyService.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,37 @@ | ||
package gg.agenda.api.user.agendaprofile.service; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import gg.agenda.api.user.agendaprofile.controller.request.AgendaProfileChangeReqDto; | ||
import gg.data.agenda.AgendaProfile; | ||
import gg.data.user.User; | ||
import gg.repo.agenda.AgendaProfileRepository; | ||
import gg.repo.user.UserRepository; | ||
import gg.utils.exception.user.UserNotFoundException; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class AgendaProfileModifyService { | ||
|
||
private final UserRepository userRepository; | ||
private final AgendaProfileRepository agendaProfileRepository; | ||
|
||
@Transactional | ||
public void modifyAgendaProfile(String intraId, AgendaProfileChangeReqDto reqDto) throws UserNotFoundException { | ||
// User와 AgendaProfile을 조회 | ||
User user = userRepository.findByIntraId(intraId) | ||
.orElseThrow(() -> new UserNotFoundException()); | ||
|
||
AgendaProfile agendaProfile = agendaProfileRepository.findByUserId(user.getId()) | ||
.orElseThrow(() -> new UserNotFoundException()); | ||
|
||
// 변경된 값들로 업데이트 | ||
agendaProfile.updateProfile(reqDto.getUserContent(), reqDto.getUserGithub()); | ||
|
||
// 변경사항을 저장 | ||
agendaProfileRepository.save(agendaProfile); | ||
} | ||
} |
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