<?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.projectV2.XmProjectPersionMapper">
    
    <resultMap type="XmProjectPersion" id="XmProjectPersionResult">
        <result property="id"    column="id"    />
        <result property="xmId"    column="xm_id"    />
        <result property="xmbh"    column="xmbh"    />
        <result property="xmmc"    column="xmmc"    />
        <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="isDel"    column="is_del"    />
        <result property="name"    column="name"    />
        <result property="address"    column="address"    />
        <result property="idcode"    column="idcode"    />
        <result property="phone"    column="phone"    />
    </resultMap>

    <sql id="selectXmProjectPersionVo">
        select id, xm_id, xmbh, xmmc, create_by, create_time, update_by, update_time, is_del, name, address, idcode, phone from xm_project_persion
    </sql>

    <select id="selectXmProjectPersionList" parameterType="XmProjectPersion" resultMap="XmProjectPersionResult">
        <include refid="selectXmProjectPersionVo"/>
        <where>  
            <if test="xmId != null "> and xm_id = #{xmId}</if>
            <if test="xmbh != null  and xmbh != ''"> and xmbh = #{xmbh}</if>
            <if test="xmmc != null  and xmmc != ''"> and xmmc = #{xmmc}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="idcode != null  and idcode != ''"> and idcode = #{idcode}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
        </where>
    </select>
    
    <select id="selectXmProjectPersionById" parameterType="Long" resultMap="XmProjectPersionResult">
        <include refid="selectXmProjectPersionVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertXmProjectPersion" parameterType="XmProjectPersion" useGeneratedKeys="true" keyProperty="id">
        insert into xm_project_persion
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="xmId != null">xm_id,</if>
            <if test="xmbh != null">xmbh,</if>
            <if test="xmmc != null">xmmc,</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="isDel != null">is_del,</if>
            <if test="name != null">name,</if>
            <if test="address != null">address,</if>
            <if test="idcode != null">idcode,</if>
            <if test="phone != null">phone,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="xmId != null">#{xmId},</if>
            <if test="xmbh != null">#{xmbh},</if>
            <if test="xmmc != null">#{xmmc},</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="isDel != null">#{isDel},</if>
            <if test="name != null">#{name},</if>
            <if test="address != null">#{address},</if>
            <if test="idcode != null">#{idcode},</if>
            <if test="phone != null">#{phone},</if>
         </trim>
    </insert>

    <update id="updateXmProjectPersion" parameterType="XmProjectPersion">
        update xm_project_persion
        <trim prefix="SET" suffixOverrides=",">
            <if test="xmId != null">xm_id = #{xmId},</if>
            <if test="xmbh != null">xmbh = #{xmbh},</if>
            <if test="xmmc != null">xmmc = #{xmmc},</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="isDel != null">is_del = #{isDel},</if>
            <if test="name != null">name = #{name},</if>
            <if test="address != null">address = #{address},</if>
            <if test="idcode != null">idcode = #{idcode},</if>
            <if test="phone != null">phone = #{phone},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="updateXmProjectPersionByXmbh">
        update xm_project_persion set xm_id = #{id}, xmmc=#{xmmc} where xmbh = #{xmbh}
    </update>

    <delete id="deleteXmProjectPersionById" parameterType="Long">
        delete from xm_project_persion where id = #{id}
    </delete>

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