<?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.fastbee.rechargecard.mapper.NgInformationWaterUserMapper">

    <resultMap type="NgInformationWaterUser" id="NgInformationWaterUserResult">
        <result property="waterUserId"    column="water_user_id"    />
        <result property="name"    column="name"    />
        <result property="account"    column="account"    />
        <result property="waterConsumption"    column="water_consumption"    />
        <result property="waterConsumptionindex"    column="water_consumptionIndex"    />
        <result property="warningStatus"    column="warning_status"    />
        <result property="irrigatedArea"    column="irrigated_area"    />
        <result property="belongingGegion"    column="belonging_gegion"    />
        <result property="contactInformation"    column="contact_information"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="userId"    column="user_id"    />
        <result property="deptId"    column="dept_id"    />
    </resultMap>

    <sql id="selectNgInformationWaterUserVo">
        select water_user_id, name, account, water_consumption, water_consumptionIndex, warning_status, irrigated_area, belonging_gegion, contact_information, remark, create_time, create_by, update_time, update_by,user_id,dept_id from ng_information_water_user
    </sql>

    <select id="selectNgInformationWaterUserList" parameterType="NgInformationWaterUser" resultMap="NgInformationWaterUserResult">
        <include refid="selectNgInformationWaterUserVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="account != null  and account != ''"> and account = #{account}</if>
            <if test="waterConsumption != null "> and water_consumption = #{waterConsumption}</if>
            <if test="waterConsumptionindex != null "> and water_consumptionIndex = #{waterConsumptionindex}</if>
            <if test="warningStatus != null "> and warning_status = #{warningStatus}</if>
            <if test="irrigatedArea != null "> and irrigated_area = #{irrigatedArea}</if>
            <if test="belongingGegion != null  and belongingGegion != ''"> and belonging_gegion = #{belongingGegion}</if>
            <if test="contactInformation != null  and contactInformation != ''"> and contact_information = #{contactInformation}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
        </where>
    </select>

    <select id="selectNgInformationWaterUserByWaterUserId" parameterType="Long" resultMap="NgInformationWaterUserResult">
        <include refid="selectNgInformationWaterUserVo"/>
        where water_user_id = #{waterUserId}
    </select>

    <insert id="insertNgInformationWaterUser" parameterType="NgInformationWaterUser" useGeneratedKeys="true" keyProperty="waterUserId">
        insert into ng_information_water_user
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="account != null">account,</if>
            <if test="waterConsumption != null">water_consumption,</if>
            <if test="waterConsumptionindex != null">water_consumptionIndex,</if>
            <if test="warningStatus != null">warning_status,</if>
            <if test="irrigatedArea != null">irrigated_area,</if>
            <if test="belongingGegion != null">belonging_gegion,</if>
            <if test="contactInformation != null">contact_information,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="account != null">#{account},</if>
            <if test="waterConsumption != null">#{waterConsumption},</if>
            <if test="waterConsumptionindex != null">#{waterConsumptionindex},</if>
            <if test="warningStatus != null">#{warningStatus},</if>
            <if test="irrigatedArea != null">#{irrigatedArea},</if>
            <if test="belongingGegion != null">#{belongingGegion},</if>
            <if test="contactInformation != null">#{contactInformation},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
        </trim>
    </insert>

    <update id="updateNgInformationWaterUser" parameterType="NgInformationWaterUser">
        update ng_information_water_user
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="account != null">account = #{account},</if>
            <if test="waterConsumption != null">water_consumption = #{waterConsumption},</if>
            <if test="waterConsumptionindex != null">water_consumptionIndex = #{waterConsumptionindex},</if>
            <if test="warningStatus != null">warning_status = #{warningStatus},</if>
            <if test="irrigatedArea != null">irrigated_area = #{irrigatedArea},</if>
            <if test="belongingGegion != null">belonging_gegion = #{belongingGegion},</if>
            <if test="contactInformation != null">contact_information = #{contactInformation},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where water_user_id = #{waterUserId}
    </update>

    <delete id="deleteNgInformationWaterUserByWaterUserId" parameterType="Long">
        delete from ng_information_water_user where water_user_id = #{waterUserId}
    </delete>

    <delete id="deleteNgInformationWaterUserByWaterUserIds" parameterType="String">
        delete from ng_information_water_user where water_user_id in
        <foreach item="waterUserId" collection="array" open="(" separator="," close=")">
            #{waterUserId}
        </foreach>
    </delete>
</mapper>