lyh
5 天以前 fda571324684bc8d0945b3e2841305b1207fc3e9
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
67
68
69
70
71
72
73
74
package com.lxzn.base.controller;
 
import com.lxzn.api.base.MultilevelDictionaryControllerApi;
import com.lxzn.base.service.IMultilevelDictionaryService;
import com.lxzn.framework.domain.base.MultilevelDictionary;
import com.lxzn.framework.domain.base.ext.MultilevelDictionaryExt;
import com.lxzn.framework.domain.base.request.MultilevelDictionaryRequest;
import com.lxzn.framework.model.response.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.Collections;
import java.util.List;
 
@RestController
@RequestMapping("/multilevel/dictionary")
public class MultilevelDictionaryController implements MultilevelDictionaryControllerApi {
    @Autowired
    private IMultilevelDictionaryService multilevelDictionaryService;
 
    @Override
    @PostMapping("/add")
    public ResponseResult addDictionary(@RequestBody MultilevelDictionary dictionary) {
        boolean b = multilevelDictionaryService.addDictionary(dictionary);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    @Override
    @GetMapping("/find/page/{page}/{size}")
    public QueryPageResponseResult<MultilevelDictionary> findPageList(@PathVariable("page") int page,@PathVariable("size") int size, MultilevelDictionaryRequest multilevelRequest) {
        return multilevelDictionaryService.findByPageList(page, size, multilevelRequest);
    }
 
    @Override
    @GetMapping("/load/tree")
    public QueryListResponseResult<CommonJsonTree> loadTree() {
        List<CommonJsonTree> tree = multilevelDictionaryService.loadTree();
        if(tree == null)
            tree = Collections.emptyList();
        return new QueryListResponseResult(CommonCode.SUCCESS, tree);
    }
 
    @Override
    @PutMapping("/edit/{id}")
    public ResponseResult editDictionary(@PathVariable("id") String id,@RequestBody MultilevelDictionary dictionary) {
        boolean b = multilevelDictionaryService.editDictionary(id,dictionary);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    @Override
    @DeleteMapping("/delete")
    public ResponseResult deleteDictionary(@RequestParam("id") String id) {
        boolean b = multilevelDictionaryService.deleteDictionaryById(id);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    @Override
    @GetMapping("/find/select/list")
    public QueryListResponseResult<MultilevelDictionaryExt> findListByTypeCode(@RequestParam("typeCode") String typeCode) {
        List<MultilevelDictionaryExt>  list = multilevelDictionaryService.findListByTypeCode(typeCode);
        if(list == null)
            list = Collections.emptyList();
        return new QueryListResponseResult(CommonCode.SUCCESS, list);
    }
}