<?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.jeeplus.finance.workClientInfo.mapper.CwWorkClientContactMapper">

    <resultMap id="BaseResultMap" type="com.jeeplus.finance.workClientInfo.service.dto.CwWorkClientContactDTO">
            <id property="id" column="id" jdbcType="VARCHAR"/>
            <result property="createBy.id" column="create_by" jdbcType="VARCHAR"/>
            <result property="createTime" column="create_date" jdbcType="TIMESTAMP"/>
            <result property="updateBy.id" column="update_by" jdbcType="VARCHAR"/>
            <result property="updateTime" column="update_date" jdbcType="TIMESTAMP"/>
            <result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
            <result property="remarks" column="remarks" jdbcType="VARCHAR"/>
            <result property="clientId" column="client_id" jdbcType="VARCHAR"/>
            <result property="name" column="name" jdbcType="VARCHAR"/>
            <result property="sex" column="sex" jdbcType="VARCHAR"/>
            <result property="officeId" column="office_id" jdbcType="VARCHAR"/>
            <result property="position" column="position" jdbcType="VARCHAR"/>
            <result property="contactFirst" column="contact_first" jdbcType="VARCHAR"/>
            <result property="contactSecond" column="contact_second" jdbcType="VARCHAR"/>
            <result property="fax" column="fax" jdbcType="VARCHAR"/>
            <result property="email" column="email" jdbcType="VARCHAR"/>
        <result property="projectId" column="project_id" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Contact_Column_List">
        cw_wcc.id,
        cw_wcc.create_by,
        cw_wcc.create_date,
        cw_wcc.update_by,
        cw_wcc.update_date,
        cw_wcc.del_flag,
        cw_wcc.remarks,
        cw_wcc.client_id,
        cw_wcc.name,
        cw_wcc.sex,
        cw_wcc.office_id,
        cw_wcc.position,
        cw_wcc.contact_first,
        cw_wcc.contact_second,
        cw_wcc.fax,
        cw_wcc.email,
        cw_wcc.project_id
    </sql>

    <select id="getInfoByData" resultType="com.jeeplus.finance.workClientInfo.domain.CwWorkClientContact">
        select * from cw_work_client_contact
        where 1=1
        <if test="name != null and name != ''">
            and `name` = #{name}
        </if>
        <if test="sex != null and sex != ''">
            and sex = #{sex}
        </if>
        <if test="officeId != null and officeId != ''">
            and office_id = #{officeId}
        </if>
        <if test="position != null and position != ''">
            and `position` = #{position}
        </if>
        <if test="contactFirst != null and contactFirst != ''">
            and contact_first = #{contactFirst}
        </if>
        <if test="contactSecond != null and contactSecond != ''">
            and contact_second = #{contactSecond}
        </if>
        <if test="fax != null and fax != ''">
            and fax = #{fax}
        </if>
        <if test="email != null and email != ''">
            and email = #{email}
        </if>
        <if test="remarks != null and remarks != ''">
            and remarks = #{remarks}
        </if>
        <if test="clientId != null and clientId != ''">
            and client_id = #{clientId}
        </if>
        and del_flag = 0
        order by id asc limit 1
    </select>

    <select id="getInfoByInfo" resultType="com.jeeplus.finance.workClientInfo.domain.CwWorkClientContact">
        select * from cw_work_client_contact
        where 1=1
        <if test="name != null and name != ''">
            and `name` = #{name}
        </if>
        <if test="sex != null and sex != ''">
            and sex = #{sex}
        </if>
        <if test="officeId != null and officeId != ''">
            and office_id = #{officeId}
        </if>
        <if test="position != null and position != ''">
            and `position` = #{position}
        </if>
        <if test="contactFirst != null and contactFirst != ''">
            and contact_first = #{contactFirst}
        </if>
        <if test="contactSecond != null and contactSecond != ''">
            and contact_second = #{contactSecond}
        </if>
        <if test="fax != null and fax != ''">
            and fax = #{fax}
        </if>
        <if test="email != null and email != ''">
            and email = #{email}
        </if>
        <if test="remarks != null and remarks != ''">
            and remarks = #{remarks}
        </if>
        and del_flag = 0
        order by id asc limit 1
    </select>
    <select id="getInfoById" resultType="com.jeeplus.finance.workClientInfo.domain.CwWorkClientContact">
        select * from cw_work_client_contact
        where id = #{id} and del_flag = 0
        order by id asc limit 1
    </select>
</mapper>
