From 191b912d2baa22e2af97b835c87f7711ac553a42 Mon Sep 17 00:00:00 2001 From: U-Geon Date: Sat, 21 Sep 2024 00:29:27 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20DTO=20type=EC=9D=84=20record?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/FindMemberRequestDTO.java | 20 ++--- .../Member/dto/request/LoginRequestDTO.java | 19 ++--- .../dto/request/PasswordUpdateRequestDTO.java | 10 +-- .../request/ReissueAccessTokenRequestDTO.java | 8 +- .../Member/dto/request/SignupRequestDTO.java | 32 ++++---- .../Member/dto/response/LoginResponseDTO.java | 20 ++--- .../response/PasswordUpdateResponseDTO.java | 18 ++--- .../ReissueAccessTokenResponseDTO.java | 12 +-- .../response/SearchStudentIdResponseDTO.java | 14 ++-- .../dto/response/SignupResponseDTO.java | 10 +-- .../domain/Member/service/AuthService.java | 12 +-- .../dto/request/AdminConfirmRequestDTO.java | 12 +-- .../dto/request/UserRecruitRequestDTO.java | 27 +++---- .../dto/response/AdminFindAllNoticeDTO.java | 30 +++---- .../dto/response/RecruitsResponseDTO.java | 80 +++++++++---------- .../UserFindAllNoticeResponseDTO.java | 27 +++---- .../UserFindDetailNoticeResponseDTO.java | 20 ++--- .../Notice/service/UserNoticeService.java | 1 - 18 files changed, 148 insertions(+), 224 deletions(-) diff --git a/src/main/java/bootcamp/wssrs/domain/Member/dto/request/FindMemberRequestDTO.java b/src/main/java/bootcamp/wssrs/domain/Member/dto/request/FindMemberRequestDTO.java index c663fce..e54488c 100644 --- a/src/main/java/bootcamp/wssrs/domain/Member/dto/request/FindMemberRequestDTO.java +++ b/src/main/java/bootcamp/wssrs/domain/Member/dto/request/FindMemberRequestDTO.java @@ -1,18 +1,14 @@ package bootcamp.wssrs.domain.Member.dto.request; import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Pattern; -import lombok.Getter; -import lombok.Setter; -@Getter @Setter -public class FindMemberRequestDTO { - @Pattern(regexp = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", message = "올바르지 않은 이메일 형식입니다.") - @NotBlank(message = "이메일을 입력해주세요.") - private String email; +public record FindMemberRequestDTO( + @Pattern(regexp = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", message = "올바르지 않은 이메일 형식입니다.") + @NotBlank(message = "이메일을 입력해주세요.") + String email, - @NotBlank(message = "학번을 입력해주세요.") - @Pattern(regexp = "^\\d{8}$", message = "올바르지 않은 형식입니다.") - private String studentId; -} + @NotBlank(message = "학번을 입력해주세요.") + @Pattern(regexp = "^\\d{8}$", message = "올바르지 않은 형식입니다.") + String studentId +) {} diff --git a/src/main/java/bootcamp/wssrs/domain/Member/dto/request/LoginRequestDTO.java b/src/main/java/bootcamp/wssrs/domain/Member/dto/request/LoginRequestDTO.java index be7382b..cd6de71 100644 --- a/src/main/java/bootcamp/wssrs/domain/Member/dto/request/LoginRequestDTO.java +++ b/src/main/java/bootcamp/wssrs/domain/Member/dto/request/LoginRequestDTO.java @@ -2,16 +2,13 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Pattern; -import lombok.Getter; -import lombok.Setter; -@Getter @Setter -public class LoginRequestDTO { - @Pattern(regexp = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", message = "올바르지 않은 이메일 형식입니다.") - @NotBlank(message = "이메일을 입력해주세요.") - private String email; +public record LoginRequestDTO( + @Pattern(regexp = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", message = "올바르지 않은 이메일 형식입니다.") + @NotBlank(message = "이메일을 입력해주세요.") + String email, - @Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*\\d)(?=.*[~!@#$%^&*()_+`\\-={}|:\";'<>?,./]).{8,}$", message = "영문자, 숫자, 특수문자를 각각 최소 1개 이상 사용해주세요.") - @NotBlank(message = "비밀번호를 입력해주세요.") - private String password; -} + @Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*\\d)(?=.*[~!@#$%^&*()_+`\\-={}|:\";'<>?,./]).{8,}$", message = "영문자, 숫자, 특수문자를 각각 최소 1개 이상 사용해주세요.") + @NotBlank(message = "비밀번호를 입력해주세요.") + String password +) {} diff --git a/src/main/java/bootcamp/wssrs/domain/Member/dto/request/PasswordUpdateRequestDTO.java b/src/main/java/bootcamp/wssrs/domain/Member/dto/request/PasswordUpdateRequestDTO.java index f04e6c8..3386200 100644 --- a/src/main/java/bootcamp/wssrs/domain/Member/dto/request/PasswordUpdateRequestDTO.java +++ b/src/main/java/bootcamp/wssrs/domain/Member/dto/request/PasswordUpdateRequestDTO.java @@ -6,8 +6,8 @@ import lombok.Setter; @Getter @Setter -public class PasswordUpdateRequestDTO { - @Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*\\d)(?=.*[~!@#$%^&*()_+`\\-={}|:\";'<>?,./]).{8,}$", message = "영문자, 숫자, 특수문자를 각각 최소 1개 이상 사용해주세요.") - @NotBlank(message = "비밀번호를 입력해주세요.") - private String newPassword; -} +public record PasswordUpdateRequestDTO( + @Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*\\d)(?=.*[~!@#$%^&*()_+`\\-={}|:\";'<>?,./]).{8,}$", message = "영문자, 숫자, 특수문자를 각각 최소 1개 이상 사용해주세요.") + @NotBlank(message = "비밀번호를 입력해주세요.") + String newPassword +) {} diff --git a/src/main/java/bootcamp/wssrs/domain/Member/dto/request/ReissueAccessTokenRequestDTO.java b/src/main/java/bootcamp/wssrs/domain/Member/dto/request/ReissueAccessTokenRequestDTO.java index 291008e..3657988 100644 --- a/src/main/java/bootcamp/wssrs/domain/Member/dto/request/ReissueAccessTokenRequestDTO.java +++ b/src/main/java/bootcamp/wssrs/domain/Member/dto/request/ReissueAccessTokenRequestDTO.java @@ -5,7 +5,7 @@ import lombok.Setter; @Getter @Setter -public class ReissueAccessTokenRequestDTO { - @NotBlank(message = "토큰이 존재하지 않습니다.") - private String refreshToken; -} \ No newline at end of file +public record ReissueAccessTokenRequestDTO( + @NotBlank(message = "토큰이 존재하지 않습니다.") + String refreshToken +) {} \ No newline at end of file diff --git a/src/main/java/bootcamp/wssrs/domain/Member/dto/request/SignupRequestDTO.java b/src/main/java/bootcamp/wssrs/domain/Member/dto/request/SignupRequestDTO.java index b162b40..606fe06 100644 --- a/src/main/java/bootcamp/wssrs/domain/Member/dto/request/SignupRequestDTO.java +++ b/src/main/java/bootcamp/wssrs/domain/Member/dto/request/SignupRequestDTO.java @@ -1,26 +1,22 @@ package bootcamp.wssrs.domain.Member.dto.request; import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Pattern; -import lombok.Getter; -import lombok.Setter; -@Getter @Setter -public class SignupRequestDTO { - @NotBlank(message = "학번을 입력해주세요.") - @Pattern(regexp = "^\\d{8}$", message = "8자리의 숫자만 입력해주세요.") - private String studentId; +public record SignupRequestDTO( + @NotBlank(message = "학번을 입력해주세요.") + @Pattern(regexp = "^\\d{8}$", message = "8자리의 숫자만 입력해주세요.") + String studentId, - @Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*\\d)(?=.*[~!@#$%^&*()_+`\\-={}|:\";'<>?,./]).{8,}$", message = "영문자, 숫자, 특수문자를 각각 최소 1개 이상 사용해주세요.") - @NotBlank(message = "비밀번호를 입력해주세요.") - private String password; + @Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*\\d)(?=.*[~!@#$%^&*()_+`\\-={}|:\";'<>?,./]).{8,}$", message = "영문자, 숫자, 특수문자를 각각 최소 1개 이상 사용해주세요.") + @NotBlank(message = "비밀번호를 입력해주세요.") + String password, - @Pattern(regexp = "^[a-zA-Z가-힣]+$", message = "올바르지 않은 형식입니다.") - @NotBlank(message = "이름을 입력해주세요.") - private String username; + @Pattern(regexp = "^[a-zA-Z가-힣]+$", message = "올바르지 않은 형식입니다.") + @NotBlank(message = "이름을 입력해주세요.") + String username, - @Pattern(regexp = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", message = "올바르지 않은 이메일 형식입니다.") - @NotBlank(message = "이메일을 입력해주세요.") - private String email; -} + @Pattern(regexp = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", message = "올바르지 않은 이메일 형식입니다.") + @NotBlank(message = "이메일을 입력해주세요.") + String email +) {} diff --git a/src/main/java/bootcamp/wssrs/domain/Member/dto/response/LoginResponseDTO.java b/src/main/java/bootcamp/wssrs/domain/Member/dto/response/LoginResponseDTO.java index 90b3419..20208d5 100644 --- a/src/main/java/bootcamp/wssrs/domain/Member/dto/response/LoginResponseDTO.java +++ b/src/main/java/bootcamp/wssrs/domain/Member/dto/response/LoginResponseDTO.java @@ -1,16 +1,8 @@ package bootcamp.wssrs.domain.Member.dto.response; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter @Setter -@NoArgsConstructor -@AllArgsConstructor -public class LoginResponseDTO { - private String accessToken; - private String refreshToken; - private String username; - private String studentId; -} +public record LoginResponseDTO( + String accessToken, + String refreshToken, + String username, + String studentId +) {} diff --git a/src/main/java/bootcamp/wssrs/domain/Member/dto/response/PasswordUpdateResponseDTO.java b/src/main/java/bootcamp/wssrs/domain/Member/dto/response/PasswordUpdateResponseDTO.java index d889840..65ea144 100644 --- a/src/main/java/bootcamp/wssrs/domain/Member/dto/response/PasswordUpdateResponseDTO.java +++ b/src/main/java/bootcamp/wssrs/domain/Member/dto/response/PasswordUpdateResponseDTO.java @@ -1,18 +1,10 @@ package bootcamp.wssrs.domain.Member.dto.response; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter @Setter -@NoArgsConstructor -public class PasswordUpdateResponseDTO { - - private String msg; - private String newPassword; - +public record PasswordUpdateResponseDTO( + String msg, + String newPassword +) { public PasswordUpdateResponseDTO(String newPassword) { - this.msg = "ok"; - this.newPassword = newPassword; + this("ok", newPassword); } } diff --git a/src/main/java/bootcamp/wssrs/domain/Member/dto/response/ReissueAccessTokenResponseDTO.java b/src/main/java/bootcamp/wssrs/domain/Member/dto/response/ReissueAccessTokenResponseDTO.java index 4dd6edd..44ed7e7 100644 --- a/src/main/java/bootcamp/wssrs/domain/Member/dto/response/ReissueAccessTokenResponseDTO.java +++ b/src/main/java/bootcamp/wssrs/domain/Member/dto/response/ReissueAccessTokenResponseDTO.java @@ -1,11 +1,5 @@ package bootcamp.wssrs.domain.Member.dto.response; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; - -@Getter @Setter -@AllArgsConstructor -public class ReissueAccessTokenResponseDTO { - private String newAccessToken; -} +public record ReissueAccessTokenResponseDTO( + String newAccessToken +) {} diff --git a/src/main/java/bootcamp/wssrs/domain/Member/dto/response/SearchStudentIdResponseDTO.java b/src/main/java/bootcamp/wssrs/domain/Member/dto/response/SearchStudentIdResponseDTO.java index 6c46791..5ca2fd2 100644 --- a/src/main/java/bootcamp/wssrs/domain/Member/dto/response/SearchStudentIdResponseDTO.java +++ b/src/main/java/bootcamp/wssrs/domain/Member/dto/response/SearchStudentIdResponseDTO.java @@ -1,16 +1,12 @@ package bootcamp.wssrs.domain.Member.dto.response; import bootcamp.wssrs.domain.Member.entity.Member; -import lombok.Getter; -import lombok.Setter; - -@Getter @Setter -public class SearchStudentIdResponseDTO { - private String msg; - private String password; +public record SearchStudentIdResponseDTO( + String msg, + String password +) { public SearchStudentIdResponseDTO(Member member) { - this.msg = "ok"; - this.password = member.getPassword(); + this("ok", member.getPassword()); } } diff --git a/src/main/java/bootcamp/wssrs/domain/Member/dto/response/SignupResponseDTO.java b/src/main/java/bootcamp/wssrs/domain/Member/dto/response/SignupResponseDTO.java index cd4e848..a8905d1 100644 --- a/src/main/java/bootcamp/wssrs/domain/Member/dto/response/SignupResponseDTO.java +++ b/src/main/java/bootcamp/wssrs/domain/Member/dto/response/SignupResponseDTO.java @@ -1,9 +1,5 @@ package bootcamp.wssrs.domain.Member.dto.response; -import lombok.Getter; -import lombok.Setter; - -@Getter @Setter -public class SignupResponseDTO { - private String msg; -} +public record SignupResponseDTO( + String msg +) {} \ No newline at end of file diff --git a/src/main/java/bootcamp/wssrs/domain/Member/service/AuthService.java b/src/main/java/bootcamp/wssrs/domain/Member/service/AuthService.java index 607736e..3dc3359 100644 --- a/src/main/java/bootcamp/wssrs/domain/Member/service/AuthService.java +++ b/src/main/java/bootcamp/wssrs/domain/Member/service/AuthService.java @@ -37,9 +37,9 @@ public class AuthService { // 로그인 public LoginResponseDTO login(LoginRequestDTO requestDTO) { - String email = requestDTO.getEmail(); + String email = requestDTO.email(); Member member = authRepository.findByEmail(email).orElseThrow(() -> new CustomException(ErrorCode.MEMBER_NOT_FOUND)); - if(!passwordEncoder.matches(requestDTO.getPassword(), member.getPassword())) { + if(!passwordEncoder.matches(requestDTO.password(), member.getPassword())) { throw new CustomException(ErrorCode.INVALID_PASSWORD); } @@ -73,10 +73,10 @@ public Member signUp(SignupRequestDTO requestDTO) { // 회원 조회 public TokenDTO findMember(FindMemberRequestDTO requestDTO) { - Member member = authRepository.findByEmailAndStudentId(requestDTO.getEmail(), requestDTO.getStudentId()) + Member member = authRepository.findByEmailAndStudentId(requestDTO.email(), requestDTO.studentId()) .orElseThrow(() -> new CustomException(ErrorCode.MEMBER_NOT_FOUND)); - String accessToken = jwtProvider.createAccessToken(requestDTO.getEmail(), member.getRole().toString()); + String accessToken = jwtProvider.createAccessToken(requestDTO.email(), member.getRole().toString()); return new TokenDTO(accessToken); } @@ -86,8 +86,8 @@ public TokenDTO findMember(FindMemberRequestDTO requestDTO) { public PasswordUpdateResponseDTO updatePassword(String email, PasswordUpdateRequestDTO requestDTO) { return authRepository.findByEmail(email) .map(member -> { - member.setPassword(requestDTO.getNewPassword(), passwordEncoder); // 새 비밀번호를 암호화하도록 수정 - return new PasswordUpdateResponseDTO(requestDTO.getNewPassword()); + member.setPassword(requestDTO.newPassword(), passwordEncoder); // 새 비밀번호를 암호화하도록 수정 + return new PasswordUpdateResponseDTO(requestDTO.newPassword()); }).orElseThrow(() -> new CustomException(ErrorCode.MEMBER_NOT_FOUND)); } diff --git a/src/main/java/bootcamp/wssrs/domain/Notice/dto/request/AdminConfirmRequestDTO.java b/src/main/java/bootcamp/wssrs/domain/Notice/dto/request/AdminConfirmRequestDTO.java index b285ea7..66cfbb9 100644 --- a/src/main/java/bootcamp/wssrs/domain/Notice/dto/request/AdminConfirmRequestDTO.java +++ b/src/main/java/bootcamp/wssrs/domain/Notice/dto/request/AdminConfirmRequestDTO.java @@ -1,13 +1,9 @@ package bootcamp.wssrs.domain.Notice.dto.request; import jakarta.validation.constraints.NotNull; -import lombok.Getter; -import lombok.Setter; - import java.util.List; -@Getter @Setter -public class AdminConfirmRequestDTO { - @NotNull(message = "근무 지원 ID를 선택해주세요.") - private List recruitIds; -} +public record AdminConfirmRequestDTO( + @NotNull(message = "근무 지원 ID를 선택해주세요.") + List recruitIds +) {} diff --git a/src/main/java/bootcamp/wssrs/domain/Notice/dto/request/UserRecruitRequestDTO.java b/src/main/java/bootcamp/wssrs/domain/Notice/dto/request/UserRecruitRequestDTO.java index fc35ed2..8ac3507 100644 --- a/src/main/java/bootcamp/wssrs/domain/Notice/dto/request/UserRecruitRequestDTO.java +++ b/src/main/java/bootcamp/wssrs/domain/Notice/dto/request/UserRecruitRequestDTO.java @@ -1,27 +1,22 @@ package bootcamp.wssrs.domain.Notice.dto.request; - import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Pattern; -import lombok.Getter; -import lombok.Setter; - import java.util.List; -@Getter @Setter -public class UserRecruitRequestDTO { - @NotBlank(message = "근무 코드를 입력해주세요.") - private String code; +public record UserRecruitRequestDTO( + @NotBlank(message = "근무 코드를 입력해주세요.") + String code, - @Pattern(regexp = "^(01[016789]-?\\d{3,4}-?\\d{4}|\\d{2,3}-?\\d{3,4}-?\\d{4})$") - @NotBlank(message = "전화번호를 입력해주세요.") - private String phoneNum; + @Pattern(regexp = "^(01[016789]-?\\d{3,4}-?\\d{4}|\\d{2,3}-?\\d{3,4}-?\\d{4})$") + @NotBlank(message = "전화번호를 입력해주세요.") + String phoneNum, - @NotEmpty(message = "근무 날짜를 한 개 이상 선택해주세요.") // @NotBlank는 문자열(String) 타입에만 적용 가능, 컬렉션 객체에 사용. - private List day; + @NotEmpty(message = "근무 날짜를 한 개 이상 선택해주세요.") + List day, - @NotNull(message = "조합원 가입 유무에 체크해주세요.") - private Boolean isUnion; // @NotBlank는 문자열(String) 타입에만 적용 가능 -} + @NotNull(message = "조합원 가입 유무에 체크해주세요.") + Boolean isUnion +) {} diff --git a/src/main/java/bootcamp/wssrs/domain/Notice/dto/response/AdminFindAllNoticeDTO.java b/src/main/java/bootcamp/wssrs/domain/Notice/dto/response/AdminFindAllNoticeDTO.java index 522eec6..6e07790 100644 --- a/src/main/java/bootcamp/wssrs/domain/Notice/dto/response/AdminFindAllNoticeDTO.java +++ b/src/main/java/bootcamp/wssrs/domain/Notice/dto/response/AdminFindAllNoticeDTO.java @@ -1,33 +1,25 @@ package bootcamp.wssrs.domain.Notice.dto.response; import bootcamp.wssrs.domain.Notice.entity.Notice; -import lombok.Getter; -import lombok.Setter; import org.springframework.data.domain.Page; - import java.time.LocalDateTime; import java.util.List; -@Getter @Setter -public class AdminFindAllNoticeDTO { - private Long totalCount; - private List notices; - +public record AdminFindAllNoticeDTO( + Long totalCount, + List notices +) { public AdminFindAllNoticeDTO(Long totalCount, Page pages) { - this.notices = pages.stream().map(AdminFindAllNoticeInnerClass::new).toList(); - this.totalCount = totalCount; + this(totalCount, pages.stream().map(AdminFindAllNoticeInnerClass::new).toList()); } - @Getter @Setter - static class AdminFindAllNoticeInnerClass { - private Long id; - private String title; - private LocalDateTime createdAt; - + public record AdminFindAllNoticeInnerClass( + Long id, + String title, + LocalDateTime createdAt + ) { public AdminFindAllNoticeInnerClass(Notice notice) { - this.id = notice.getId(); - this.title = notice.getTitle(); - this.createdAt = notice.getCreatedAt(); + this(notice.getId(), notice.getTitle(), notice.getCreatedAt()); } } } diff --git a/src/main/java/bootcamp/wssrs/domain/Notice/dto/response/RecruitsResponseDTO.java b/src/main/java/bootcamp/wssrs/domain/Notice/dto/response/RecruitsResponseDTO.java index ee706cd..6d0e5e8 100644 --- a/src/main/java/bootcamp/wssrs/domain/Notice/dto/response/RecruitsResponseDTO.java +++ b/src/main/java/bootcamp/wssrs/domain/Notice/dto/response/RecruitsResponseDTO.java @@ -1,54 +1,50 @@ package bootcamp.wssrs.domain.Notice.dto.response; - import bootcamp.wssrs.domain.Day.entity.Day; -import bootcamp.wssrs.domain.Member.entity.Member; import bootcamp.wssrs.domain.Recruit.entity.Recruit; -import lombok.Getter; -import lombok.Setter; - - -@Getter @Setter -public class RecruitsResponseDTO { - private Long recruitId; - private String username; - private String studentId; - private String phoneNum; - private String code; - private DayDTO day; - private Boolean isUnion; - private Boolean isConfirmed; +public record RecruitsResponseDTO( + Long recruitId, + String username, + String studentId, + String phoneNum, + String code, + DayDTO day, + Boolean isUnion, + Boolean isConfirmed +) { public RecruitsResponseDTO(Recruit recruit) { - Member member = recruit.getMember(); - this.recruitId = recruit.getId(); - this.username = member.getUsername(); - this.studentId = member.getStudentId(); - this.phoneNum = recruit.getPhoneNum(); - this.code = recruit.getCode(); - this.day = new DayDTO(recruit.getDay()); - this.isUnion = recruit.getIsUnion(); - this.isConfirmed = recruit.getIsConfirmed(); + this( + recruit.getId(), + recruit.getMember().getUsername(), + recruit.getMember().getStudentId(), + recruit.getPhoneNum(), + recruit.getCode(), + new DayDTO(recruit.getDay()), + recruit.getIsUnion(), + recruit.getIsConfirmed() + ); } - @Getter @Setter - static class DayDTO { - private Boolean monday; - private Boolean tuesday; - private Boolean wednesday; - private Boolean thursday; - private Boolean friday; - private Boolean saturday; - private Boolean sunday; - + public record DayDTO( + Boolean monday, + Boolean tuesday, + Boolean wednesday, + Boolean thursday, + Boolean friday, + Boolean saturday, + Boolean sunday + ) { public DayDTO(Day day) { - this.monday = day.getMonday(); - this.tuesday = day.getTuesday(); - this.wednesday = day.getWednesday(); - this.thursday = day.getThursday(); - this.friday = day.getFriday(); - this.saturday = day.getSaturday(); - this.sunday = day.getSunday(); + this( + day.getMonday(), + day.getTuesday(), + day.getWednesday(), + day.getThursday(), + day.getFriday(), + day.getSaturday(), + day.getSunday() + ); } } } diff --git a/src/main/java/bootcamp/wssrs/domain/Notice/dto/response/UserFindAllNoticeResponseDTO.java b/src/main/java/bootcamp/wssrs/domain/Notice/dto/response/UserFindAllNoticeResponseDTO.java index 63754bd..f109fd0 100644 --- a/src/main/java/bootcamp/wssrs/domain/Notice/dto/response/UserFindAllNoticeResponseDTO.java +++ b/src/main/java/bootcamp/wssrs/domain/Notice/dto/response/UserFindAllNoticeResponseDTO.java @@ -2,24 +2,21 @@ import bootcamp.wssrs.domain.File.entity.File; import bootcamp.wssrs.domain.Notice.entity.Notice; -import lombok.Getter; -import lombok.Setter; - import java.time.LocalDateTime; import java.util.List; -@Getter @Setter -public class UserFindAllNoticeResponseDTO { - - private Long id; - private String title; - private LocalDateTime createdAt; - private List url; - +public record UserFindAllNoticeResponseDTO( + Long id, + String title, + LocalDateTime createdAt, + List url +) { public UserFindAllNoticeResponseDTO(Notice notice) { - this.id = notice.getId(); - this.title = notice.getTitle(); - this.createdAt = notice.getCreatedAt(); - this.url = notice.getFiles().stream().map(File::getUrl).toList(); + this( + notice.getId(), + notice.getTitle(), + notice.getCreatedAt(), + notice.getFiles().stream().map(File::getUrl).toList() + ); } } diff --git a/src/main/java/bootcamp/wssrs/domain/Notice/dto/response/UserFindDetailNoticeResponseDTO.java b/src/main/java/bootcamp/wssrs/domain/Notice/dto/response/UserFindDetailNoticeResponseDTO.java index 6f8d014..ad6c826 100644 --- a/src/main/java/bootcamp/wssrs/domain/Notice/dto/response/UserFindDetailNoticeResponseDTO.java +++ b/src/main/java/bootcamp/wssrs/domain/Notice/dto/response/UserFindDetailNoticeResponseDTO.java @@ -1,19 +1,9 @@ package bootcamp.wssrs.domain.Notice.dto.response; - import bootcamp.wssrs.domain.Notice.entity.Notice; -import lombok.Getter; -import lombok.Setter; - -@Getter @Setter -public class UserFindDetailNoticeResponseDTO { - private String username; - private String studentId; - private Notice notice; - public UserFindDetailNoticeResponseDTO(String username, String studentId, Notice notice) { - this.username = username; - this.studentId = studentId; - this.notice = notice; - } -} +public record UserFindDetailNoticeResponseDTO( + String username, + String studentId, + Notice notice +) {} diff --git a/src/main/java/bootcamp/wssrs/domain/Notice/service/UserNoticeService.java b/src/main/java/bootcamp/wssrs/domain/Notice/service/UserNoticeService.java index c0b960e..3d6ac29 100644 --- a/src/main/java/bootcamp/wssrs/domain/Notice/service/UserNoticeService.java +++ b/src/main/java/bootcamp/wssrs/domain/Notice/service/UserNoticeService.java @@ -19,7 +19,6 @@ public class UserNoticeService { private final NoticeRepository noticeRepository; - private final RecruitService recruitService; // 공고 목록 public List findAll() {