/** * 获取用户收藏内容列表 * * @param uname * @param pageNum * @param pageSize * @return */ public List<AllContent> queryUserFavor(String uname, int pageNum, int pageSize) { User user = userDao.getUserInfo(uname); if (user == null) { return new ArrayList<AllContent>(); } List<AllContent> contentList = contentDao.queryUserFavor(uname, pageNum, pageSize); if (contentList != null && contentList.size() > 0) { for (AllContent content : contentList) { content.setSubList(subContentDao.getSubList(content.getId())); changeContent(content); } return contentList; } else { return new ArrayList<AllContent>(); } }
/** * 收藏内容 * * @param uname 用户名 * @param columnId 栏目id * @param contentId 内容id * @return */ public boolean stowContent(String uname, Long columnId, String contentId) { User user = userDao.getUserInfo(uname); if (user == null || columnId == null || contentId == null) { return false; } UserFavor userFav = userFavorDao.getUserFavor(uname, columnId, contentId); if (userFav != null) { return true; } else { userFav = new UserFavor(); userFav.setUserId(user.getId()); userFav.setUname(user.getUname()); userFav.setColumnId(columnId); userFav.setContentId(contentId); userFav.setStowTime(new Date()); return userFavorDao.storeUserFavor(userFav); } }