Commit 9f9c63a221ee0998530a40183e50b3f8b510459a
1 parent
78e847a8
整理 dict data 模块的 url
Showing
10 changed files
with
159 additions
and
263 deletions
ruoyi-ui/src/api/system/dict/data.js
| ... | ... | @@ -38,7 +38,7 @@ export function addData(data) { |
| 38 | 38 | export function updateData(data) { |
| 39 | 39 | return request({ |
| 40 | 40 | url: '/system/dict-data/update', |
| 41 | - method: 'post', | |
| 41 | + method: 'put', | |
| 42 | 42 | data: data |
| 43 | 43 | }) |
| 44 | 44 | } |
| ... | ... | @@ -47,7 +47,7 @@ export function updateData(data) { |
| 47 | 47 | export function delData(dictCode) { |
| 48 | 48 | return request({ |
| 49 | 49 | url: '/system/dict-data/delete?id=' + dictCode, |
| 50 | - method: 'post' | |
| 50 | + method: 'delete' | |
| 51 | 51 | }) |
| 52 | 52 | } |
| 53 | 53 | ... | ... |
ruoyi-ui/src/api/system/dict/type.js
| ... | ... | @@ -30,7 +30,7 @@ export function addType(data) { |
| 30 | 30 | export function updateType(data) { |
| 31 | 31 | return request({ |
| 32 | 32 | url: '/system/dict-type/update', |
| 33 | - method: 'post', | |
| 33 | + method: 'put', | |
| 34 | 34 | data: data |
| 35 | 35 | }) |
| 36 | 36 | } |
| ... | ... | @@ -39,7 +39,7 @@ export function updateType(data) { |
| 39 | 39 | export function delType(dictId) { |
| 40 | 40 | return request({ |
| 41 | 41 | url: '/system/dict-type/delete?id=' + dictId, |
| 42 | - method: 'post' | |
| 42 | + method: 'delete' | |
| 43 | 43 | }) |
| 44 | 44 | } |
| 45 | 45 | ... | ... |
ruoyi-ui/src/views/system/dict/data.vue
| ... | ... | @@ -3,31 +3,15 @@ |
| 3 | 3 | <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> |
| 4 | 4 | <el-form-item label="字典名称" prop="dictType"> |
| 5 | 5 | <el-select v-model="queryParams.dictType" size="small"> |
| 6 | - <el-option | |
| 7 | - v-for="item in typeOptions" | |
| 8 | - :key="item.id" | |
| 9 | - :label="item.name" | |
| 10 | - :value="item.type" | |
| 11 | - /> | |
| 6 | + <el-option v-for="item in typeOptions" :key="item.id" :label="item.name" :value="item.type"/> | |
| 12 | 7 | </el-select> |
| 13 | 8 | </el-form-item> |
| 14 | 9 | <el-form-item label="字典标签" prop="label"> |
| 15 | - <el-input | |
| 16 | - v-model="queryParams.label" | |
| 17 | - placeholder="请输入字典标签" | |
| 18 | - clearable | |
| 19 | - size="small" | |
| 20 | - @keyup.enter.native="handleQuery" | |
| 21 | - /> | |
| 10 | + <el-input v-model="queryParams.label" placeholder="请输入字典标签" clearable size="small" @keyup.enter.native="handleQuery"/> | |
| 22 | 11 | </el-form-item> |
| 23 | 12 | <el-form-item label="状态" prop="status"> |
| 24 | 13 | <el-select v-model="queryParams.status" placeholder="数据状态" clearable size="small"> |
| 25 | - <el-option | |
| 26 | - v-for="dict in statusOptions" | |
| 27 | - :key="dict.value" | |
| 28 | - :label="dict.label" | |
| 29 | - :value="dict.value" | |
| 30 | - /> | |
| 14 | + <el-option v-for="dict in statusOptions" :key="dict.value" :label="dict.label" :value="dict.value"/> | |
| 31 | 15 | </el-select> |
| 32 | 16 | </el-form-item> |
| 33 | 17 | <el-form-item> |
| ... | ... | @@ -38,22 +22,12 @@ |
| 38 | 22 | |
| 39 | 23 | <el-row :gutter="10" class="mb8"> |
| 40 | 24 | <el-col :span="1.5"> |
| 41 | - <el-button | |
| 42 | - type="primary" | |
| 43 | - icon="el-icon-plus" | |
| 44 | - size="mini" | |
| 45 | - @click="handleAdd" | |
| 46 | - v-hasPermi="['system:dict:add']" | |
| 47 | - >新增</el-button> | |
| 25 | + <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd" | |
| 26 | + v-hasPermi="['system:dict:create']">新增</el-button> | |
| 48 | 27 | </el-col> |
| 49 | 28 | <el-col :span="1.5"> |
| 50 | - <el-button | |
| 51 | - type="warning" | |
| 52 | - icon="el-icon-download" | |
| 53 | - size="mini" | |
| 54 | - @click="handleExport" | |
| 55 | - v-hasPermi="['system:dict:export']" | |
| 56 | - >导出</el-button> | |
| 29 | + <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport" | |
| 30 | + v-hasPermi="['system:dict:export']">导出</el-button> | |
| 57 | 31 | </el-col> |
| 58 | 32 | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> |
| 59 | 33 | </el-row> |
| ... | ... | @@ -72,31 +46,16 @@ |
| 72 | 46 | </el-table-column> |
| 73 | 47 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| 74 | 48 | <template slot-scope="scope"> |
| 75 | - <el-button | |
| 76 | - size="mini" | |
| 77 | - type="text" | |
| 78 | - icon="el-icon-edit" | |
| 79 | - @click="handleUpdate(scope.row)" | |
| 80 | - v-hasPermi="['system:dict:edit']" | |
| 81 | - >修改</el-button> | |
| 82 | - <el-button | |
| 83 | - size="mini" | |
| 84 | - type="text" | |
| 85 | - icon="el-icon-delete" | |
| 86 | - @click="handleDelete(scope.row)" | |
| 87 | - v-hasPermi="['system:dict:remove']" | |
| 88 | - >删除</el-button> | |
| 49 | + <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" | |
| 50 | + v-hasPermi="['system:dict:update']">修改</el-button> | |
| 51 | + <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" | |
| 52 | + v-hasPermi="['system:dict:delete']">删除</el-button> | |
| 89 | 53 | </template> |
| 90 | 54 | </el-table-column> |
| 91 | 55 | </el-table> |
| 92 | 56 | |
| 93 | - <pagination | |
| 94 | - v-show="total>0" | |
| 95 | - :total="total" | |
| 96 | - :page.sync="queryParams.pageNo" | |
| 97 | - :limit.sync="queryParams.pageSize" | |
| 98 | - @pagination="getList" | |
| 99 | - /> | |
| 57 | + <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" | |
| 58 | + @pagination="getList"/> | |
| 100 | 59 | |
| 101 | 60 | <!-- 添加或修改参数配置对话框 --> |
| 102 | 61 | <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> |
| ... | ... | @@ -115,11 +74,7 @@ |
| 115 | 74 | </el-form-item> |
| 116 | 75 | <el-form-item label="状态" prop="status"> |
| 117 | 76 | <el-radio-group v-model="form.status"> |
| 118 | - <el-radio | |
| 119 | - v-for="dict in statusDictDatas" | |
| 120 | - :key="parseInt(dict.value)" | |
| 121 | - :label="parseInt(dict.value)" | |
| 122 | - >{{dict.label}}</el-radio> | |
| 77 | + <el-radio v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="parseInt(dict.value)">{{dict.label}}</el-radio> | |
| 123 | 78 | </el-radio-group> |
| 124 | 79 | </el-form-item> |
| 125 | 80 | <el-form-item label="备注" prop="remark"> | ... | ... |
ruoyi-ui/src/views/system/dict/index.vue
| ... | ... | @@ -2,52 +2,19 @@ |
| 2 | 2 | <div class="app-container"> |
| 3 | 3 | <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> |
| 4 | 4 | <el-form-item label="字典名称" prop="name"> |
| 5 | - <el-input | |
| 6 | - v-model="queryParams.name" | |
| 7 | - placeholder="请输入字典名称" | |
| 8 | - clearable | |
| 9 | - size="small" | |
| 10 | - style="width: 240px" | |
| 11 | - @keyup.enter.native="handleQuery" | |
| 12 | - /> | |
| 5 | + <el-input v-model="queryParams.name" placeholder="请输入字典名称" clearable size="small" style="width: 240px" @keyup.enter.native="handleQuery"/> | |
| 13 | 6 | </el-form-item> |
| 14 | 7 | <el-form-item label="字典类型" prop="type"> |
| 15 | - <el-input | |
| 16 | - v-model="queryParams.type" | |
| 17 | - placeholder="请输入字典类型" | |
| 18 | - clearable | |
| 19 | - size="small" | |
| 20 | - style="width: 240px" | |
| 21 | - @keyup.enter.native="handleQuery" | |
| 22 | - /> | |
| 8 | + <el-input v-model="queryParams.type" placeholder="请输入字典类型" clearable size="small" style="width: 240px" @keyup.enter.native="handleQuery"/> | |
| 23 | 9 | </el-form-item> |
| 24 | 10 | <el-form-item label="状态" prop="status"> |
| 25 | - <el-select | |
| 26 | - v-model="queryParams.status" | |
| 27 | - placeholder="字典状态" | |
| 28 | - clearable | |
| 29 | - size="small" | |
| 30 | - style="width: 240px" | |
| 31 | - > | |
| 32 | - <el-option | |
| 33 | - v-for="dict in statusDictDatas" | |
| 34 | - :key="parseInt(dict.value)" | |
| 35 | - :label="dict.label" | |
| 36 | - :value="parseInt(dict.value)" | |
| 37 | - /> | |
| 11 | + <el-select v-model="queryParams.status" placeholder="字典状态" clearable size="small" style="width: 240px"> | |
| 12 | + <el-option v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/> | |
| 38 | 13 | </el-select> |
| 39 | 14 | </el-form-item> |
| 40 | 15 | <el-form-item label="创建时间"> |
| 41 | - <el-date-picker | |
| 42 | - v-model="dateRangeCreateTime" | |
| 43 | - size="small" | |
| 44 | - style="width: 240px" | |
| 45 | - value-format="yyyy-MM-dd" | |
| 46 | - type="daterange" | |
| 47 | - range-separator="-" | |
| 48 | - start-placeholder="开始日期" | |
| 49 | - end-placeholder="结束日期" | |
| 50 | - ></el-date-picker> | |
| 16 | + <el-date-picker v-model="dateRangeCreateTime" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" | |
| 17 | + range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker> | |
| 51 | 18 | </el-form-item> |
| 52 | 19 | <el-form-item> |
| 53 | 20 | <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> |
| ... | ... | @@ -57,22 +24,12 @@ |
| 57 | 24 | |
| 58 | 25 | <el-row :gutter="10" class="mb8"> |
| 59 | 26 | <el-col :span="1.5"> |
| 60 | - <el-button | |
| 61 | - type="primary" | |
| 62 | - icon="el-icon-plus" | |
| 63 | - size="mini" | |
| 64 | - @click="handleAdd" | |
| 65 | - v-hasPermi="['system:dict:add']" | |
| 66 | - >新增</el-button> | |
| 27 | + <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd" | |
| 28 | + v-hasPermi="['system:dict:create']">新增</el-button> | |
| 67 | 29 | </el-col> |
| 68 | 30 | <el-col :span="1.5"> |
| 69 | - <el-button | |
| 70 | - type="warning" | |
| 71 | - icon="el-icon-download" | |
| 72 | - size="mini" | |
| 73 | - @click="handleExport" | |
| 74 | - v-hasPermi="['system:dict:export']" | |
| 75 | - >导出</el-button> | |
| 31 | + <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport" | |
| 32 | + v-hasPermi="['system:dict:export']">导出</el-button> | |
| 76 | 33 | </el-col> |
| 77 | 34 | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> |
| 78 | 35 | </el-row> |
| ... | ... | @@ -96,31 +53,16 @@ |
| 96 | 53 | </el-table-column> |
| 97 | 54 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| 98 | 55 | <template slot-scope="scope"> |
| 99 | - <el-button | |
| 100 | - size="mini" | |
| 101 | - type="text" | |
| 102 | - icon="el-icon-edit" | |
| 103 | - @click="handleUpdate(scope.row)" | |
| 104 | - v-hasPermi="['system:dict:edit']" | |
| 105 | - >修改</el-button> | |
| 106 | - <el-button | |
| 107 | - size="mini" | |
| 108 | - type="text" | |
| 109 | - icon="el-icon-delete" | |
| 110 | - @click="handleDelete(scope.row)" | |
| 111 | - v-hasPermi="['system:dict:remove']" | |
| 112 | - >删除</el-button> | |
| 56 | + <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" | |
| 57 | + v-hasPermi="['system:dict:update']">修改</el-button> | |
| 58 | + <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" | |
| 59 | + v-hasPermi="['system:dict:delete']">删除</el-button> | |
| 113 | 60 | </template> |
| 114 | 61 | </el-table-column> |
| 115 | 62 | </el-table> |
| 116 | 63 | |
| 117 | - <pagination | |
| 118 | - v-show="total>0" | |
| 119 | - :total="total" | |
| 120 | - :page.sync="queryParams.pageNo" | |
| 121 | - :limit.sync="queryParams.pageSize" | |
| 122 | - @pagination="getList" | |
| 123 | - /> | |
| 64 | + <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" | |
| 65 | + @pagination="getList"/> | |
| 124 | 66 | |
| 125 | 67 | <!-- 添加或修改参数配置对话框 --> |
| 126 | 68 | <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> |
| ... | ... | @@ -133,11 +75,7 @@ |
| 133 | 75 | </el-form-item> |
| 134 | 76 | <el-form-item label="状态" prop="status"> |
| 135 | 77 | <el-radio-group v-model="form.status"> |
| 136 | - <el-radio | |
| 137 | - v-for="dict in statusDictDatas" | |
| 138 | - :key="parseInt(dict.value)" | |
| 139 | - :label="parseInt(dict.value)" | |
| 140 | - >{{dict.label}}</el-radio> | |
| 78 | + <el-radio v-for="dict in statusDictDatas" :key="parseInt(dict.value)" :label="parseInt(dict.value)">{{dict.label}}</el-radio> | |
| 141 | 79 | </el-radio-group> |
| 142 | 80 | </el-form-item> |
| 143 | 81 | <el-form-item label="备注" prop="remark"> | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/SysDictDataController.java
| ... | ... | @@ -3,6 +3,7 @@ package cn.iocoder.dashboard.modules.system.controller.dict; |
| 3 | 3 | import cn.iocoder.dashboard.common.pojo.CommonResult; |
| 4 | 4 | import cn.iocoder.dashboard.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils; |
| 6 | +import cn.iocoder.dashboard.framework.logger.operatelog.core.annotations.OperateLog; | |
| 6 | 7 | import cn.iocoder.dashboard.modules.system.controller.dict.vo.data.*; |
| 7 | 8 | import cn.iocoder.dashboard.modules.system.convert.dict.SysDictDataConvert; |
| 8 | 9 | import cn.iocoder.dashboard.modules.system.dal.dataobject.dict.SysDictDataDO; |
| ... | ... | @@ -10,84 +11,85 @@ import cn.iocoder.dashboard.modules.system.service.dict.SysDictDataService; |
| 10 | 11 | import io.swagger.annotations.Api; |
| 11 | 12 | import io.swagger.annotations.ApiImplicitParam; |
| 12 | 13 | import io.swagger.annotations.ApiOperation; |
| 14 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 13 | 15 | import org.springframework.validation.annotation.Validated; |
| 14 | 16 | import org.springframework.web.bind.annotation.*; |
| 15 | 17 | |
| 16 | 18 | import javax.annotation.Resource; |
| 17 | 19 | import javax.servlet.http.HttpServletResponse; |
| 20 | +import javax.validation.Valid; | |
| 18 | 21 | import java.io.IOException; |
| 19 | 22 | import java.util.List; |
| 20 | 23 | |
| 21 | 24 | import static cn.iocoder.dashboard.common.pojo.CommonResult.success; |
| 25 | +import static cn.iocoder.dashboard.framework.logger.operatelog.core.enums.OperateTypeEnum.EXPORT; | |
| 22 | 26 | |
| 23 | 27 | @Api(tags = "字典数据") |
| 24 | 28 | @RestController |
| 25 | 29 | @RequestMapping("/system/dict-data") |
| 30 | +@Validated | |
| 26 | 31 | public class SysDictDataController { |
| 27 | 32 | |
| 28 | 33 | @Resource |
| 29 | 34 | private SysDictDataService dictDataService; |
| 30 | 35 | |
| 31 | - @ApiOperation(value = "获得全部字典数据列表", notes = "一般用于管理后台缓存字典数据在本地") | |
| 32 | - @GetMapping("/list-all-simple") | |
| 33 | - // 无需添加权限认证,因为前端全局都需要 | |
| 34 | - public CommonResult<List<SysDictDataSimpleVO>> listSimpleDictDatas() { | |
| 35 | - List<SysDictDataDO> list = dictDataService.getDictDataList(); | |
| 36 | - return success(SysDictDataConvert.INSTANCE.convertList(list)); | |
| 37 | - } | |
| 38 | - | |
| 39 | - @ApiOperation("/获得字典类型的分页列表") | |
| 40 | - @GetMapping("/page") | |
| 41 | -// @PreAuthorize("@ss.hasPermi('system:dict:list')") | |
| 42 | - public CommonResult<PageResult<SysDictDataRespVO>> pageDictTypes(@Validated SysDictDataPageReqVO reqVO) { | |
| 43 | - return success(SysDictDataConvert.INSTANCE.convertPage(dictDataService.getDictDataPage(reqVO))); | |
| 44 | - } | |
| 45 | - | |
| 46 | - @ApiOperation("/查询字典数据详细") | |
| 47 | - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | |
| 48 | - @GetMapping(value = "/get") | |
| 49 | -// @PreAuthorize("@ss.hasPermi('system:dict:query')") | |
| 50 | - public CommonResult<SysDictDataRespVO> getDictData(@RequestParam("id") Long id) { | |
| 51 | - return success(SysDictDataConvert.INSTANCE.convert(dictDataService.getDictData(id))); | |
| 52 | - } | |
| 53 | - | |
| 54 | - @ApiOperation("新增字典数据") | |
| 55 | 36 | @PostMapping("/create") |
| 56 | -// @PreAuthorize("@ss.hasPermi('system:dict:add')") | |
| 57 | -// @Log(title = "字典数据", businessData = BusinessData.INSERT) | |
| 58 | - public CommonResult<Long> createDictData(@Validated @RequestBody SysDictDataCreateReqVO reqVO) { | |
| 37 | + @ApiOperation("新增字典数据") | |
| 38 | + @PreAuthorize("@ss.hasPermission('system:dict:create')") | |
| 39 | + public CommonResult<Long> createDictData(@Valid @RequestBody SysDictDataCreateReqVO reqVO) { | |
| 59 | 40 | Long dictDataId = dictDataService.createDictData(reqVO); |
| 60 | 41 | return success(dictDataId); |
| 61 | 42 | } |
| 62 | 43 | |
| 44 | + @PutMapping("update") | |
| 63 | 45 | @ApiOperation("修改字典数据") |
| 64 | - @PostMapping("update") | |
| 65 | -// @PreAuthorize("@ss.hasPermi('system:dict:edit')") | |
| 66 | -// @Log(title = "字典数据", businessData = BusinessData.UPDATE) | |
| 67 | - public CommonResult<Boolean> updateDictData(@Validated @RequestBody SysDictDataUpdateReqVO reqVO) { | |
| 46 | + @PreAuthorize("@ss.hasPermission('system:dict:update')") | |
| 47 | + public CommonResult<Boolean> updateDictData(@Valid @RequestBody SysDictDataUpdateReqVO reqVO) { | |
| 68 | 48 | dictDataService.updateDictData(reqVO); |
| 69 | 49 | return success(true); |
| 70 | 50 | } |
| 71 | 51 | |
| 52 | + @DeleteMapping("/delete") | |
| 72 | 53 | @ApiOperation("删除字典数据") |
| 73 | 54 | @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) |
| 74 | - @PostMapping("/delete") | |
| 75 | -// @PreAuthorize("@ss.hasPermi('system:dict:remove')") | |
| 55 | + @PreAuthorize("@ss.hasPermission('system:dict:delete')") | |
| 76 | 56 | public CommonResult<Boolean> deleteDictData(Long id) { |
| 77 | 57 | dictDataService.deleteDictData(id); |
| 78 | 58 | return success(true); |
| 79 | 59 | } |
| 80 | 60 | |
| 81 | - @ApiOperation("导出字典数据") | |
| 61 | + @GetMapping("/list-all-simple") | |
| 62 | + @ApiOperation(value = "获得全部字典数据列表", notes = "一般用于管理后台缓存字典数据在本地") | |
| 63 | + // 无需添加权限认证,因为前端全局都需要 | |
| 64 | + public CommonResult<List<SysDictDataSimpleVO>> getSimpleDictDatas() { | |
| 65 | + List<SysDictDataDO> list = dictDataService.getDictDatas(); | |
| 66 | + return success(SysDictDataConvert.INSTANCE.convertList(list)); | |
| 67 | + } | |
| 68 | + | |
| 69 | + @GetMapping("/page") | |
| 70 | + @ApiOperation("/获得字典类型的分页列表") | |
| 71 | + @PreAuthorize("@ss.hasPermission('system:dict:query')") | |
| 72 | + public CommonResult<PageResult<SysDictDataRespVO>> getDictTypePage(@Valid SysDictDataPageReqVO reqVO) { | |
| 73 | + return success(SysDictDataConvert.INSTANCE.convertPage(dictDataService.getDictDataPage(reqVO))); | |
| 74 | + } | |
| 75 | + | |
| 76 | + @GetMapping(value = "/get") | |
| 77 | + @ApiOperation("/查询字典数据详细") | |
| 78 | + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | |
| 79 | + @PreAuthorize("@ss.hasPermission('system:dict:query')") | |
| 80 | + public CommonResult<SysDictDataRespVO> getDictData(@RequestParam("id") Long id) { | |
| 81 | + return success(SysDictDataConvert.INSTANCE.convert(dictDataService.getDictData(id))); | |
| 82 | + } | |
| 83 | + | |
| 82 | 84 | @GetMapping("/export") |
| 83 | -// @Log(title = "字典类型", businessType = BusinessType.EXPORT) | |
| 84 | -// @PreAuthorize("@ss.hasPermi('system:dict:export')") | |
| 85 | - public void export(HttpServletResponse response, @Validated SysDictDataExportReqVO reqVO) throws IOException { | |
| 86 | - List<SysDictDataDO> list = dictDataService.getDictDataList(reqVO); | |
| 87 | - List<SysDictDataExcelVO> excelDataList = SysDictDataConvert.INSTANCE.convertList02(list); | |
| 85 | + @ApiOperation("导出字典数据") | |
| 86 | + @PreAuthorize("@ss.hasPermission('system:dict:export')") | |
| 87 | + @OperateLog(type = EXPORT) | |
| 88 | + public void export(HttpServletResponse response, @Valid SysDictDataExportReqVO reqVO) throws IOException { | |
| 89 | + List<SysDictDataDO> list = dictDataService.getDictDatas(reqVO); | |
| 90 | + List<SysDictDataExcelVO> data = SysDictDataConvert.INSTANCE.convertList02(list); | |
| 88 | 91 | // 输出 |
| 89 | - ExcelUtils.write(response, "字典数据.xls", "数据列表", | |
| 90 | - SysDictDataExcelVO.class, excelDataList); | |
| 92 | + ExcelUtils.write(response, "字典数据.xls", "数据列表", SysDictDataExcelVO.class, data); | |
| 91 | 93 | } |
| 92 | 94 | |
| 93 | 95 | } | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/SysDictTypeController.java
| ... | ... | @@ -3,6 +3,7 @@ package cn.iocoder.dashboard.modules.system.controller.dict; |
| 3 | 3 | import cn.iocoder.dashboard.common.pojo.CommonResult; |
| 4 | 4 | import cn.iocoder.dashboard.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils; |
| 6 | +import cn.iocoder.dashboard.framework.logger.operatelog.core.annotations.OperateLog; | |
| 6 | 7 | import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.*; |
| 7 | 8 | import cn.iocoder.dashboard.modules.system.convert.dict.SysDictTypeConvert; |
| 8 | 9 | import cn.iocoder.dashboard.modules.system.dal.dataobject.dict.SysDictTypeDO; |
| ... | ... | @@ -10,66 +11,67 @@ import cn.iocoder.dashboard.modules.system.service.dict.SysDictTypeService; |
| 10 | 11 | import io.swagger.annotations.Api; |
| 11 | 12 | import io.swagger.annotations.ApiImplicitParam; |
| 12 | 13 | import io.swagger.annotations.ApiOperation; |
| 14 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 13 | 15 | import org.springframework.validation.annotation.Validated; |
| 14 | 16 | import org.springframework.web.bind.annotation.*; |
| 15 | 17 | |
| 16 | 18 | import javax.annotation.Resource; |
| 17 | 19 | import javax.servlet.http.HttpServletResponse; |
| 20 | +import javax.validation.Valid; | |
| 18 | 21 | import java.io.IOException; |
| 19 | 22 | import java.util.List; |
| 20 | 23 | |
| 21 | 24 | import static cn.iocoder.dashboard.common.pojo.CommonResult.success; |
| 25 | +import static cn.iocoder.dashboard.framework.logger.operatelog.core.enums.OperateTypeEnum.EXPORT; | |
| 22 | 26 | |
| 23 | 27 | @Api(tags = "字典类型") |
| 24 | 28 | @RestController |
| 25 | 29 | @RequestMapping("/system/dict-type") |
| 30 | +@Validated | |
| 26 | 31 | public class SysDictTypeController { |
| 27 | 32 | |
| 28 | 33 | @Resource |
| 29 | 34 | private SysDictTypeService dictTypeService; |
| 30 | 35 | |
| 31 | - @ApiOperation("/获得字典类型的分页列表") | |
| 32 | - @GetMapping("/page") | |
| 33 | -// @PreAuthorize("@ss.hasPermi('system:dict:list')") | |
| 34 | - public CommonResult<PageResult<SysDictTypeRespVO>> pageDictTypes(@Validated SysDictTypePageReqVO reqVO) { | |
| 35 | - return success(SysDictTypeConvert.INSTANCE.convertPage(dictTypeService.getDictTypePage(reqVO))); | |
| 36 | - } | |
| 37 | - | |
| 38 | - @ApiOperation("/查询字典类型详细") | |
| 39 | - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | |
| 40 | - @GetMapping(value = "/get") | |
| 41 | -// @PreAuthorize("@ss.hasPermi('system:dict:query')") | |
| 42 | - public CommonResult<SysDictTypeRespVO> getDictType(@RequestParam("id") Long id) { | |
| 43 | - return success(SysDictTypeConvert.INSTANCE.convert(dictTypeService.getDictType(id))); | |
| 44 | - } | |
| 45 | - | |
| 46 | - @ApiOperation("新增字典类型") | |
| 47 | 36 | @PostMapping("/create") |
| 48 | -// @PreAuthorize("@ss.hasPermi('system:dict:add')") | |
| 49 | -// @Log(title = "字典类型", businessType = BusinessType.INSERT) | |
| 50 | - public CommonResult<Long> createDictType(@Validated @RequestBody SysDictTypeCreateReqVO reqVO) { | |
| 37 | + @ApiOperation("创建字典类型") | |
| 38 | + @PreAuthorize("@ss.hasPermission('system:dict:create')") | |
| 39 | + public CommonResult<Long> createDictType(@Valid @RequestBody SysDictTypeCreateReqVO reqVO) { | |
| 51 | 40 | Long dictTypeId = dictTypeService.createDictType(reqVO); |
| 52 | 41 | return success(dictTypeId); |
| 53 | 42 | } |
| 54 | 43 | |
| 55 | - @ApiOperation("修改字典类型") | |
| 56 | 44 | @PostMapping("update") |
| 57 | -// @PreAuthorize("@ss.hasPermi('system:dict:edit')") | |
| 58 | -// @Log(title = "字典类型", businessType = BusinessType.UPDATE) | |
| 59 | - public CommonResult<Boolean> updateDictType(@Validated @RequestBody SysDictTypeUpdateReqVO reqVO) { | |
| 45 | + @ApiOperation("修改字典类型") | |
| 46 | + @PreAuthorize("@ss.hasPermission('system:dict:update')") | |
| 47 | + public CommonResult<Boolean> updateDictType(@Valid @RequestBody SysDictTypeUpdateReqVO reqVO) { | |
| 60 | 48 | dictTypeService.updateDictType(reqVO); |
| 61 | 49 | return success(true); |
| 62 | 50 | } |
| 63 | 51 | |
| 52 | + @DeleteMapping("/delete") | |
| 64 | 53 | @ApiOperation("删除字典类型") |
| 65 | 54 | @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) |
| 66 | - @PostMapping("/delete") | |
| 67 | -// @PreAuthorize("@ss.hasPermi('system:dict:remove')") | |
| 55 | + @PreAuthorize("@ss.hasPermission('system:dict:delete')") | |
| 68 | 56 | public CommonResult<Boolean> deleteDictType(Long id) { |
| 69 | 57 | dictTypeService.deleteDictType(id); |
| 70 | 58 | return success(true); |
| 71 | 59 | } |
| 72 | 60 | |
| 61 | + @ApiOperation("/获得字典类型的分页列表") | |
| 62 | + @GetMapping("/page") | |
| 63 | + @PreAuthorize("@ss.hasPermission('system:dict:quey')") | |
| 64 | + public CommonResult<PageResult<SysDictTypeRespVO>> pageDictTypes(@Valid SysDictTypePageReqVO reqVO) { | |
| 65 | + return success(SysDictTypeConvert.INSTANCE.convertPage(dictTypeService.getDictTypePage(reqVO))); | |
| 66 | + } | |
| 67 | + | |
| 68 | + @ApiOperation("/查询字典类型详细") | |
| 69 | + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | |
| 70 | + @GetMapping(value = "/get") | |
| 71 | + @PreAuthorize("@ss.hasPermission('system:dict:quey')") | |
| 72 | + public CommonResult<SysDictTypeRespVO> getDictType(@RequestParam("id") Long id) { | |
| 73 | + return success(SysDictTypeConvert.INSTANCE.convert(dictTypeService.getDictType(id))); | |
| 74 | + } | |
| 73 | 75 | |
| 74 | 76 | @GetMapping("/list-all-simple") |
| 75 | 77 | @ApiOperation(value = "获得全部字典类型列表", notes = "包括开启 + 禁用的字典类型,主要用于前端的下拉选项") |
| ... | ... | @@ -81,14 +83,13 @@ public class SysDictTypeController { |
| 81 | 83 | |
| 82 | 84 | @ApiOperation("导出数据类型") |
| 83 | 85 | @GetMapping("/export") |
| 84 | -// @Log(title = "字典类型", businessType = BusinessType.EXPORT) | |
| 85 | -// @PreAuthorize("@ss.hasPermi('system:dict:export')") | |
| 86 | - public void export(HttpServletResponse response, @Validated SysDictTypeExportReqVO reqVO) throws IOException { | |
| 86 | + @PreAuthorize("@ss.hasPermission('system:dict:quey')") | |
| 87 | + @OperateLog(type = EXPORT) | |
| 88 | + public void export(HttpServletResponse response, @Valid SysDictTypeExportReqVO reqVO) throws IOException { | |
| 87 | 89 | List<SysDictTypeDO> list = dictTypeService.getDictTypeList(reqVO); |
| 88 | - List<SysDictTypeExcelVO> excelTypeList = SysDictTypeConvert.INSTANCE.convertList02(list); | |
| 90 | + List<SysDictTypeExcelVO> data = SysDictTypeConvert.INSTANCE.convertList02(list); | |
| 89 | 91 | // 输出 |
| 90 | - ExcelUtils.write(response, "字典类型.xls", "类型列表", | |
| 91 | - SysDictTypeExcelVO.class, excelTypeList); | |
| 92 | + ExcelUtils.write(response, "字典类型.xls", "类型列表", SysDictTypeExcelVO.class, data); | |
| 92 | 93 | } |
| 93 | 94 | |
| 94 | 95 | } | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/dict/SysDictDataService.java
| ... | ... | @@ -23,57 +23,57 @@ public interface SysDictDataService extends DictDataFrameworkService { |
| 23 | 23 | void initLocalCache(); |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | - * 获得字典数据列表 | |
| 26 | + * 创建字典数据 | |
| 27 | 27 | * |
| 28 | - * @return 字典数据全列表 | |
| 28 | + * @param reqVO 字典数据信息 | |
| 29 | + * @return 字典数据编号 | |
| 29 | 30 | */ |
| 30 | - List<SysDictDataDO> getDictDataList(); | |
| 31 | + Long createDictData(SysDictDataCreateReqVO reqVO); | |
| 31 | 32 | |
| 32 | 33 | /** |
| 33 | - * 获得字典数据分页列表 | |
| 34 | + * 更新字典数据 | |
| 34 | 35 | * |
| 35 | - * @param reqVO 分页请求 | |
| 36 | - * @return 字典数据分页列表 | |
| 36 | + * @param reqVO 字典数据信息 | |
| 37 | 37 | */ |
| 38 | - PageResult<SysDictDataDO> getDictDataPage(SysDictDataPageReqVO reqVO); | |
| 38 | + void updateDictData(SysDictDataUpdateReqVO reqVO); | |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | - * 获得字典数据列表 | |
| 41 | + * 删除字典数据 | |
| 42 | 42 | * |
| 43 | - * @param reqVO 列表请求 | |
| 44 | - * @return 字典数据列表 | |
| 43 | + * @param id 字典数据编号 | |
| 45 | 44 | */ |
| 46 | - List<SysDictDataDO> getDictDataList(SysDictDataExportReqVO reqVO); | |
| 45 | + void deleteDictData(Long id); | |
| 47 | 46 | |
| 48 | 47 | /** |
| 49 | - * 获得字典数据详情 | |
| 48 | + * 获得字典数据列表 | |
| 50 | 49 | * |
| 51 | - * @param id 字典数据编号 | |
| 52 | - * @return 字典数据 | |
| 50 | + * @return 字典数据全列表 | |
| 53 | 51 | */ |
| 54 | - SysDictDataDO getDictData(Long id); | |
| 52 | + List<SysDictDataDO> getDictDatas(); | |
| 55 | 53 | |
| 56 | 54 | /** |
| 57 | - * 创建字典数据 | |
| 55 | + * 获得字典数据分页列表 | |
| 58 | 56 | * |
| 59 | - * @param reqVO 字典数据信息 | |
| 60 | - * @return 字典数据编号 | |
| 57 | + * @param reqVO 分页请求 | |
| 58 | + * @return 字典数据分页列表 | |
| 61 | 59 | */ |
| 62 | - Long createDictData(SysDictDataCreateReqVO reqVO); | |
| 60 | + PageResult<SysDictDataDO> getDictDataPage(SysDictDataPageReqVO reqVO); | |
| 63 | 61 | |
| 64 | 62 | /** |
| 65 | - * 更新字典数据 | |
| 63 | + * 获得字典数据列表 | |
| 66 | 64 | * |
| 67 | - * @param reqVO 字典数据信息 | |
| 65 | + * @param reqVO 列表请求 | |
| 66 | + * @return 字典数据列表 | |
| 68 | 67 | */ |
| 69 | - void updateDictData(SysDictDataUpdateReqVO reqVO); | |
| 68 | + List<SysDictDataDO> getDictDatas(SysDictDataExportReqVO reqVO); | |
| 70 | 69 | |
| 71 | 70 | /** |
| 72 | - * 删除字典数据 | |
| 71 | + * 获得字典数据详情 | |
| 73 | 72 | * |
| 74 | 73 | * @param id 字典数据编号 |
| 74 | + * @return 字典数据 | |
| 75 | 75 | */ |
| 76 | - void deleteDictData(Long id); | |
| 76 | + SysDictDataDO getDictData(Long id); | |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * 获得指定字典类型的数据数量 | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/dict/SysDictTypeService.java
| ... | ... | @@ -17,6 +17,28 @@ import java.util.List; |
| 17 | 17 | public interface SysDictTypeService { |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | + * 创建字典类型 | |
| 21 | + * | |
| 22 | + * @param reqVO 字典类型信息 | |
| 23 | + * @return 字典类型编号 | |
| 24 | + */ | |
| 25 | + Long createDictType(SysDictTypeCreateReqVO reqVO); | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * 更新字典类型 | |
| 29 | + * | |
| 30 | + * @param reqVO 字典类型信息 | |
| 31 | + */ | |
| 32 | + void updateDictType(SysDictTypeUpdateReqVO reqVO); | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * 删除字典类型 | |
| 36 | + * | |
| 37 | + * @param id 字典类型编号 | |
| 38 | + */ | |
| 39 | + void deleteDictType(Long id); | |
| 40 | + | |
| 41 | + /** | |
| 20 | 42 | * 获得字典类型分页列表 |
| 21 | 43 | * |
| 22 | 44 | * @param reqVO 分页请求 |
| ... | ... | @@ -49,28 +71,6 @@ public interface SysDictTypeService { |
| 49 | 71 | SysDictTypeDO getDictType(String type); |
| 50 | 72 | |
| 51 | 73 | /** |
| 52 | - * 创建字典类型 | |
| 53 | - * | |
| 54 | - * @param reqVO 字典类型信息 | |
| 55 | - * @return 字典类型编号 | |
| 56 | - */ | |
| 57 | - Long createDictType(SysDictTypeCreateReqVO reqVO); | |
| 58 | - | |
| 59 | - /** | |
| 60 | - * 更新字典类型 | |
| 61 | - * | |
| 62 | - * @param reqVO 字典类型信息 | |
| 63 | - */ | |
| 64 | - void updateDictType(SysDictTypeUpdateReqVO reqVO); | |
| 65 | - | |
| 66 | - /** | |
| 67 | - * 删除字典类型 | |
| 68 | - * | |
| 69 | - * @param id 字典类型编号 | |
| 70 | - */ | |
| 71 | - void deleteDictType(Long id); | |
| 72 | - | |
| 73 | - /** | |
| 74 | 74 | * 获得全部字典类型列表 |
| 75 | 75 | * |
| 76 | 76 | * @return 字典类型列表 | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/dict/impl/SysDictDataServiceImpl.java
| ... | ... | @@ -131,7 +131,7 @@ public class SysDictDataServiceImpl implements SysDictDataService { |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | @Override |
| 134 | - public List<SysDictDataDO> getDictDataList() { | |
| 134 | + public List<SysDictDataDO> getDictDatas() { | |
| 135 | 135 | List<SysDictDataDO> list = dictDataMapper.selectList(); |
| 136 | 136 | list.sort(COMPARATOR_TYPE_AND_SORT); |
| 137 | 137 | return list; |
| ... | ... | @@ -143,7 +143,7 @@ public class SysDictDataServiceImpl implements SysDictDataService { |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | @Override |
| 146 | - public List<SysDictDataDO> getDictDataList(SysDictDataExportReqVO reqVO) { | |
| 146 | + public List<SysDictDataDO> getDictDatas(SysDictDataExportReqVO reqVO) { | |
| 147 | 147 | List<SysDictDataDO> list = dictDataMapper.selectList(reqVO); |
| 148 | 148 | list.sort(COMPARATOR_TYPE_AND_SORT); |
| 149 | 149 | return list; | ... | ... |
src/test/java/cn/iocoder/dashboard/modules/system/service/dict/SysDictDataServiceTest.java
| ... | ... | @@ -133,7 +133,7 @@ public class SysDictDataServiceTest extends BaseDbUnitTest { |
| 133 | 133 | reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); |
| 134 | 134 | |
| 135 | 135 | // 调用 |
| 136 | - List<SysDictDataDO> list = dictDataService.getDictDataList(reqVO); | |
| 136 | + List<SysDictDataDO> list = dictDataService.getDictDatas(reqVO); | |
| 137 | 137 | // 断言 |
| 138 | 138 | assertEquals(1, list.size()); |
| 139 | 139 | assertPojoEquals(dbDictData, list.get(0)); | ... | ... |