<?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.bonus.canteen.core.customer.mapper.CustPsnTypeMapper">


    <resultMap type="com.bonus.canteen.core.customer.model.CustPsnType" id="BaseResultMap">
        <result property="id" column="id"/>
        <result property="psnType" column="psn_type"/>
        <result property="psnTypeName" column="psn_type_name"/>
        <result property="delFlag" column="del_flag"/>
        <result property="revision" column="revision"/>
        <result property="crby" column="crby"/>
        <result property="crtime" column="crtime"/>
        <result property="upby" column="upby"/>
        <result property="uptime" column="uptime"/>
    </resultMap>

    <!-- 人员类别数据检验 -->
    <select id="selectPsnType" resultMap="BaseResultMap">
        select id,
               psn_type,
               psn_type_name,
               del_flag,
               revision,
               crby,
               crtime,
               upby,
               uptime
        from cust_psn_type
        where (psn_type = #{psnType}
            or psn_type_name = #{psnTypeName})
          and del_flag = #{delFlag}
    </select>

    <select id="pagePsnTypeList" resultType="com.bonus.canteen.core.customer.v4.web.vo.ExportPsnTypeVO">
        select id,
        psn_type,
        psn_type_name,
        crby,
        crtime,
        upby,
        uptime
        from cust_psn_type
        <where>
            <if test="param.psnType != null">
                and psn_type = #{param.psnType}
            </if>
            <if test="param.psnTypeName != null and param.psnTypeName != ''">
               and ( psn_type_name = #{param.psnTypeName} or psn_type=#{param.psnTypeName} )
            </if>
            <if test="param.delFlag != null">
                and del_flag = #{param.delFlag}
            </if>
            <if test="param.delFlag == null">
                and del_flag = 2
            </if>
        </where>


    </select>
</mapper>
