You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
4.9 KiB
148 lines
4.9 KiB
2 years ago
|
<?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">
|
||
|
<!-- 配置Mabatis映射文件 -->
|
||
|
<mapper namespace="com.dao.ArticleDAO">
|
||
|
<resultMap type="article" id="articleMap">
|
||
|
<id property="articleid" column="articleid" />
|
||
|
<result property="title" column="title" />
|
||
|
<result property="bannerid" column="bannerid" />
|
||
|
<result property="image" column="image" />
|
||
|
<result property="istop" column="istop" />
|
||
|
<result property="isflv" column="isflv" />
|
||
|
<result property="contents" column="contents" />
|
||
|
<result property="addtime" column="addtime" />
|
||
|
<result property="hits" column="hits" />
|
||
|
<result property="bannername" column="bannername" />
|
||
|
</resultMap>
|
||
|
<!-- 插入语句 DAO通过id调用此配置 -->
|
||
|
<insert id="insertArticle" parameterType="article">
|
||
|
insert into article(articleid , title , bannerid , image , istop , isflv , contents , addtime , hits )
|
||
|
values(#{articleid} , #{title} , #{bannerid} , #{image} ,
|
||
|
#{istop} , #{isflv} , #{contents} , #{addtime} , #{hits} )
|
||
|
</insert>
|
||
|
<!-- 更新语句 DAO通过id调用此配置 -->
|
||
|
<update id="updateArticle" parameterType="article">
|
||
|
update article set title=#{title} , bannerid=#{bannerid} , image=#{image} , istop=#{istop} , isflv=#{isflv} ,
|
||
|
contents=#{contents} , addtime=#{addtime} ,
|
||
|
hits=#{hits} where articleid=#{articleid}
|
||
|
</update>
|
||
|
<!-- 按主键删除 DAO通过id调用此配置 -->
|
||
|
<delete id="deleteArticle" parameterType="String">
|
||
|
delete from article where articleid = #{articleid}
|
||
|
</delete>
|
||
|
<!-- 查询全部信息 DAO通过id调用此配置 -->
|
||
|
<select id="getAllArticle" resultMap="articleMap">
|
||
|
select a.* , b.bannername from article a , banner b where a.bannerid = b.bannerid order by articleid desc
|
||
|
</select>
|
||
|
<select id="getFlvArticle" resultMap="articleMap">
|
||
|
select a.* , b.bannername
|
||
|
from article a , banner b where a.bannerid = b.bannerid and isflv =
|
||
|
'是' order by
|
||
|
articleid
|
||
|
desc limit 7
|
||
|
</select>
|
||
|
<select id="getTopArticle" resultMap="articleMap">
|
||
|
select a.* , b.bannername
|
||
|
from article a , banner b where a.bannerid = b.bannerid and istop = '是' order by articleid desc limit 7
|
||
|
</select>
|
||
|
<select id="getArticleByBanner" parameterType="String" resultMap="articleMap">
|
||
|
select a.* , b.bannername from article a , banner b where
|
||
|
a.bannerid =
|
||
|
b.bannerid and
|
||
|
a.bannerid = #{bannerid} order by
|
||
|
articleid
|
||
|
desc limit 7
|
||
|
</select>
|
||
|
<!-- 按主键查询 DAO通过id调用此配置 -->
|
||
|
<select id="getArticleById" parameterType="String" resultMap="articleMap">
|
||
|
select a.* , b.bannername from article a , banner b where a.bannerid = b.bannerid
|
||
|
and articleid=#{articleid} order by articleid desc
|
||
|
</select>
|
||
|
<!-- 按条件精确查询 DAO通过id调用此配置 -->
|
||
|
<select id="getArticleByCond" parameterType="article" resultMap="articleMap">
|
||
|
select a.* , b.bannername from article a , banner b where a.bannerid = b.bannerid
|
||
|
<if test="title != null and '' != title">
|
||
|
and a.title = #{title}
|
||
|
</if>
|
||
|
<if test="bannerid != null and '' != bannerid">
|
||
|
and a.bannerid = #{bannerid}
|
||
|
</if>
|
||
|
<if test="image != null and '' != image">
|
||
|
and a.image = #{image}
|
||
|
</if>
|
||
|
<if test="istop != null and '' != istop">
|
||
|
and a.istop = #{istop}
|
||
|
</if>
|
||
|
<if test="isflv != null and '' != isflv">
|
||
|
and a.isflv = #{isflv}
|
||
|
</if>
|
||
|
<if test="contents != null and '' != contents">
|
||
|
and a.contents = #{contents}
|
||
|
</if>
|
||
|
<if test="addtime != null and '' != addtime">
|
||
|
and a.addtime = #{addtime}
|
||
|
</if>
|
||
|
<if test="hits != null and '' != hits">
|
||
|
and a.hits = #{hits}
|
||
|
</if>
|
||
|
</select>
|
||
|
<!-- 按条件模糊查询 DAO通过id调用此配置 -->
|
||
|
<select id="getArticleByLike" parameterType="article" resultMap="articleMap">
|
||
|
select a.* , b.bannername from article a , banner b where a.bannerid = b.bannerid
|
||
|
<if test="title != null and '' != title">
|
||
|
and a.title like CONCAT('%', CONCAT(#{title}, '%'))
|
||
|
</if>
|
||
|
<if test="bannerid != null and '' != bannerid">
|
||
|
and b.bannername like CONCAT('%', CONCAT(#{bannerid}, '%'))
|
||
|
</if>
|
||
|
<if test="image != null and '' != image">
|
||
|
and a.image like CONCAT('%', CONCAT(#{image}, '%'))
|
||
|
</if>
|
||
|
<if test="istop != null and '' != istop">
|
||
|
and a.istop like CONCAT('%', CONCAT(#{istop}, '%'))
|
||
|
</if>
|
||
|
<if test="isflv != null and '' != isflv">
|
||
|
and a.isflv like CONCAT('%', CONCAT(#{isflv}, '%'))
|
||
|
</if>
|
||
|
<if test="contents != null and '' != contents">
|
||
|
and a.contents like CONCAT('%', CONCAT(#{contents}, '%'))
|
||
|
</if>
|
||
|
<if test="addtime != null and '' != addtime">
|
||
|
and a.addtime like CONCAT('%', CONCAT(#{addtime}, '%'))
|
||
|
</if>
|
||
|
<if test="hits != null and '' != hits">
|
||
|
and a.hits like CONCAT('%', CONCAT(#{hits}, '%'))
|
||
|
</if>
|
||
|
</select>
|
||
|
</mapper>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|