Skip to content

Commit

Permalink
Merge pull request #92 from Leets-Official/feat/#90/전역-내정보-조회
Browse files Browse the repository at this point in the history
Feat #92 전역 내정보 조회
  • Loading branch information
hyxklee authored Dec 30, 2024
2 parents b9ace1f + 316fb17 commit f7ad810
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 8 deletions.
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) {
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);
}
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

0 comments on commit f7ad810

Please sign in to comment.