Search in sources :

Example 1 with SysConfig

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;
}
Also used : SysConfig(com.publiccms.views.pojo.entities.SysConfig) LogOperate(com.publiccms.entities.log.LogOperate) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with SysConfig

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;
}
Also used : SysConfig(com.publiccms.views.pojo.entities.SysConfig) Config(com.publiccms.common.api.Config) SysConfig(com.publiccms.views.pojo.entities.SysConfig) ArrayList(java.util.ArrayList)

Example 3 with SysConfig

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;
}
Also used : SysConfig(com.publiccms.views.pojo.entities.SysConfig) Config(com.publiccms.common.api.Config) SysConfig(com.publiccms.views.pojo.entities.SysConfig)

Example 4 with SysConfig

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;
}
Also used : SysConfig(com.publiccms.views.pojo.entities.SysConfig) HashMap(java.util.HashMap) TypeReference(com.fasterxml.jackson.core.type.TypeReference) IOException(java.io.IOException) File(java.io.File)

Example 5 with SysConfig

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;
}
Also used : SysConfig(com.publiccms.views.pojo.entities.SysConfig) LogOperate(com.publiccms.entities.log.LogOperate) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SysConfig (com.publiccms.views.pojo.entities.SysConfig)5 Config (com.publiccms.common.api.Config)2 LogOperate (com.publiccms.entities.log.LogOperate)2 SysSite (com.publiccms.entities.sys.SysSite)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1