CaptionSetController.java
1.58 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
package com.viontech.storage.controller;
import com.viontech.storage.entity.Message;
import com.viontech.storage.model.CaptionSet;
import com.viontech.storage.service.CaptionSetService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2021/11/8
*/
@RestController
@RequestMapping("/captionSets")
public class CaptionSetController {
@Resource
private CaptionSetService captionSetService;
@GetMapping("/{id}")
public Message<CaptionSet> getById(@PathVariable("id") Long id) {
CaptionSet byId = captionSetService.getById(id);
return Message.success(byId);
}
@GetMapping
public Message<List<CaptionSet>> listAll() {
List<CaptionSet> list = captionSetService.list();
return Message.success(list);
}
@PostMapping
public Message<CaptionSet> add(@RequestBody CaptionSet captionSet) {
boolean save = captionSetService.save(captionSet);
if (save) {
return Message.success(captionSet);
} else {
return Message.error();
}
}
@PutMapping("/{id}")
public Message<CaptionSet> updateById(@PathVariable Long id, @RequestBody CaptionSet captionSet) {
captionSet.setId(id);
boolean b = captionSetService.updateById(captionSet);
return Message.success(captionSet);
}
@DeleteMapping("/{id}")
public Message<CaptionSet> deleteById(@PathVariable Long id) {
boolean b = captionSetService.removeById(id);
return Message.success();
}
}