Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat #92 전역 내정보 조회 #92

Merged
merged 5 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public record SummaryResponse(
Integer id,
String name,
List<Integer> cardinals,
Position position
Position position,
Role role
) {
}

Expand Down Expand Up @@ -75,4 +76,12 @@ public record SocialAuthResponse(
Long kakaoId
) {
}

public record UserInfo(
Long id,
String name,
List<Integer> cardinals,
Role role
) {
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package leets.weeth.domain.user.application.mapper;

import leets.weeth.domain.user.application.dto.response.UserResponseDto.*;
import leets.weeth.domain.user.application.dto.response.UserResponseDto;
import leets.weeth.domain.user.application.dto.response.UserResponseDto.SummaryResponse;
import leets.weeth.domain.user.application.dto.response.UserResponseDto.UserResponse;
import leets.weeth.domain.user.domain.entity.User;
import leets.weeth.domain.user.domain.entity.enums.Department;
import leets.weeth.global.auth.jwt.application.dto.JwtDto;
Expand Down Expand Up @@ -56,6 +59,8 @@ public interface UserMapper {
})
UserResponse toUserResponse(User user);

UserResponseDto.UserInfo toUserInfoDto(User user);

default String toString(Department department) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기 엔터 하나만 있으면 좋을거같아요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정했습니당

return department.getValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ public interface UserUseCase {

JwtDto refresh(String refreshToken);

UserResponseDto.UserInfo findUserInfo(Long userId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ public JwtDto refresh(String refreshToken) {
return new JwtDto(token.accessToken(), token.refreshToken());
}

@Override
public UserResponseDto.UserInfo findUserInfo(Long userId) {
User user = userGetService.find(userId);

return mapper.toUserInfoDto(user);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 엔터 하나만,,,.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정했어욤

private long getKakaoId(Login dto) {
KakaoTokenResponse tokenResponse = kakaoAuthService.getKakaoToken(dto.authCode());
KakaoUserInfoResponse userInfo = kakaoAuthService.getUserInfo(tokenResponse.access_token());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import leets.weeth.domain.user.application.usecase.UserManageUseCase;
import leets.weeth.domain.user.application.usecase.UserUseCase;
import leets.weeth.global.common.response.CommonResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
Expand All @@ -22,41 +21,41 @@ public class UserAdminController {
private final UserManageUseCase userManageUseCase;

@GetMapping("/all")
@Operation(summary="어드민용 회원 조회")
@Operation(summary = "어드민용 회원 조회")
public CommonResponse<List<AdminResponse>> findAll() {
return CommonResponse.createSuccess(USER_FIND_ALL_SUCCESS.getMessage(), userManageUseCase.findAllByAdmin());
}

@PatchMapping
@Operation(summary="가입 신청 승인")
@Operation(summary = "가입 신청 승인")
public CommonResponse<Void> accept(@RequestParam Long userId) {
userManageUseCase.accept(userId);
return CommonResponse.createSuccess(USER_ACCEPT_SUCCESS.getMessage());
}

@DeleteMapping
@Operation(summary="유저 추방")
@Operation(summary = "유저 추방")
public CommonResponse<Void> ban(@RequestParam Long userId) {
userManageUseCase.ban(userId);
return CommonResponse.createSuccess(USER_BAN_SUCCESS.getMessage());
}

@PatchMapping("/role")
@Operation(summary="관리자로 승격/강등")
@Operation(summary = "관리자로 승격/강등")
public CommonResponse<Void> update(@RequestParam Long userId, @RequestParam String role) {
userManageUseCase.update(userId, role);
return CommonResponse.createSuccess(USER_ROLE_UPDATE_SUCCESS.getMessage());
}

@PatchMapping("/apply")
@Operation(summary="다음 기수도 이어서 진행")
@Operation(summary = "다음 기수도 이어서 진행")
public CommonResponse<Void> applyOB(@RequestParam Long userId, @RequestParam Integer cardinal) {
userManageUseCase.applyOB(userId, cardinal);
return CommonResponse.createSuccess(USER_APPLY_OB_SUCCESS.getMessage());
}

@PatchMapping("/reset")
@Operation(summary="회원 비밀번호 초기화")
@Operation(summary = "회원 비밀번호 초기화")
public CommonResponse<Void> resetPassword(@RequestParam Long userId) {
userManageUseCase.reset(userId);
return CommonResponse.createSuccess(USER_PASSWORD_RESET_SUCCESS.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ public CommonResponse<Response> find(@Parameter(hidden = true) @CurrentUser Long
return CommonResponse.createSuccess(USER_FIND_BY_ID_SUCCESS.getMessage(), userUseCase.find(userId));
}

@GetMapping("/info")
@Operation(summary = "전역 내 정보 조회 API")
public CommonResponse<UserResponseDto.UserInfo> findMyInfo(@Parameter(hidden = true) @CurrentUser Long userId) {
return CommonResponse.createSuccess(USER_FIND_BY_ID_SUCCESS.getMessage(), userUseCase.findUserInfo(userId));
}

@PatchMapping
@Operation(summary = "내 정보 수정")
public CommonResponse<Void> update(@RequestBody @Valid Update dto, @Parameter(hidden = true) @CurrentUser Long userId) {
Expand Down
Loading