Search in sources :

Example 1 with SysConfigDataId

use of com.publiccms.entities.sys.SysConfigDataId in project PublicCMS-preview by sanluan.

the class SysConfigDataAdminController method delete.

/**
 * @param code
 * @param request
 * @param session
 * @return view name
 */
@RequestMapping("delete")
public String delete(String code, HttpServletRequest request, HttpSession session) {
    SysSite site = getSite(request);
    SysConfigData entity = service.getEntity(new SysConfigDataId(site.getId(), code));
    if (null != entity) {
        service.delete(entity.getId());
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.configData", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
        configComponent.removeCache(site.getId(), entity.getId().getCode());
    }
    return TEMPLATE_DONE;
}
Also used : SysConfigData(com.publiccms.entities.sys.SysConfigData) LogOperate(com.publiccms.entities.log.LogOperate) SysConfigDataId(com.publiccms.entities.sys.SysConfigDataId) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with SysConfigDataId

use of com.publiccms.entities.sys.SysConfigDataId in project PublicCMS-preview by sanluan.

the class ConfigComponent method getConfigData.

/**
 * @param siteId
 * @param code
 * @return config data
 */
public Map<String, String> getConfigData(short siteId, String code) {
    Map<String, Map<String, String>> siteMap = cache.get(siteId);
    if (CommonUtils.empty(siteMap)) {
        siteMap = new HashMap<>();
    }
    Map<String, String> configMap = siteMap.get(code);
    if (CommonUtils.empty(configMap)) {
        SysConfigData entity = service.getEntity(new SysConfigDataId(siteId, code));
        if (null != entity && CommonUtils.notEmpty(entity.getData())) {
            configMap = ExtendUtils.getExtendMap(entity.getData());
        } else {
            configMap = new HashMap<>();
        }
        siteMap.put(code, configMap);
        cache.put(siteId, siteMap);
    }
    return configMap;
}
Also used : SysConfigData(com.publiccms.entities.sys.SysConfigData) SysConfigDataId(com.publiccms.entities.sys.SysConfigDataId) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with SysConfigDataId

use of com.publiccms.entities.sys.SysConfigDataId in project PublicCMS-preview by sanluan.

the class SysConfigDataDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    String code = handler.getString("code");
    String[] codes = handler.getStringArray("codes");
    SysSite site = getSite(handler);
    if (CommonUtils.notEmpty(code)) {
        SysConfigData entity = service.getEntity(new SysConfigDataId(site.getId(), code));
        if (null != entity) {
            handler.put("object", ExtendUtils.getExtendMap(entity.getData())).render();
        }
    } else if (CommonUtils.notEmpty(codes)) {
        SysConfigDataId[] ids = new SysConfigDataId[codes.length];
        int i = 0;
        for (String s : codes) {
            if (CommonUtils.notEmpty(s)) {
                ids[i++] = new SysConfigDataId(site.getId(), s);
            }
        }
        Map<String, Map<String, String>> map = new HashMap<>();
        for (SysConfigData entity : service.getEntitys(ids)) {
            map.put(entity.getId().getCode(), ExtendUtils.getExtendMap(entity.getData()));
        }
        handler.put("map", map).render();
    }
}
Also used : SysConfigData(com.publiccms.entities.sys.SysConfigData) SysConfigDataId(com.publiccms.entities.sys.SysConfigDataId) HashMap(java.util.HashMap) Map(java.util.Map) SysSite(com.publiccms.entities.sys.SysSite)

Aggregations

SysConfigData (com.publiccms.entities.sys.SysConfigData)3 SysConfigDataId (com.publiccms.entities.sys.SysConfigDataId)3 SysSite (com.publiccms.entities.sys.SysSite)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 LogOperate (com.publiccms.entities.log.LogOperate)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1