DictionaryController.java
2.53 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 vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import vion.Global;
import vion.dto.DictionaryDTO;
import vion.dto.DictionaryTypeDTO;
import vion.model.Dictionary;
import vion.model.DictionaryType;
import vion.service.IDictionaryService;
import vion.service.IDictionaryTypeService;
@RestController
@RequestMapping(Global.BASE_URL)
@RequiredArgsConstructor
@Slf4j
public class DictionaryController {
private final IDictionaryService dictionaryService;
private final IDictionaryTypeService dictionaryTypeService;
private final Converter converter;
@GetMapping("/dictionarys")
@SaCheckPermission(value = "dict:list", orRole="admin")
public Page<Dictionary> getDictionaryList(DictionaryDTO data) {
return dictionaryService.lambdaQuery(converter.convert(data, new Dictionary()))
.page(Page.of(data.getPageNum(), data.getPageSize()));
}
@GetMapping("/dictionary")
@SaCheckPermission(value = "dict:query", orRole="admin")
public Object getDictionaryByID(@RequestParam(name = "id") Integer id) {
return dictionaryService.getById(id);
}
@PostMapping("/dictionary")
@SaCheckPermission(value = "dict:editAndSave", orRole="admin")
public String saveOrUpdateDictionary(@RequestBody DictionaryDTO data) {
Dictionary dictionary = converter.convert(data, new Dictionary());
return dictionaryService.saveOrUpdate(dictionary) ? "成功" : "失败";
}
@GetMapping("/dictionaryTypes")
@SaCheckPermission("dict:type:list")
public Page<DictionaryType> getDictionaryTypeList(DictionaryTypeDTO data) {
return dictionaryTypeService.lambdaQuery(converter.convert(data, new DictionaryType()))
.page(Page.of(data.getPageNum(), data.getPageSize()));
}
@GetMapping("/dictionaryType")
@SaCheckPermission("dict:type:query")
public Object getDictionaryTypeByID(@RequestParam Integer id) {
return dictionaryTypeService.getById(id);
}
@PostMapping("/dictionaryType")
@SaCheckPermission("dict:type:editAndSave")
public String saveOrUpdateDictionaryType(@RequestBody DictionaryTypeDTO data) {
DictionaryType dictionaryType = converter.convert(data, new DictionaryType());
return dictionaryTypeService.saveOrUpdate(dictionaryType) ? "成功" : "失败";
}
}