<?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.TEnterpriseInfoMapper">
    
    <resultMap type="TEnterpriseInfo" id="TEnterpriseInfoResult">
        <result property="infoId"    column="info_id"    />
        <result property="unitName"    column="unit_name"    />
        <result property="orgCode"    column="org_code"    />
        <result property="orgFilePath"    column="org_file_path"    />
        <result property="orgFileName"    column="org_file_name"    />
        <result property="runAddress"    column="run_address"    />
        <result property="regAddress"    column="reg_address"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="legalPerson"    column="legal_person"    />
        <result property="legalPersonPhone"    column="legal_person_phone"    />
        <result property="legalPersonEmail"    column="legal_person_email"    />
        <result property="createUserId"    column="create_user_id"    />
        <result property="updateUserId"    column="update_user_id"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="remarks"    column="remarks"    />
    </resultMap>

    <sql id="selectTEnterpriseInfoVo">
        select info_id, unit_name, org_code, org_file_path, org_file_name, run_address, reg_address, longitude, latitude, legal_person, legal_person_phone, legal_person_email, create_user_id, update_user_id, update_time, create_time, remarks from t_enterprise_info
    </sql>

    <select id="selectTEnterpriseInfoList" parameterType="TEnterpriseInfo" resultMap="TEnterpriseInfoResult">
        <include refid="selectTEnterpriseInfoVo"/>
        <where>  
            <if test="unitName != null  and unitName != ''"> and unit_name like concat('%', #{unitName}, '%')</if>
            <if test="orgCode != null  and orgCode != ''"> and org_code = #{orgCode}</if>
            <if test="orgFilePath != null  and orgFilePath != ''"> and org_file_path = #{orgFilePath}</if>
            <if test="orgFileName != null  and orgFileName != ''"> and org_file_name like concat('%', #{orgFileName}, '%')</if>
            <if test="runAddress != null  and runAddress != ''"> and run_address = #{runAddress}</if>
            <if test="regAddress != null  and regAddress != ''"> and reg_address = #{regAddress}</if>
            <if test="longitude != null "> and longitude = #{longitude}</if>
            <if test="latitude != null "> and latitude = #{latitude}</if>
            <if test="legalPerson != null  and legalPerson != ''"> and legal_person = #{legalPerson}</if>
            <if test="legalPersonPhone != null  and legalPersonPhone != ''"> and legal_person_phone = #{legalPersonPhone}</if>
            <if test="legalPersonEmail != null  and legalPersonEmail != ''"> and legal_person_email = #{legalPersonEmail}</if>
            <if test="createUserId != null  and createUserId != ''"> and create_user_id = #{createUserId}</if>
            <if test="updateUserId != null  and updateUserId != ''"> and update_user_id = #{updateUserId}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
        </where>
    </select>
    
    <select id="selectTEnterpriseInfoById" parameterType="int" resultMap="TEnterpriseInfoResult">
        <include refid="selectTEnterpriseInfoVo"/>
        where info_id = #{infoId}
    </select>
        
    <insert id="insertTEnterpriseInfo" parameterType="TEnterpriseInfo">
        insert into t_enterprise_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="infoId != null">info_id,</if>
            <if test="unitName != null">unit_name,</if>
            <if test="orgCode != null">org_code,</if>
            <if test="orgFilePath != null">org_file_path,</if>
            <if test="orgFileName != null">org_file_name,</if>
            <if test="runAddress != null">run_address,</if>
            <if test="regAddress != null">reg_address,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="legalPerson != null">legal_person,</if>
            <if test="legalPersonPhone != null">legal_person_phone,</if>
            <if test="legalPersonEmail != null">legal_person_email,</if>
            <if test="createUserId != null">create_user_id,</if>
            <if test="updateUserId != null">update_user_id,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="infoId != null">#{infoId},</if>
            <if test="unitName != null">#{unitName},</if>
            <if test="orgCode != null">#{orgCode},</if>
            <if test="orgFilePath != null">#{orgFilePath},</if>
            <if test="orgFileName != null">#{orgFileName},</if>
            <if test="runAddress != null">#{runAddress},</if>
            <if test="regAddress != null">#{regAddress},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="legalPerson != null">#{legalPerson},</if>
            <if test="legalPersonPhone != null">#{legalPersonPhone},</if>
            <if test="legalPersonEmail != null">#{legalPersonEmail},</if>
            <if test="createUserId != null">#{createUserId},</if>
            <if test="updateUserId != null">#{updateUserId},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTEnterpriseInfo" parameterType="TEnterpriseInfo">
        update t_enterprise_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="unitName != null">unit_name = #{unitName},</if>
            <if test="orgCode != null">org_code = #{orgCode},</if>
            <if test="orgFilePath != null">org_file_path = #{orgFilePath},</if>
            <if test="orgFileName != null">org_file_name = #{orgFileName},</if>
            <if test="runAddress != null">run_address = #{runAddress},</if>
            <if test="regAddress != null">reg_address = #{regAddress},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="legalPerson != null">legal_person = #{legalPerson},</if>
            <if test="legalPersonPhone != null">legal_person_phone = #{legalPersonPhone},</if>
            <if test="legalPersonEmail != null">legal_person_email = #{legalPersonEmail},</if>
            <if test="createUserId != null">create_user_id = #{createUserId},</if>
            <if test="updateUserId != null">update_user_id = #{updateUserId},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where info_id = #{infoId}
    </update>

    <delete id="deleteTEnterpriseInfoById" parameterType="Long">
        delete from t_enterprise_info where info_id = #{infoId}
    </delete>

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