lyh
10 小时以前 371365543363969fd3afcc404440c838817ecc3d
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
package com.lxzn.base.controller;
 
import com.lxzn.api.base.SingleDictionaryControllerApi;
import com.lxzn.base.service.ISingleDictionaryService;
import com.lxzn.framework.domain.base.SingleDictionary;
import com.lxzn.framework.domain.base.request.SingleDictionaryRequest;
import com.lxzn.framework.model.response.CommonCode;
import com.lxzn.framework.model.response.QueryListResponseResult;
import com.lxzn.framework.model.response.QueryPageResponseResult;
import com.lxzn.framework.model.response.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.Collections;
import java.util.List;
 
@RestController
@RequestMapping("/base/single")
public class SingleDictionaryController implements SingleDictionaryControllerApi {
    @Autowired
    private ISingleDictionaryService dictionaryService;
 
    @Override
    @PostMapping("/add")
    public ResponseResult addDictionary(@RequestBody SingleDictionary dictionary) {
        boolean b = dictionaryService.addDictionary(dictionary);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    @Override
    @GetMapping("/find/page/{page}/{size}")
    public QueryPageResponseResult<SingleDictionary> findPageList(@PathVariable("page") int page, @PathVariable("size") int size, SingleDictionaryRequest requestParams) {
        return dictionaryService.findPageList(page, size, requestParams);
    }
 
    @Override
    @PutMapping("/edit/{id}")
    public ResponseResult editDictionary(@PathVariable("id") String id,@RequestBody SingleDictionary dictionary) {
        boolean b = dictionaryService.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 = dictionaryService.deleteDictionaryById(id);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    @Override
    @GetMapping("/find/list")
    public QueryListResponseResult<SingleDictionary> findListByTypeCode(@RequestParam("typeCode") String typeCode) {
        List<SingleDictionary> list = dictionaryService.findListFromTypeCode(typeCode);
        if(list == null)
            list = Collections.emptyList();
        return new QueryListResponseResult(CommonCode.SUCCESS, list);
    }
}