Search in sources :

Example 16 with CmsContent

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

the class CmsContentService method updateStatistics.

/**
 * @param entitys
 */
public void updateStatistics(Collection<CmsContentStatistics> entitys) {
    for (CmsContentStatistics entityStatistics : entitys) {
        CmsContent entity = getEntity(entityStatistics.getId());
        if (null != entity) {
            entity.setClicks(entity.getClicks() + entityStatistics.getClicks());
            entity.setComments(entity.getComments() + entityStatistics.getComments());
            entity.setScores(entity.getScores() + entityStatistics.getScores());
        }
    }
}
Also used : CmsContent(com.publiccms.entities.cms.CmsContent) CmsContentStatistics(com.publiccms.views.pojo.entities.CmsContentStatistics)

Example 17 with CmsContent

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

the class CmsContentDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    Long id = handler.getLong("id");
    SysSite site = getSite(handler);
    if (CommonUtils.notEmpty(id)) {
        CmsContent 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<CmsContent> entityList = service.getEntitys(ids);
            Map<String, CmsContent> map = new LinkedHashMap<>();
            for (CmsContent entity : entityList) {
                if (site.getId() == entity.getSiteId()) {
                    map.put(String.valueOf(entity.getId()), entity);
                }
            }
            handler.put("map", map).render();
        }
    }
}
Also used : CmsContent(com.publiccms.entities.cms.CmsContent) SysSite(com.publiccms.entities.sys.SysSite) LinkedHashMap(java.util.LinkedHashMap)

Example 18 with CmsContent

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

the class CmsContentAdminController method delete.

/**
 * @param ids
 * @param request
 * @param session
 * @return view name
 */
@RequestMapping("delete")
public String delete(Long[] ids, HttpServletRequest request, HttpSession session) {
    SysSite site = getSite(request);
    if (CommonUtils.notEmpty(ids)) {
        for (CmsContent entity : service.getEntitys(ids)) {
            if (!entity.isDisabled() && site.getId() == entity.getSiteId()) {
                if (CommonUtils.notEmpty(entity.getParentId())) {
                    service.updateChilds(entity.getParentId(), -1);
                }
            } else {
                ArrayUtils.removeElements(ids, entity.getId());
            }
        }
        service.delete(site.getId(), ids);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.content", RequestUtils.getIpAddress(request), CommonUtils.getDate(), StringUtils.join(ids, ',')));
    }
    return TEMPLATE_DONE;
}
Also used : CmsContent(com.publiccms.entities.cms.CmsContent) LogOperate(com.publiccms.entities.log.LogOperate) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with CmsContent

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

the class CmsContentAdminController method sort.

/**
 * @param id
 * @param sort
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("sort")
public String sort(Long id, int sort, HttpServletRequest request, HttpSession session, ModelMap model) {
    SysSite site = getSite(request);
    if (CommonUtils.notEmpty(id)) {
        CmsContent entity = service.sort(site.getId(), id, sort);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "sort.content", RequestUtils.getIpAddress(request), CommonUtils.getDate(), new StringBuilder().append(entity.getId()).append(":").append(entity.getTitle()).append(" to ").append(sort).toString()));
    }
    return TEMPLATE_DONE;
}
Also used : CmsContent(com.publiccms.entities.cms.CmsContent) LogOperate(com.publiccms.entities.log.LogOperate) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 20 with CmsContent

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

the class CmsContentAdminController method uncheck.

/**
 * @param ids
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("uncheck")
public String uncheck(Long[] ids, HttpServletRequest request, HttpSession session, ModelMap model) {
    if (CommonUtils.notEmpty(ids)) {
        SysSite site = getSite(request);
        Long userId = getAdminFromSession(session).getId();
        List<CmsContent> entityList = service.uncheck(site.getId(), userId, ids);
        Set<Integer> categoryIdSet = new HashSet<>();
        for (CmsContent entity : entityList) {
            if (null != entity && site.getId() == entity.getSiteId()) {
                if (CommonUtils.notEmpty(entity.getParentId())) {
                    publish(new Long[] { entity.getParentId() }, request, session, model);
                }
                publish(new Long[] { entity.getId() }, request, session, model);
                categoryIdSet.add(entity.getCategoryId());
            }
        }
        for (CmsCategory category : categoryService.getEntitys(categoryIdSet.toArray(new Integer[categoryIdSet.size()]))) {
            templateComponent.createCategoryFile(site, category, null, null);
        }
        logOperateService.save(new LogOperate(site.getId(), userId, LogLoginService.CHANNEL_WEB_MANAGER, "uncheck.content", RequestUtils.getIpAddress(request), CommonUtils.getDate(), StringUtils.join(ids, ',')));
    }
    return TEMPLATE_DONE;
}
Also used : CmsContent(com.publiccms.entities.cms.CmsContent) LogOperate(com.publiccms.entities.log.LogOperate) CmsCategory(com.publiccms.entities.cms.CmsCategory) SysSite(com.publiccms.entities.sys.SysSite) HashSet(java.util.HashSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

CmsContent (com.publiccms.entities.cms.CmsContent)20 SysSite (com.publiccms.entities.sys.SysSite)12 LogOperate (com.publiccms.entities.log.LogOperate)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 CmsCategory (com.publiccms.entities.cms.CmsCategory)6 ArrayList (java.util.ArrayList)4 SysUser (com.publiccms.entities.sys.SysUser)3 Date (java.util.Date)3 CmsCategoryModel (com.publiccms.entities.cms.CmsCategoryModel)2 CmsCategoryModelId (com.publiccms.entities.cms.CmsCategoryModelId)2 SysExtendField (com.publiccms.entities.sys.SysExtendField)2 CmsModel (com.publiccms.views.pojo.entities.CmsModel)2 ExtendField (com.publiccms.views.pojo.entities.ExtendField)2 CmsContentQuery (com.publiccms.views.pojo.query.CmsContentQuery)2 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 CmsContentAttribute (com.publiccms.entities.cms.CmsContentAttribute)1 SysDept (com.publiccms.entities.sys.SysDept)1 SysDeptCategoryId (com.publiccms.entities.sys.SysDeptCategoryId)1