Skip to content

Commit 1af64a9

Browse files
committed
Add get rest routes
1 parent e503288 commit 1af64a9

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/main/java/com/example/demo/domain/service/jdbc/RestServiceJdbcImpl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ public boolean insert(User user) {
2929
// 1件検索用メソッド
3030
@Override
3131
public User selectOne(String userId) {
32-
return null;
32+
return dao.selectOne(userId);
3333
}
3434

3535
// 全件検索用メソッド
3636
@Override
3737
public List<User> selectMany() {
38-
return null;
38+
return dao.selectMany();
3939
}
4040

4141
// 1件更新用メソッド
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
11
package com.example.demo.login.controller;
22

3+
import java.util.List;
4+
35
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.web.bind.annotation.GetMapping;
7+
import org.springframework.web.bind.annotation.PathVariable;
48
import org.springframework.web.bind.annotation.RestController;
59

10+
import com.example.demo.domain.model.User;
611
import com.example.demo.domain.service.RestService;
712

813

914
@RestController
1015
public class UserRestController {
1116
@Autowired
1217
RestService service;
18+
19+
// ユーザー全件取得
20+
@GetMapping("/rest/get")
21+
public List<User> getUserMany() {
22+
// ユーザー全件取得
23+
return service.selectMany();
24+
}
25+
26+
// ユーザー1件取得
27+
@GetMapping("/rest/get/{id:.+}")
28+
public User getUserOne(@PathVariable("id") String userId) {
29+
// ユーザー1件取得
30+
return service.selectOne(userId);
31+
}
1332
}

0 commit comments

Comments
 (0)