<?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.dao.DonationTypeMapper">
    <resultMap id="BaseResultMap" type="com.entity.DonationType">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="name" property="name" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">
    id, `name`
  </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        from donation_type
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from donation_type
    where id = #{id,jdbcType=INTEGER}
  </delete>
    <insert id="insert" parameterType="com.entity.DonationType">
    insert into donation_type (id, `name`)
    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR})
  </insert>
    <insert id="insertSelective" parameterType="com.entity.DonationType">
        insert into donation_type
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="name != null">
                `name`,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="name != null">
                #{name,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.entity.DonationType">
        update donation_type
        <set>
            <if test="name != null">
                `name` = #{name,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.entity.DonationType">
    update donation_type
    set `name` = #{name,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>

    <select id="getCount" parameterType="java.util.Map" resultType="int">
        select count(*) from donation_type where 1=1
        <if test="name!=null">
            and name =#{name,jdbcType=VARCHAR}
        </if>

    </select>
    <select id="getAll" parameterType="java.util.Map" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>

        from donation_type where 1=1
        <if test="name!=null">
            and name =#{name,jdbcType=VARCHAR}
        </if>
        <if test="id!=null">
            and id != #{id,jdbcType=INTEGER}
        </if>
        order by id desc
    </select>

    <select id="checkName" parameterType="java.util.Map" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from donation_type where 1=1
        <if test="name!=null">
            and name =#{name,jdbcType=VARCHAR}
        </if>
    </select>
    <select id="getByPage" parameterType="java.util.Map" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from donation_type where 1=1
        <if test="name!=null">
            and name =#{name,jdbcType=VARCHAR}
        </if>
        order by id desc
        <if test="pageno!=null and pageSize!=null">
            limit #{pageno},#{pageSize}
        </if>
    </select>
</mapper>