Search in sources :

Example 1 with CmsTag

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

Example 2 with CmsTag

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();
        }
    }
}
Also used : CmsTag(com.publiccms.entities.cms.CmsTag) SysSite(com.publiccms.entities.sys.SysSite) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with CmsTag

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()]);
}
Also used : CmsTag(com.publiccms.entities.cms.CmsTag) HashSet(java.util.HashSet)

Aggregations

CmsTag (com.publiccms.entities.cms.CmsTag)3 SysSite (com.publiccms.entities.sys.SysSite)2 LogOperate (com.publiccms.entities.log.LogOperate)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1