-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleController.java
More file actions
33 lines (26 loc) · 1.1 KB
/
ExampleController.java
File metadata and controls
33 lines (26 loc) · 1.1 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
package com.project.example.controller;
import org.springframework.http.ResponseEntity;
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.RestController;
import com.project.example.controller.dto.SaveExampleRequest;
import com.project.example.infra.entity.ExampleEntity;
import com.project.example.service.ExampleService;
import lombok.RequiredArgsConstructor;
@RestController
@RequestMapping("/example")
@RequiredArgsConstructor
public class ExampleController {
private final ExampleService exampleService;
@GetMapping("/{exampleId}")
public ResponseEntity<ExampleEntity> find(@PathVariable Long exampleId) {
return ResponseEntity.ok(exampleService.find(exampleId));
}
@PostMapping
public void save(@RequestBody SaveExampleRequest request) {
exampleService.save(request);
}
}