Skip to content

Commit

Permalink
feat: 전체 사용자 조회 API 구현 (#448)
Browse files Browse the repository at this point in the history
* chore: 임시 API 삭제

* feat: 전체 사용자 조회 API 구현

* chore: 기존 멘션 사용자 조회 API deprecated 처리
  • Loading branch information
mikekks authored Oct 13, 2024
1 parent 2f94ddf commit ce20f79
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.sopt.makers.crew.main.global.dto.TempResponseDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllMeetingByUserMeetingDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllMentionUserDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllUserDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAppliedMeetingByUserResponseDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetCreatedMeetingByUserResponseDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetUserOwnProfileResponseDto;
Expand All @@ -34,21 +35,18 @@ public interface UserV2Api {
@ApiResponse(responseCode = "200", description = "성공")})
ResponseEntity<List<UserV2GetAllMentionUserDto>> getAllMentionUser(Principal principal);

@Operation(summary = "유저 본인 프로필 조회")
@ResponseStatus(HttpStatus.OK)
@Operation(summary = "전체 사용자 조회")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "400", description = "해당 유저가 없는 경우", content = @Content),
})
ResponseEntity<UserV2GetUserOwnProfileResponseDto> getUserOwnProfile(Principal principal);
@ApiResponse(responseCode = "200", description = "성공")})
ResponseEntity<List<UserV2GetAllUserDto>> getAllUser(Principal principal);

@Operation(summary = "[TEMP] 유저 본인 프로필 조회")
@Operation(summary = "유저 본인 프로필 조회")
@ResponseStatus(HttpStatus.OK)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "400", description = "해당 유저가 없는 경우", content = @Content),
})
ResponseEntity<TempResponseDto<UserV2GetUserOwnProfileResponseDto>> getUserOwnProfileTemp(Principal principal);
ResponseEntity<UserV2GetUserOwnProfileResponseDto> getUserOwnProfile(Principal principal);

@Operation(summary = "내가 신청한 모임 조회")
@ResponseStatus(HttpStatus.OK)
Expand All @@ -58,14 +56,6 @@ public interface UserV2Api {
ResponseEntity<UserV2GetAppliedMeetingByUserResponseDto> getAppliedMeetingByUser(
Principal principal);

@Operation(summary = "[TEMP] 내가 신청한 모임 조회")
@ResponseStatus(HttpStatus.OK)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공")
})
ResponseEntity<TempResponseDto<UserV2GetAppliedMeetingByUserResponseDto>> getAppliedMeetingByUserTemp(
Principal principal);

@Operation(summary = "내가 만든 모임 조회")
@ResponseStatus(HttpStatus.OK)
@ApiResponses(value = {
Expand All @@ -74,12 +64,5 @@ ResponseEntity<TempResponseDto<UserV2GetAppliedMeetingByUserResponseDto>> getApp
ResponseEntity<UserV2GetCreatedMeetingByUserResponseDto> getCreatedMeetingByUser(
Principal principal);

@Operation(summary = "[TEMP] 내가 만든 모임 조회")
@ResponseStatus(HttpStatus.OK)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공")
})
ResponseEntity<TempResponseDto<UserV2GetCreatedMeetingByUserResponseDto>> getCreatedMeetingByUserTemp(
Principal principal);

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import lombok.RequiredArgsConstructor;

