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
package com.talentcard.server.talentcard;
 
import com.talentcard.server.common.ApiResponse;
import jakarta.validation.Valid;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
 
@RestController
@RequestMapping("/api/talent-cards")
public class TalentCardController {
 
    private final TalentCardService talentCardService;
 
    public TalentCardController(TalentCardService talentCardService) {
        this.talentCardService = talentCardService;
    }
 
    @PostMapping
    @ResponseStatus(HttpStatus.CREATED)
    public ApiResponse<TalentCardResponse> create(@Valid @RequestBody TalentCardRequest request) {
        return ApiResponse.success(talentCardService.create(request));
    }
 
    @GetMapping("/{id}")
    public ApiResponse<TalentCardResponse> getById(@PathVariable Long id) {
        return ApiResponse.success(talentCardService.getById(id));
    }
 
    @GetMapping
    public ApiResponse<Page<TalentCardResponse>> page(@PageableDefault(size = 20) Pageable pageable) {
        return ApiResponse.success(talentCardService.page(pageable));
    }
}