-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUserController.java
More file actions
120 lines (106 loc) · 4.82 KB
/
UserController.java
File metadata and controls
120 lines (106 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package com.example.RealMatch.user.presentation.controller;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.example.RealMatch.global.config.jwt.CustomUserDetails;
import com.example.RealMatch.global.presentation.CustomResponse;
import com.example.RealMatch.match.presentation.dto.request.MatchRequestDto;
import com.example.RealMatch.user.application.service.UserFeatureService;
import com.example.RealMatch.user.application.service.UserService;
import com.example.RealMatch.user.presentation.dto.request.MyEditInfoRequestDto;
import com.example.RealMatch.user.presentation.dto.response.MyEditInfoResponseDto;
import com.example.RealMatch.user.presentation.dto.response.MyFeatureResponseDto;
import com.example.RealMatch.user.presentation.dto.response.MyLoginResponseDto;
import com.example.RealMatch.user.presentation.dto.response.MyPageResponseDto;
import com.example.RealMatch.user.presentation.dto.response.MyProfileCardResponseDto;
import com.example.RealMatch.user.presentation.dto.response.MyScrapResponseDto;
import com.example.RealMatch.user.presentation.dto.response.NicknameAvailableResponseDto;
import com.example.RealMatch.user.presentation.swagger.UserSwagger;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
@Tag(name = "user", description = "유저 API")
@RestController
@RequestMapping("/api/v1/users")
@RequiredArgsConstructor
public class UserController implements UserSwagger {
private final UserService userService;
private final UserFeatureService userFeatureService;
@Override
@GetMapping("/me")
public CustomResponse<MyPageResponseDto> getMyPage(
@AuthenticationPrincipal CustomUserDetails userDetails
) {
return CustomResponse.ok(userService.getMyPage(userDetails.getUserId()));
}
@Override
@GetMapping("/me/profile-card")
public CustomResponse<MyProfileCardResponseDto> getMyProfileCard(
@AuthenticationPrincipal CustomUserDetails userDetails
) {
return CustomResponse.ok(
userService.getMyProfileCard(userDetails.getUserId())
);
}
@Override
@GetMapping("/me/scrap")
public CustomResponse<MyScrapResponseDto> getMyScrap(
@AuthenticationPrincipal CustomUserDetails userDetails,
@RequestParam String type,
@RequestParam(required = false, defaultValue = "matchingRate") String sort
) {
return CustomResponse.ok(userService.getMyScrap(userDetails.getUserId(), type, sort));
}
@Override
@GetMapping("/me/edit")
public CustomResponse<MyEditInfoResponseDto> getMyEditInfo(
@AuthenticationPrincipal CustomUserDetails userDetails
) {
return CustomResponse.ok(userService.getMyEditInfo(userDetails.getUserId()));
}
@PostMapping("/me/edit")
public CustomResponse<Void> updateMyInfo(
@AuthenticationPrincipal CustomUserDetails userDetails,
@Valid @RequestBody MyEditInfoRequestDto request
) {
userService.updateMyInfo(userDetails.getUserId(), request);
return CustomResponse.ok(null);
}
@Override
@GetMapping("/me/social-login")
public CustomResponse<MyLoginResponseDto> getSocialLoginInfo(
@AuthenticationPrincipal CustomUserDetails userDetails
) {
return CustomResponse.ok(userService.getSocialLoginInfo(userDetails.getUserId()));
}
@Override
@GetMapping("/me/feature")
public CustomResponse<MyFeatureResponseDto> getMyFeature(
@AuthenticationPrincipal CustomUserDetails userDetails
) {
MyFeatureResponseDto response = userFeatureService.getMyFeatures(userDetails.getUserId());
return CustomResponse.ok(response);
}
@Override
@PatchMapping("/me/feature")
public CustomResponse<Void> updateMyFeature(
@AuthenticationPrincipal CustomUserDetails userDetails,
@RequestBody MatchRequestDto request
) {
userFeatureService.updateMyFeatures(userDetails.getUserId(), request);
return CustomResponse.ok(null);
}
@Override
@GetMapping("/nickname/available")
public CustomResponse<NicknameAvailableResponseDto> checkNicknameAvailable(
@RequestParam String nickname
) {
boolean available = userService.isNicknameAvailable(nickname);
return CustomResponse.ok(new NicknameAvailableResponseDto(available));
}
}