UserMapper.xml 1.1 KB
Newer Older
Q
qinyingjie 已提交
1 2 3 4
<?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.kwan.springbootkwan.mapper.UserMapper">

5 6 7 8 9
    <select id="getUserByName" resultType="com.kwan.springbootkwan.entity.User">
        SELECT *
        FROM user
        WHERE sex = #{sex}
    </select>
10 11 12 13 14 15 16 17 18 19
    <select id="getUserByOr" resultType="com.kwan.springbootkwan.entity.User">
        SELECT *
        FROM user
        WHERE 1 = 1
        <if test="invFlag != null and invFlag.size>0">
            <foreach collection="invFlag" item="flag" open="AND (" close=")" separator="or">
                <if test="flag==1">
                    id &lt;= 1
                </if>
                <if test="flag==2">
20
                    (id &gt;= 2 and id &lt; 4)
21 22
                </if>
                <if test="flag==3">
23
                    ( id &gt;= 5 and id &lt; 6)
24 25
                </if>
                <if test="flag==4">
26
                    ( id &gt;= 8 and id &lt; 9)
27 28 29 30
                </if>
            </foreach>
        </if>
    </select>
Q
qinyingjie 已提交
31
</mapper>