[fix]修改App中根据字典类型查询字典数据列表(只包含默认租户的数据)
This commit is contained in:
parent
03a9967da4
commit
e23afb299b
5
pom.xml
5
pom.xml
@ -432,11 +432,12 @@
|
||||
<version>1.6.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!--<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-springdoc-ui</artifactId>
|
||||
<version>3.0.3</version>
|
||||
</dependency>
|
||||
</dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
|
@ -36,7 +36,7 @@ public class AppDictController {
|
||||
*/
|
||||
@GetMapping(value = "/type/{dictType}")
|
||||
public R<List<SysDictDataVo>> dictType(@PathVariable String dictType) {
|
||||
List<SysDictDataVo> data = dictTypeService.selectDictDataByType(dictType);
|
||||
List<SysDictDataVo> data = dictTypeService.selectDictDataByTypeWithDefaultTenantID(dictType);
|
||||
if (ObjectUtil.isNull(data)) {
|
||||
data = new ArrayList<>();
|
||||
}
|
||||
|
@ -35,6 +35,11 @@ public interface CacheNames {
|
||||
*/
|
||||
String SYS_DICT_TYPE = "sys_dict_type";
|
||||
|
||||
/**
|
||||
* 数据字典类型
|
||||
*/
|
||||
String SYS_DICT_TYPE_WITH_DEFAULT_TENANTID= "sys_dict_type_with_default_tenantid";
|
||||
|
||||
/**
|
||||
* 租户
|
||||
*/
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.dromara.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.dromara.common.core.constant.TenantConstants;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.system.domain.SysDictData;
|
||||
import org.dromara.system.domain.vo.SysDictDataVo;
|
||||
@ -26,4 +27,18 @@ public interface SysDictDataMapper extends BaseMapperPlus<SysDictData, SysDictDa
|
||||
.eq(SysDictData::getDictType, dictType)
|
||||
.orderByAsc(SysDictData::getDictSort));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据列表(只包含默认租户的数据)
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 符合条件的字典数据列表
|
||||
*/
|
||||
default List<SysDictDataVo> selectDictDataByTypeWithDefaultTenantID(String dictType) {
|
||||
return selectVoList(
|
||||
new LambdaQueryWrapper<SysDictData>()
|
||||
.eq(SysDictData::getDictType, dictType)
|
||||
.eq(SysDictData::getTenantId, TenantConstants.DEFAULT_TENANT_ID)
|
||||
.orderByAsc(SysDictData::getDictSort));
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,14 @@ public interface ISysDictTypeService {
|
||||
*/
|
||||
List<SysDictDataVo> selectDictDataByType(String dictType);
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据(只包含默认租户的数据)
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
List<SysDictDataVo> selectDictDataByTypeWithDefaultTenantID(String dictType);
|
||||
|
||||
/**
|
||||
* 根据字典类型ID查询信息
|
||||
*
|
||||
|
@ -104,6 +104,23 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据(只包含默认租户的数据)
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
@Cacheable(cacheNames = CacheNames.SYS_DICT_TYPE_WITH_DEFAULT_TENANTID, key = "#dictType")
|
||||
@Override
|
||||
public List<SysDictDataVo> selectDictDataByTypeWithDefaultTenantID(String dictType) {
|
||||
List<SysDictDataVo> dictDatas = dictDataMapper.selectDictDataByTypeWithDefaultTenantID(dictType);
|
||||
if (CollUtil.isNotEmpty(dictDatas)) {
|
||||
return dictDatas;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据字典类型ID查询信息
|
||||
*
|
||||
@ -142,6 +159,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
}
|
||||
CacheUtils.evict(CacheNames.SYS_DICT, dictType.getDictType());
|
||||
CacheUtils.evict(CacheNames.SYS_DICT_TYPE, dictType.getDictType());
|
||||
CacheUtils.evict(CacheNames.SYS_DICT_TYPE_WITH_DEFAULT_TENANTID, dictType.getDictType());
|
||||
}
|
||||
baseMapper.deleteByIds(Arrays.asList(dictIds));
|
||||
}
|
||||
@ -153,6 +171,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
public void resetDictCache() {
|
||||
CacheUtils.clear(CacheNames.SYS_DICT);
|
||||
CacheUtils.clear(CacheNames.SYS_DICT_TYPE);
|
||||
CacheUtils.clear(CacheNames.SYS_DICT_TYPE_WITH_DEFAULT_TENANTID);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,6 +211,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
if (row > 0) {
|
||||
CacheUtils.evict(CacheNames.SYS_DICT, oldDict.getDictType());
|
||||
CacheUtils.evict(CacheNames.SYS_DICT_TYPE, oldDict.getDictType());
|
||||
CacheUtils.evict(CacheNames.SYS_DICT_TYPE_WITH_DEFAULT_TENANTID, oldDict.getDictType());
|
||||
return dictDataMapper.selectDictDataByType(dict.getDictType());
|
||||
}
|
||||
throw new ServiceException("操作失败");
|
||||
|
Loading…
x
Reference in New Issue
Block a user