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);
}
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;
}
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);
}
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;
}
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()));
}
Aggregations