2019-11-18 01:22:27 +08:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace= "com.rymcu.vertical.mapper.ArticleMapper" >
<resultMap id= "BaseResultMap" type= "com.rymcu.vertical.entity.Article" >
<!--
WARNING - @mbg.generated
-->
<id column= "id" jdbcType= "INTEGER" property= "idArticle" />
<result column= "article_title" property= "articleTitle" > </result>
<result column= "article_thumbnail_url" property= "articleThumbnailUrl" > </result>
<result column= "article_author_id" property= "articleAuthorId" > </result>
<result column= "article_type" property= "articleType" > </result>
<result column= "article_tags" property= "articleTags" > </result>
<result column= "article_view_count" property= "articleViewCount" > </result>
<result column= "article_preview_content" property= "articlePreviewContent" > </result>
2019-11-23 00:57:29 +08:00
<result column= "comment_count" property= "articleCommentCount" > </result>
2019-11-18 01:22:27 +08:00
<result column= "article_permalink" property= "articlePermalink" > </result>
<result column= "article_link" property= "articleLink" > </result>
<result column= "created_time" property= "createdTime" > </result>
<result column= "updated_time" property= "updatedTime" > </result>
</resultMap>
<resultMap id= "DTOResultMap" type= "com.rymcu.vertical.dto.ArticleDTO" >
<result column= "id" property= "idArticle" > </result>
<result column= "article_title" property= "articleTitle" > </result>
<result column= "article_thumbnail_url" property= "articleThumbnailUrl" > </result>
<result column= "article_author_id" property= "articleAuthorId" > </result>
<result column= "nickname" property= "articleAuthorName" > </result>
<result column= "avatar_url" property= "articleAuthorAvatarUrl" > </result>
<result column= "article_type" property= "articleType" > </result>
<result column= "article_tags" property= "articleTags" > </result>
<result column= "article_view_count" property= "articleViewCount" > </result>
<result column= "article_preview_content" property= "articlePreviewContent" > </result>
2019-11-18 19:04:39 +08:00
<result column= "article_content" property= "articleContent" > </result>
2019-11-23 00:57:29 +08:00
<result column= "comment_count" property= "articleCommentCount" > </result>
2019-11-18 01:22:27 +08:00
<result column= "time_ago" property= "timeAgo" > </result>
<result column= "article_permalink" property= "articlePermalink" > </result>
<result column= "article_link" property= "articleLink" > </result>
2020-03-13 17:32:56 +08:00
<result column= "article_status" property= "articleStatus" > </result>
2019-11-18 01:22:27 +08:00
<result column= "updated_time" property= "updatedTime" > </result>
2020-04-13 23:41:48 +08:00
<result column= "sort_no" property= "sortNo" > </result>
2019-11-18 01:22:27 +08:00
</resultMap>
2019-11-18 19:04:39 +08:00
<resultMap id= "ArticleContentResultMap" type= "com.rymcu.vertical.entity.ArticleContent" >
<result column= "id_article" property= "idArticle" />
<result column= "article_content" property= "articleContent" />
<result column= "article_content_html" property= "articleContentHtml" />
<result column= "created_time" property= "createdTime" />
<result column= "updated_time" property= "updatedTime" />
2019-11-18 01:22:27 +08:00
</resultMap>
2019-12-18 01:15:31 +08:00
<resultMap id= "ArticleTagDTOResultMap" type= "com.rymcu.vertical.dto.ArticleTagDTO" >
2020-03-14 17:21:05 +08:00
<id column= "id" property= "idArticleTag" />
<result column= "id_tag" property= "idTag" > </result>
<result column= "id_article" property= "idArticle" > </result>
<result column= "tag_title" property= "tagTitle" > </result>
<result column= "tag_icon_path" property= "tagIconPath" > </result>
<result column= "tag_uri" property= "tagUri" > </result>
<result column= "tag_description" property= "tagDescription" > </result>
2019-12-18 01:15:31 +08:00
</resultMap>
2020-04-10 15:12:02 +08:00
<resultMap id= "PortfolioArticleResultMap" type= "com.rymcu.vertical.dto.PortfolioArticleDTO" >
<result column= "id_vertical_portfolio" property= "idPortfolio" > </result>
<result column= "id_vertical_article" property= "idArticle" > </result>
<result column= "portfolio_title" property= "portfolioTitle" > </result>
<result column= "portfolio_head_img_url" property= "headImgUrl" > </result>
</resultMap>
2019-11-18 01:22:27 +08:00
<insert id= "insertArticleContent" >
2019-11-23 00:57:29 +08:00
insert into vertical_article_content (id_article,article_content,article_content_html,created_time,updated_time)
2019-11-18 01:22:27 +08:00
values (#{idArticle},#{articleContent},#{articleContentHtml},sysdate(),sysdate())
</insert>
<update id= "updateArticleContent" >
2019-11-23 00:57:29 +08:00
update vertical_article_content set article_content = #{articleContent},article_content_html = #{articleContentHtml},updated_time = sysdate() where id_article = #{idArticle}
2019-11-18 01:22:27 +08:00
</update>
2020-01-14 14:24:18 +08:00
<update id= "updateArticleViewCount" >
update vertical_article set article_view_count = #{articleViewCount} where id = #{id}
</update>
2020-09-23 22:39:08 +08:00
<update id= "updateArticleTags" >
update vertical_article set article_tags = #{tags} where id = #{idArticle}
</update>
2019-12-18 01:15:31 +08:00
<delete id= "deleteTagArticle" >
delete from vertical_tag_article where id_article = #{id}
</delete>
2020-03-14 17:21:05 +08:00
<delete id= "deleteUnusedArticleTag" >
delete from vertical_tag_article where id = #{idArticleTag}
</delete>
2020-09-24 22:07:18 +08:00
<delete id= "deleteLinkedPortfolioData" >
delete from vertical_portfolio_article where id_vertical_article = #{id}
</delete>
2019-11-18 01:22:27 +08:00
<select id= "selectArticles" resultMap= "DTOResultMap" >
2020-09-23 21:03:50 +08:00
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on art.article_author_id = su.id
where article_status = '0'
<if test= "topicUri != 'news'" >
2020-09-25 13:05:45 +08:00
and FIND_IN_SET('划水',art.article_tags) = 0
2020-09-23 21:03:50 +08:00
</if>
order by updated_time desc
2019-11-18 01:22:27 +08:00
</select>
<select id= "selectArticleDTOById" resultMap= "DTOResultMap" >
2020-05-06 19:03:30 +08:00
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on art.article_author_id = su.id where art.id = #{id}
2020-03-15 19:21:44 +08:00
<if test= "type == 1" >
and art.article_status = 0
</if>
2019-11-18 01:22:27 +08:00
</select>
2019-11-18 19:04:39 +08:00
<select id= "selectArticleContent" resultMap= "ArticleContentResultMap" >
2019-11-23 00:57:29 +08:00
select article_content,article_content_html from vertical_article_content where id_article = #{idArticle}
</select>
2019-12-26 00:05:28 +08:00
<select id= "selectArticlesByTopicUri" resultMap= "DTOResultMap" >
2020-05-06 19:03:30 +08:00
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on art.article_author_id = su.id
2019-12-26 00:05:28 +08:00
where exists(select * from vertical_tag_article vta where vta.id_article = art.id and exists(select * from vertical_topic_tag vtt
2020-05-06 19:03:30 +08:00
join vertical_tag vt on vtt.id_tag = vt.id where vt.id = vta.id_tag and exists(select * from vertical_topic topic
2019-12-26 00:05:28 +08:00
where topic.id = vtt.id_topic and topic.topic_uri = #{topicName}))) order by updated_time desc
2019-11-23 00:57:29 +08:00
</select>
<select id= "selectArticlesByTagName" resultMap= "DTOResultMap" >
2020-05-06 19:03:30 +08:00
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on art.article_author_id = su.id order by updated_time desc
2019-11-23 00:57:29 +08:00
</select>
<select id= "selectUserArticles" resultMap= "DTOResultMap" >
2020-05-06 19:03:30 +08:00
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on su.id = #{idUser}
2020-03-30 10:33:46 +08:00
and art.article_author_id = su.id where article_author_id = #{idUser} and art.article_status = 0 order by updated_time desc
2019-11-18 19:04:39 +08:00
</select>
2019-12-18 01:15:31 +08:00
<select id= "selectTags" resultMap= "ArticleTagDTOResultMap" >
2020-05-06 19:03:30 +08:00
select vta.id, vta.id_tag, vta.id_article, vt.tag_title, vt.tag_icon_path, vt.tag_uri, vt.tag_description from vertical_tag vt join vertical_tag_article vta on vt.id = vta.id_tag where vta.id_article = #{idArticle}
2019-12-18 01:15:31 +08:00
</select>
2020-03-13 17:32:56 +08:00
<select id= "selectDrafts" resultMap= "DTOResultMap" >
2020-05-06 19:03:30 +08:00
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on art.article_author_id = su.id where article_status = '1' and art.article_author_id = #{idUser} order by updated_time desc
2020-03-13 17:32:56 +08:00
</select>
2020-04-08 17:53:32 +08:00
<select id= "selectArticlesByIdPortfolio" resultMap= "DTOResultMap" >
2020-04-13 23:41:48 +08:00
select art.*,su.nickname,su.avatar_url,vpa.sort_no from vertical_article art join vertical_portfolio_article vpa on vpa.id_vertical_article = art.id and vpa.id_vertical_portfolio = #{idPortfolio}
2020-05-06 19:03:30 +08:00
join vertical_user su on art.article_author_id = su.id where art.article_status = 0 and vpa.id_vertical_portfolio = #{idPortfolio} order by sort_no
2020-04-10 15:12:02 +08:00
</select>
<select id= "selectUnbindArticlesByIdPortfolio" resultMap= "DTOResultMap" >
2020-05-06 19:03:30 +08:00
select art.*,su.nickname,su.avatar_url from vertical_article art join vertical_user su on su.id = #{idUser} and art.article_author_id = su.id where art.article_author_id = #{idUser} and art.article_status = 0
2020-04-10 15:12:02 +08:00
and instr(art.article_title, #{searchText}) > 0 and art.id not in (select id_vertical_article from vertical_portfolio_article where id_vertical_portfolio = #{idPortfolio}) order by updated_time desc
</select>
<select id= "selectPortfolioArticles" resultMap= "PortfolioArticleResultMap" >
select vp.portfolio_title,vp.portfolio_head_img_url,vpa.id_vertical_portfolio,vpa.id_vertical_article from vertical_portfolio vp join vertical_portfolio_article vpa on vp.id = vpa.id_vertical_portfolio where vpa.id_vertical_article = #{idArticle}
2020-04-08 17:53:32 +08:00
</select>
2020-09-24 22:07:18 +08:00
<select id= "existsCommentWithPrimaryKey" resultType= "java.lang.Boolean" >
select exists (select * from vertical_comment where comment_article_id = #{id})
</select>
2019-11-18 01:22:27 +08:00
</mapper>