Search in sources :

Example 1 with ArticleTags

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

the class BizArticleTagsServiceImpl method insertList.

/**
 * 批量添加
 *
 * @param tagIds
 * @param articleId
 */
@Override
public void insertList(Long[] tagIds, Long articleId) {
    if (tagIds == null || tagIds.length == 0) {
        return;
    }
    List<ArticleTags> list = new ArrayList<>();
    ArticleTags articleTags = null;
    for (Long tagId : tagIds) {
        articleTags = new ArticleTags();
        articleTags.setTagId(tagId);
        articleTags.setArticleId(articleId);
        list.add(articleTags);
    }
    this.insertList(list);
}
Also used : ArticleTags(com.zyd.blog.business.entity.ArticleTags) BizArticleTags(com.zyd.blog.persistence.beans.BizArticleTags) ArrayList(java.util.ArrayList)

Example 2 with ArticleTags

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

the class BizArticleTagsServiceImpl method insertList.

/**
 * 批量插入,支持批量插入的数据库可以使用,例如MySQL,H2等,另外该接口限制实体包含id属性并且必须为自增列
 *
 * @param entities
 */
@Override
public void insertList(List<ArticleTags> entities) {
    Assert.notNull(entities, "ArticleTagss不可为空!");
    List<BizArticleTags> list = new ArrayList<>();
    for (ArticleTags entity : entities) {
        entity.setUpdateTime(new Date());
        entity.setCreateTime(new Date());
        list.add(entity.getBizArticleTags());
    }
    bizArticleTagsMapper.insertList(list);
}
Also used : ArticleTags(com.zyd.blog.business.entity.ArticleTags) BizArticleTags(com.zyd.blog.persistence.beans.BizArticleTags) ArrayList(java.util.ArrayList) Date(java.util.Date) BizArticleTags(com.zyd.blog.persistence.beans.BizArticleTags)

Aggregations

ArticleTags (com.zyd.blog.business.entity.ArticleTags)2 BizArticleTags (com.zyd.blog.persistence.beans.BizArticleTags)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)1