use of com.publiccms.entities.sys.SysConfigData in project PublicCMS-preview by sanluan.
the class SysConfigDataAdminController method save.
/**
* @param entity
* @param sysConfigParamters
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("save")
public String save(SysConfigData entity, @ModelAttribute SysConfigParamters sysConfigParamters, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
if (null != entity.getId()) {
entity.getId().setSiteId(site.getId());
SysConfigData oldEntity = service.getEntity(entity.getId());
if (null != oldEntity && ControllerUtils.verifyNotEquals("siteId", site.getId(), oldEntity.getId().getSiteId(), model)) {
return TEMPLATE_ERROR;
}
Map<String, String> map = ExtendUtils.getExtentDataMap(sysConfigParamters.getExtendDataList(), configComponent.getFieldList(site, entity.getId().getCode(), null, RequestContextUtils.getLocale(request)));
entity.setData(ExtendUtils.getExtendString(map));
if (null != oldEntity) {
entity = service.update(oldEntity.getId(), entity, ignoreProperties);
if (null != entity) {
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.configData", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
configComponent.removeCache(site.getId(), entity.getId().getCode());
}
} else {
entity.getId().setSiteId(site.getId());
service.save(entity);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "save.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.SysConfigData 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.SysConfigData 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.SysConfigData 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