Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 944d960f
由
LN
编写于
2021-12-09 10:47:50 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
新增客户端自定义配置功能
1 个父辈
eb3f2377
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
89 行增加
和
0 行删除
src/main/java/com/neotel/smfcore/common/utils/Constants.java
src/main/java/com/neotel/smfcore/core/system/rest/ClientSettingsController.java
src/main/java/com/neotel/smfcore/core/system/rest/bean/dto/ClientSettingDto.java
src/main/java/com/neotel/smfcore/common/utils/Constants.java
查看文件 @
944d960
...
...
@@ -109,4 +109,7 @@ public class Constants {
*/
public
static
final
String
CACHE_msdSetting
=
"msdSetting"
;
public
static
final
String
CACHE_clientSetting
=
"clientSetting"
;
}
src/main/java/com/neotel/smfcore/core/system/rest/ClientSettingsController.java
0 → 100644
查看文件 @
944d960
package
com
.
neotel
.
smfcore
.
core
.
system
.
rest
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.SecurityUtils
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.system.rest.bean.dto.ClientSettingDto
;
import
com.neotel.smfcore.core.system.rest.bean.dto.SysSettingsDto
;
import
com.neotel.smfcore.core.system.service.po.Settings
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
@Slf4j
@Api
(
tags
=
"界面:设置"
)
@RestController
@RequestMapping
(
"/api/clientSettings"
)
@RequiredArgsConstructor
public
class
ClientSettingsController
{
@Autowired
DataCache
dataCache
;
@ApiOperation
(
"获取界面设置"
)
@GetMapping
()
@PreAuthorize
(
"@el.check('sysSetting')"
)
public
ClientSettingDto
getSettings
(
ClientSettingDto
settingDto
)
{
if
(
settingDto
==
null
||
ObjectUtil
.
isEmpty
(
settingDto
.
getKey
())
)
{
throw
new
ValidateException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"key"
});
}
//先查找自己的用户名,没找到时再找admin
String
userName
=
SecurityUtils
.
getCurrentUsername
();
String
key
=
Constants
.
CACHE_clientSetting
+
"_"
+
userName
+
"_"
+
settingDto
.
getKey
();
String
value
=
dataCache
.
getCache
(
key
);
if
(
ObjectUtil
.
isEmpty
(
value
))
{
if
(!
userName
.
equals
(
Constants
.
SUPER_USERNAME
))
{
key
=
Constants
.
CACHE_clientSetting
+
"_"
+
Constants
.
SUPER_USERNAME
+
"_"
+
settingDto
.
getKey
();
value
=
dataCache
.
getCache
(
key
);
}
}
settingDto
.
setValue
(
value
);
return
settingDto
;
}
@ApiOperation
(
"修改界面设置"
)
@PutMapping
()
@PreAuthorize
(
"@el.check('sysSetting')"
)
public
ResultBean
updateSettings
(
@RequestBody
ClientSettingDto
settingDto
)
{
if
(
settingDto
==
null
||
ObjectUtil
.
isEmpty
(
settingDto
.
getKey
())
||
ObjectUtil
.
isEmpty
(
settingDto
.
getValue
()))
{
throw
new
ValidateException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"key"
});
}
String
userName
=
SecurityUtils
.
getCurrentUsername
();
String
key
=
Constants
.
CACHE_clientSetting
+
"_"
+
userName
+
"_"
+
settingDto
.
getKey
();
dataCache
.
updateCache
(
key
,
settingDto
.
getValue
());
// log.info("修改界面配置:[" + key + "]=[" + settingDto.getValue() + "]");
return
ResultBean
.
newOkResult
(
""
);
}
}
src/main/java/com/neotel/smfcore/core/system/rest/bean/dto/ClientSettingDto.java
0 → 100644
查看文件 @
944d960
package
com
.
neotel
.
smfcore
.
core
.
system
.
rest
.
bean
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.io.Serializable
;
@Getter
@Setter
public
class
ClientSettingDto
implements
Serializable
{
@ApiModelProperty
(
"设置的key"
)
private
String
key
;
@ApiModelProperty
(
"设置的值"
)
private
String
value
;
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论