<?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.hw.dms.mapper.DmsBaseOutsrcInfoMapper">
    
    <resultMap type="DmsBaseOutsrcInfo" id="DmsBaseOutsrcInfoResult">
        <result property="outsrcId"    column="outsrc_id"    />
        <result property="outsrcCode"    column="outsrc_code"    />
        <result property="outsrcName"    column="outsrc_name"    />
        <result property="outsrcPerson"    column="outsrc_person"    />
        <result property="outsrcTel"    column="outsrc_tel"    />
        <result property="outsrcAddress"    column="outsrc_address"    />
        <result property="outsrcStatus"    column="outsrc_status"    />
        <result property="isFlag"    column="is_flag"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectDmsBaseOutsrcInfoVo">
        select outsrc_id, outsrc_code, outsrc_name, outsrc_person, outsrc_tel, outsrc_address, outsrc_status, is_flag, remark, create_by, create_time, update_by, update_time from dms_base_outsrc_info
    </sql>

    <select id="selectDmsBaseOutsrcInfoList" parameterType="DmsBaseOutsrcInfo" resultMap="DmsBaseOutsrcInfoResult">
        <include refid="selectDmsBaseOutsrcInfoVo"/>
        <where>  
            <if test="outsrcCode != null  and outsrcCode != ''"> and outsrc_code = #{outsrcCode}</if>
            <if test="outsrcName != null  and outsrcName != ''"> and outsrc_name like concat('%', #{outsrcName}, '%')</if>
            <if test="outsrcPerson != null  and outsrcPerson != ''"> and outsrc_person = #{outsrcPerson}</if>
            <if test="outsrcTel != null  and outsrcTel != ''"> and outsrc_tel = #{outsrcTel}</if>
            <if test="outsrcAddress != null  and outsrcAddress != ''"> and outsrc_address = #{outsrcAddress}</if>
            <if test="outsrcStatus != null "> and outsrc_status = #{outsrcStatus}</if>
            <if test="isFlag != null "> and is_flag = #{isFlag}</if>
        </where>
    </select>
    
    <select id="selectDmsBaseOutsrcInfoByOutsrcId" parameterType="Long" resultMap="DmsBaseOutsrcInfoResult">
        <include refid="selectDmsBaseOutsrcInfoVo"/>
        where outsrc_id = #{outsrcId}
    </select>
        
    <insert id="insertDmsBaseOutsrcInfo" parameterType="DmsBaseOutsrcInfo" useGeneratedKeys="true" keyProperty="outsrcId">
        insert into dms_base_outsrc_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="outsrcCode != null">outsrc_code,</if>
            <if test="outsrcName != null and outsrcName != ''">outsrc_name,</if>
            <if test="outsrcPerson != null">outsrc_person,</if>
            <if test="outsrcTel != null">outsrc_tel,</if>
            <if test="outsrcAddress != null">outsrc_address,</if>
            <if test="outsrcStatus != null">outsrc_status,</if>
            <if test="isFlag != null">is_flag,</if>
            <if test="remark != null">remark,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="outsrcCode != null">#{outsrcCode},</if>
            <if test="outsrcName != null and outsrcName != ''">#{outsrcName},</if>
            <if test="outsrcPerson != null">#{outsrcPerson},</if>
            <if test="outsrcTel != null">#{outsrcTel},</if>
            <if test="outsrcAddress != null">#{outsrcAddress},</if>
            <if test="outsrcStatus != null">#{outsrcStatus},</if>
            <if test="isFlag != null">#{isFlag},</if>
            <if test="remark != null">#{remark},</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>
         </trim>
    </insert>

    <update id="updateDmsBaseOutsrcInfo" parameterType="DmsBaseOutsrcInfo">
        update dms_base_outsrc_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="outsrcCode != null">outsrc_code = #{outsrcCode},</if>
            <if test="outsrcName != null and outsrcName != ''">outsrc_name = #{outsrcName},</if>
            <if test="outsrcPerson != null">outsrc_person = #{outsrcPerson},</if>
            <if test="outsrcTel != null">outsrc_tel = #{outsrcTel},</if>
            <if test="outsrcAddress != null">outsrc_address = #{outsrcAddress},</if>
            <if test="outsrcStatus != null">outsrc_status = #{outsrcStatus},</if>
            <if test="isFlag != null">is_flag = #{isFlag},</if>
            <if test="remark != null">remark = #{remark},</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>
        </trim>
        where outsrc_id = #{outsrcId}
    </update>

    <delete id="deleteDmsBaseOutsrcInfoByOutsrcId" parameterType="Long">
        delete from dms_base_outsrc_info where outsrc_id = #{outsrcId}
    </delete>

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