use of com.publiccms.entities.cms.CmsVoteUser in project PublicCMS-preview by sanluan.
the class CmsVoteUserDirective method execute.
@Override
public void execute(RenderHandler handler) throws IOException, Exception {
Long id = handler.getLong("id");
if (CommonUtils.notEmpty(id)) {
handler.put("object", service.getEntity(id)).render();
} else {
Long[] ids = handler.getLongArray("ids");
if (CommonUtils.notEmpty(ids)) {
List<CmsVoteUser> entityList = service.getEntitys(ids);
Map<String, CmsVoteUser> map = new LinkedHashMap<>();
for (CmsVoteUser entity : entityList) {
map.put(String.valueOf(entity.getId()), entity);
}
handler.put("map", map).render();
}
}
}
use of com.publiccms.entities.cms.CmsVoteUser in project PublicCMS-preview by sanluan.
the class VoteDirective method execute.
@Override
public void execute(RenderHandler handler, SysApp app, SysUser user) throws IOException, Exception {
Integer voteId = handler.getInteger("voteId");
Long[] itemIds = handler.getLongArray("itemIds");
CmsVote vote = voteService.getEntity(voteId);
if (null != vote && CommonUtils.notEmpty(itemIds) && !vote.isDisabled() && 0 == voteUserService.getPage(voteId, user.getId(), null, null, null, null, null, null).getTotalCount()) {
CmsVoteUser entity = new CmsVoteUser(voteId, user.getId(), StringUtils.arrayToCommaDelimitedString(itemIds), RequestUtils.getIpAddress(handler.getRequest()), CommonUtils.getDate());
voteUserService.save(entity);
voteService.updateUserCounts(voteId);
voteItemService.updateScores(itemIds);
}
}
Aggregations