import org.sopt.makers.crew.main.global.dto.TempResponseDto;
import org.sopt.makers.crew.main.global.util.UserUtil;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllMeetingByUserMeetingDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllMentionUserDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllUserDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAppliedMeetingByUserResponseDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetCreatedMeetingByUserResponseDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetUserOwnProfileResponseDto;
Expand All @@ -30,13 +30,14 @@ public class UserV2Controller implements UserV2Api {
@GetMapping("/meeting/all")
@ResponseStatus(HttpStatus.OK)
public ResponseEntity<List<UserV2GetAllMeetingByUserMeetingDto>> getAllMeetingByUser(
Principal principal) {
Integer userId = UserUtil.getUserId(principal);
return ResponseEntity.ok(userV2Service.getAllMeetingByUser(userId));
Principal principal) {
Integer userId = UserUtil.getUserId(principal);
return ResponseEntity.ok(userV2Service.getAllMeetingByUser(userId));
}

@Override
@GetMapping("/mention")
@Deprecated
public ResponseEntity<List<UserV2GetAllMentionUserDto>> getAllMentionUser(
Principal principal) {

Expand All @@ -45,19 +46,18 @@ public ResponseEntity<List<UserV2GetAllMentionUserDto>> getAllMentionUser(
}

@Override
@GetMapping("/profile/me")
public ResponseEntity<UserV2GetUserOwnProfileResponseDto> getUserOwnProfile(Principal principal) {
@GetMapping
public ResponseEntity<List<UserV2GetAllUserDto>> getAllUser(Principal principal) {

Integer userId = UserUtil.getUserId(principal);
return ResponseEntity.ok().body(userV2Service.getUserOwnProfile(userId));
return ResponseEntity.ok(userV2Service.getAllUser());
}

@Override
@GetMapping("/profile/me/temp")
public ResponseEntity<TempResponseDto<UserV2GetUserOwnProfileResponseDto>> getUserOwnProfileTemp(
Principal principal) {
@GetMapping("/profile/me")
public ResponseEntity<UserV2GetUserOwnProfileResponseDto> getUserOwnProfile(Principal principal) {

Integer userId = UserUtil.getUserId(principal);
return ResponseEntity.ok().body(TempResponseDto.of(userV2Service.getUserOwnProfile(userId)));
return ResponseEntity.ok().body(userV2Service.getUserOwnProfile(userId));
}

@Override
Expand All @@ -68,14 +68,6 @@ public ResponseEntity<UserV2GetAppliedMeetingByUserResponseDto> getAppliedMeetin
return ResponseEntity.ok().body(userV2Service.getAppliedMeetingByUser(userId));
}

@Override
@GetMapping("/apply/temp")
public ResponseEntity<TempResponseDto<UserV2GetAppliedMeetingByUserResponseDto>> getAppliedMeetingByUserTemp(
Principal principal) {
Integer userId = UserUtil.getUserId(principal);
return ResponseEntity.ok().body(TempResponseDto.of(userV2Service.getAppliedMeetingByUser(userId)));
}

@Override
@GetMapping("/meeting")
public ResponseEntity<UserV2GetCreatedMeetingByUserResponseDto> getCreatedMeetingByUser(Principal principal) {
Expand All @@ -84,12 +76,4 @@ public ResponseEntity<UserV2GetCreatedMeetingByUserResponseDto> getCreatedMeetin
return ResponseEntity.ok().body(userV2Service.getCreatedMeetingByUser(userId));
}

@Override
@GetMapping("/meeting/temp")
public ResponseEntity<TempResponseDto<UserV2GetCreatedMeetingByUserResponseDto>> getCreatedMeetingByUserTemp(
Principal principal) {
Integer userId = UserUtil.getUserId(principal);
return ResponseEntity.ok().body(TempResponseDto.of(userV2Service.getCreatedMeetingByUser(userId)));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.sopt.makers.crew.main.user.v2.dto.response;

import org.sopt.makers.crew.main.entity.user.User;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;

@Schema(name = "UserV2GetAllUserDto", description = "전체 사용자 조회 응답 Dto")
public record UserV2GetAllUserDto(
@Schema(description = "크루에서 사용하는 userId", example = "103")
@NotNull
Integer userId,
@Schema(description = "메이커스 프로덕트에서 범용적으로 사용하는 userId", example = "403")
@NotNull
Integer orgId,

@Schema(description = "유저 이름", example = "홍길동")
@NotNull
String userName,

@Schema(description = "최근 파트", example = "서버")
@NotNull
String recentPart,

@Schema(description = "최근 기수", example = "33")
@NotNull
int recentGeneration,

@Schema(description = "유저 프로필 사진", example = "[url] 형식")
String profileImageUrl
) {
public static UserV2GetAllUserDto of(User user) {
return new UserV2GetAllUserDto(user.getId(), user.getOrgId(), user.getName(),
user.getRecentActivityVO().getPart(), user.getRecentActivityVO().getGeneration(), user.getProfileImage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.sopt.makers.crew.main.entity.user.User;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllMeetingByUserMeetingDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllMentionUserDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllUserDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAppliedMeetingByUserResponseDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetCreatedMeetingByUserResponseDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetUserOwnProfileResponseDto;
Expand All @@ -15,6 +16,8 @@ public interface UserV2Service {

List<UserV2GetAllMentionUserDto> getAllMentionUser();

List<UserV2GetAllUserDto> getAllUser();

UserV2GetUserOwnProfileResponseDto getUserOwnProfile(Integer userId);

UserV2GetAppliedMeetingByUserResponseDto getAppliedMeetingByUser(Integer userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.sopt.makers.crew.main.user.v2.dto.response.MeetingV2GetCreatedMeetingByUserResponseDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllMeetingByUserMeetingDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllMentionUserDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAllUserDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetAppliedMeetingByUserResponseDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetCreatedMeetingByUserResponseDto;
import org.sopt.makers.crew.main.user.v2.dto.response.UserV2GetUserOwnProfileResponseDto;
Expand Down Expand Up @@ -73,6 +74,17 @@ public List<UserV2GetAllMentionUserDto> getAllMentionUser() {
.toList();
}

@Override
public List<UserV2GetAllUserDto> getAllUser() {

List<User> users = userRepository.findAll();

return users.stream()
.filter(user -> user.getActivities() != null)
.map(UserV2GetAllUserDto::of)
.toList();
}

@Override
public UserV2GetUserOwnProfileResponseDto getUserOwnProfile(Integer userId) {
User user = userRepository.findByIdOrThrow(userId);
Expand Down

0 comments on commit ce20f79

Please sign in to comment.