Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
cocktail-party-server
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
cocktail-party
cocktail-party-server
Commits
1e2058bd
提交
1e2058bd
authored
5月 30, 2020
作者:
RuoYi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
字典管理添加缓存读取
上级
0d546e4b
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
229 行增加
和
69 行删除
+229
-69
data.js
ruoyi-ui/src/api/system/dict/data.js
+1
-1
type.js
ruoyi-ui/src/api/system/dict/type.js
+8
-0
index.vue
ruoyi-ui/src/views/system/config/index.vue
+0
-1
index.vue
ruoyi-ui/src/views/system/dict/index.vue
+20
-1
Constants.java
ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java
+5
-0
DictUtils.java
ruoyi/src/main/java/com/ruoyi/common/utils/DictUtils.java
+64
-0
StringUtils.java
ruoyi/src/main/java/com/ruoyi/common/utils/StringUtils.java
+7
-0
SysDictDataController.java
...uoyi/project/system/controller/SysDictDataController.java
+6
-2
SysDictTypeController.java
...uoyi/project/system/controller/SysDictTypeController.java
+12
-0
ISysDictDataService.java
...com/ruoyi/project/system/service/ISysDictDataService.java
+0
-16
ISysDictTypeService.java
...com/ruoyi/project/system/service/ISysDictTypeService.java
+14
-8
SysDictDataServiceImpl.java
...i/project/system/service/impl/SysDictDataServiceImpl.java
+19
-27
SysDictTypeServiceImpl.java
...i/project/system/service/impl/SysDictTypeServiceImpl.java
+73
-13
没有找到文件。
ruoyi-ui/src/api/system/dict/data.js
浏览文件 @
1e2058bd
...
@@ -20,7 +20,7 @@ export function getData(dictCode) {
...
@@ -20,7 +20,7 @@ export function getData(dictCode) {
// 根据字典类型查询字典数据信息
// 根据字典类型查询字典数据信息
export
function
getDicts
(
dictType
)
{
export
function
getDicts
(
dictType
)
{
return
request
({
return
request
({
url
:
'/system/dict/data/
dictT
ype/'
+
dictType
,
url
:
'/system/dict/data/
t
ype/'
+
dictType
,
method
:
'get'
method
:
'get'
})
})
}
}
...
...
ruoyi-ui/src/api/system/dict/type.js
浏览文件 @
1e2058bd
...
@@ -43,6 +43,14 @@ export function delType(dictId) {
...
@@ -43,6 +43,14 @@ export function delType(dictId) {
})
})
}
}
// 清理参数缓存
export
function
clearCache
()
{
return
request
({
url
:
'/system/dict/type/clearCache'
,
method
:
'delete'
})
}
// 导出字典类型
// 导出字典类型
export
function
exportType
(
query
)
{
export
function
exportType
(
query
)
{
return
request
({
return
request
({
...
...
ruoyi-ui/src/views/system/config/index.vue
浏览文件 @
1e2058bd
...
@@ -352,7 +352,6 @@ export default {
...
@@ -352,7 +352,6 @@ export default {
},
},
/** 清理缓存按钮操作 */
/** 清理缓存按钮操作 */
handleClearCache
()
{
handleClearCache
()
{
const
queryParams
=
this
.
queryParams
;
clearCache
().
then
(
response
=>
{
clearCache
().
then
(
response
=>
{
if
(
response
.
code
===
200
)
{
if
(
response
.
code
===
200
)
{
this
.
msgSuccess
(
"清理成功"
);
this
.
msgSuccess
(
"清理成功"
);
...
...
ruoyi-ui/src/views/system/dict/index.vue
浏览文件 @
1e2058bd
...
@@ -94,6 +94,15 @@
...
@@ -94,6 +94,15 @@
v-hasPermi=
"['system:dict:export']"
v-hasPermi=
"['system:dict:export']"
>
导出
</el-button>
>
导出
</el-button>
</el-col>
</el-col>
<el-col
:span=
"1.5"
>
<el-button
type=
"danger"
icon=
"el-icon-refresh"
size=
"mini"
@
click=
"handleClearCache"
v-hasPermi=
"['system:dict:remove']"
>
清理缓存
</el-button>
</el-col>
</el-row>
</el-row>
<el-table
v-loading=
"loading"
:data=
"typeList"
@
selection-change=
"handleSelectionChange"
>
<el-table
v-loading=
"loading"
:data=
"typeList"
@
selection-change=
"handleSelectionChange"
>
...
@@ -173,7 +182,7 @@
...
@@ -173,7 +182,7 @@
</template>
</template>
<
script
>
<
script
>
import
{
listType
,
getType
,
delType
,
addType
,
updateType
,
exportType
}
from
"@/api/system/dict/type"
;
import
{
listType
,
getType
,
delType
,
addType
,
updateType
,
exportType
,
clearCache
}
from
"@/api/system/dict/type"
;
export
default
{
export
default
{
name
:
"Dict"
,
name
:
"Dict"
,
...
@@ -344,6 +353,16 @@ export default {
...
@@ -344,6 +353,16 @@ export default {
}).
then
(
response
=>
{
}).
then
(
response
=>
{
this
.
download
(
response
.
msg
);
this
.
download
(
response
.
msg
);
}).
catch
(
function
()
{});
}).
catch
(
function
()
{});
},
/** 清理缓存按钮操作 */
handleClearCache
()
{
clearCache
().
then
(
response
=>
{
if
(
response
.
code
===
200
)
{
this
.
msgSuccess
(
"清理成功"
);
}
else
{
this
.
msgError
(
response
.
msg
);
}
});
}
}
}
}
};
};
...
...
ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java
浏览文件 @
1e2058bd
...
@@ -114,6 +114,11 @@ public class Constants
...
@@ -114,6 +114,11 @@ public class Constants
*/
*/
public
static
final
String
SYS_CONFIG_KEY
=
"sys_config:"
;
public
static
final
String
SYS_CONFIG_KEY
=
"sys_config:"
;
/**
* 字典管理 cache key
*/
public
static
final
String
SYS_DICT_KEY
=
"sys_dict:"
;
/**
/**
* 资源映射路径 前缀
* 资源映射路径 前缀
*/
*/
...
...
ruoyi/src/main/java/com/ruoyi/common/utils/DictUtils.java
0 → 100644
浏览文件 @
1e2058bd
package
com
.
ruoyi
.
common
.
utils
;
import
java.util.Collection
;
import
java.util.List
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
com.ruoyi.framework.redis.RedisCache
;
import
com.ruoyi.project.system.domain.SysDictData
;
/**
* 字典工具类
*
* @author ruoyi
*/
public
class
DictUtils
{
/**
* 设置字典缓存
*
* @param key 参数键
* @param dictDatas 字典数据列表
*/
public
static
void
setDictCache
(
String
key
,
List
<
SysDictData
>
dictDatas
)
{
SpringUtils
.
getBean
(
RedisCache
.
class
).
setCacheObject
(
getCacheKey
(
key
),
dictDatas
);
}
/**
* 获取字典缓存
*
* @param key 参数键
* @return dictDatas 字典数据列表
*/
public
static
List
<
SysDictData
>
getDictCache
(
String
key
)
{
Object
cacheObj
=
SpringUtils
.
getBean
(
RedisCache
.
class
).
getCacheObject
(
getCacheKey
(
key
));
if
(
StringUtils
.
isNotNull
(
cacheObj
))
{
List
<
SysDictData
>
DictDatas
=
StringUtils
.
cast
(
cacheObj
);
return
DictDatas
;
}
return
null
;
}
/**
* 清空字典缓存
*/
public
static
void
clearDictCache
()
{
Collection
<
String
>
keys
=
SpringUtils
.
getBean
(
RedisCache
.
class
).
keys
(
Constants
.
SYS_DICT_KEY
+
"*"
);
SpringUtils
.
getBean
(
RedisCache
.
class
).
deleteObject
(
keys
);
}
/**
* 设置cache key
*
* @param configKey 参数键
* @return 缓存键key
*/
public
static
String
getCacheKey
(
String
configKey
)
{
return
Constants
.
SYS_DICT_KEY
+
configKey
;
}
}
ruoyi/src/main/java/com/ruoyi/common/utils/StringUtils.java
浏览文件 @
1e2058bd
...
@@ -450,4 +450,10 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
...
@@ -450,4 +450,10 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
}
}
return
sb
.
toString
();
return
sb
.
toString
();
}
}
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
>
T
cast
(
Object
obj
)
{
return
(
T
)
obj
;
}
}
}
\ No newline at end of file
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictDataController.java
浏览文件 @
1e2058bd
...
@@ -21,6 +21,7 @@ import com.ruoyi.framework.web.domain.AjaxResult;
...
@@ -21,6 +21,7 @@ import com.ruoyi.framework.web.domain.AjaxResult;
import
com.ruoyi.framework.web.page.TableDataInfo
;
import
com.ruoyi.framework.web.page.TableDataInfo
;
import
com.ruoyi.project.system.domain.SysDictData
;
import
com.ruoyi.project.system.domain.SysDictData
;
import
com.ruoyi.project.system.service.ISysDictDataService
;
import
com.ruoyi.project.system.service.ISysDictDataService
;
import
com.ruoyi.project.system.service.ISysDictTypeService
;
/**
/**
* 数据字典信息
* 数据字典信息
...
@@ -34,6 +35,9 @@ public class SysDictDataController extends BaseController
...
@@ -34,6 +35,9 @@ public class SysDictDataController extends BaseController
@Autowired
@Autowired
private
ISysDictDataService
dictDataService
;
private
ISysDictDataService
dictDataService
;
@Autowired
private
ISysDictTypeService
dictTypeService
;
@PreAuthorize
(
"@ss.hasPermi('system:dict:list')"
)
@PreAuthorize
(
"@ss.hasPermi('system:dict:list')"
)
@GetMapping
(
"/list"
)
@GetMapping
(
"/list"
)
public
TableDataInfo
list
(
SysDictData
dictData
)
public
TableDataInfo
list
(
SysDictData
dictData
)
...
@@ -66,10 +70,10 @@ public class SysDictDataController extends BaseController
...
@@ -66,10 +70,10 @@ public class SysDictDataController extends BaseController
/**
/**
* 根据字典类型查询字典数据信息
* 根据字典类型查询字典数据信息
*/
*/
@GetMapping
(
value
=
"/
dictT
ype/{dictType}"
)
@GetMapping
(
value
=
"/
t
ype/{dictType}"
)
public
AjaxResult
dictType
(
@PathVariable
String
dictType
)
public
AjaxResult
dictType
(
@PathVariable
String
dictType
)
{
{
return
AjaxResult
.
success
(
dict
Data
Service
.
selectDictDataByType
(
dictType
));
return
AjaxResult
.
success
(
dict
Type
Service
.
selectDictDataByType
(
dictType
));
}
}
/**
/**
...
...
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictTypeController.java
浏览文件 @
1e2058bd
...
@@ -107,6 +107,18 @@ public class SysDictTypeController extends BaseController
...
@@ -107,6 +107,18 @@ public class SysDictTypeController extends BaseController
return
toAjax
(
dictTypeService
.
deleteDictTypeByIds
(
dictIds
));
return
toAjax
(
dictTypeService
.
deleteDictTypeByIds
(
dictIds
));
}
}
/**
* 清空缓存
*/
@PreAuthorize
(
"@ss.hasPermi('system:dict:remove')"
)
@Log
(
title
=
"字典类型"
,
businessType
=
BusinessType
.
CLEAN
)
@DeleteMapping
(
"/clearCache"
)
public
AjaxResult
clearCache
()
{
dictTypeService
.
clearCache
();
return
AjaxResult
.
success
();
}
/**
/**
* 获取字典选择框列表
* 获取字典选择框列表
*/
*/
...
...
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictDataService.java
浏览文件 @
1e2058bd
...
@@ -18,14 +18,6 @@ public interface ISysDictDataService
...
@@ -18,14 +18,6 @@ public interface ISysDictDataService
*/
*/
public
List
<
SysDictData
>
selectDictDataList
(
SysDictData
dictData
);
public
List
<
SysDictData
>
selectDictDataList
(
SysDictData
dictData
);
/**
* 根据字典类型查询字典数据
*
* @param dictType 字典类型
* @return 字典数据集合信息
*/
public
List
<
SysDictData
>
selectDictDataByType
(
String
dictType
);
/**
/**
* 根据字典类型和字典键值查询字典数据信息
* 根据字典类型和字典键值查询字典数据信息
*
*
...
@@ -43,14 +35,6 @@ public interface ISysDictDataService
...
@@ -43,14 +35,6 @@ public interface ISysDictDataService
*/
*/
public
SysDictData
selectDictDataById
(
Long
dictCode
);
public
SysDictData
selectDictDataById
(
Long
dictCode
);
/**
* 通过字典ID删除字典数据信息
*
* @param dictCode 字典数据ID
* @return 结果
*/
public
int
deleteDictDataById
(
Long
dictCode
);
/**
/**
* 批量删除字典数据信息
* 批量删除字典数据信息
*
*
...
...
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictTypeService.java
浏览文件 @
1e2058bd
package
com
.
ruoyi
.
project
.
system
.
service
;
package
com
.
ruoyi
.
project
.
system
.
service
;
import
java.util.List
;
import
java.util.List
;
import
com.ruoyi.project.system.domain.SysDictData
;
import
com.ruoyi.project.system.domain.SysDictType
;
import
com.ruoyi.project.system.domain.SysDictType
;
/**
/**
...
@@ -25,6 +26,14 @@ public interface ISysDictTypeService
...
@@ -25,6 +26,14 @@ public interface ISysDictTypeService
*/
*/
public
List
<
SysDictType
>
selectDictTypeAll
();
public
List
<
SysDictType
>
selectDictTypeAll
();
/**
* 根据字典类型查询字典数据
*
* @param dictType 字典类型
* @return 字典数据集合信息
*/
public
List
<
SysDictData
>
selectDictDataByType
(
String
dictType
);
/**
/**
* 根据字典类型ID查询信息
* 根据字典类型ID查询信息
*
*
...
@@ -41,14 +50,6 @@ public interface ISysDictTypeService
...
@@ -41,14 +50,6 @@ public interface ISysDictTypeService
*/
*/
public
SysDictType
selectDictTypeByType
(
String
dictType
);
public
SysDictType
selectDictTypeByType
(
String
dictType
);
/**
* 通过字典ID删除字典信息
*
* @param dictId 字典ID
* @return 结果
*/
public
int
deleteDictTypeById
(
Long
dictId
);
/**
/**
* 批量删除字典信息
* 批量删除字典信息
*
*
...
@@ -57,6 +58,11 @@ public interface ISysDictTypeService
...
@@ -57,6 +58,11 @@ public interface ISysDictTypeService
*/
*/
public
int
deleteDictTypeByIds
(
Long
[]
dictIds
);
public
int
deleteDictTypeByIds
(
Long
[]
dictIds
);
/**
* 清空缓存数据
*/
public
void
clearCache
();
/**
/**
* 新增保存字典类型信息
* 新增保存字典类型信息
*
*
...
...
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictDataServiceImpl.java
浏览文件 @
1e2058bd
...
@@ -3,6 +3,7 @@ package com.ruoyi.project.system.service.impl;
...
@@ -3,6 +3,7 @@ package com.ruoyi.project.system.service.impl;
import
java.util.List
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.common.utils.DictUtils
;
import
com.ruoyi.project.system.domain.SysDictData
;
import
com.ruoyi.project.system.domain.SysDictData
;
import
com.ruoyi.project.system.mapper.SysDictDataMapper
;
import
com.ruoyi.project.system.mapper.SysDictDataMapper
;
import
com.ruoyi.project.system.service.ISysDictDataService
;
import
com.ruoyi.project.system.service.ISysDictDataService
;
...
@@ -30,18 +31,6 @@ public class SysDictDataServiceImpl implements ISysDictDataService
...
@@ -30,18 +31,6 @@ public class SysDictDataServiceImpl implements ISysDictDataService
return
dictDataMapper
.
selectDictDataList
(
dictData
);
return
dictDataMapper
.
selectDictDataList
(
dictData
);
}
}
/**
* 根据字典类型查询字典数据
*
* @param dictType 字典类型
* @return 字典数据集合信息
*/
@Override
public
List
<
SysDictData
>
selectDictDataByType
(
String
dictType
)
{
return
dictDataMapper
.
selectDictDataByType
(
dictType
);
}
/**
/**
* 根据字典类型和字典键值查询字典数据信息
* 根据字典类型和字典键值查询字典数据信息
*
*
...
@@ -67,18 +56,6 @@ public class SysDictDataServiceImpl implements ISysDictDataService
...
@@ -67,18 +56,6 @@ public class SysDictDataServiceImpl implements ISysDictDataService
return
dictDataMapper
.
selectDictDataById
(
dictCode
);
return
dictDataMapper
.
selectDictDataById
(
dictCode
);
}
}
/**
* 通过字典ID删除字典数据信息
*
* @param dictCode 字典数据ID
* @return 结果
*/
@Override
public
int
deleteDictDataById
(
Long
dictCode
)
{
return
dictDataMapper
.
deleteDictDataById
(
dictCode
);
}
/**
/**
* 批量删除字典数据信息
* 批量删除字典数据信息
*
*
...
@@ -87,7 +64,12 @@ public class SysDictDataServiceImpl implements ISysDictDataService
...
@@ -87,7 +64,12 @@ public class SysDictDataServiceImpl implements ISysDictDataService
*/
*/
public
int
deleteDictDataByIds
(
Long
[]
dictCodes
)
public
int
deleteDictDataByIds
(
Long
[]
dictCodes
)
{
{
return
dictDataMapper
.
deleteDictDataByIds
(
dictCodes
);
int
row
=
dictDataMapper
.
deleteDictDataByIds
(
dictCodes
);
if
(
row
>
0
)
{
DictUtils
.
clearDictCache
();
}
return
row
;
}
}
/**
/**
...
@@ -99,7 +81,12 @@ public class SysDictDataServiceImpl implements ISysDictDataService
...
@@ -99,7 +81,12 @@ public class SysDictDataServiceImpl implements ISysDictDataService
@Override
@Override
public
int
insertDictData
(
SysDictData
dictData
)
public
int
insertDictData
(
SysDictData
dictData
)
{
{
return
dictDataMapper
.
insertDictData
(
dictData
);
int
row
=
dictDataMapper
.
insertDictData
(
dictData
);
if
(
row
>
0
)
{
DictUtils
.
clearDictCache
();
}
return
row
;
}
}
/**
/**
...
@@ -111,6 +98,11 @@ public class SysDictDataServiceImpl implements ISysDictDataService
...
@@ -111,6 +98,11 @@ public class SysDictDataServiceImpl implements ISysDictDataService
@Override
@Override
public
int
updateDictData
(
SysDictData
dictData
)
public
int
updateDictData
(
SysDictData
dictData
)
{
{
return
dictDataMapper
.
updateDictData
(
dictData
);
int
row
=
dictDataMapper
.
updateDictData
(
dictData
);
if
(
row
>
0
)
{
DictUtils
.
clearDictCache
();
}
return
row
;
}
}
}
}
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictTypeServiceImpl.java
浏览文件 @
1e2058bd
package
com
.
ruoyi
.
project
.
system
.
service
.
impl
;
package
com
.
ruoyi
.
project
.
system
.
service
.
impl
;
import
java.util.List
;
import
java.util.List
;
import
javax.annotation.PostConstruct
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.exception.CustomException
;
import
com.ruoyi.common.utils.DictUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.project.system.domain.SysDictData
;
import
com.ruoyi.project.system.domain.SysDictType
;
import
com.ruoyi.project.system.domain.SysDictType
;
import
com.ruoyi.project.system.mapper.SysDictDataMapper
;
import
com.ruoyi.project.system.mapper.SysDictDataMapper
;
import
com.ruoyi.project.system.mapper.SysDictTypeMapper
;
import
com.ruoyi.project.system.mapper.SysDictTypeMapper
;
...
@@ -25,6 +29,20 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
...
@@ -25,6 +29,20 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
@Autowired
@Autowired
private
SysDictDataMapper
dictDataMapper
;
private
SysDictDataMapper
dictDataMapper
;
/**
* 项目启动时,初始化字典到缓存
*/
@PostConstruct
public
void
init
()
{
List
<
SysDictType
>
dictTypeList
=
dictTypeMapper
.
selectDictTypeAll
();
for
(
SysDictType
dictType
:
dictTypeList
)
{
List
<
SysDictData
>
dictDatas
=
dictDataMapper
.
selectDictDataByType
(
dictType
.
getDictType
());
DictUtils
.
setDictCache
(
dictType
.
getDictType
(),
dictDatas
);
}
}
/**
/**
* 根据条件分页查询字典类型
* 根据条件分页查询字典类型
*
*
...
@@ -48,6 +66,29 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
...
@@ -48,6 +66,29 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
return
dictTypeMapper
.
selectDictTypeAll
();
return
dictTypeMapper
.
selectDictTypeAll
();
}
}
/**
* 根据字典类型查询字典数据
*
* @param dictType 字典类型
* @return 字典数据集合信息
*/
@Override
public
List
<
SysDictData
>
selectDictDataByType
(
String
dictType
)
{
List
<
SysDictData
>
dictDatas
=
DictUtils
.
getDictCache
(
dictType
);
if
(
StringUtils
.
isNotNull
(
dictDatas
))
{
return
dictDatas
;
}
dictDatas
=
dictDataMapper
.
selectDictDataByType
(
dictType
);
if
(
StringUtils
.
isNotNull
(
dictDatas
))
{
DictUtils
.
setDictCache
(
dictType
,
dictDatas
);
return
dictDatas
;
}
return
null
;
}
/**
/**
* 根据字典类型ID查询信息
* 根据字典类型ID查询信息
*
*
...
@@ -72,26 +113,35 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
...
@@ -72,26 +113,35 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
}
}
/**
/**
*
通过字典ID删除字典
信息
*
批量删除字典类型
信息
*
*
* @param dictId
字典ID
* @param dictId
s 需要删除的
字典ID
* @return 结果
* @return 结果
*/
*/
@Override
public
int
deleteDictTypeByIds
(
Long
[]
dictIds
)
public
int
deleteDictTypeById
(
Long
dictId
)
{
{
return
dictTypeMapper
.
deleteDictTypeById
(
dictId
);
for
(
Long
dictId
:
dictIds
)
{
SysDictType
dictType
=
selectDictTypeById
(
dictId
);
if
(
dictDataMapper
.
countDictDataByType
(
dictType
.
getDictType
())
>
0
)
{
throw
new
CustomException
(
String
.
format
(
"%1$s已分配,不能删除"
,
dictType
.
getDictName
()));
}
}
int
count
=
dictTypeMapper
.
deleteDictTypeByIds
(
dictIds
);
if
(
count
>
0
)
{
DictUtils
.
clearDictCache
();
}
return
count
;
}
}
/**
/**
* 批量删除字典类型信息
* 清空缓存数据
*
* @param dictIds 需要删除的字典ID
* @return 结果
*/
*/
public
int
deleteDictTypeByIds
(
Long
[]
dictIds
)
public
void
clearCache
(
)
{
{
return
dictTypeMapper
.
deleteDictTypeByIds
(
dictIds
);
DictUtils
.
clearDictCache
(
);
}
}
/**
/**
...
@@ -103,7 +153,12 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
...
@@ -103,7 +153,12 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
@Override
@Override
public
int
insertDictType
(
SysDictType
dictType
)
public
int
insertDictType
(
SysDictType
dictType
)
{
{
return
dictTypeMapper
.
insertDictType
(
dictType
);
int
row
=
dictTypeMapper
.
insertDictType
(
dictType
);
if
(
row
>
0
)
{
DictUtils
.
clearDictCache
();
}
return
row
;
}
}
/**
/**
...
@@ -118,7 +173,12 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
...
@@ -118,7 +173,12 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
{
{
SysDictType
oldDict
=
dictTypeMapper
.
selectDictTypeById
(
dictType
.
getDictId
());
SysDictType
oldDict
=
dictTypeMapper
.
selectDictTypeById
(
dictType
.
getDictId
());
dictDataMapper
.
updateDictDataType
(
oldDict
.
getDictType
(),
dictType
.
getDictType
());
dictDataMapper
.
updateDictDataType
(
oldDict
.
getDictType
(),
dictType
.
getDictType
());
return
dictTypeMapper
.
updateDictType
(
dictType
);
int
row
=
dictTypeMapper
.
updateDictType
(
dictType
);
if
(
row
>
0
)
{
DictUtils
.
clearDictCache
();
}
return
row
;
}
}
/**
/**
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论