diff --git a/src/main/java/com/smunity/server/domain/member/controller/MemberController.java b/src/main/java/com/smunity/server/domain/member/controller/MemberController.java index 5198d92..1549e9d 100644 --- a/src/main/java/com/smunity/server/domain/member/controller/MemberController.java +++ b/src/main/java/com/smunity/server/domain/member/controller/MemberController.java @@ -2,6 +2,7 @@ import com.smunity.server.domain.member.dto.ChangePasswordRequestDto; import com.smunity.server.domain.member.dto.MemberInfoResponseDto; +import com.smunity.server.domain.member.dto.MemberResponseDto; import com.smunity.server.domain.member.service.MemberCommandService; import com.smunity.server.domain.member.service.MemberQueryService; import com.smunity.server.global.security.annotation.AuthMember; @@ -23,8 +24,8 @@ public class MemberController { private final MemberCommandService memberCommandService; @GetMapping - public ResponseEntity> readMembers(@ParameterObject Pageable pageable) { - Page responseDtoPage = memberQueryService.readMembers(pageable); + public ResponseEntity> readMembers(@ParameterObject Pageable pageable) { + Page responseDtoPage = memberQueryService.readMembers(pageable); return ResponseEntity.ok(responseDtoPage); } diff --git a/src/main/java/com/smunity/server/domain/member/dto/MemberInfoResponseDto.java b/src/main/java/com/smunity/server/domain/member/dto/MemberInfoResponseDto.java index b2824a7..daa0d99 100644 --- a/src/main/java/com/smunity/server/domain/member/dto/MemberInfoResponseDto.java +++ b/src/main/java/com/smunity/server/domain/member/dto/MemberInfoResponseDto.java @@ -1,32 +1,24 @@ package com.smunity.server.domain.member.dto; import com.smunity.server.global.common.entity.Member; -import com.smunity.server.global.common.entity.enums.MemberRole; import lombok.Builder; -import org.springframework.data.domain.Page; - -import java.time.LocalDateTime; @Builder public record MemberInfoResponseDto( Long id, String username, - MemberRole memberRole, - LocalDateTime createdAt, - LocalDateTime updatedAt + String name, + String department, + String email ) { public static MemberInfoResponseDto from(Member member) { return MemberInfoResponseDto.builder() .id(member.getId()) .username(member.getUsername()) - .memberRole(member.getRole()) - .createdAt(member.getCreatedAt()) - .updatedAt(member.getUpdatedAt()) + .name(member.getName()) + .department(member.getDepartment().getName()) + .email(member.getEmail()) .build(); } - - public static Page from(Page memberPage) { - return memberPage.map(MemberInfoResponseDto::from); - } } diff --git a/src/main/java/com/smunity/server/domain/member/dto/MemberResponseDto.java b/src/main/java/com/smunity/server/domain/member/dto/MemberResponseDto.java new file mode 100644 index 0000000..a25402a --- /dev/null +++ b/src/main/java/com/smunity/server/domain/member/dto/MemberResponseDto.java @@ -0,0 +1,38 @@ +package com.smunity.server.domain.member.dto; + +import com.smunity.server.global.common.entity.Member; +import com.smunity.server.global.common.entity.enums.MemberRole; +import lombok.Builder; +import org.springframework.data.domain.Page; + +import java.time.LocalDateTime; + +@Builder +public record MemberResponseDto( + Long id, + String username, + String name, + String department, + String email, + MemberRole memberRole, + LocalDateTime createdAt, + LocalDateTime updatedAt +) { + + public static MemberResponseDto from(Member member) { + return MemberResponseDto.builder() + .id(member.getId()) + .username(member.getUsername()) + .name(member.getName()) + .department(member.getDepartment().getName()) + .email(member.getEmail()) + .memberRole(member.getRole()) + .createdAt(member.getCreatedAt()) + .updatedAt(member.getUpdatedAt()) + .build(); + } + + public static Page from(Page memberPage) { + return memberPage.map(MemberResponseDto::from); + } +} diff --git a/src/main/java/com/smunity/server/domain/member/service/MemberQueryService.java b/src/main/java/com/smunity/server/domain/member/service/MemberQueryService.java index 5cb1f48..27cfa87 100644 --- a/src/main/java/com/smunity/server/domain/member/service/MemberQueryService.java +++ b/src/main/java/com/smunity/server/domain/member/service/MemberQueryService.java @@ -1,6 +1,7 @@ package com.smunity.server.domain.member.service; import com.smunity.server.domain.member.dto.MemberInfoResponseDto; +import com.smunity.server.domain.member.dto.MemberResponseDto; import com.smunity.server.global.common.entity.Member; import com.smunity.server.global.common.repository.MemberRepository; import com.smunity.server.global.exception.GeneralException; @@ -18,9 +19,9 @@ public class MemberQueryService { private final MemberRepository memberRepository; - public Page readMembers(Pageable pageable) { + public Page readMembers(Pageable pageable) { Page memberPage = memberRepository.findAll(pageable); - return MemberInfoResponseDto.from(memberPage); + return MemberResponseDto.from(memberPage); } public MemberInfoResponseDto readMember(Long memberId) {