<?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="cn.superdesk.uniorder.dao.mapper.unified.UnifiedCustomerContactsMapper">
	<resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.unified.UnifiedCustomerContactsKey">
		<id column="virt_id" property="virtId" jdbcType="BIGINT"/>
		<id column="sys_user_id" property="sysUserId" jdbcType="BIGINT"/>
	</resultMap>
	<resultMap id="DetailResultMap" type="cn.superdesk.uniorder.dto.vo.unified.UnifiedCustomerContactsDetail">
		<id column="virt_id" property="virtId" jdbcType="BIGINT"/>
		<id column="sys_user_id" property="sysUserId" jdbcType="BIGINT"/>
		<result column="realname" jdbcType="VARCHAR" property="sysUserName"/>
		<result column="mobile" jdbcType="VARCHAR" property="mobile"/>
	</resultMap>
	<select id="getContacts" resultMap="DetailResultMap" parameterType="java.lang.Long">
  SELECT
a.virt_id,
a.sys_user_id,
b.realname,
b.mobile
FROM
unified_customer_contacts AS a
LEFT JOIN sys_oder_user AS b ON a.sys_user_id = b.user_id 
where 1=1 
and a.virt_id = #{virtId,jdbcType=BIGINT}
  </select>

	<delete id="deleteByVirtId" parameterType="java.lang.Long">
  	delete from unified_customer_contacts
    where virt_id = #{virtId,jdbcType=BIGINT}
  </delete>
	<delete id="deleteByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.unified.UnifiedCustomerContactsKey">
    delete from unified_customer_contacts
    where virt_id = #{virtId,jdbcType=BIGINT}
      and sys_user_id = #{sysUserId,jdbcType=BIGINT}
  </delete>
	<insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.unified.UnifiedCustomerContactsKey">
    insert into unified_customer_contacts (virt_id, sys_user_id)
    values (#{virtId,jdbcType=BIGINT}, #{sysUserId,jdbcType=BIGINT})
  </insert>
	<insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.unified.UnifiedCustomerContactsKey">
		insert into unified_customer_contacts
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="virtId != null">
				virt_id,
			</if>
			<if test="sysUserId != null">
				sys_user_id,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="virtId != null">
				#{virtId,jdbcType=BIGINT},
			</if>
			<if test="sysUserId != null">
				#{sysUserId,jdbcType=BIGINT},
			</if>
		</trim>
	</insert>
</mapper>