<?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.yanzhu.manage.mapper.ProProjectInfoSettingMapper">
    
    <resultMap type="ProProjectInfoSetting" id="ProProjectInfoSettingResult">
        <result property="id"    column="id"    />
        <result property="projectId"    column="project_id"    />
        <result property="projectName"    column="project_name"    />
        <result property="orgName"    column="org_name"    />
        <result property="orgLogo"    column="org_logo"    />
        <result property="orgImage"    column="org_image"    />
        <result property="orgVideo"    column="org_video"    />
        <result property="orgPlane"    column="org_plane"    />
        <result property="isDel"    column="is_del"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectProProjectInfoSettingVo">
        select ps.id, ps.project_id, pi.project_name, ps.org_name, ps.org_logo, ps.org_image, ps.org_video, ps.org_plane, ps.is_del, ps.create_by, ps.create_time, ps.update_by, ps.update_time, ps.remark from pro_project_info_setting ps
        left join pro_project_info pi on pi.id = ps.project_id
        left join sys_dept sd on sd.dept_id = pi.com_id
    </sql>

    <select id="selectProProjectInfoSettingList" parameterType="ProProjectInfoSetting" resultMap="ProProjectInfoSettingResult">
        <include refid="selectProProjectInfoSettingVo"/>
        <where>
            <if test="activeComId != null "> and sd.dept_id = #{activeComId}</if>
            <if test="projectId != null "> and ps.project_id = #{projectId}</if>
            <if test="projectName != null  and projectName != ''"> and pi.project_name like concat('%', #{projectName}, '%')</if>
            <if test="orgName != null  and orgName != ''"> and ps.org_name like concat('%', #{orgName}, '%')</if>
            <if test="isDel != null "> and ps.is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectProProjectInfoSettingById" parameterType="Long" resultMap="ProProjectInfoSettingResult">
        <include refid="selectProProjectInfoSettingVo"/>
        where ps.id = #{id}
    </select>
        
    <insert id="insertProProjectInfoSetting" parameterType="ProProjectInfoSetting" useGeneratedKeys="true" keyProperty="id">
        insert into pro_project_info_setting
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectId != null">project_id,</if>
            <if test="orgName != null">org_name,</if>
            <if test="orgLogo != null">org_logo,</if>
            <if test="orgImage != null">org_image,</if>
            <if test="orgVideo != null">org_video,</if>
            <if test="orgPlane != null">org_plane,</if>
            <if test="isDel != null">is_del,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projectId != null">#{projectId},</if>
            <if test="orgName != null">#{orgName},</if>
            <if test="orgLogo != null">#{orgLogo},</if>
            <if test="orgImage != null">#{orgImage},</if>
            <if test="orgVideo != null">#{orgVideo},</if>
            <if test="orgPlane != null">#{orgPlane},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateProProjectInfoSetting" parameterType="ProProjectInfoSetting">
        update pro_project_info_setting
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectId != null">project_id = #{projectId},</if>
            <if test="orgName != null">org_name = #{orgName},</if>
            <if test="orgLogo != null">org_logo = #{orgLogo},</if>
            <if test="orgImage != null">org_image = #{orgImage},</if>
            <if test="orgVideo != null">org_video = #{orgVideo},</if>
            <if test="orgPlane != null">org_plane = #{orgPlane},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteProProjectInfoSettingById" parameterType="Long">
        delete from pro_project_info_setting where id = #{id}
    </delete>

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