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());
}
}
}
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();
}
}
}
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;
}
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;
}
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;
}
Aggregations