<?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.zehong.system.mapper.TGasUserInfoMapper">

    <resultMap type="TGasUserInfo" id="TGasUserInfoResult">
        <result property="gasUserId"    column="gas_user_id"    />
        <result property="gasUserName"    column="gas_user_name"    />
        <result property="gasUserCode"    column="gas_user_code"    />
        <result property="gasUserType"    column="gas_user_type"    />
        <result property="telNum"    column="tel_num"    />
        <result property="gasUserStatus"    column="gas_user_status"    />
        <result property="gasUserAddress"    column="gas_user_address"    />
        <result property="lastDeliveryDate"    column="last_delivery_date"    />
        <result property="gasUserCheckStatus"    column="gas_user_check_status"    />
        <result property="totalCheckNum"    column="total_check_num"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTGasUserInfoVo">
        select gas_user_id, gas_user_name, gas_user_code, gas_user_type, tel_num, gas_user_status, gas_user_address, last_delivery_date, gas_user_check_status, total_check_num, create_time, update_time, is_del, remark from t_gas_user_info
    </sql>

    <select id="selectTGasUserInfoList" parameterType="TGasUserInfo" resultMap="TGasUserInfoResult">
        <include refid="selectTGasUserInfoVo"/>
        <where>
            <if test="gasUserName != null  and gasUserName != ''"> and gas_user_name like concat('%', #{gasUserName}, '%')</if>
            <if test="gasUserCode != null  and gasUserCode != ''"> and gas_user_code = #{gasUserCode}</if>
            <if test="gasUserType != null  and gasUserType != ''"> and gas_user_type = #{gasUserType}</if>
            <if test="telNum != null  and telNum != ''"> and tel_num = #{telNum}</if>
            <if test="gasUserStatus != null  and gasUserStatus != ''"> and gas_user_status = #{gasUserStatus}</if>
            <if test="gasUserAddress != null  and gasUserAddress != ''"> and gas_user_address = #{gasUserAddress}</if>
            <if test="lastDeliveryDate != null "> and last_delivery_date = #{lastDeliveryDate}</if>
            <if test="gasUserCheckStatus != null  and gasUserCheckStatus != ''"> and gas_user_check_status = #{gasUserCheckStatus}</if>
            <if test="totalCheckNum != null "> and total_check_num = #{totalCheckNum}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
        </where>
        order by  gas_user_id desc
    </select>

    <select id="selectTGasUserInfoById" parameterType="Long" resultMap="TGasUserInfoResult">
        <include refid="selectTGasUserInfoVo"/>
        where gas_user_id = #{gasUserId}
    </select>

    <insert id="insertTGasUserInfo" parameterType="TGasUserInfo" useGeneratedKeys="true" keyProperty="gasUserId">
        insert into t_gas_user_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="gasUserName != null">gas_user_name,</if>
            <if test="gasUserCode != null">gas_user_code,</if>
            <if test="gasUserType != null">gas_user_type,</if>
            <if test="telNum != null">tel_num,</if>
            <if test="gasUserStatus != null">gas_user_status,</if>
            <if test="gasUserAddress != null">gas_user_address,</if>
            <if test="lastDeliveryDate != null">last_delivery_date,</if>
            <if test="gasUserCheckStatus != null">gas_user_check_status,</if>
            <if test="totalCheckNum != null">total_check_num,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="gasUserName != null">#{gasUserName},</if>
            <if test="gasUserCode != null">#{gasUserCode},</if>
            <if test="gasUserType != null">#{gasUserType},</if>
            <if test="telNum != null">#{telNum},</if>
            <if test="gasUserStatus != null">#{gasUserStatus},</if>
            <if test="gasUserAddress != null">#{gasUserAddress},</if>
            <if test="lastDeliveryDate != null">#{lastDeliveryDate},</if>
            <if test="gasUserCheckStatus != null">#{gasUserCheckStatus},</if>
            <if test="totalCheckNum != null">#{totalCheckNum},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTGasUserInfo" parameterType="TGasUserInfo">
        update t_gas_user_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="gasUserName != null">gas_user_name = #{gasUserName},</if>
            <if test="gasUserCode != null">gas_user_code = #{gasUserCode},</if>
            <if test="gasUserType != null">gas_user_type = #{gasUserType},</if>
            <if test="telNum != null">tel_num = #{telNum},</if>
            <if test="gasUserStatus != null">gas_user_status = #{gasUserStatus},</if>
            <if test="gasUserAddress != null">gas_user_address = #{gasUserAddress},</if>
            <if test="lastDeliveryDate != null">last_delivery_date = #{lastDeliveryDate},</if>
            <if test="gasUserCheckStatus != null">gas_user_check_status = #{gasUserCheckStatus},</if>
            <if test="totalCheckNum != null">total_check_num = #{totalCheckNum},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where gas_user_id = #{gasUserId}
    </update>

    <delete id="deleteTGasUserInfoById" parameterType="Long">
        delete from t_gas_user_info where gas_user_id = #{gasUserId}
    </delete>

    <delete id="deleteTGasUserInfoByIds" parameterType="String">
        delete from t_gas_user_info where gas_user_id in
        <foreach item="gasUserId" collection="array" open="(" separator="," close=")">
            #{gasUserId}
        </foreach>
    </delete>

    <!--查询燃气用户信息-->
    <select id="gasUser" parameterType="TGasUserInfo" resultMap="TGasUserInfoResult">
        <include refid="selectTGasUserInfoVo"/>
        where gas_user_name like concat('%', #{gasUserName}, '%')
    </select>
</mapper>