forked from solid-connection/solid-connect-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyPageController.java
More file actions
62 lines (54 loc) · 2.32 KB
/
MyPageController.java
File metadata and controls
62 lines (54 loc) · 2.32 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
package com.example.solidconnection.siteuser.controller;
import com.example.solidconnection.common.resolver.AuthorizedUser;
import com.example.solidconnection.siteuser.dto.LocationUpdateRequest;
import com.example.solidconnection.siteuser.dto.MyPageResponse;
import com.example.solidconnection.siteuser.dto.PasswordUpdateRequest;
import com.example.solidconnection.siteuser.service.MyPageService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
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 org.springframework.web.multipart.MultipartFile;
@RequiredArgsConstructor
@RequestMapping("/my")
@RestController
class MyPageController {
private final MyPageService myPageService;
@GetMapping
public ResponseEntity<MyPageResponse> getMyPageInfo(
@AuthorizedUser long siteUserId
) {
MyPageResponse myPageResponse = myPageService.getMyPageInfo(siteUserId);
return ResponseEntity.ok(myPageResponse);
}
@PatchMapping
public ResponseEntity<Void> updateMyPageInfo(
@AuthorizedUser long siteUserId,
@RequestParam(value = "file", required = false) MultipartFile imageFile,
@RequestParam(value = "nickname", required = false) String nickname
) {
myPageService.updateMyPageInfo(siteUserId, imageFile, nickname);
return ResponseEntity.ok().build();
}
@PatchMapping("/password")
public ResponseEntity<Void> updatePassword(
@AuthorizedUser long siteUserId,
@RequestBody @Valid PasswordUpdateRequest request
) {
myPageService.updatePassword(siteUserId, request);
return ResponseEntity.ok().build();
}
@PatchMapping("/interested-location")
public ResponseEntity<Void> updateLocation(
@AuthorizedUser long siteUserId,
@RequestBody @Valid LocationUpdateRequest request
) {
myPageService.updateLocation(siteUserId, request);
return ResponseEntity.ok().build();
}
}