<?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="cn.timer.api.dao.admin.AdminAssoTxjlbMapper">

    <resultMap id="BaseResultMap" type="cn.timer.api.bean.admin.AdminAssoTxjlb" >
                <id column="id" property="id" />
                <result column="content" property="content" />
                <result column="user_name" property="userName" />
                <result column="emp_num" property="empNum" />
                <result column="tx_type" property="txType" />
                <result column="org_code" property="orgCode" />
                <result column="addtime" property="addtime" />
                <result column="txstate" property="txstate" />
    </resultMap>

    <sql id="Base_Column_List">
                id,
                content,
                user_name,
                emp_num,
                tx_type,
                org_code,
                addtime,
                txstate
    </sql>

    <!-- 分页查询 -->
    <sql id="pageTxjlbCondition">
        <where>
            <if test="param.text != null and param.text !=''">
                and (txjlb.user_name like CONCAT('%',#{param.text},'%') or txjlb.emp_num = #{param.text})
            </if>
            <if test="param.txType != null">
                and txjlb.tx_type = #{param.txType}
            </if>
            <if test="param.txstate != null">
                and txjlb.txstate = #{param.txstate}
            </if>
            <if test="param.empNum != null">
                and txjlb.emp_num = #{param.empNum}
            </if>
            <if test="param.orgCode != null">
                and txjlb.org_code = #{param.orgCode}
            </if>
        </where>
    </sql>
    <select id="pageTxjlbCount" resultType="java.lang.Long">
        SELECT count(*) FROM admin_asso_txjlb txjlb
        <include refid="pageTxjlbCondition" />
    </select>
    <select id="pageTxjlb" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM admin_asso_txjlb txjlb
        <include refid="pageTxjlbCondition" />
        ORDER BY txjlb.txstate ASC
        LIMIT #{param.offset}, #{param.totalPage}
    </select>
</mapper>