Skip to content

Commit a04478b

Browse files
committed
init get list
1 parent 08d0d3b commit a04478b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/main/java/com/jap/rest101/controller/UserController.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
import com.jap.rest101.db.repository.UserRepository;
55
import lombok.RequiredArgsConstructor;
66
import org.springframework.http.ResponseEntity;
7-
import org.springframework.web.bind.annotation.PostMapping;
8-
import org.springframework.web.bind.annotation.RequestBody;
9-
import org.springframework.web.bind.annotation.RequestMapping;
10-
import org.springframework.web.bind.annotation.RestController;
7+
import org.springframework.web.bind.annotation.*;
8+
9+
import java.util.List;
1110

1211
@RestController
1312
@RequestMapping("/users")
@@ -21,5 +20,11 @@ public ResponseEntity<User> createUser(@RequestBody User user) {
2120
repository.save(user);
2221
return ResponseEntity.ok(user);
2322
}
23+
24+
@GetMapping
25+
public ResponseEntity<List<User>> listUser() {
26+
List<User> users = repository.findAll();
27+
return ResponseEntity.ok(users);
28+
}
2429
}
2530

0 commit comments

Comments
 (0)