diff --git a/src/main/java/com/rymcu/vertical/service/impl/TagServiceImpl.java b/src/main/java/com/rymcu/vertical/service/impl/TagServiceImpl.java index f0ef482..6c1b3e3 100644 --- a/src/main/java/com/rymcu/vertical/service/impl/TagServiceImpl.java +++ b/src/main/java/com/rymcu/vertical/service/impl/TagServiceImpl.java @@ -37,11 +37,11 @@ public class TagServiceImpl extends AbstractService implements TagService { private ArticleMapper articleMapper; @Override - @Transactional(rollbackFor = { UnsupportedEncodingException.class,BaseApiException.class }) + @Transactional(rollbackFor = {UnsupportedEncodingException.class, BaseApiException.class}) public Integer saveTagArticle(Article article) throws UnsupportedEncodingException, BaseApiException { User user = UserUtils.getCurrentUserByToken(); String articleTags = article.getArticleTags(); - if(StringUtils.isNotBlank(articleTags)){ + if (StringUtils.isNotBlank(articleTags)) { String[] tags = articleTags.split(","); List articleTagDTOList = articleMapper.selectTags(article.getIdArticle()); for (int i = 0; i < tags.length; i++) { @@ -50,10 +50,10 @@ public class TagServiceImpl extends AbstractService implements TagService { Tag tag = new Tag(); tag.setTagTitle(tags[i]); tag = tagMapper.selectOne(tag); - if(tag == null){ + if (tag == null) { tag = new Tag(); tag.setTagTitle(tags[i]); - tag.setTagUri(URLEncoder.encode(tag.getTagTitle(),"UTF-8")); + tag.setTagUri(URLEncoder.encode(tag.getTagTitle(), "UTF-8")); tag.setCreatedTime(new Date()); tag.setUpdatedTime(tag.getCreatedTime()); tag.setTagArticleCount(1); @@ -61,31 +61,34 @@ public class TagServiceImpl extends AbstractService implements TagService { addTagArticle = true; addUserTag = true; } else { - for(int m=0,n=articleTagDTOList.size()-1;m { articleMapper.deleteUnusedArticleTag(articleTagDTO.getIdArticleTag()); }); - if(addTagArticle){ - tagMapper.insertTagArticle(tag.getIdTag(),article.getIdArticle()); + if (addTagArticle) { + tagMapper.insertTagArticle(tag.getIdTag(), article.getIdArticle()); } - if(addUserTag){ - tagMapper.insertUserTag(tag.getIdTag(),user.getIdUser(),1); + if (addUserTag) { + tagMapper.insertUserTag(tag.getIdTag(), user.getIdUser(), 1); } } return 1; @@ -109,14 +112,14 @@ public class TagServiceImpl extends AbstractService implements TagService { Map map = new HashMap(1); if (tag.getIdTag() == null) { if (StringUtils.isBlank(tag.getTagTitle())) { - map.put("message","标签名不能为空!"); + map.put("message", "标签名不能为空!"); return map; } else { Condition tagCondition = new Condition(Tag.class); tagCondition.createCriteria().andCondition("tag_title =", tag.getTagTitle()); List tags = tagMapper.selectByCondition(tagCondition); if (!tags.isEmpty()) { - map.put("message","标签 '" + tag.getTagTitle() + "' 已存在!"); + map.put("message", "标签 '" + tag.getTagTitle() + "' 已存在!"); return map; } } @@ -132,10 +135,10 @@ public class TagServiceImpl extends AbstractService implements TagService { result = tagMapper.insertSelective(newTag); } else { tag.setUpdatedTime(new Date()); - result = tagMapper.update(tag.getIdTag(),tag.getTagUri(),tag.getTagIconPath(),tag.getTagStatus(),tag.getTagDescription(),tag.getTagReservation()); + result = tagMapper.update(tag.getIdTag(), tag.getTagUri(), tag.getTagIconPath(), tag.getTagStatus(), tag.getTagDescription(), tag.getTagReservation()); } if (result == 0) { - map.put("message","操作失败!"); + map.put("message", "操作失败!"); } else { map.put("tag", tag); }