-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathProfileController.java
More file actions
61 lines (48 loc) · 2.09 KB
/
ProfileController.java
File metadata and controls
61 lines (48 loc) · 2.09 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
package com.example.feeda.domain.profile.controller;
import com.example.feeda.domain.profile.dto.*;
import com.example.feeda.domain.profile.service.ProfileServiceImpl;
import com.example.feeda.security.jwt.JwtPayload;
import jakarta.validation.Valid;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api")
public class ProfileController {
private final ProfileServiceImpl profileService;
public ProfileController(ProfileServiceImpl profileService) {
this.profileService = profileService;
}
/**
* 프로필 단건 조회 API
*/
@GetMapping("/profiles/{id}")
public ResponseEntity<GetProfileWithFollowCountResponseDto> getProfile(@PathVariable Long id) {
GetProfileWithFollowCountResponseDto responseDto = profileService.getProfile(id);
return new ResponseEntity<>(responseDto, HttpStatus.OK);
}
/**
* 프로필 전체 조회 API (검색, 페이징)
*/
@GetMapping("/profiles")
public ResponseEntity<ProfileListResponseDto> getProfiles(
@RequestParam(required = false) String keyword,
@RequestParam(defaultValue = "1") int page,
@RequestParam(defaultValue = "10") int size) {
ProfileListResponseDto response = profileService.getProfiles(keyword, page, size);
return new ResponseEntity<>(response, HttpStatus.OK);
}
/**
* 프로필 전체 수정 API (검색, 페이징)
*/
@PutMapping("/profiles/{id}")
public ResponseEntity<UpdateProfileResponseDto> updateProfile(
@AuthenticationPrincipal JwtPayload jwtPayload,
@PathVariable Long id,
@Valid @RequestBody UpdateProfileRequestDto requestDto) {
Long accountId = jwtPayload.getAccountId();
UpdateProfileResponseDto responseDto = profileService.updateProfile(accountId, id, requestDto);
return new ResponseEntity<>(responseDto, HttpStatus.OK);
}
}