<?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.ruoyi.system.mapper.EnterprisePhotoMapper">
    
    <resultMap type="EnterprisePhoto" id="EnterprisePhotoResult">
        <result property="id"    column="id"    />
        <result property="enterpriseId"    column="enterprise_id"    />
        <result property="path"    column="path"    />
        <result property="type"    column="type"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectEnterprisePhotoVo">
        select id, enterprise_id, path, type, remark from enterprise_photo
    </sql>

    <select id="selectEnterprisePhotoList" parameterType="EnterprisePhoto" resultMap="EnterprisePhotoResult">
        <include refid="selectEnterprisePhotoVo"/>
        <where>  
            <if test="enterpriseId != null "> and enterprise_id = #{enterpriseId}</if>
            <if test="path != null  and path != ''"> and path = #{path}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
        </where>
    </select>
    
    <select id="selectEnterprisePhotoById" parameterType="Long" resultMap="EnterprisePhotoResult">
        <include refid="selectEnterprisePhotoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertEnterprisePhoto" parameterType="EnterprisePhoto" useGeneratedKeys="true" keyProperty="id">
        insert into enterprise_photo
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="enterpriseId != null">enterprise_id,</if>
            <if test="path != null">path,</if>
            <if test="type != null">type,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="enterpriseId != null">#{enterpriseId},</if>
            <if test="path != null">#{path},</if>
            <if test="type != null">#{type},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateEnterprisePhoto" parameterType="EnterprisePhoto">
        update enterprise_photo
        <trim prefix="SET" suffixOverrides=",">
            <if test="enterpriseId != null">enterprise_id = #{enterpriseId},</if>
            <if test="path != null">path = #{path},</if>
            <if test="type != null">type = #{type},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteEnterprisePhotoById" parameterType="Long">
        delete from enterprise_photo where id = #{id}
    </delete>

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

    <delete id="deleteEnterprisePhotoByEnterpriseId" parameterType="EnterprisePhoto">
        delete from enterprise_photo where enterprise_id = #{enterpriseId}
    </delete>
</mapper>