-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointAPI.java
More file actions
66 lines (63 loc) · 1.82 KB
/
PointAPI.java
File metadata and controls
66 lines (63 loc) · 1.82 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.hcmutap.elearning.controller.api;
import com.hcmutap.elearning.exception.NotFoundException;
import com.hcmutap.elearning.model.PointModel;
import com.hcmutap.elearning.service.IPointService;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api")
public class PointAPI {
private static final Logger logger = LoggerFactory.getLogger(PointAPI.class);
@Resource
private IPointService pointService;
@GetMapping("/points/findAll")
public List<PointModel> findAll() {
try{
return pointService.findAll();
}catch (Exception e) {
// throw new RuntimeException(e);
logger.error(String.valueOf(new RuntimeException(e)));
return null;
}
}
@GetMapping("/points/findById")
public PointModel findById(@RequestParam String id) {
try {
return pointService.findById(id);
} catch (NotFoundException e) {
// throw new RuntimeException(e);
logger.error(String.valueOf(new RuntimeException(e)));
return null;
}
}
@PostMapping("/points")
public void save(@RequestBody PointModel pointModel) {
try{
pointService.save(pointModel);
}catch (Exception e) {
// throw new RuntimeException(e);
logger.error(String.valueOf(new RuntimeException(e)));
}
}
@PutMapping("/points")
public void update(@RequestBody PointModel pointModel) {
try {
pointService.update(pointModel);
} catch (NotFoundException e) {
// throw new RuntimeException(e);
logger.error(String.valueOf(new RuntimeException(e)));
}
}
@DeleteMapping("/points")
public void delete(@RequestBody List<String> ids) {
try {
pointService.delete(ids);
} catch (NotFoundException e) {
// throw new RuntimeException(e);
logger.error(String.valueOf(new RuntimeException(e)));
}
}
}