✨ 修改文章标签功能
This commit is contained in:
parent
c5454b6666
commit
3d64707c9b
@ -136,4 +136,12 @@ public interface ArticleMapper extends Mapper<Article> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<PortfolioArticleDTO> selectPortfolioArticles(@Param("idArticle") Integer idArticle);
|
List<PortfolioArticleDTO> selectPortfolioArticles(@Param("idArticle") Integer idArticle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新文章标签
|
||||||
|
* @param idArticle
|
||||||
|
* @param tags
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer updateArticleTags(@Param("idArticle") Integer idArticle, @Param("tags") String tags);
|
||||||
}
|
}
|
||||||
|
@ -105,4 +105,12 @@ public interface ArticleService extends Service<Article> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<ArticleDTO> selectUnbindArticles(Integer idPortfolio, String searchText, Integer idUser);
|
List<ArticleDTO> selectUnbindArticles(Integer idPortfolio, String searchText, Integer idUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新文章标签
|
||||||
|
* @param idArticle
|
||||||
|
* @param tags
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Map updateTags(Integer idArticle, String tags) throws UnsupportedEncodingException, BaseApiException;
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,7 @@ import tk.mybatis.mapper.entity.Condition;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ronger
|
* @author ronger
|
||||||
@ -294,6 +291,23 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Map updateTags(Integer idArticle, String tags) throws UnsupportedEncodingException, BaseApiException {
|
||||||
|
Map map = new HashMap(2);
|
||||||
|
Article article = articleMapper.selectByPrimaryKey(idArticle);
|
||||||
|
if (Objects.nonNull(article)) {
|
||||||
|
article.setArticleTags(tags);
|
||||||
|
articleMapper.updateArticleTags(idArticle, tags);
|
||||||
|
tagService.saveTagArticle(article);
|
||||||
|
map.put("success", true);
|
||||||
|
} else {
|
||||||
|
map.put("success", false);
|
||||||
|
map.put("message", "更新失败,文章不存在!");
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
private ArticleDTO genArticle(ArticleDTO article, Integer type) {
|
private ArticleDTO genArticle(ArticleDTO article, Integer type) {
|
||||||
Integer ARTICLE_LIST = 0;
|
Integer ARTICLE_LIST = 0;
|
||||||
Integer ARTICLE_VIEW = 1;
|
Integer ARTICLE_VIEW = 1;
|
||||||
|
@ -6,6 +6,7 @@ import com.rymcu.vertical.core.result.GlobalResult;
|
|||||||
import com.rymcu.vertical.core.result.GlobalResultGenerator;
|
import com.rymcu.vertical.core.result.GlobalResultGenerator;
|
||||||
import com.rymcu.vertical.dto.ArticleDTO;
|
import com.rymcu.vertical.dto.ArticleDTO;
|
||||||
import com.rymcu.vertical.dto.CommentDTO;
|
import com.rymcu.vertical.dto.CommentDTO;
|
||||||
|
import com.rymcu.vertical.entity.Article;
|
||||||
import com.rymcu.vertical.service.ArticleService;
|
import com.rymcu.vertical.service.ArticleService;
|
||||||
import com.rymcu.vertical.service.CommentService;
|
import com.rymcu.vertical.service.CommentService;
|
||||||
import com.rymcu.vertical.util.Utils;
|
import com.rymcu.vertical.util.Utils;
|
||||||
@ -80,4 +81,10 @@ public class ArticleController {
|
|||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/{id}/update-tags")
|
||||||
|
public GlobalResult updateTags(@PathVariable Integer id, @RequestBody Article article) throws BaseApiException, UnsupportedEncodingException {
|
||||||
|
Map map = articleService.updateTags(id, article.getArticleTags());
|
||||||
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,9 @@
|
|||||||
<update id="updateArticleViewCount">
|
<update id="updateArticleViewCount">
|
||||||
update vertical_article set article_view_count = #{articleViewCount} where id = #{id}
|
update vertical_article set article_view_count = #{articleViewCount} where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
<update id="updateArticleTags">
|
||||||
|
update vertical_article set article_tags = #{tags} where id = #{idArticle}
|
||||||
|
</update>
|
||||||
<delete id="deleteTagArticle">
|
<delete id="deleteTagArticle">
|
||||||
delete from vertical_tag_article where id_article = #{id}
|
delete from vertical_tag_article where id_article = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
|
Loading…
Reference in New Issue
Block a user