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;
}
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;
}
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();
}
}
Aggregations