Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
T
topology
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
姜立玮
topology
Commits
0d546e4b
提交
0d546e4b
authored
5月 30, 2020
作者:
RuoYi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
参数管理支持缓存操作
上级
b16b860b
变更
6
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
120 行增加
和
23 行删除
+120
-23
config.js
ruoyi-ui/src/api/system/config.js
+8
-0
index.vue
ruoyi-ui/src/views/system/config/index.vue
+21
-1
Constants.java
ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java
+5
-0
SysConfigController.java
.../ruoyi/project/system/controller/SysConfigController.java
+12
-0
ISysConfigService.java
...a/com/ruoyi/project/system/service/ISysConfigService.java
+5
-8
SysConfigServiceImpl.java
...oyi/project/system/service/impl/SysConfigServiceImpl.java
+69
-14
没有找到文件。
ruoyi-ui/src/api/system/config.js
浏览文件 @
0d546e4b
...
@@ -51,6 +51,14 @@ export function delConfig(configId) {
...
@@ -51,6 +51,14 @@ export function delConfig(configId) {
})
})
}
}
// 清理参数缓存
export
function
clearCache
()
{
return
request
({
url
:
'/system/config/clearCache'
,
method
:
'delete'
})
}
// 导出参数
// 导出参数
export
function
exportConfig
(
query
)
{
export
function
exportConfig
(
query
)
{
return
request
({
return
request
({
...
...
ruoyi-ui/src/views/system/config/index.vue
浏览文件 @
0d546e4b
...
@@ -88,6 +88,15 @@
...
@@ -88,6 +88,15 @@
v-hasPermi=
"['system:config:export']"
v-hasPermi=
"['system:config: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:config:remove']"
>
清理缓存
</el-button>
</el-col>
</el-row>
</el-row>
<el-table
v-loading=
"loading"
:data=
"configList"
@
selection-change=
"handleSelectionChange"
>
<el-table
v-loading=
"loading"
:data=
"configList"
@
selection-change=
"handleSelectionChange"
>
...
@@ -165,7 +174,7 @@
...
@@ -165,7 +174,7 @@
</template>
</template>
<
script
>
<
script
>
import
{
listConfig
,
getConfig
,
delConfig
,
addConfig
,
updateConfig
,
exportConfig
}
from
"@/api/system/config"
;
import
{
listConfig
,
getConfig
,
delConfig
,
addConfig
,
updateConfig
,
exportConfig
,
clearCache
}
from
"@/api/system/config"
;
export
default
{
export
default
{
name
:
"Config"
,
name
:
"Config"
,
...
@@ -340,6 +349,17 @@ export default {
...
@@ -340,6 +349,17 @@ export default {
}).
then
(
response
=>
{
}).
then
(
response
=>
{
this
.
download
(
response
.
msg
);
this
.
download
(
response
.
msg
);
}).
catch
(
function
()
{});
}).
catch
(
function
()
{});
},
/** 清理缓存按钮操作 */
handleClearCache
()
{
const
queryParams
=
this
.
queryParams
;
clearCache
().
then
(
response
=>
{
if
(
response
.
code
===
200
)
{
this
.
msgSuccess
(
"清理成功"
);
}
else
{
this
.
msgError
(
response
.
msg
);
}
});
}
}
}
}
};
};
...
...
ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java
浏览文件 @
0d546e4b
...
@@ -109,6 +109,11 @@ public class Constants
...
@@ -109,6 +109,11 @@ public class Constants
*/
*/
public
static
final
String
JWT_AUTHORITIES
=
"authorities"
;
public
static
final
String
JWT_AUTHORITIES
=
"authorities"
;
/**
* 参数管理 cache key
*/
public
static
final
String
SYS_CONFIG_KEY
=
"sys_config:"
;
/**
/**
* 资源映射路径 前缀
* 资源映射路径 前缀
*/
*/
...
...
ruoyi/src/main/java/com/ruoyi/project/system/controller/SysConfigController.java
浏览文件 @
0d546e4b
...
@@ -118,4 +118,16 @@ public class SysConfigController extends BaseController
...
@@ -118,4 +118,16 @@ public class SysConfigController extends BaseController
{
{
return
toAjax
(
configService
.
deleteConfigByIds
(
configIds
));
return
toAjax
(
configService
.
deleteConfigByIds
(
configIds
));
}
}
/**
* 清空缓存
*/
@PreAuthorize
(
"@ss.hasPermi('system:config:remove')"
)
@Log
(
title
=
"参数管理"
,
businessType
=
BusinessType
.
CLEAN
)
@DeleteMapping
(
"/clearCache"
)
public
AjaxResult
clearCache
()
{
configService
.
clearCache
();
return
AjaxResult
.
success
();
}
}
}
ruoyi/src/main/java/com/ruoyi/project/system/service/ISysConfigService.java
浏览文件 @
0d546e4b
...
@@ -50,14 +50,6 @@ public interface ISysConfigService
...
@@ -50,14 +50,6 @@ public interface ISysConfigService
*/
*/
public
int
updateConfig
(
SysConfig
config
);
public
int
updateConfig
(
SysConfig
config
);
/**
* 删除参数配置信息
*
* @param configId 参数ID
* @return 结果
*/
public
int
deleteConfigById
(
Long
configId
);
/**
/**
* 批量删除参数信息
* 批量删除参数信息
*
*
...
@@ -66,6 +58,11 @@ public interface ISysConfigService
...
@@ -66,6 +58,11 @@ public interface ISysConfigService
*/
*/
public
int
deleteConfigByIds
(
Long
[]
configIds
);
public
int
deleteConfigByIds
(
Long
[]
configIds
);
/**
* 清空缓存数据
*/
public
void
clearCache
();
/**
/**
* 校验参数键名是否唯一
* 校验参数键名是否唯一
*
*
...
...
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysConfigServiceImpl.java
浏览文件 @
0d546e4b
package
com
.
ruoyi
.
project
.
system
.
service
.
impl
;
package
com
.
ruoyi
.
project
.
system
.
service
.
impl
;
import
java.util.Collection
;
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
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.core.text.Convert
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.framework.redis.RedisCache
;
import
com.ruoyi.project.system.domain.SysConfig
;
import
com.ruoyi.project.system.domain.SysConfig
;
import
com.ruoyi.project.system.mapper.SysConfigMapper
;
import
com.ruoyi.project.system.mapper.SysConfigMapper
;
import
com.ruoyi.project.system.service.ISysConfigService
;
import
com.ruoyi.project.system.service.ISysConfigService
;
...
@@ -20,6 +25,22 @@ public class SysConfigServiceImpl implements ISysConfigService
...
@@ -20,6 +25,22 @@ public class SysConfigServiceImpl implements ISysConfigService
@Autowired
@Autowired
private
SysConfigMapper
configMapper
;
private
SysConfigMapper
configMapper
;
@Autowired
private
RedisCache
redisCache
;
/**
* 项目启动时,初始化参数到缓存
*/
@PostConstruct
public
void
init
()
{
List
<
SysConfig
>
configsList
=
configMapper
.
selectConfigList
(
new
SysConfig
());
for
(
SysConfig
config
:
configsList
)
{
redisCache
.
setCacheObject
(
getCacheKey
(
config
.
getConfigKey
()),
config
.
getConfigValue
());
}
}
/**
/**
* 查询参数配置信息
* 查询参数配置信息
*
*
...
@@ -43,10 +64,20 @@ public class SysConfigServiceImpl implements ISysConfigService
...
@@ -43,10 +64,20 @@ public class SysConfigServiceImpl implements ISysConfigService
@Override
@Override
public
String
selectConfigByKey
(
String
configKey
)
public
String
selectConfigByKey
(
String
configKey
)
{
{
String
configValue
=
Convert
.
toStr
(
redisCache
.
getCacheObject
(
getCacheKey
(
configKey
)));
if
(
StringUtils
.
isNotEmpty
(
configValue
))
{
return
configValue
;
}
SysConfig
config
=
new
SysConfig
();
SysConfig
config
=
new
SysConfig
();
config
.
setConfigKey
(
configKey
);
config
.
setConfigKey
(
configKey
);
SysConfig
retConfig
=
configMapper
.
selectConfig
(
config
);
SysConfig
retConfig
=
configMapper
.
selectConfig
(
config
);
return
StringUtils
.
isNotNull
(
retConfig
)
?
retConfig
.
getConfigValue
()
:
""
;
if
(
StringUtils
.
isNotNull
(
retConfig
))
{
redisCache
.
setCacheObject
(
getCacheKey
(
configKey
),
retConfig
.
getConfigValue
());
return
retConfig
.
getConfigValue
();
}
return
StringUtils
.
EMPTY
;
}
}
/**
/**
...
@@ -70,7 +101,12 @@ public class SysConfigServiceImpl implements ISysConfigService
...
@@ -70,7 +101,12 @@ public class SysConfigServiceImpl implements ISysConfigService
@Override
@Override
public
int
insertConfig
(
SysConfig
config
)
public
int
insertConfig
(
SysConfig
config
)
{
{
return
configMapper
.
insertConfig
(
config
);
int
row
=
configMapper
.
insertConfig
(
config
);
if
(
row
>
0
)
{
redisCache
.
setCacheObject
(
getCacheKey
(
config
.
getConfigKey
()),
config
.
getConfigValue
());
}
return
row
;
}
}
/**
/**
...
@@ -82,31 +118,39 @@ public class SysConfigServiceImpl implements ISysConfigService
...
@@ -82,31 +118,39 @@ public class SysConfigServiceImpl implements ISysConfigService
@Override
@Override
public
int
updateConfig
(
SysConfig
config
)
public
int
updateConfig
(
SysConfig
config
)
{
{
return
configMapper
.
updateConfig
(
config
);
int
row
=
configMapper
.
updateConfig
(
config
);
if
(
row
>
0
)
{
redisCache
.
setCacheObject
(
getCacheKey
(
config
.
getConfigKey
()),
config
.
getConfigValue
());
}
return
row
;
}
}
/**
/**
*
删除参数配置
信息
*
批量删除参数
信息
*
*
* @param configId
参数ID
* @param configId
s 需要删除的
参数ID
* @return 结果
* @return 结果
*/
*/
@Override
@Override
public
int
deleteConfigById
(
Long
configId
)
public
int
deleteConfigById
s
(
Long
[]
configIds
)
{
{
return
configMapper
.
deleteConfigById
(
configId
);
int
count
=
configMapper
.
deleteConfigByIds
(
configIds
);
if
(
count
>
0
)
{
Collection
<
String
>
keys
=
redisCache
.
keys
(
Constants
.
SYS_CONFIG_KEY
+
"*"
);
redisCache
.
deleteObject
(
keys
);
}
return
count
;
}
}
/**
/**
* 批量删除参数信息
* 清空缓存数据
*
* @param configIds 需要删除的参数ID
* @return 结果
*/
*/
@Override
public
void
clearCache
()
public
int
deleteConfigByIds
(
Long
[]
configIds
)
{
{
return
configMapper
.
deleteConfigByIds
(
configIds
);
Collection
<
String
>
keys
=
redisCache
.
keys
(
Constants
.
SYS_CONFIG_KEY
+
"*"
);
redisCache
.
deleteObject
(
keys
);
}
}
/**
/**
...
@@ -126,4 +170,15 @@ public class SysConfigServiceImpl implements ISysConfigService
...
@@ -126,4 +170,15 @@ public class SysConfigServiceImpl implements ISysConfigService
}
}
return
UserConstants
.
UNIQUE
;
return
UserConstants
.
UNIQUE
;
}
}
/**
* 设置cache key
*
* @param configKey 参数键
* @return 缓存键key
*/
private
String
getCacheKey
(
String
configKey
)
{
return
Constants
.
SYS_CONFIG_KEY
+
configKey
;
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论