修改sql
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<result column="a_summary" property="summary"/>
|
||||
<result column="a_md_content" property="mdContent"/>
|
||||
<result column="a_url" property="url"/>
|
||||
<result column="a_author_id" property="authorId"/>
|
||||
<result column="a_author_id" property="user.id"/>
|
||||
<result column="a_is_open" property="open"/>
|
||||
<result column="a_is_original" property="type"/>
|
||||
<!-- <result column="next_a_id" property="nextArticleId"/>-->
|
||||
@@ -15,11 +15,12 @@
|
||||
<result column="a_reading_number" property="readingNumber"/>
|
||||
<result column="a_publish_date" property="publishDate"/>
|
||||
<result column="a_update_date" property="updateDate"/>
|
||||
<association property="category" column="a_category_id" javaType="cn.celess.blog.entity.Category"
|
||||
<result column="is_delete" property="deleted"/>
|
||||
<association property="category" column="a_category_id" javaType="cn.celess.blog.entity.TagCategory"
|
||||
resultMap="cn.celess.blog.mapper.CategoryMapper.categoryResultMap">
|
||||
</association>
|
||||
<collection property="tags" ofType="cn.celess.blog.entity.Article"
|
||||
resultMap="cn.celess.blog.mapper.TagMapper.tagResultMap">
|
||||
<collection property="tags" ofType="cn.celess.blog.entity.TagCategory"
|
||||
resultMap="cn.celess.blog.mapper.CategoryMapper.categoryResultMap">
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
@@ -37,6 +38,7 @@
|
||||
<result column="readingCount" property="readingNumber"/>
|
||||
<result column="publishDate" property="publishDate"/>
|
||||
<result column="updateDate" property="updateDate"/>
|
||||
<result column="isDelete" property="deleted"/>
|
||||
<association property="category" column="categoryId" javaType="cn.celess.blog.entity.Category">
|
||||
<id column="categoryId" property="id"/>
|
||||
<result column="categoryName" property="name"/>
|
||||
@@ -55,10 +57,9 @@
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="cn.celess.blog.entity.Article">
|
||||
insert into article (a_author_id, a_category_id, a_md_content, a_publish_date,
|
||||
insert into article (a_author_id, a_category_id, a_md_content, a_is_original,
|
||||
a_summary, a_title, a_url)
|
||||
values (#{user.id}, #{category.id}, #{mdContent}, #{publishDate},
|
||||
#{summary}, #{title}, #{url})
|
||||
values (#{user.id}, #{category.id}, #{mdContent}, #{type}, #{summary}, #{title}, #{url})
|
||||
</insert>
|
||||
<update id="delete">
|
||||
update article
|
||||
@@ -85,24 +86,18 @@
|
||||
where a_id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getLastestArticle" resultMap="articleResultMap" resultType="cn.celess.blog.entity.Article">
|
||||
<select id="getLastestArticle" resultMap="articleViewResultMap" resultType="cn.celess.blog.entity.Article">
|
||||
select *
|
||||
from article,
|
||||
tag_category
|
||||
where tag_category.is_category = true
|
||||
and article.a_category_id = tag_category.t_id
|
||||
order by a_id desc
|
||||
from articleView
|
||||
order by articleId desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
|
||||
<select id="findArticleById" resultMap="articleResultMap">
|
||||
<select id="findArticleById" resultMap="articleViewResultMap">
|
||||
select *
|
||||
from article,
|
||||
tag_category
|
||||
where a_id = #{id}
|
||||
and tag_category.is_category = true
|
||||
and article.a_category_id = tag_category.t_id
|
||||
from articleView
|
||||
where articleId = #{id}
|
||||
</select>
|
||||
|
||||
<select id="existsByTitle" resultType="boolean">
|
||||
@@ -113,37 +108,40 @@
|
||||
select is_delete
|
||||
from article
|
||||
WHERE a_id = #{id}
|
||||
# SELECT EXISTS(SELECT * FROM article
|
||||
</select>
|
||||
|
||||
<select id="findAllByAuthorId" resultMap="articleResultMap">
|
||||
<select id="findAllByAuthorId" resultMap="articleViewResultMap">
|
||||
select *
|
||||
from article
|
||||
where a_author_id = #{authorID}
|
||||
order by a_id desc
|
||||
from articleView
|
||||
where authorId = #{authorID}
|
||||
and isDelete = false
|
||||
order by articleId desc
|
||||
</select>
|
||||
|
||||
<select id="findAllByOpen" resultMap="articleResultMap">
|
||||
<select id="findAllByOpen" resultMap="articleViewResultMap">
|
||||
select *
|
||||
from article
|
||||
where a_is_open = #{isOpen}
|
||||
order by a_id desc
|
||||
from articleView
|
||||
where isOpen = #{isOpen}
|
||||
and isDelete = false
|
||||
order by articleId desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getTitleById" resultType="string">
|
||||
SELECT a_title
|
||||
from article
|
||||
where a_id = #{id}
|
||||
SELECT title
|
||||
from articleView
|
||||
where articleId = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findAllByCategoryId" resultMap="articleResultMap">
|
||||
select a_id, a_title, a_summary
|
||||
from article
|
||||
where a_category_id = #{id}
|
||||
order by a_id desc
|
||||
<select id="findAllByCategoryId" resultMap="articleViewResultMap">
|
||||
select *
|
||||
from articleView
|
||||
where categoryId = #{id}
|
||||
and isDelete = false
|
||||
order by articleId desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="findAll" resultMap="articleViewResultMap">
|
||||
select *
|
||||
from articleView
|
||||
@@ -151,33 +149,11 @@
|
||||
order by articleId desc
|
||||
</select>
|
||||
|
||||
<select id="getSimpleInfo" resultMap="articleResultMap">
|
||||
select a_id, a_summary, a_title
|
||||
from article
|
||||
where a_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getSimpleInfoByCategory" resultMap="articleResultMap">
|
||||
select a_id, a_summary, a_title
|
||||
from article
|
||||
where a_category_id = #{categoryId}
|
||||
order by a_id desc
|
||||
</select>
|
||||
|
||||
<select id="getSimpleInfoByTag" resultMap="articleResultMap">
|
||||
Select
|
||||
a_id, a_summary, a_title
|
||||
from article where a_id in
|
||||
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
order by a_id desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="count" resultType="long">
|
||||
select count(*)
|
||||
from article;
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user