Search in sources :

Example 1 with CmsTagType

use of com.publiccms.entities.cms.CmsTagType in project PublicCMS-preview by sanluan.

the class CmsTagTypeAdminController method delete.

/**
 * @param id
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("delete")
public String delete(Integer id, HttpServletRequest request, HttpSession session, ModelMap model) {
    SysSite site = getSite(request);
    CmsTagType entity = service.getEntity(id);
    if (null != entity) {
        if (ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model)) {
            return TEMPLATE_ERROR;
        }
        service.delete(id);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.tagType", RequestUtils.getIpAddress(request), CommonUtils.getDate(), id.toString()));
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) CmsTagType(com.publiccms.entities.cms.CmsTagType) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with CmsTagType

use of com.publiccms.entities.cms.CmsTagType in project PublicCMS-preview by sanluan.

the class CmsTagTypeService method update.

/**
 * @param siteId
 * @param entitys
 * @return
 */
public Integer[] update(short siteId, List<CmsTagType> entitys) {
    Set<Integer> idList = new HashSet<>();
    if (CommonUtils.notEmpty(entitys)) {
        for (CmsTagType 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 Integer[idList.size()]);
}
Also used : CmsTagType(com.publiccms.entities.cms.CmsTagType) HashSet(java.util.HashSet)

Example 3 with CmsTagType

use of com.publiccms.entities.cms.CmsTagType in project PublicCMS-preview by sanluan.

the class CmsTagTypeDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    Integer id = handler.getInteger("id");
    SysSite site = getSite(handler);
    if (CommonUtils.notEmpty(id)) {
        CmsTagType entity = service.getEntity(id);
        if (null != entity && site.getId() == entity.getSiteId()) {
            handler.put("object", entity).render();
        }
    } else {
        Integer[] ids = handler.getIntegerArray("ids");
        if (CommonUtils.notEmpty(ids)) {
            List<CmsTagType> entityList = service.getEntitys(ids);
            Map<String, CmsTagType> map = new LinkedHashMap<>();
            for (CmsTagType entity : entityList) {
                if (site.getId() == entity.getSiteId()) {
                    map.put(String.valueOf(entity.getId()), entity);
                }
            }
            handler.put("map", map).render();
        }
    }
}
Also used : CmsTagType(com.publiccms.entities.cms.CmsTagType) SysSite(com.publiccms.entities.sys.SysSite) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with CmsTagType

use of com.publiccms.entities.cms.CmsTagType in project PublicCMS-preview by sanluan.

the class CmsTagTypeAdminController method save.

/**
 * @param entity
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("save")
public String save(CmsTagType entity, HttpServletRequest request, HttpSession session, ModelMap model) {
    SysSite site = getSite(request);
    if (null != entity.getId()) {
        CmsTagType 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.tagType", 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.tagType", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) CmsTagType(com.publiccms.entities.cms.CmsTagType) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

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