use of com.publiccms.entities.cms.CmsTag in project PublicCMS-preview by sanluan.
the class CmsTagAdminController method save.
/**
* @param entity
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("save")
public String save(CmsTag entity, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
if (null != entity.getId()) {
CmsTag oldEntity = service.getEntity(entity.getId());
if (null == oldEntity || ControllerUtils.verifyNotEquals("siteId", site.getId(), oldEntity.getSiteId(), model)) {
return TEMPLATE_ERROR;
}
entity = service.update(entity.getId(), entity, ignoreProperties);
if (null != entity) {
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.tag", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
} else {
entity.setSiteId(site.getId());
service.save(entity);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "save.tag", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
use of com.publiccms.entities.cms.CmsTag in project PublicCMS-preview by sanluan.
the class CmsTagDirective method execute.
@Override
public void execute(RenderHandler handler) throws IOException, Exception {
Long id = handler.getLong("id");
SysSite site = getSite(handler);
if (CommonUtils.notEmpty(id)) {
CmsTag entity = service.getEntity(id);
if (null != entity && site.getId() == entity.getSiteId()) {
handler.put("object", entity).render();
}
} else {
Long[] ids = handler.getLongArray("ids");
if (CommonUtils.notEmpty(ids)) {
List<CmsTag> entityList = service.getEntitys(ids);
Map<String, CmsTag> map = new LinkedHashMap<>();
for (CmsTag entity : entityList) {
if (site.getId() == entity.getSiteId()) {
map.put(String.valueOf(entity.getId()), entity);
}
}
handler.put("map", map).render();
}
}
}
use of com.publiccms.entities.cms.CmsTag in project PublicCMS-preview by sanluan.
the class CmsTagService method update.
/**
* @param siteId
* @param entitys
* @return
*/
public Long[] update(short siteId, List<CmsTag> entitys) {
Set<Long> idList = new HashSet<>();
if (CommonUtils.notEmpty(entitys)) {
for (CmsTag entity : entitys) {
if (null != entity.getId()) {
entity = getEntity(entity.getId());
if (siteId == entity.getSiteId()) {
idList.add(entity.getId());
}
} else {
entity.setSiteId(siteId);
save(entity);
idList.add(entity.getId());
}
}
}
return idList.toArray(new Long[idList.size()]);
}
Aggregations