use of com.publiccms.views.pojo.entities.SysConfig in project PublicCMS-preview by sanluan.
the class SysConfigAdminController method delete.
/**
* @param code
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("delete")
public String delete(String code, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
Map<String, SysConfig> modelMap = configComponent.getMap(site);
SysConfig entity = modelMap.remove(code);
if (null != entity) {
configComponent.save(site, modelMap);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.config", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
use of com.publiccms.views.pojo.entities.SysConfig in project PublicCMS-preview by sanluan.
the class ConfigComponent method getConfigList.
/**
* @param site
* @param locale
* @return config list
*/
public List<ConfigInfo> getConfigList(SysSite site, Locale locale) {
List<ConfigInfo> configList = new ArrayList<>();
List<String> configCodeList = new ArrayList<>();
if (CommonUtils.notEmpty(configPluginList)) {
for (Config config : configPluginList) {
String code = config.getCode(site);
if (!configCodeList.contains(code)) {
configList.add(new ConfigInfo(config.getCode(site), config.getCodeDescription(site, locale)));
configCodeList.add(code);
}
}
}
for (Entry<String, SysConfig> entry : getMap(site).entrySet()) {
if (!configCodeList.contains(entry.getKey())) {
ConfigInfo configInfo = new ConfigInfo(entry.getKey(), entry.getValue().getDescription());
configInfo.setCustomed(true);
configList.add(configInfo);
configCodeList.add(entry.getKey());
}
}
return configList;
}
use of com.publiccms.views.pojo.entities.SysConfig in project PublicCMS-preview by sanluan.
the class ConfigComponent method getConfig.
/**
* @param site
* @param code
* @param locale
* @return config
*/
public ConfigInfo getConfig(SysSite site, String code, Locale locale) {
Map<String, SysConfig> map = getMap(site);
SysConfig entity = map.get(code);
ConfigInfo configInfo = null;
if (null != entity) {
configInfo = new ConfigInfo(entity.getCode(), entity.getDescription());
configInfo.setCustomed(true);
}
if (CommonUtils.notEmpty(configPluginList)) {
for (Config configPlugin : configPluginList) {
if (configPlugin.getCode(site).equals(code)) {
configInfo = new ConfigInfo(code, configPlugin.getCodeDescription(site, locale));
}
}
}
return configInfo;
}
use of com.publiccms.views.pojo.entities.SysConfig in project PublicCMS-preview by sanluan.
the class ConfigComponent method getMap.
/**
* @param site
* @return config map
*/
public Map<String, SysConfig> getMap(SysSite site) {
Map<String, SysConfig> modelMap;
File file = new File(siteComponent.getConfigFilePath(site));
if (CommonUtils.notEmpty(file)) {
try {
modelMap = objectMapper.readValue(file, new TypeReference<Map<String, SysConfig>>() {
});
} catch (IOException | ClassCastException e) {
modelMap = new HashMap<>();
}
} else {
modelMap = new HashMap<>();
}
return modelMap;
}
use of com.publiccms.views.pojo.entities.SysConfig in project PublicCMS-preview by sanluan.
the class SysConfigAdminController method save.
/**
* @param entity
* @param configCode
* @param request
* @param session
* @return view name
*/
@RequestMapping("save")
public String save(@ModelAttribute SysConfig entity, String configCode, HttpServletRequest request, HttpSession session) {
SysSite site = getSite(request);
if (CommonUtils.notEmpty(configCode)) {
Map<String, SysConfig> map = configComponent.getMap(site);
map.remove(configCode);
map.put(entity.getCode(), entity);
configComponent.save(site, map);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.config", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
} else {
Map<String, SysConfig> map = configComponent.getMap(site);
map.put(entity.getCode(), entity);
configComponent.save(site, map);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "save.config", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
Aggregations