12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?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.xc.dao.NewsMapper">
- <resultMap id="BaseResultMap" type="com.xc.pojo.News">
- <constructor>
- <idArg column="id" jdbcType="INTEGER" javaType="java.lang.Integer"/>
- <arg column="title" jdbcType="VARCHAR" javaType="java.lang.String"/>
- <arg column="cover" jdbcType="VARCHAR" javaType="java.lang.String"/>
- <arg column="content" jdbcType="VARCHAR" javaType="java.lang.String"/>
- <arg column="source" jdbcType="VARCHAR" javaType="java.lang.String"/>
- <arg column="hot" jdbcType="INTEGER" javaType="java.lang.Integer"/>
- <arg column="publish_time" jdbcType="TIMESTAMP" javaType="java.util.Date"/>
- <arg column="create_time" jdbcType="TIMESTAMP" javaType="java.util.Date"/>
- <arg column="update_time" jdbcType="TIMESTAMP" javaType="java.util.Date"/>
- </constructor>
- </resultMap>
- <sql id="Base_Column_List">
- id, title, cover, content, source, hot, publish_time, create_time, update_time
- </sql>
- <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
- select
- <include refid="Base_Column_List"/>
- from news
- where id = #{id,jdbcType=INTEGER}
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
- delete from news
- where id = #{id,jdbcType=INTEGER}
- </delete>
- <insert id="insert" parameterType="com.xc.pojo.News">
- insert into news (
- title, cover, content, source, hot, publish_time, create_time
- )
- values (#{title,jdbcType=VARCHAR}, #{cover,jdbcType=VARCHAR},
- #{content,jdbcType=VARCHAR},#{source,jdbcType=VARCHAR},
- #{hot,jdbcType=INTEGER}, #{publishTime,jdbcType=TIMESTAMP}, now()
- )
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="com.xc.pojo.News">
- update news
- <set>
- <if test="title != null">
- title = #{title,jdbcType=VARCHAR},
- </if>
- <if test="cover != null">
- cover = #{cover,jdbcType=VARCHAR},
- </if>
- <if test="content != null">
- content = #{content,jdbcType=VARCHAR},
- </if>
- <if test="source != null">
- source = #{source,jdbcType=VARCHAR},
- </if>
- <if test="hot != null">
- hot = #{hot,jdbcType=INTEGER},
- </if>
- <if test="publishTime != null">
- publish_time = #{publishTime,jdbcType=TIMESTAMP},
- </if>
- </set>
- where id = #{id,jdbcType=INTEGER}
- </update>
- <select id="listByNews" parameterType="map" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM news
- <where>
- <if test="title != null and title != '' ">
- and title like CONCAT('%',#{title},'%')
- </if>
- <if test="source != null and source != '' ">
- and source like CONCAT('%',#{source},'%')
- </if>
- <if test="hot != null">
- and hot = #{hot}
- </if>
- </where>
- order by
- id
- desc
- </select>
- </mapper>
|