-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBatchDetailsController.java
More file actions
37 lines (27 loc) · 1.09 KB
/
BatchDetailsController.java
File metadata and controls
37 lines (27 loc) · 1.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
package com.example.demo.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
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.example.demo.dao.BatchDetailsRepo;
import com.example.demo.entity.BatchDetails;
@Controller
@RestController
@RequestMapping(value = "/rest/BatchDetails")
public class BatchDetailsController {
@Autowired
BatchDetailsRepo repo1;
@GetMapping(value = "/all")
public List<BatchDetails> getAll() {
return (List<BatchDetails>) repo1.findAll();
}
@PostMapping(value = "/load")
public List<BatchDetails> persist(@RequestBody final BatchDetails batchDetails) {
repo1.save(batchDetails);
return (List<BatchDetails>) repo1.findAll();
}
}