<?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.project.mapper.ProProjectInfoMapper">
    
    <resultMap type="ProProjectInfo" id="ProProjectInfoResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="deptId"    column="dept_id"    />
        <result property="address"    column="address"    />
        <result property="infos"    column="infos"    />
        <result property="personName"    column="person_name"    />
        <result property="personPhone"    column="person_phone"    />
        <result property="mainImage"    column="main_image"    />
        <result property="images"    column="images"    />
        <result property="projStatus"    column="proj_status"    />
        <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"    />
        <result property="unit"    column="unit"    />
    </resultMap>

    <sql id="selectProProjectInfoVo">
        select id, name, dept_id, address, infos, person_name, person_phone, main_image, images, proj_status, is_del, create_by, create_time, update_by, update_time, remark, unit from pro_project_info
    </sql>

    <select id="selectProProjectInfoList" parameterType="ProProjectInfo" resultMap="ProProjectInfoResult">
        <include refid="selectProProjectInfoVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="personName != null  and personName != ''"> and person_name like concat('%', #{personName}, '%')</if>
            <if test="personPhone != null  and personPhone != ''"> and person_phone = #{personPhone}</if>
            <if test="projStatus != null  and projStatus != ''"> and proj_status = #{projStatus}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
            <if test="unit != null  and unit != ''"> and unit = #{unit}</if>
        </where>
    </select>
    
    <select id="selectProProjectInfoById" parameterType="Long" resultMap="ProProjectInfoResult">
        <include refid="selectProProjectInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertProProjectInfo" parameterType="ProProjectInfo">
        insert into pro_project_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null">name,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="address != null">address,</if>
            <if test="infos != null">infos,</if>
            <if test="personName != null">person_name,</if>
            <if test="personPhone != null">person_phone,</if>
            <if test="mainImage != null">main_image,</if>
            <if test="images != null">images,</if>
            <if test="projStatus != null">proj_status,</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>
            <if test="unit != null">unit,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="address != null">#{address},</if>
            <if test="infos != null">#{infos},</if>
            <if test="personName != null">#{personName},</if>
            <if test="personPhone != null">#{personPhone},</if>
            <if test="mainImage != null">#{mainImage},</if>
            <if test="images != null">#{images},</if>
            <if test="projStatus != null">#{projStatus},</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>
            <if test="unit != null">#{unit},</if>
         </trim>
    </insert>

    <update id="updateProProjectInfo" parameterType="ProProjectInfo">
        update pro_project_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="address != null">address = #{address},</if>
            <if test="infos != null">infos = #{infos},</if>
            <if test="personName != null">person_name = #{personName},</if>
            <if test="personPhone != null">person_phone = #{personPhone},</if>
            <if test="mainImage != null">main_image = #{mainImage},</if>
            <if test="images != null">images = #{images},</if>
            <if test="projStatus != null">proj_status = #{projStatus},</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>
            <if test="unit != null">unit = #{unit},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteProProjectInfoById" parameterType="Long">
        delete from pro_project_info where id = #{id}
    </delete>

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