完善系统与APP配置参数功能
This commit is contained in:
parent
a3681f65b3
commit
6c7ebe83bf
@ -13,8 +13,16 @@ import java.util.Map;
|
||||
* @Version: 1.0
|
||||
**/
|
||||
public interface ISystemConfigManager {
|
||||
|
||||
|
||||
Map<String, String> getConfig();
|
||||
|
||||
Map<String, String> getSystemConfigParams();
|
||||
|
||||
String getSystemConfigParamsValue(String key);
|
||||
|
||||
Map<String, String> getAppConfigParams();
|
||||
|
||||
String getAppConfigParamsValue(String key);
|
||||
|
||||
void refreshConfig();
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package ink.wgink.login.base.manager;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.interfaces.manager.ISystemConfigManager;
|
||||
import ink.wgink.login.base.dao.config.IConfigDao;
|
||||
import ink.wgink.login.base.pojo.dtos.config.ConfigDTO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -51,6 +53,44 @@ public class ConfigManager implements ISystemConfigManager {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getSystemConfigParams() {
|
||||
Map<String, String> config = getConfig();
|
||||
String systemParams = config.get("systemConfigParams");
|
||||
if (StringUtils.isBlank(systemParams)) {
|
||||
return null;
|
||||
}
|
||||
return JSONObject.parseObject(systemParams, Map.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSystemConfigParamsValue(String key) {
|
||||
Map<String, String> systemParams = getSystemConfigParams();
|
||||
if (systemParams == null) {
|
||||
return null;
|
||||
}
|
||||
return systemParams.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getAppConfigParams() {
|
||||
Map<String, String> config = getConfig();
|
||||
String appParams = config.get("appConfigParams");
|
||||
if (StringUtils.isBlank(appParams)) {
|
||||
return null;
|
||||
}
|
||||
return JSONObject.parseObject(appParams, Map.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppConfigParamsValue(String key) {
|
||||
Map<String, String> appParams = getAppConfigParams();
|
||||
if (appParams == null) {
|
||||
return null;
|
||||
}
|
||||
return appParams.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新配置
|
||||
*/
|
||||
|
@ -72,6 +72,10 @@ public class ConfigVO {
|
||||
@ApiModelProperty(name = "menuMode", value = "菜单模式")
|
||||
@CheckEmptyAnnotation(name = "菜单模式", types = {"fixedLeft", "floatLeft"})
|
||||
private String menuMode;
|
||||
@ApiModelProperty(name = "systemConfigParams", value = "系统配置参数")
|
||||
private String systemConfigParams;
|
||||
@ApiModelProperty(name = "appConfigParams", value = "app配置参数")
|
||||
private String appConfigParams;
|
||||
|
||||
public String getPasswordValidity() {
|
||||
return passwordValidity == null ? "" : passwordValidity.trim();
|
||||
@ -248,4 +252,20 @@ public class ConfigVO {
|
||||
public void setSystemShortTitle(String systemShortTitle) {
|
||||
this.systemShortTitle = systemShortTitle;
|
||||
}
|
||||
|
||||
public String getSystemConfigParams() {
|
||||
return systemConfigParams == null ? "" : systemConfigParams.trim();
|
||||
}
|
||||
|
||||
public void setSystemConfigParams(String systemConfigParams) {
|
||||
this.systemConfigParams = systemConfigParams;
|
||||
}
|
||||
|
||||
public String getAppConfigParams() {
|
||||
return appConfigParams == null ? "" : appConfigParams.trim();
|
||||
}
|
||||
|
||||
public void setAppConfigParams(String appConfigParams) {
|
||||
this.appConfigParams = appConfigParams;
|
||||
}
|
||||
}
|
||||
|
@ -256,7 +256,7 @@
|
||||
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||
<a href="javascript:void(0);"><cite>系统参数配置(参数名唯一且只能是字母、数字与下划线的组合)</cite></a>
|
||||
</span>
|
||||
<button id="systemParamsPlusBtn" type="button" class="layui-btn layui-btn-xs" style="float: right; margin-top: 12px;">
|
||||
<button id="systemConfigParamsPlusBtn" type="button" class="layui-btn layui-btn-xs" style="float: right; margin-top: 12px;">
|
||||
<i class="fa fa-plus" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
@ -275,7 +275,7 @@
|
||||
<th style="text-align: center;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="systemParamsBody"></tbody>
|
||||
<tbody id="systemConfigParamsBody"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@ -285,7 +285,7 @@
|
||||
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||
<a href="javascript:void(0);"><cite>APP参数配置(参数名唯一且只能是字母、数字与下划线的组合)</cite></a>
|
||||
</span>
|
||||
<button id="appParamsPlusBtn" type="button" class="layui-btn layui-btn-xs" style="float: right; margin-top: 12px;">
|
||||
<button id="appConfigParamsPlusBtn" type="button" class="layui-btn layui-btn-xs" style="float: right; margin-top: 12px;">
|
||||
<i class="fa fa-plus" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
@ -304,7 +304,7 @@
|
||||
<th style="text-align: center;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="appParamsBody"></tbody>
|
||||
<tbody id="appConfigParamsBody"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@ -380,6 +380,8 @@
|
||||
var photoViewer = new Viewer(document.getElementById('photoShow'), {});
|
||||
var logoViewer = new Viewer(document.getElementById('logoShow'), {});
|
||||
var shortLogoViewer = new Viewer(document.getElementById('shortLogoShow'), {});
|
||||
var systemConfigParams;
|
||||
var appConfigParams;
|
||||
|
||||
// 设置logo图片
|
||||
function setLogoTemple() {
|
||||
@ -392,7 +394,7 @@
|
||||
});
|
||||
logoViewer.update();
|
||||
}
|
||||
|
||||
|
||||
// 设置logo图片
|
||||
function setShortLogoTemple() {
|
||||
var shortLogoTemple = document.getElementById('shortLogoTemple').innerHTML;
|
||||
@ -417,7 +419,7 @@
|
||||
}
|
||||
setLogoTemple();
|
||||
});
|
||||
|
||||
|
||||
// 事件-删除图片
|
||||
$(document).on('click', '.remove-logo-short-btn', function() {
|
||||
var fileId = this.dataset.id;
|
||||
@ -450,7 +452,7 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// 事件-上传图片
|
||||
$(document).on('click', '#selectShortLogo', function() {
|
||||
top.dialog.file({
|
||||
@ -516,8 +518,8 @@
|
||||
});
|
||||
});
|
||||
|
||||
// 系统参数事件
|
||||
function paramsConfigInit(idPrefix, classPrefix, initObj) {
|
||||
// 系统参数配置
|
||||
function ParamsConfigInit(idPrefix, classPrefix, paramsJsonString) {
|
||||
var paramsArray = [];
|
||||
var keyupSetTimeout;
|
||||
|
||||
@ -566,11 +568,6 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
}
|
||||
init();
|
||||
|
||||
$(document).on('keyup', '.'+ classPrefix +'-key', function() {
|
||||
var self = this;
|
||||
var index = this.dataset.index;
|
||||
@ -615,6 +612,31 @@
|
||||
paramsArray.splice(index, 1);
|
||||
refreshTr();
|
||||
})
|
||||
|
||||
this.init = function() {
|
||||
if(!paramsJsonString) {
|
||||
return;
|
||||
}
|
||||
var paramsObj = JSON.parse(paramsJsonString);
|
||||
console.log(paramsObj);
|
||||
for(var k in paramsObj) {
|
||||
paramsArray.push({
|
||||
key: k,
|
||||
value: paramsObj[k]
|
||||
})
|
||||
}
|
||||
refreshTr();
|
||||
}
|
||||
this.getConfigParams = function() {
|
||||
var obj = {};
|
||||
for(var i = 0, item; item = paramsArray[i++];) {
|
||||
if(!item.key) {
|
||||
continue;
|
||||
}
|
||||
obj[item.key] = item.value;
|
||||
}
|
||||
return JSON.stringify(obj);
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化
|
||||
@ -640,7 +662,7 @@
|
||||
uKeyLogin: data.uKeyLogin,
|
||||
scanCodeLogin: data.scanCodeLogin,
|
||||
loginBoxPosition: data.loginBoxPosition,
|
||||
menuMode: data.menuMode
|
||||
menuMode: data.menuMode,
|
||||
});
|
||||
form.render(null, 'dataForm');
|
||||
if(data.systemLogo) {
|
||||
@ -655,8 +677,11 @@
|
||||
photos = data.loginBackgroundImages.split(',');
|
||||
}
|
||||
setBackgroundTemple();
|
||||
paramsConfigInit('systemParams', 'system-params', {});
|
||||
paramsConfigInit('appParams', 'app-params', {});
|
||||
systemConfigParams = new ParamsConfigInit('systemConfigParams', 'system-config-params', data.systemConfigParams);
|
||||
systemConfigParams.init();
|
||||
|
||||
appConfigParams = new ParamsConfigInit('appConfigParams', 'app-config-params', data.appConfigParams);
|
||||
appConfigParams.init();
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
@ -675,6 +700,8 @@
|
||||
formData.field.loginBackgroundImages = photos.toString();
|
||||
formData.field.systemLogo = logos.length > 0 ? logos[0] : '';
|
||||
formData.field.systemShortLogo = shortLogos.length > 0 ? shortLogos[0] : '';
|
||||
formData.field.systemConfigParams = systemConfigParams.getConfigParams();
|
||||
formData.field.appConfigParams = appConfigParams.getConfigParams();
|
||||
top.restAjax.put(top.restAjax.path('api/config/updateconfig', []), formData.field, null, function(code, data) {
|
||||
var layerIndex = top.dialog.msg('更新成功', {
|
||||
time: 0,
|
||||
|
Loading…
Reference in New Issue
Block a user