Search in sources :

Example 1 with BizArticleTags

use of com.zyd.blog.persistence.beans.BizArticleTags 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)

Example 2 with BizArticleTags

use of com.zyd.blog.persistence.beans.BizArticleTags in project OneBlog by zhangyd-c.

the class BizTagsServiceImpl method removeByPrimaryKey.

@Override
@Transactional(rollbackFor = Exception.class)
@RedisCache(flush = true)
public boolean removeByPrimaryKey(Long primaryKey) {
    BizArticleTags articleTag = new BizArticleTags();
    articleTag.setTagId(primaryKey);
    List<BizArticleTags> articleTags = bizArticleTagsMapper.select(articleTag);
    if (!CollectionUtils.isEmpty(articleTags)) {
        throw new ZhydException("当前标签下存在文章信息,禁止删除!");
    }
    return bizTagsMapper.deleteByPrimaryKey(primaryKey) > 0;
}
Also used : ZhydException(com.zyd.blog.framework.exception.ZhydException) BizArticleTags(com.zyd.blog.persistence.beans.BizArticleTags) RedisCache(com.zyd.blog.business.annotation.RedisCache) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

BizArticleTags (com.zyd.blog.persistence.beans.BizArticleTags)2 RedisCache (com.zyd.blog.business.annotation.RedisCache)1 ArticleTags (com.zyd.blog.business.entity.ArticleTags)1 ZhydException (com.zyd.blog.framework.exception.ZhydException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Transactional (org.springframework.transaction.annotation.Transactional)1