<?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.willalp.system.mapper.SysCardInfoMapper">

    <sql id="columns">
         id, card_username as cardUsername, card_phonenumber as cardPhonenumber, card_password as cardPassword, user_id as userId, organization_code as organizationCode, is_delete as isDelete, create_by as createBy, create_time as createTime, update_by as updateBy, update_time as updateTime, card_code as cardCode , card_state as cardState
    </sql>

    <sql id="where">
        <where>
            <if test="@sqlt.Ognl@isNotEmpty(cardUsername)">
                and card_username like concat('%', #{cardUsername}, '%')
            </if>
            <if test="@sqlt.Ognl@isNotEmpty(cardPhonenumber)">
                and card_phonenumber = #{cardPhonenumber}
            </if>
            <if test="@sqlt.Ognl@isNotEmpty(cardPassword)">
                and card_password = #{cardPassword}
            </if>
            <if test="@sqlt.Ognl@isNotEmpty(userId)">
                and user_id = #{userId}
            </if>
            <if test="@sqlt.Ognl@isNotEmpty(organizationCode)">
                and organization_code = #{organizationCode}
            </if>
            <if test="@sqlt.Ognl@isNotEmpty(isDelete)">
                and is_delete = #{isDelete}
            </if>
            <if test="@sqlt.Ognl@isNotEmpty(cardCode)">
                and card_code = #{cardCode}
            </if>
            <if test="@sqlt.Ognl@isNotEmpty(cardState)">
                and card_state = #{cardState}
            </if>
            <if test="@sqlt.Ognl@isNotEmpty(organizations)">
                and organization_code in
                <foreach collection="organizations" item="z" open="(" close=")" >
                    #{z}
                </foreach>
            </if>
        </where>
    </sql>

    <select id="selectSysCardInfoList" resultType="com.willalp.system.domain.SysCardInfo">
        select
        <include refid="columns"/>
        from sys_card_info
        <include refid="where"/>
    </select>
</mapper>
