<?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.ggroup.mapper.GSiteRiverInfoMapper">

    <resultMap type="GSiteRiverInfo" id="GRiverInfoResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="code"    column="code"    />
        <result property="length"    column="length"    />
        <result property="area"    column="area"    />
        <result property="towns"    column="towns"    />
        <result property="startLatitude"    column="start_latitude"    />
        <result property="startLongitude"    column="start_longitude"    />
        <result property="startLocation"    column="start_location"    />
        <result property="endLatitude"    column="end_latitude"    />
        <result property="endLongitude"    column="end_longitude"    />
        <result property="endLocation"    column="end_location"    />
        <result property="pollutionDrainageNumber"    column="pollution_drainage_number"    />
        <result property="waterRelatedProjectsAndFacilitiesNumber"    column="water_related_projects_and_facilities_number"    />
        <result property="spannedCrossedNearbyBuildingsNumber"    column="spanned_crossed_nearby_buildings_number"    />
        <result property="designStandardRecurrencePeriod"    column="design_standard_recurrence_period"    />
        <result property="riverSupervisorName"    column="river_supervisor_name"    />
        <result property="riverSupervisorPosition"    column="river_supervisor_position"    />
        <result property="riverSupervisorPhone"    column="river_supervisor_phone"    />
        <result property="contactUnit"    column="contact_unit"    />
        <result property="unitContactPersonName"    column="unit_contact_person_name"    />
        <result property="unitContactPersonPhone"    column="unit_contact_person_phone"    />
        <result property="contactPersonName"    column="contact_person_name"    />
        <result property="contactPersonPhone"    column="contact_person_phone"    />
        <result property="floodPreventionMaterials"    column="flood_prevention_materials"    />
        <result property="adminPersonName"    column="admin_person_name"    />
        <result property="adminPersonPosition"    column="admin_person_position"    />
        <result property="adminPersonPhone"    column="admin_person_phone"    />
        <result property="techPersonName"    column="tech_person_name"    />
        <result property="techPersonPosition"    column="tech_person_position"    />
        <result property="techPersonPhone"    column="tech_person_phone"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createdBy"    column="created_by"    />
        <result property="updatedBy"    column="updated_by"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="siteId"    column="site_id"    />
    </resultMap>

    <sql id="selectGRiverInfoVo">
        select id, name, code, length, area, towns, start_latitude, start_longitude, start_location, end_latitude, end_longitude, end_location, pollution_drainage_number, water_related_projects_and_facilities_number, spanned_crossed_nearby_buildings_number, design_standard_recurrence_period, river_supervisor_name, river_supervisor_position, river_supervisor_phone, contact_unit, unit_contact_person_name, unit_contact_person_phone, contact_person_name, contact_person_phone, flood_prevention_materials, admin_person_name, admin_person_position, admin_person_phone, tech_person_name, tech_person_position, tech_person_phone, create_time, update_time, created_by, updated_by, del_flag, site_id from g_site_river_info
    </sql>

    <select id="selectGRiverInfoList" parameterType="GSiteRiverInfo" resultMap="GRiverInfoResult">
        <include refid="selectGRiverInfoVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="code != null  and code != ''"> and code = #{code}</if>
            <if test="length != null "> and length = #{length}</if>
            <if test="area != null "> and area = #{area}</if>
            <if test="towns != null  and towns != ''"> and towns = #{towns}</if>
            <if test="startLatitude != null "> and start_latitude = #{startLatitude}</if>
            <if test="startLongitude != null "> and start_longitude = #{startLongitude}</if>
            <if test="startLocation != null  and startLocation != ''"> and start_location = #{startLocation}</if>
            <if test="endLatitude != null "> and end_latitude = #{endLatitude}</if>
            <if test="endLongitude != null "> and end_longitude = #{endLongitude}</if>
            <if test="endLocation != null  and endLocation != ''"> and end_location = #{endLocation}</if>
            <if test="pollutionDrainageNumber != null "> and pollution_drainage_number = #{pollutionDrainageNumber}</if>
            <if test="waterRelatedProjectsAndFacilitiesNumber != null "> and water_related_projects_and_facilities_number = #{waterRelatedProjectsAndFacilitiesNumber}</if>
            <if test="spannedCrossedNearbyBuildingsNumber != null "> and spanned_crossed_nearby_buildings_number = #{spannedCrossedNearbyBuildingsNumber}</if>
            <if test="designStandardRecurrencePeriod != null "> and design_standard_recurrence_period = #{designStandardRecurrencePeriod}</if>
            <if test="riverSupervisorName != null  and riverSupervisorName != ''"> and river_supervisor_name like concat('%', #{riverSupervisorName}, '%')</if>
            <if test="riverSupervisorPosition != null  and riverSupervisorPosition != ''"> and river_supervisor_position = #{riverSupervisorPosition}</if>
            <if test="riverSupervisorPhone != null  and riverSupervisorPhone != ''"> and river_supervisor_phone = #{riverSupervisorPhone}</if>
            <if test="contactUnit != null  and contactUnit != ''"> and contact_unit = #{contactUnit}</if>
            <if test="unitContactPersonName != null  and unitContactPersonName != ''"> and unit_contact_person_name like concat('%', #{unitContactPersonName}, '%')</if>
            <if test="unitContactPersonPhone != null  and unitContactPersonPhone != ''"> and unit_contact_person_phone = #{unitContactPersonPhone}</if>
            <if test="contactPersonName != null  and contactPersonName != ''"> and contact_person_name like concat('%', #{contactPersonName}, '%')</if>
            <if test="contactPersonPhone != null  and contactPersonPhone != ''"> and contact_person_phone = #{contactPersonPhone}</if>
            <if test="floodPreventionMaterials != null  and floodPreventionMaterials != ''"> and flood_prevention_materials = #{floodPreventionMaterials}</if>
            <if test="adminPersonName != null  and adminPersonName != ''"> and admin_person_name like concat('%', #{adminPersonName}, '%')</if>
            <if test="adminPersonPosition != null  and adminPersonPosition != ''"> and admin_person_position = #{adminPersonPosition}</if>
            <if test="adminPersonPhone != null  and adminPersonPhone != ''"> and admin_person_phone = #{adminPersonPhone}</if>
            <if test="techPersonName != null  and techPersonName != ''"> and tech_person_name like concat('%', #{techPersonName}, '%')</if>
            <if test="techPersonPosition != null  and techPersonPosition != ''"> and tech_person_position = #{techPersonPosition}</if>
            <if test="techPersonPhone != null  and techPersonPhone != ''"> and tech_person_phone = #{techPersonPhone}</if>
            <if test="createdBy != null  and createdBy != ''"> and created_by = #{createdBy}</if>
            <if test="updatedBy != null  and updatedBy != ''"> and updated_by = #{updatedBy}</if>
            <if test="siteId != null "> and site_id = #{siteId}</if>
        </where>
    </select>

    <select id="selectGRiverInfoBySiteId" parameterType="Long" resultMap="GRiverInfoResult">
        <include refid="selectGRiverInfoVo"/>
        where site_id = #{siteId}
    </select>

    <insert id="insertGRiverInfo" parameterType="GSiteRiverInfo" useGeneratedKeys="true" keyProperty="id">
        insert into g_site_river_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="code != null">code,</if>
            <if test="length != null">length,</if>
            <if test="area != null">area,</if>
            <if test="towns != null">towns,</if>
            <if test="startLatitude != null">start_latitude,</if>
            <if test="startLongitude != null">start_longitude,</if>
            <if test="startLocation != null">start_location,</if>
            <if test="endLatitude != null">end_latitude,</if>
            <if test="endLongitude != null">end_longitude,</if>
            <if test="endLocation != null">end_location,</if>
            <if test="pollutionDrainageNumber != null">pollution_drainage_number,</if>
            <if test="waterRelatedProjectsAndFacilitiesNumber != null">water_related_projects_and_facilities_number,</if>
            <if test="spannedCrossedNearbyBuildingsNumber != null">spanned_crossed_nearby_buildings_number,</if>
            <if test="designStandardRecurrencePeriod != null">design_standard_recurrence_period,</if>
            <if test="riverSupervisorName != null">river_supervisor_name,</if>
            <if test="riverSupervisorPosition != null">river_supervisor_position,</if>
            <if test="riverSupervisorPhone != null">river_supervisor_phone,</if>
            <if test="contactUnit != null">contact_unit,</if>
            <if test="unitContactPersonName != null">unit_contact_person_name,</if>
            <if test="unitContactPersonPhone != null">unit_contact_person_phone,</if>
            <if test="contactPersonName != null">contact_person_name,</if>
            <if test="contactPersonPhone != null">contact_person_phone,</if>
            <if test="floodPreventionMaterials != null">flood_prevention_materials,</if>
            <if test="adminPersonName != null">admin_person_name,</if>
            <if test="adminPersonPosition != null">admin_person_position,</if>
            <if test="adminPersonPhone != null">admin_person_phone,</if>
            <if test="techPersonName != null">tech_person_name,</if>
            <if test="techPersonPosition != null">tech_person_position,</if>
            <if test="techPersonPhone != null">tech_person_phone,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createdBy != null">created_by,</if>
            <if test="updatedBy != null">updated_by,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="siteId != null">site_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="code != null">#{code},</if>
            <if test="length != null">#{length},</if>
            <if test="area != null">#{area},</if>
            <if test="towns != null">#{towns},</if>
            <if test="startLatitude != null">#{startLatitude},</if>
            <if test="startLongitude != null">#{startLongitude},</if>
            <if test="startLocation != null">#{startLocation},</if>
            <if test="endLatitude != null">#{endLatitude},</if>
            <if test="endLongitude != null">#{endLongitude},</if>
            <if test="endLocation != null">#{endLocation},</if>
            <if test="pollutionDrainageNumber != null">#{pollutionDrainageNumber},</if>
            <if test="waterRelatedProjectsAndFacilitiesNumber != null">#{waterRelatedProjectsAndFacilitiesNumber},</if>
            <if test="spannedCrossedNearbyBuildingsNumber != null">#{spannedCrossedNearbyBuildingsNumber},</if>
            <if test="designStandardRecurrencePeriod != null">#{designStandardRecurrencePeriod},</if>
            <if test="riverSupervisorName != null">#{riverSupervisorName},</if>
            <if test="riverSupervisorPosition != null">#{riverSupervisorPosition},</if>
            <if test="riverSupervisorPhone != null">#{riverSupervisorPhone},</if>
            <if test="contactUnit != null">#{contactUnit},</if>
            <if test="unitContactPersonName != null">#{unitContactPersonName},</if>
            <if test="unitContactPersonPhone != null">#{unitContactPersonPhone},</if>
            <if test="contactPersonName != null">#{contactPersonName},</if>
            <if test="contactPersonPhone != null">#{contactPersonPhone},</if>
            <if test="floodPreventionMaterials != null">#{floodPreventionMaterials},</if>
            <if test="adminPersonName != null">#{adminPersonName},</if>
            <if test="adminPersonPosition != null">#{adminPersonPosition},</if>
            <if test="adminPersonPhone != null">#{adminPersonPhone},</if>
            <if test="techPersonName != null">#{techPersonName},</if>
            <if test="techPersonPosition != null">#{techPersonPosition},</if>
            <if test="techPersonPhone != null">#{techPersonPhone},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createdBy != null">#{createdBy},</if>
            <if test="updatedBy != null">#{updatedBy},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="siteId != null">#{siteId},</if>
        </trim>
    </insert>

    <update id="updateGRiverInfo" parameterType="GSiteRiverInfo">
        update g_site_river_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="code != null">code = #{code},</if>
            <if test="length != null">length = #{length},</if>
            <if test="area != null">area = #{area},</if>
            <if test="towns != null">towns = #{towns},</if>
            <if test="startLatitude != null">start_latitude = #{startLatitude},</if>
            <if test="startLongitude != null">start_longitude = #{startLongitude},</if>
            <if test="startLocation != null">start_location = #{startLocation},</if>
            <if test="endLatitude != null">end_latitude = #{endLatitude},</if>
            <if test="endLongitude != null">end_longitude = #{endLongitude},</if>
            <if test="endLocation != null">end_location = #{endLocation},</if>
            <if test="pollutionDrainageNumber != null">pollution_drainage_number = #{pollutionDrainageNumber},</if>
            <if test="waterRelatedProjectsAndFacilitiesNumber != null">water_related_projects_and_facilities_number = #{waterRelatedProjectsAndFacilitiesNumber},</if>
            <if test="spannedCrossedNearbyBuildingsNumber != null">spanned_crossed_nearby_buildings_number = #{spannedCrossedNearbyBuildingsNumber},</if>
            <if test="designStandardRecurrencePeriod != null">design_standard_recurrence_period = #{designStandardRecurrencePeriod},</if>
            <if test="riverSupervisorName != null">river_supervisor_name = #{riverSupervisorName},</if>
            <if test="riverSupervisorPosition != null">river_supervisor_position = #{riverSupervisorPosition},</if>
            <if test="riverSupervisorPhone != null">river_supervisor_phone = #{riverSupervisorPhone},</if>
            <if test="contactUnit != null">contact_unit = #{contactUnit},</if>
            <if test="unitContactPersonName != null">unit_contact_person_name = #{unitContactPersonName},</if>
            <if test="unitContactPersonPhone != null">unit_contact_person_phone = #{unitContactPersonPhone},</if>
            <if test="contactPersonName != null">contact_person_name = #{contactPersonName},</if>
            <if test="contactPersonPhone != null">contact_person_phone = #{contactPersonPhone},</if>
            <if test="floodPreventionMaterials != null">flood_prevention_materials = #{floodPreventionMaterials},</if>
            <if test="adminPersonName != null">admin_person_name = #{adminPersonName},</if>
            <if test="adminPersonPosition != null">admin_person_position = #{adminPersonPosition},</if>
            <if test="adminPersonPhone != null">admin_person_phone = #{adminPersonPhone},</if>
            <if test="techPersonName != null">tech_person_name = #{techPersonName},</if>
            <if test="techPersonPosition != null">tech_person_position = #{techPersonPosition},</if>
            <if test="techPersonPhone != null">tech_person_phone = #{techPersonPhone},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createdBy != null">created_by = #{createdBy},</if>
            <if test="updatedBy != null">updated_by = #{updatedBy},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="siteId != null">site_id = #{siteId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteGRiverInfoById" parameterType="Long">
        delete from g_site_river_info where id = #{id}
    </delete>

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