From ec00936532de83ac10166fca760022744eff10de Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 12 Jan 2021 21:01:57 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=AE=8C=E6=88=90=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9A=84=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/api/system/dict/data.js | 16 +- ruoyi-ui/src/api/system/dict/type.js | 4 +- ruoyi-ui/src/views/system/dict/data.vue | 144 +++++++----------- ruoyi-ui/src/views/system/dict/index.vue | 6 - .../dict/SysDictTypeController.java | 22 ++- .../dict/vo/type/SysDictTypeSimpleRespVO.java | 5 +- .../convert/dict/SysDictTypeConvert.java | 5 + .../dal/mysql/dao/dict/SysDictTypeMapper.java | 7 + .../service/dict/SysDictTypeService.java | 9 ++ .../dict/impl/SysDictTypeServiceImpl.java | 7 + 10 files changed, 110 insertions(+), 115 deletions(-) diff --git a/ruoyi-ui/src/api/system/dict/data.js b/ruoyi-ui/src/api/system/dict/data.js index f4f91e694..e756a2f9e 100644 --- a/ruoyi-ui/src/api/system/dict/data.js +++ b/ruoyi-ui/src/api/system/dict/data.js @@ -3,7 +3,7 @@ import request from '@/utils/request' // 查询字典数据列表 export function listData(query) { return request({ - url: '/system/dict/data/list', + url: '/system/dict-data/page', method: 'get', params: query }) @@ -12,7 +12,7 @@ export function listData(query) { // 查询字典数据详细 export function getData(dictCode) { return request({ - url: '/system/dict/data/' + dictCode, + url: '/system/dict-data/get?id=' + dictCode, method: 'get' }) } @@ -20,7 +20,7 @@ export function getData(dictCode) { // 根据字典类型查询字典数据信息 export function getDicts(dictType) { return request({ - url: '/system/dict/data/type/' + dictType, + url: '/system/dict-data/type/' + dictType, method: 'get' }) } @@ -28,7 +28,7 @@ export function getDicts(dictType) { // 新增字典数据 export function addData(data) { return request({ - url: '/system/dict/data', + url: '/system/dict-data/create', method: 'post', data: data }) @@ -37,8 +37,8 @@ export function addData(data) { // 修改字典数据 export function updateData(data) { return request({ - url: '/system/dict/data', - method: 'put', + url: '/system/dict-data/update', + method: 'post', data: data }) } @@ -46,8 +46,8 @@ export function updateData(data) { // 删除字典数据 export function delData(dictCode) { return request({ - url: '/system/dict/data/' + dictCode, - method: 'delete' + url: '/system/dict-data/delete?id=' + dictCode, + method: 'post' }) } diff --git a/ruoyi-ui/src/api/system/dict/type.js b/ruoyi-ui/src/api/system/dict/type.js index 6b20f4e17..3738ae198 100644 --- a/ruoyi-ui/src/api/system/dict/type.js +++ b/ruoyi-ui/src/api/system/dict/type.js @@ -53,9 +53,9 @@ export function exportType(query) { } // 获取字典选择框列表 -export function optionselect() { +export function listAllSimple() { return request({ - url: '/system/dict-type/optionselect', + url: '/system/dict-type/list-all-simple', method: 'get' }) } diff --git a/ruoyi-ui/src/views/system/dict/data.vue b/ruoyi-ui/src/views/system/dict/data.vue index 900d7ce92..3a1071e4d 100644 --- a/ruoyi-ui/src/views/system/dict/data.vue +++ b/ruoyi-ui/src/views/system/dict/data.vue @@ -5,15 +5,15 @@ - + @@ -46,26 +46,6 @@ v-hasPermi="['system:dict:add']" >新增 - - 修改 - - - 删除 - - - - - - - + + + + + @@ -114,7 +93,7 @@ @@ -125,22 +104,22 @@ - - + + - - + + - - + + {{dict.dictLabel}} + v-for="dict in statusDictDatas" + :key="parseInt(dict.value)" + :label="parseInt(dict.value)" + >{{dict.label}} @@ -157,7 +136,10 @@ \ No newline at end of file + diff --git a/ruoyi-ui/src/views/system/dict/index.vue b/ruoyi-ui/src/views/system/dict/index.vue index b62360684..ea91bda2a 100644 --- a/ruoyi-ui/src/views/system/dict/index.vue +++ b/ruoyi-ui/src/views/system/dict/index.vue @@ -314,12 +314,6 @@ export default { }).then(response => { this.download(response.msg); }) - }, - /** 清理缓存按钮操作 */ - handleClearCache() { - clearCache().then(response => { - this.msgSuccess("清理成功"); - }); } } }; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/SysDictTypeController.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/SysDictTypeController.java index cbfb24fb4..b9a7e54bf 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/SysDictTypeController.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/SysDictTypeController.java @@ -2,11 +2,9 @@ package cn.iocoder.dashboard.modules.system.controller.dict; import cn.iocoder.dashboard.common.pojo.CommonResult; import cn.iocoder.dashboard.common.pojo.PageResult; -import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypeCreateReqVO; -import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypePageReqVO; -import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypeRespVO; -import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypeUpdateReqVO; +import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.*; import cn.iocoder.dashboard.modules.system.convert.dict.SysDictTypeConvert; +import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dict.SysDictTypeDO; import cn.iocoder.dashboard.modules.system.service.dict.SysDictTypeService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -15,6 +13,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.List; import static cn.iocoder.dashboard.common.pojo.CommonResult.success; @@ -69,14 +68,13 @@ public class SysDictTypeController { } -// /** -// * 获取字典选择框列表 -// */ -// @GetMapping("/optionselect") -// public AjaxResult optionselect() { -// List dictTypes = dictTypeService.selectDictTypeAll(); -// return AjaxResult.success(dictTypes); -// } + @GetMapping("/list-all-simple") + @ApiOperation(value = "获得全部字典类型列表", notes = "包括开启 + 禁用的字典类型,主要用于前端的下拉选项") + // 无需添加权限认证,因为前端全局都需要 + public CommonResult> listSimpleDictTypes() { + List list = dictTypeService.listDictTypes(); + return success(SysDictTypeConvert.INSTANCE.convertList(list)); + } // // @Log(title = "字典类型", businessType = BusinessType.EXPORT) diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/vo/type/SysDictTypeSimpleRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/vo/type/SysDictTypeSimpleRespVO.java index 13580a4cf..382544b7f 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/vo/type/SysDictTypeSimpleRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dict/vo/type/SysDictTypeSimpleRespVO.java @@ -13,9 +13,12 @@ import lombok.NoArgsConstructor; public class SysDictTypeSimpleRespVO { @ApiModelProperty(value = "字典类型编号", required = true, example = "1024") - private Integer id; + private Long id; @ApiModelProperty(value = "字典类型名称", required = true, example = "芋道") private String name; + @ApiModelProperty(value = "字典类型", required = true, example = "sys_common_sex") + private String type; + } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/convert/dict/SysDictTypeConvert.java b/src/main/java/cn/iocoder/dashboard/modules/system/convert/dict/SysDictTypeConvert.java index f7a52df2a..03bc41ba4 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/convert/dict/SysDictTypeConvert.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/convert/dict/SysDictTypeConvert.java @@ -3,6 +3,7 @@ package cn.iocoder.dashboard.modules.system.convert.dict; import cn.iocoder.dashboard.common.pojo.PageResult; import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypeCreateReqVO; import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypeRespVO; +import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypeSimpleRespVO; import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypeUpdateReqVO; import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dict.SysDictTypeDO; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -10,6 +11,8 @@ import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; +import java.util.List; + @Mapper public interface SysDictTypeConvert { @@ -26,4 +29,6 @@ public interface SysDictTypeConvert { SysDictTypeDO convert(SysDictTypeUpdateReqVO bean); + List convertList(List list); + } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/dict/SysDictTypeMapper.java b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/dict/SysDictTypeMapper.java index 7c348a174..f9aa104ce 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/dict/SysDictTypeMapper.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/dict/SysDictTypeMapper.java @@ -4,10 +4,13 @@ import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; import cn.iocoder.dashboard.framework.mybatis.core.util.MyBatisUtils; import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypePageReqVO; import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dict.SysDictTypeDO; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + @Mapper public interface SysDictTypeMapper extends BaseMapper { @@ -27,4 +30,8 @@ public interface SysDictTypeMapper extends BaseMapper { return selectOne(new QueryWrapperX().eq("name", name)); } + default List selectList() { + return selectList(new QueryWrapper<>()); + } + } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/dict/SysDictTypeService.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/dict/SysDictTypeService.java index e4d1b594e..3a1e46f9f 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/dict/SysDictTypeService.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/dict/SysDictTypeService.java @@ -6,6 +6,8 @@ import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypePa import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypeUpdateReqVO; import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dict.SysDictTypeDO; +import java.util.List; + /** * 字典类型 Service 接口 * @@ -59,4 +61,11 @@ public interface SysDictTypeService { */ void deleteDictType(Long id); + /** + * 获得全部字典类型列表 + * + * @return 字典类型列表 + */ + List listDictTypes(); + } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/dict/impl/SysDictTypeServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/dict/impl/SysDictTypeServiceImpl.java index 7c8dea31d..7738b16d1 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/dict/impl/SysDictTypeServiceImpl.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/dict/impl/SysDictTypeServiceImpl.java @@ -15,6 +15,8 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.List; + import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.*; /** @@ -74,6 +76,11 @@ public class SysDictTypeServiceImpl implements SysDictTypeService { // TODO 发送 MQ 消息 } + @Override + public List listDictTypes() { + return dictTypeMapper.selectList(); + } + @Transactional public void deleteDictType0(Long id) { // 校验是否存在