-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from Media-XI/feat/member-조회-관련-api
Feat/member 조회 관련 api
- Loading branch information
Showing
7 changed files
with
391 additions
and
228 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
31 changes: 31 additions & 0 deletions
31
src/main/java/com/example/codebase/domain/member/dto/MembersResponseDTO.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 com.example.codebase.domain.member.dto; | ||
|
||
import com.example.codebase.controller.dto.PageInfo; | ||
import com.example.codebase.domain.member.entity.Member; | ||
import lombok.Getter; | ||
import org.springframework.data.domain.Page; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
public class MembersResponseDTO { | ||
|
||
List<MemberResponseDTO> members; | ||
|
||
PageInfo pageInfo; | ||
|
||
public static MembersResponseDTO of (List<MemberResponseDTO> members, PageInfo pageInfo) { | ||
MembersResponseDTO dto = new MembersResponseDTO(); | ||
dto.members = members; | ||
dto.pageInfo = pageInfo; | ||
return dto; | ||
} | ||
|
||
public static MembersResponseDTO from(Page<Member> members) { | ||
PageInfo pageInfo = PageInfo.from(members); | ||
List<MemberResponseDTO> dtos = members.stream() | ||
.map(MemberResponseDTO::from) | ||
.toList(); | ||
return MembersResponseDTO.of(dtos, pageInfo); | ||
} | ||
} |
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
13 changes: 5 additions & 8 deletions
13
src/main/java/com/example/codebase/domain/member/entity/RoleStatus.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 |
---|---|---|
@@ -1,22 +1,19 @@ | ||
package com.example.codebase.domain.member.entity; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public enum RoleStatus { | ||
NONE, ARTIST_PENDING, ARTIST_REJECTED, ARTIST, CURATOR_PENDING, CURATOR_REJECTED, CURATOR; | ||
|
||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING) | ||
public static RoleStatus create(String value) { | ||
public static RoleStatus create(String roleStatus) { | ||
return Stream.of(RoleStatus.values()) | ||
.filter(status -> status.name().equals(value)) | ||
.findFirst() | ||
.orElseThrow(() -> new IllegalArgumentException("부적절한 미디어 타입입니다. 지원하는 형식 : " + | ||
Stream.of(RoleStatus.values()) | ||
.map(RoleStatus::name) | ||
.reduce((a, b) -> a + ", " + b) | ||
.get())); | ||
.filter(status -> status.name().equals(roleStatus)) | ||
.findFirst() | ||
.orElseThrow(() -> new IllegalArgumentException("부적절한 역할 상태 입니다.")); | ||
} | ||
|
||
} |
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
Oops, something went wrong.