Search in sources :

Example 1 with Tags

use of com.zyd.blog.business.entity.Tags in project OneBlog by zhangyd-c.

the class BizTagsServiceImpl method getByPrimaryKey.

@Override
public Tags getByPrimaryKey(Long primaryKey) {
    Assert.notNull(primaryKey, "PrimaryKey不可为空!");
    BizTags entity = bizTagsMapper.selectByPrimaryKey(primaryKey);
    return null == entity ? null : new Tags(entity);
}
Also used : BizTags(com.zyd.blog.persistence.beans.BizTags) BizArticleTags(com.zyd.blog.persistence.beans.BizArticleTags) BizTags(com.zyd.blog.persistence.beans.BizTags) Tags(com.zyd.blog.business.entity.Tags)

Example 2 with Tags

use of com.zyd.blog.business.entity.Tags in project OneBlog by zhangyd-c.

the class BizTagsServiceImpl method findPageBreakByCondition.

@Override
public PageInfo<Tags> findPageBreakByCondition(TagsConditionVO vo) {
    PageHelper.startPage(vo.getPageNumber(), vo.getPageSize());
    List<BizTags> list = bizTagsMapper.findPageBreakByCondition(vo);
    List<Tags> boList = getTags(list);
    if (boList == null)
        return null;
    PageInfo bean = new PageInfo<BizTags>(list);
    bean.setList(boList);
    return bean;
}
Also used : PageInfo(com.github.pagehelper.PageInfo) BizTags(com.zyd.blog.persistence.beans.BizTags) BizArticleTags(com.zyd.blog.persistence.beans.BizArticleTags) BizTags(com.zyd.blog.persistence.beans.BizTags) Tags(com.zyd.blog.business.entity.Tags)

Example 3 with Tags

use of com.zyd.blog.business.entity.Tags in project OneBlog by zhangyd-c.

the class BizTagsServiceImpl method getByName.

@Override
public Tags getByName(String name) {
    if (StringUtils.isEmpty(name)) {
        return null;
    }
    BizTags tags = new BizTags();
    tags.setName(name);
    tags = bizTagsMapper.selectOne(tags);
    return null == tags ? null : new Tags(tags);
}
Also used : BizTags(com.zyd.blog.persistence.beans.BizTags) BizArticleTags(com.zyd.blog.persistence.beans.BizArticleTags) BizTags(com.zyd.blog.persistence.beans.BizTags) Tags(com.zyd.blog.business.entity.Tags)

Example 4 with Tags

use of com.zyd.blog.business.entity.Tags in project OneBlog by zhangyd-c.

the class BizTagsServiceImpl method updateSelective.

@Override
@Transactional(rollbackFor = Exception.class)
@RedisCache(flush = true)
public boolean updateSelective(Tags entity) {
    Assert.notNull(entity, "Tags不可为空!");
    Tags old = this.getByName(entity.getName());
    if (old != null && !old.getId().equals(entity.getId())) {
        throw new ZhydException("标签修改失败,标签已存在![" + entity.getName() + "]");
    }
    entity.setUpdateTime(new Date());
    return bizTagsMapper.updateByPrimaryKeySelective(entity.getBizTags()) > 0;
}
Also used : ZhydException(com.zyd.blog.framework.exception.ZhydException) BizArticleTags(com.zyd.blog.persistence.beans.BizArticleTags) BizTags(com.zyd.blog.persistence.beans.BizTags) Tags(com.zyd.blog.business.entity.Tags) Date(java.util.Date) RedisCache(com.zyd.blog.business.annotation.RedisCache) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Tags

use of com.zyd.blog.business.entity.Tags in project OneBlog by zhangyd-c.

the class RemoverServiceImpl method saveTags.

/**
 * 保存文章的标签
 *
 * @param writerUtil           writer
 * @param originalTags         原始的标签列表
 * @param article              以保存的文章
 * @param spiderVirtualArticle 爬虫抓取完成的虚拟文章
 */
private void saveTags(HunterPrintWriter writerUtil, Map<String, Long> originalTags, Article article, VirtualArticle spiderVirtualArticle) {
    List<Long> tagIds = new ArrayList<>();
    Tags newTag;
    for (String tag : spiderVirtualArticle.getTags()) {
        if (originalTags.containsKey(tag.toUpperCase())) {
            tagIds.add(originalTags.get(tag.toUpperCase()));
            continue;
        }
        newTag = new Tags();
        newTag.setName(tag);
        newTag.setDescription(tag);
        newTag = tagsService.insert(newTag);
        // 防止重复添加,将新添加的标签信息保存到临时map中
        originalTags.put(newTag.getName().toUpperCase(), newTag.getId());
        tagIds.add(newTag.getId());
    }
    // 添加文章-标签关联信息
    articleTagsService.insertList(tagIds.toArray(new Long[0]), article.getId());
    writerUtil.print(String.format("[ sync tags ] Succeed! <a href=\"%s\" target=\"_blank\">%s</a>", spiderVirtualArticle.getSource(), article.getTitle()));
}
Also used : CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Tags(com.zyd.blog.business.entity.Tags)

Aggregations

Tags (com.zyd.blog.business.entity.Tags)6 BizArticleTags (com.zyd.blog.persistence.beans.BizArticleTags)4 BizTags (com.zyd.blog.persistence.beans.BizTags)4 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 Transactional (org.springframework.transaction.annotation.Transactional)2 PageInfo (com.github.pagehelper.PageInfo)1 RedisCache (com.zyd.blog.business.annotation.RedisCache)1 Article (com.zyd.blog.business.entity.Article)1 User (com.zyd.blog.business.entity.User)1 ArticleStatusEnum (com.zyd.blog.business.enums.ArticleStatusEnum)1 BizArticleService (com.zyd.blog.business.service.BizArticleService)1 BizArticleTagsService (com.zyd.blog.business.service.BizArticleTagsService)1 BizTagsService (com.zyd.blog.business.service.BizTagsService)1 RemoverService (com.zyd.blog.business.service.RemoverService)1 ImageDownloadUtil (com.zyd.blog.business.util.ImageDownloadUtil)1 ZhydException (com.zyd.blog.framework.exception.ZhydException)1 SessionUtil (com.zyd.blog.util.SessionUtil)1 PrintWriter (java.io.PrintWriter)1 java.util (java.util)1 Date (java.util.Date)1