<?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.mapper.UserMapper">
<!--    sql语句抽取-->
    <cache />
    <sql id="all">select * from user</sql>
<select id="findUserListByCondition" resultType="user"
        parameterType="user" >
    <include refid="all"></include>
    <where>
        <if test="id !=null">
            and id = #{id}
        </if>
        <if test="name !=null">
            and name = #{name}
        </if>
        <if test="age !=null">
            and age = #{age}
        </if>
    </where>
</select>
<select id="findUserForEach" parameterType="list" resultType="user">
    <include refid="all"></include>
    <where>
    <foreach collection="list" open="id in(" close=")" item="item" separator=",">
        #{item}
    </foreach>
</where>
</select>
<delete id="deleteOne" parameterType="integer">
    delete from user where id=#{id}
</delete>
    <select id="findUserByParam" resultType="user">
        select *
        from user where name = '${arg0}' and age = ${param2};
    </select>
    <select id="findUserByMap" resultType="user">
        select *
        from user where name = #{name}  and age = #{age};
    </select>
    <select id="findUserByAnnoParam" resultType="user">
        select *
        from user where name = #{param1.name}  and age = #{users.age};
    </select>
    <select id="findByMap" resultType="map">
        select *
        from user where id = #{id}
    </select>
    <select id="findAllByMap" resultType="map">
        select *
        from user
    </select>
</mapper>
