从"Blog"仓库中分离出来
This commit is contained in:
84
src/main/resources/mapper/CategoryMapper.xml
Normal file
84
src/main/resources/mapper/CategoryMapper.xml
Normal file
@@ -0,0 +1,84 @@
|
||||
<?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="cn.celess.blog.mapper.CategoryMapper">
|
||||
<resultMap id="categoryResultMap" type="cn.celess.blog.entity.Category">
|
||||
<id column="c_id" property="id"/>
|
||||
<result column="c_name" property="name"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert">
|
||||
insert into category (c_name, articles)
|
||||
values (#{name}, #{articles});
|
||||
<selectKey resultType="java.lang.Long" keyProperty="id">
|
||||
SELECT LAST_INSERT_ID() AS id
|
||||
</selectKey>
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
update category
|
||||
set c_name=#{name},
|
||||
articles=#{articles}
|
||||
where c_id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="delete">
|
||||
delete
|
||||
from category
|
||||
where c_id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="findCategoryByName" resultMap="categoryResultMap">
|
||||
select *
|
||||
from category
|
||||
where c_name = #{name}
|
||||
</select>
|
||||
|
||||
<select id="findCategoryById" resultMap="categoryResultMap">
|
||||
select *
|
||||
from category
|
||||
where c_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findAll" resultMap="categoryResultMap">
|
||||
select *
|
||||
from category
|
||||
</select>
|
||||
|
||||
<select id="getAllName" resultType="java.lang.String">
|
||||
select c_name
|
||||
from category
|
||||
</select>
|
||||
|
||||
<select id="getNameById" resultType="java.lang.String">
|
||||
select c_name
|
||||
from category
|
||||
where c_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getIDByName" resultType="java.lang.Long">
|
||||
select c_id
|
||||
from category
|
||||
where c_name = #{name}
|
||||
</select>
|
||||
|
||||
<select id="existsByName" resultType="java.lang.Boolean">
|
||||
SELECT EXISTS(SELECT * FROM category WHERE c_name = #{name})
|
||||
</select>
|
||||
|
||||
<select id="existsById" resultType="java.lang.Boolean">
|
||||
SELECT EXISTS(SELECT * FROM category WHERE c_id = #{id})
|
||||
</select>
|
||||
|
||||
<select id="getLastestCategory" resultMap="categoryResultMap">
|
||||
select *
|
||||
from category
|
||||
order by c_id desc
|
||||
limit 1;
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(*)
|
||||
from category;
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
98
src/main/resources/mapper/CommentMapper.xml
Normal file
98
src/main/resources/mapper/CommentMapper.xml
Normal file
@@ -0,0 +1,98 @@
|
||||
<?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="cn.celess.blog.mapper.CommentMapper">
|
||||
<resultMap id="commentResultMap" type="cn.celess.blog.entity.Comment">
|
||||
<id column="co_id" property="id"/>
|
||||
<result column="co_article_id" property="articleID"/>
|
||||
<result column="is_comment" property="type"/>
|
||||
<result column="author_id" property="authorID"/>
|
||||
<result column="co_content" property="content"/>
|
||||
<result column="co_date" property="date"/>
|
||||
<result column="co_pid" property="pid"/>
|
||||
<result column="co_response_id" property="responseId"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert">
|
||||
insert into comment (co_article_id, is_comment, author_id, co_content, co_date, co_pid)
|
||||
VALUES (#{articleID}, #{type}, #{authorID}, #{content}, #{date}, #{pid})
|
||||
<selectKey resultType="java.lang.Long" keyProperty="id">
|
||||
SELECT LAST_INSERT_ID() AS id
|
||||
</selectKey>
|
||||
</insert>
|
||||
|
||||
<update id="updateContent">
|
||||
update comment
|
||||
set co_content=#{content}
|
||||
where co_id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateResponder">
|
||||
update comment
|
||||
set co_response_id =#{responder}
|
||||
where co_id = #{id}
|
||||
</update>
|
||||
<delete id="delete">
|
||||
delete
|
||||
from comment
|
||||
where co_id = #{id}
|
||||
</delete>
|
||||
<delete id="deleteByArticleId">
|
||||
delete
|
||||
from comment
|
||||
where co_article_id = #{articleId}
|
||||
</delete>
|
||||
<select id="existsById" resultType="java.lang.Boolean">
|
||||
SELECT EXISTS(SELECT * FROM comment WHERE co_id = #{id})
|
||||
</select>
|
||||
<select id="findCommentById" resultMap="commentResultMap">
|
||||
select *
|
||||
from comment
|
||||
where co_id = #{id}
|
||||
</select>
|
||||
<select id="findAllByAuthorIDAndType" resultMap="commentResultMap">
|
||||
select *
|
||||
from comment
|
||||
where author_id = #{id}
|
||||
and is_comment = #{isComment}
|
||||
</select>
|
||||
<select id="findAllByPId" resultMap="commentResultMap">
|
||||
select *
|
||||
from comment
|
||||
where co_pid = #{pid}
|
||||
</select>
|
||||
<select id="findAllByArticleID" resultMap="commentResultMap">
|
||||
select *
|
||||
from comment
|
||||
where co_article_id = #{articleId}
|
||||
</select>
|
||||
<select id="findAllByArticleIDAndPId" resultMap="commentResultMap">
|
||||
select *
|
||||
from comment
|
||||
where co_article_id = #{articleID}
|
||||
and co_pid = #{pid}
|
||||
</select>
|
||||
<select id="findCommentsByTypeAndPId" resultMap="commentResultMap">
|
||||
select *
|
||||
from comment
|
||||
where is_comment = #{isComment}
|
||||
and co_pid = #{pid}
|
||||
</select>
|
||||
<select id="findAllByType" resultMap="commentResultMap">
|
||||
select *
|
||||
from comment
|
||||
where is_comment = #{isComment}
|
||||
</select>
|
||||
<select id="countByType" resultType="java.lang.Long">
|
||||
select count(*)
|
||||
from comment
|
||||
where is_comment = #{isComment}
|
||||
</select>
|
||||
<select id="getLastestComment" resultMap="commentResultMap">
|
||||
select *
|
||||
from comment
|
||||
order by co_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
76
src/main/resources/mapper/PartnerSiteMapper.xml
Normal file
76
src/main/resources/mapper/PartnerSiteMapper.xml
Normal file
@@ -0,0 +1,76 @@
|
||||
<?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="cn.celess.blog.mapper.PartnerMapper">
|
||||
<resultMap id="partnerSiteResultMap" type="cn.celess.blog.entity.PartnerSite">
|
||||
<id column="site_id" property="id"/>
|
||||
<result column="site_name" property="name"/>
|
||||
<result column="site_url" property="url"/>
|
||||
<result column="is_open" property="open"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="cn.celess.blog.entity.PartnerSite">
|
||||
insert into links (site_name, is_open, site_url)
|
||||
values (#{name}, #{open}, #{url})
|
||||
<selectKey resultType="java.lang.Long" keyProperty="id">
|
||||
SELECT LAST_INSERT_ID() AS id
|
||||
</selectKey>
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="cn.celess.blog.entity.PartnerSite">
|
||||
update links set
|
||||
<if test="name!=null">site_name=#{name},</if>
|
||||
<if test="url!=null">site_url=#{url},</if>
|
||||
<if test="open!=null">is_open=#{open}</if>
|
||||
where site_id=#{id}
|
||||
</update>
|
||||
|
||||
<delete id="delete">
|
||||
delete
|
||||
from links
|
||||
where site_id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="existsById" resultType="boolean">
|
||||
SELECT EXISTS(SELECT * FROM links WHERE site_id = #{id})
|
||||
</select>
|
||||
|
||||
<select id="existsByName" resultType="boolean">
|
||||
SELECT EXISTS(SELECT * FROM links WHERE site_name = #{name})
|
||||
|
||||
</select>
|
||||
|
||||
<select id="existsByUrl" resultType="boolean">
|
||||
SELECT EXISTS(SELECT * FROM links WHERE site_url = #{url})
|
||||
|
||||
</select>
|
||||
|
||||
<select id="findById" resultMap="partnerSiteResultMap">
|
||||
select *
|
||||
from links
|
||||
where site_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findByName" resultMap="partnerSiteResultMap">
|
||||
select *
|
||||
from links
|
||||
where site_name = #{name}
|
||||
</select>
|
||||
|
||||
<select id="findByUrl" resultMap="partnerSiteResultMap">
|
||||
select *
|
||||
from links
|
||||
where site_url = #{url}
|
||||
</select>
|
||||
<select id="getLastest" resultMap="partnerSiteResultMap">
|
||||
select *
|
||||
from links
|
||||
order by site_id desc
|
||||
limit 1
|
||||
</select>
|
||||
<select id="findAll" resultMap="partnerSiteResultMap">
|
||||
select *
|
||||
from links
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
127
src/main/resources/mapper/UserMapper.xml
Normal file
127
src/main/resources/mapper/UserMapper.xml
Normal file
@@ -0,0 +1,127 @@
|
||||
<?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="cn.celess.blog.mapper.UserMapper">
|
||||
<resultMap id="userResultMap" type="cn.celess.blog.entity.User">
|
||||
<id column="u_id" property="id"/>
|
||||
<result column="u_email" property="email"/>
|
||||
<result column="u_uid" property="uid"/>
|
||||
<result column="u_pwd" property="pwd"/>
|
||||
<result column="email_status" property="emailStatus"/>
|
||||
<result column="u_avatar" property="avatarImgUrl"/>
|
||||
<result column="u_desc" property="desc"/>
|
||||
<result column="recently_landed_time" property="recentlyLandedDate"/>
|
||||
<result column="email_verify_id" property="emailVerifyId"/>
|
||||
<result column="display_name" property="displayName"/>
|
||||
<result column="role" property="role"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="addUser">
|
||||
insert into user(u_email, u_pwd)
|
||||
values (#{email}, #{pwd})
|
||||
</insert>
|
||||
|
||||
<update id="updateInfo">
|
||||
update user set
|
||||
<if test="desc!=null">`u_desc`=#{desc},</if>
|
||||
<if test="displayName!=null">`display_name`=#{displayName}</if>
|
||||
where u_id=#{id}
|
||||
</update>
|
||||
<update id="updateLoginTime">
|
||||
update user
|
||||
set `recently_landed_time`=#{date}
|
||||
where `u_email` = #{email}
|
||||
</update>
|
||||
<update id="updateAvatarImgUrl">
|
||||
update user
|
||||
set `u_avatar`=#{avatarImgUrl}
|
||||
where `u_id` = #{id}
|
||||
</update>
|
||||
<update id="updateEmailStatus">
|
||||
update user
|
||||
set `email_status`=#{status}
|
||||
where `u_email` = #{email}
|
||||
</update>
|
||||
<update id="updatePwd">
|
||||
update user
|
||||
set `u_pwd`=#{pwd}
|
||||
where `u_email` = #{email}
|
||||
</update>
|
||||
<update id="setUserRole">
|
||||
update user
|
||||
set role=#{role}
|
||||
where u_id = #{uid}
|
||||
</update>
|
||||
<update id="update">
|
||||
update user
|
||||
set `u_email` = #{email},
|
||||
`u_pwd` = #{pwd},
|
||||
`email_status` = #{emailStatus},
|
||||
`u_desc` = #{desc},
|
||||
`display_name` = #{displayName},
|
||||
`role` = #{role}
|
||||
where `u_id` = #{id}
|
||||
</update>
|
||||
<delete id="delete">
|
||||
delete
|
||||
from user
|
||||
where u_id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="existsByEmail" resultType="java.lang.Boolean">
|
||||
select exists(select * from user where u_email = #{email})
|
||||
</select>
|
||||
|
||||
<select id="findByEmail" resultMap="userResultMap">
|
||||
select *
|
||||
from user
|
||||
where u_email = #{email}
|
||||
</select>
|
||||
|
||||
<select id="findById" resultMap="userResultMap">
|
||||
select *
|
||||
from user
|
||||
where u_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getAvatarImgUrlById" resultType="string">
|
||||
select u_avatar
|
||||
from user
|
||||
where u_id = #{id};
|
||||
</select>
|
||||
|
||||
<select id="getEmail" resultType="java.lang.String">
|
||||
select u_email
|
||||
from user
|
||||
where u_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getDisPlayName" resultType="java.lang.String">
|
||||
select display_name
|
||||
from user
|
||||
where u_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getPwd" resultType="java.lang.String">
|
||||
select u_pwd
|
||||
from user
|
||||
where u_email = #{email}
|
||||
</select>
|
||||
<select id="getRoleByEmail" resultType="java.lang.String">
|
||||
select role
|
||||
from user
|
||||
where u_email = #{emai}
|
||||
</select>
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(*)
|
||||
from user
|
||||
</select>
|
||||
<select id="getRoleById" resultType="java.lang.String">
|
||||
select role
|
||||
from user
|
||||
where u_id = #{id}
|
||||
</select>
|
||||
<select id="findAll" resultMap="userResultMap">
|
||||
select *
|
||||
from user
|
||||
</select>
|
||||
</mapper>
|
||||
33
src/main/resources/mapper/VisitorMapper.xml
Normal file
33
src/main/resources/mapper/VisitorMapper.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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="cn.celess.blog.mapper.VisitorMapper">
|
||||
<resultMap id="partnerSiteResultMap" type="cn.celess.blog.entity.Visitor">
|
||||
<id column="v_id" property="id"/>
|
||||
<result column="v_date" property="date"/>
|
||||
<result column="v_user_agent" property="ua"/>
|
||||
<result column="v_ip" property="ip"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert">
|
||||
insert into visitor (v_date, v_ip, v_user_agent)
|
||||
values (#{date}, #{ip}, #{ua})
|
||||
<selectKey resultType="java.lang.Long" keyProperty="id">
|
||||
SELECT LAST_INSERT_ID() AS id
|
||||
</selectKey>
|
||||
</insert>
|
||||
<delete id="delete">
|
||||
delete
|
||||
from visitor
|
||||
where v_id = #{id}
|
||||
</delete>
|
||||
<select id="findAll" resultMap="partnerSiteResultMap">
|
||||
select *
|
||||
from visitor order by v_id desc
|
||||
</select>
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(*)
|
||||
from visitor
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
50
src/main/resources/mapper/WebUpdateInfoMapper.xml
Normal file
50
src/main/resources/mapper/WebUpdateInfoMapper.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?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="cn.celess.blog.mapper.WebUpdateInfoMapper">
|
||||
<resultMap id="webUpdateResultMap" type="cn.celess.blog.entity.WebUpdate">
|
||||
<id column="update_id" property="id"/>
|
||||
<result column="update_info" property="updateInfo"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
</resultMap>
|
||||
<insert id="insert" parameterType="cn.celess.blog.entity.WebUpdate">
|
||||
insert into web_update(update_info, update_time)
|
||||
values (#{updateInfo}, #{updateTime})
|
||||
<selectKey resultType="java.lang.Long" keyProperty="id">
|
||||
SELECT LAST_INSERT_ID() AS id
|
||||
</selectKey>
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
update web_update
|
||||
set update_info=#{info}
|
||||
where update_id = #{id};
|
||||
|
||||
</update>
|
||||
|
||||
<delete id="delete">
|
||||
delete
|
||||
from web_update
|
||||
where update_id = #{id}
|
||||
</delete>
|
||||
<select id="existsById" resultType="java.lang.Boolean">
|
||||
select EXISTS(select * from web_update where update_id = #{id})
|
||||
</select>
|
||||
<select id="findById" resultMap="webUpdateResultMap">
|
||||
select *
|
||||
from web_update
|
||||
where update_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findAll" resultMap="webUpdateResultMap">
|
||||
select *
|
||||
from web_update
|
||||
</select>
|
||||
<select id="getLastestOne" resultType="date">
|
||||
select update_time
|
||||
from web_update
|
||||
order by update_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
163
src/main/resources/mapper/articleMapper.xml
Normal file
163
src/main/resources/mapper/articleMapper.xml
Normal file
@@ -0,0 +1,163 @@
|
||||
<?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="cn.celess.blog.mapper.ArticleMapper">
|
||||
<resultMap id="articleResultMap" type="cn.celess.blog.entity.Article">
|
||||
<id column="a_id" property="id"/>
|
||||
<result column="a_title" property="title"/>
|
||||
<result column="a_summary" property="summary"/>
|
||||
<result column="a_md_content" property="mdContent"/>
|
||||
<result column="a_tags_id" property="tagsId"/>
|
||||
<result column="a_category_id" property="categoryId"/>
|
||||
<result column="a_url" property="url"/>
|
||||
<result column="a_author_id" property="authorId"/>
|
||||
<result column="a_is_open" property="open"/>
|
||||
<result column="a_is_original" property="type"/>
|
||||
<result column="next_a_id" property="nextArticleId"/>
|
||||
<result column="pre_a_id" property="preArticleId"/>
|
||||
<result column="a_reading_number" property="readingNumber"/>
|
||||
<result column="a_publish_date" property="publishDate"/>
|
||||
<result column="a_update_date" property="updateDate"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="cn.celess.blog.entity.Article">
|
||||
insert into article (a_author_id, a_category_id, a_tags_id, a_md_content, a_publish_date,
|
||||
a_summary, a_title, a_url)
|
||||
values (#{authorId}, #{categoryId}, #{tagsId}, #{mdContent}, #{publishDate},
|
||||
#{summary}, #{title}, #{url})
|
||||
<selectKey resultType="java.lang.Long" keyProperty="id">
|
||||
SELECT LAST_INSERT_ID() AS id
|
||||
</selectKey>
|
||||
</insert>
|
||||
<delete id="delete">
|
||||
delete
|
||||
from article
|
||||
where a_id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="update">
|
||||
update article
|
||||
set
|
||||
<if test="title!=null">a_title=#{title},</if>
|
||||
<if test="mdContent!=null">a_md_content=#{mdContent},</if>
|
||||
<if test="summary!=null">a_summary=#{summary},</if>
|
||||
<if test="type!=null">a_is_original=#{type},</if>
|
||||
<if test="url!=null">a_url=#{url},</if>
|
||||
<if test="updateDate!=null">a_update_date=#{updateDate},</if>
|
||||
<if test="categoryId!=null">a_category_id=#{categoryId},</if>
|
||||
<if test="tagsId!=null">a_tags_id=#{tagsId},</if>
|
||||
<if test="nextArticleId!=null">next_a_id=#{nextArticleId},</if>
|
||||
<if test="preArticleId!=null">pre_a_id=#{preArticleId},</if>
|
||||
<if test="open!=null">a_is_open=#{open}</if>
|
||||
where a_id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateNextArticleId">
|
||||
update article
|
||||
set next_a_id=#{nextArticleID}
|
||||
where a_id = #{targetArticleID}
|
||||
</update>
|
||||
|
||||
<update id="updatePreArticleId">
|
||||
update article
|
||||
set pre_a_id=#{preArticleID}
|
||||
where a_id = #{targetArticleID}
|
||||
</update>
|
||||
<update id="setReadingNumber">
|
||||
update article
|
||||
set a_reading_number=#{number}
|
||||
where a_id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getLastestArticleId" resultType="long">
|
||||
select a_id
|
||||
from article
|
||||
order by a_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="getLastestArticle" resultMap="articleResultMap" resultType="cn.celess.blog.entity.Article">
|
||||
select *
|
||||
from article
|
||||
order by a_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
|
||||
<select id="findArticleById" resultMap="articleResultMap">
|
||||
select *
|
||||
from article
|
||||
where a_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="existsByTitle" resultType="boolean">
|
||||
SELECT EXISTS(SELECT * FROM article WHERE a_title = #{title})
|
||||
</select>
|
||||
|
||||
<select id="existsById" resultType="boolean">
|
||||
SELECT EXISTS(SELECT * FROM article WHERE a_id = #{id})
|
||||
</select>
|
||||
|
||||
<select id="findAllByAuthorId" resultMap="articleResultMap">
|
||||
select *
|
||||
from article
|
||||
where a_author_id = #{authorID}
|
||||
order by a_id desc
|
||||
</select>
|
||||
|
||||
<select id="findAllByOpen" resultMap="articleResultMap">
|
||||
select *
|
||||
from article
|
||||
where a_is_open = #{isOpen}
|
||||
order by a_id desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getTitleById" resultType="string">
|
||||
SELECT a_title
|
||||
from article
|
||||
where a_id = #{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>
|
||||
|
||||
<select id="findAll" resultMap="articleResultMap">
|
||||
select *
|
||||
from article
|
||||
order by a_id 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>
|
||||
75
src/main/resources/mapper/tagMapper.xml
Normal file
75
src/main/resources/mapper/tagMapper.xml
Normal file
@@ -0,0 +1,75 @@
|
||||
<?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="cn.celess.blog.mapper.TagMapper">
|
||||
<resultMap id="tagResultMap" type="cn.celess.blog.entity.Tag">
|
||||
<id column="tag_id" property="id"/>
|
||||
<result column="tag_name" property="name"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert">
|
||||
insert into tag (tag_name, articles)
|
||||
VALUES (#{name}, #{articles});
|
||||
<selectKey resultType="java.lang.Long" keyProperty="id">
|
||||
SELECT LAST_INSERT_ID() AS id
|
||||
</selectKey>
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
update tag
|
||||
set tag_name=#{name},
|
||||
articles=#{articles}
|
||||
where tag_id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="delete">
|
||||
delete
|
||||
from tag
|
||||
where tag_id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="findTagById" resultMap="tagResultMap">
|
||||
select *
|
||||
from tag
|
||||
where tag_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="findTagByName" resultMap="tagResultMap">
|
||||
select *
|
||||
from tag
|
||||
where tag_name = #{name}
|
||||
</select>
|
||||
|
||||
<select id="existsByName" resultType="boolean">
|
||||
SELECT EXISTS(SELECT * FROM tag WHERE tag_name = #{name})
|
||||
</select>
|
||||
|
||||
<select id="getIDByName" resultType="long">
|
||||
select tag_id
|
||||
from tag
|
||||
where tag_name = #{name}
|
||||
</select>
|
||||
|
||||
<select id="getNameById" resultType="string">
|
||||
select tag_name
|
||||
from tag
|
||||
where tag_id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getLastestTag" resultMap="tagResultMap">
|
||||
select *
|
||||
from tag
|
||||
order by tag_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="findAll" resultMap="tagResultMap">
|
||||
select *
|
||||
from tag
|
||||
</select>
|
||||
|
||||
<select id="count" resultType="long">
|
||||
select count(*)
|
||||
from tag;
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user