-
Notifications
You must be signed in to change notification settings - Fork 4
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
5684966
commit 1780e47
Showing
9 changed files
with
118 additions
and
8 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
17 changes: 17 additions & 0 deletions
17
src/main/java/UMC/campusNote/user/converter/UserConverter.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,17 @@ | ||
package UMC.campusNote.user.converter; | ||
|
||
import UMC.campusNote.user.dto.UserResponseDTO; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class UserConverter { | ||
|
||
public static UserResponseDTO.AttendedSemesterUpdateDTO toAttendedSemesterUpdateDTO(String attendedSemester, int count) { | ||
return UserResponseDTO.AttendedSemesterUpdateDTO.builder() | ||
.count(count) | ||
.attendedSemester(attendedSemester) | ||
.build(); | ||
} | ||
} |
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,22 @@ | ||
package UMC.campusNote.user.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
public class UserRequestDTO { | ||
|
||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
@Builder | ||
public static class AttendedSemesterUpdateDTO{ | ||
|
||
@Schema(description = "수정할 수강 학기", example = "4-2") | ||
@NotNull | ||
String attendedSemester; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/UMC/campusNote/user/dto/UserResponseDTO.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,18 @@ | ||
package UMC.campusNote.user.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
public class UserResponseDTO { | ||
|
||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class AttendedSemesterUpdateDTO { | ||
int count; | ||
String attendedSemester; | ||
} | ||
} |
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,12 @@ | ||
package UMC.campusNote.user.service; | ||
|
||
import UMC.campusNote.user.dto.UserRequestDTO; | ||
import UMC.campusNote.user.dto.UserResponseDTO; | ||
import UMC.campusNote.user.repository.UserRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class UserService { | ||
|
||
private final UserRepository userRepository; | ||
public interface UserService { | ||
|
||
UserResponseDTO.AttendedSemesterUpdateDTO updateAttendedSemester(Long userId, UserRequestDTO.AttendedSemesterUpdateDTO request); | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/UMC/campusNote/user/service/UserServiceImpl.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,26 @@ | ||
package UMC.campusNote.user.service; | ||
|
||
|
||
import UMC.campusNote.mapping.repository.UserLessonRepository; | ||
import UMC.campusNote.user.converter.UserConverter; | ||
import UMC.campusNote.user.dto.UserRequestDTO; | ||
import UMC.campusNote.user.dto.UserResponseDTO; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class UserServiceImpl implements UserService{ | ||
|
||
private final UserLessonRepository userLessonRepository; | ||
|
||
@Override | ||
@Transactional | ||
public UserResponseDTO.AttendedSemesterUpdateDTO updateAttendedSemester(Long userId, UserRequestDTO.AttendedSemesterUpdateDTO request) { | ||
int count = userLessonRepository.updateAttendedSemester(userId, request.getAttendedSemester()); | ||
return UserConverter.toAttendedSemesterUpdateDTO(request.getAttendedSemester(), count); | ||
} | ||
} |