Skip to content

Commit

Permalink
Merge pull request #89 from 0702Yoon/main
Browse files Browse the repository at this point in the history
상세 조회, 유저 전체 조회
  • Loading branch information
0702Yoon authored Aug 14, 2024
2 parents 18fc3f0 + ae03679 commit f7e20b1
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public interface MemberController {
@Operation(summary = "test용", description = "현재는 로그인 멤버의 AffiliationRoleLost를 가져오는 값")
ResponseEntity<com.example.bigbrotherbe.global.exception.response.ApiResponse<AffiliationListDto>> test();

@GetMapping("/member-information")
@GetMapping("/information")
@Operation(summary = "유저 상세 정보 조회")
ResponseEntity<com.example.bigbrotherbe.global.exception.response.ApiResponse<MemberInfoResponse>> inquireMemberInfo();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,10 @@ public ResponseEntity<ApiResponse<MemberInfoResponse>> changeMemberInfo(
MemberInfoChangeRequest memberInfoChangeRequest) {
return ResponseEntity.ok(ApiResponse.success(SUCCESS,memberService.changeMemberInfo(memberInfoChangeRequest.userName())));
}

@Override
public ResponseEntity<ApiResponse<List<MemberInfoResponse>>> inquireAllUserInfo() {

return ResponseEntity.ok(ApiResponse.success(SUCCESS,memberService.inquireAllMemberInfo()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ public interface MemberService {
void deleteSelf();

MemberInfoResponse changeMemberInfo(String userName);

List<MemberInfoResponse> inquireAllMemberInfo();
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
Expand Down Expand Up @@ -259,6 +260,22 @@ public MemberInfoResponse changeMemberInfo(String username) {
.build();
}

@Override
public List<MemberInfoResponse> inquireAllMemberInfo() {
List<MemberInfoResponse> memberInfoResponseList = new ArrayList<>();
for(Member member: memberLoader.getAllMember()){
memberInfoResponseList.add(MemberInfoResponse
.builder()
.email(member.getEmail())
.memberName(member.getUsername())
.createAt(member.getCreateAt())
.updateAt(member.getUpdateAt())
.affiliationListDto(getMemberAffiliationRoleList())
.build());
}
return memberInfoResponseList;
}


@Override
public AffiliationListDto getMemberAffiliationRoleList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.example.bigbrotherbe.domain.member.repository.MemberRepository;
import com.example.bigbrotherbe.global.exception.BusinessException;
import com.example.bigbrotherbe.global.exception.enums.ErrorCode;
import java.util.List;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -41,4 +42,7 @@ public Optional<Member> findByMemberEmailForCheck(String memberEmail) {
return memberRepository.findByEmail(memberEmail);
}

public List<Member> getAllMember() {
return memberRepository.findAll();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
// USER 권한이 있어야 요청할 수 있음
.requestMatchers(SERVER+"/members/test").hasAnyRole("ADMIN","USER")
.requestMatchers(SERVER+"/members").hasAnyRole("ADMIN","USER")
.requestMatchers(SERVER+"/members/information").hasAnyRole("ADMIN","USER")
// 유저 어드민 권한이 있어야 요청할 수 있음
.requestMatchers(SERVER+"/members/password").hasAnyRole("ADMIN","USER")
.requestMatchers(SERVER+"/members/manager").hasRole("ADMIN")
.requestMatchers(SERVER+"members/information").hasAnyRole("ADMIN","USER")
// 이 밖에 모든 요청에 대해서 인증을 필요로 한다는 설정
.anyRequest().permitAll()
)
Expand Down

0 comments on commit f7e20b1

Please sign in to comment.