111
k94314517
2025-03-19 19fd7785705f30d25c6c8e44b9356cc585af68cd
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package com.doumee.api.system;
 
import com.doumee.api.BaseController;
import com.doumee.biz.system.SystemDictBiz;
import com.doumee.core.annotation.pr.PreventRepeat;
import com.doumee.core.constants.Constants;
import com.doumee.core.constants.OperaType;
import com.doumee.core.model.ApiResponse;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.dao.system.dto.QuerySystemDictDTO;
import com.doumee.dao.system.model.SystemDict;
import com.doumee.dao.system.model.SystemDictData;
import com.doumee.dao.system.vo.SystemDictListVO;
import com.doumee.service.system.SystemDictDataService;
import com.doumee.service.system.SystemDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
 
/**
 * @author Eva.Caesar Liu
 * @date 2022/03/15 09:54
 */
@Api(tags = "系统字典")
@RestController
@RequestMapping("/system/dict")
public class SystemDictController extends BaseController {
 
    @Autowired
    private SystemDictService systemDictService;
 
    @Autowired
    private SystemDictDataService systemDictDataService;
 
 
    @Autowired
    private SystemDictBiz systemDictBiz;
 
    @PreventRepeat
    @ApiOperation("新建")
    @PostMapping("/create")
    @RequiresPermissions("system:dict:create")
    public ApiResponse create(@Validated(OperaType.Create.class) @RequestBody SystemDict systemDict) {
        return ApiResponse.success(systemDictBiz.create(systemDict));
    }
 
    @ApiOperation("删除")
    @GetMapping("/delete/{id}")
    @RequiresPermissions("system:dict:delete")
    public ApiResponse deleteById(@PathVariable Integer id) {
        systemDictService.deleteById(id);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("批量删除")
    @GetMapping("/delete/batch")
    @RequiresPermissions("system:dict:delete")
    public ApiResponse deleteByIdInBatch(@RequestParam String ids) {
        String [] idArray = ids.split(",");
        List<Integer> idList = new ArrayList<>();
        for (String id : idArray) {
            idList.add(Integer.valueOf(id));
        }
        systemDictService.deleteByIdInBatch(idList);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("修改")
    @PostMapping("/updateById")
    @RequiresPermissions("system:dict:update")
    public ApiResponse updateById(@Validated(OperaType.Update.class) @RequestBody SystemDict systemDict) {
        systemDictBiz.updateById(systemDict);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("分页查询")
    @PostMapping("/page")
    @RequiresPermissions("system:dict:query")
    public ApiResponse<PageData<SystemDictListVO>> findPage (@RequestBody PageWrap<QuerySystemDictDTO> pageWrap) {
        return ApiResponse.success(systemDictService.findPage(pageWrap));
    }
 
    @ApiOperation("科目列表")
    @GetMapping("/subjectAndTypeList")
    public ApiResponse subjectAndTypeList() {
        SystemDict systemDict = new SystemDict();
        systemDict.setCode("SHIFT_SUBJECT");
        SystemDict dbSystemDict =systemDictService.findOne(systemDict);
        if(Objects.isNull(dbSystemDict)){
            return ApiResponse.failed("未查询到当前类别");
        }
        SystemDictData systemDictData = new SystemDictData();
        systemDictData.setDictId(dbSystemDict.getId());
        return ApiResponse.success(systemDictDataService.findList(systemDictData));
    }
 
 
    @ApiOperation("字典列表查询")
    @GetMapping("/selectList")
    public ApiResponse selectList(@RequestParam String parentCode) {
        SystemDict systemDict = new SystemDict();
        systemDict.setCode(parentCode);
        SystemDict dbSystemDict =systemDictService.findOne(systemDict);
        if(Objects.isNull(dbSystemDict)){
            return ApiResponse.failed("未查询到当前类别");
        }
        SystemDictData systemDictData = new SystemDictData();
        systemDictData.setDictId(dbSystemDict.getId());
        systemDictData.setDisabled(Constants.ZERO);
        systemDictData.setDeleted(Constants.ZERO);
        return ApiResponse.success(systemDictDataService.findList(systemDictData));
    }
 
 
 
}