GuiderMapper.xml 6.82 KB
<?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.runsa.crmapp.customer.mapper.GuiderMapper" >
  <resultMap id="BaseResultMap" type="cn.runsa.crmapp.customer.entity.Guider" >
    <!--
      WARNING - @mbggenerated
    -->
    <id column="GUIDER_ID" property="guiderId" jdbcType="VARCHAR" />
    <result column="EMP_ID" property="empId" jdbcType="INTEGER" />
    <result column="SITE_ID" property="siteId" jdbcType="INTEGER" />
    <result column="role" property="role" jdbcType="INTEGER" />
    <result column="HEADER" property="header" jdbcType="VARCHAR" />
    <result column="role_description" property="roleDescription" jdbcType="INTEGER" />
    <result column="state" property="state" jdbcType="INTEGER" />
    <result column="REC_TIME" property="recTime" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    <!--
      WARNING - @mbggenerated
    -->
    GUIDER_ID, EMP_ID, SITE_ID, role, HEADER, role_description, state, REC_TIME
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    <!--
      WARNING - @mbggenerated
    -->
    select 
    <include refid="Base_Column_List" />
    from crm_guider
    where GUIDER_ID = #{guiderId,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    <!--
      WARNING - @mbggenerated
    -->
    delete from crm_guider
    where GUIDER_ID = #{guiderId,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="cn.runsa.crmapp.customer.entity.Guider" >
    <!--
      WARNING - @mbggenerated
    -->
    insert into crm_guider (GUIDER_ID, EMP_ID, SITE_ID, 
      role, HEADER, role_description, state, 
      REC_TIME)
    values (#{guiderId,jdbcType=VARCHAR}, #{empId,jdbcType=INTEGER}, #{siteId,jdbcType=INTEGER}, 
      #{role,jdbcType=INTEGER}, #{header,jdbcType=VARCHAR}, #{roleDescription,jdbcType=INTEGER}, #{state,jdbcType=INTEGER}, 
      #{recTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="cn.runsa.crmapp.customer.entity.Guider" >
    <!--
      WARNING - @mbggenerated
    -->
    insert into crm_guider
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="guiderId != null" >
        GUIDER_ID,
      </if>
      <if test="empId != null" >
        EMP_ID,
      </if>
      <if test="siteId != null" >
        SITE_ID,
      </if>
      <if test="role != null" >
        role,
      </if>
      <if test="header != null" >
        HEADER,
      </if>
      <if test="roleDescription != null" >
        role_description,
      </if>
      <if test="state != null" >
        state,
      </if>
      <if test="recTime != null" >
        REC_TIME,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="guiderId != null" >
        #{guiderId,jdbcType=VARCHAR},
      </if>
      <if test="empId != null" >
        #{empId,jdbcType=INTEGER},
      </if>
      <if test="siteId != null" >
        #{siteId,jdbcType=INTEGER},
      </if>
      <if test="role != null" >
        #{role,jdbcType=INTEGER},
      </if>
      <if test="header != null" >
        #{header,jdbcType=VARCHAR},
      </if>
      <if test="roleDescription != null" >
        #{roleDescription,jdbcType=INTEGER},
      </if>
      <if test="state != null" >
        #{state,jdbcType=INTEGER},
      </if>
      <if test="recTime != null" >
        #{recTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="cn.runsa.crmapp.customer.entity.Guider" >
    <!--
      WARNING - @mbggenerated
    -->
    update crm_guider
    <set >
      <if test="empId != null" >
        EMP_ID = #{empId,jdbcType=INTEGER},
      </if>
      <if test="siteId != null" >
        SITE_ID = #{siteId,jdbcType=INTEGER},
      </if>
      <if test="role != null" >
        role = #{role,jdbcType=INTEGER},
      </if>
      <if test="header != null" >
        HEADER = #{header,jdbcType=VARCHAR},
      </if>
      <if test="roleDescription != null" >
        role_description = #{roleDescription,jdbcType=INTEGER},
      </if>
      <if test="state != null" >
        state = #{state,jdbcType=INTEGER},
      </if>
      <if test="recTime != null" >
        REC_TIME = #{recTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where GUIDER_ID = #{guiderId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.runsa.crmapp.customer.entity.Guider" >
    <!--
      WARNING - @mbggenerated
    -->
    update crm_guider
    set EMP_ID = #{empId,jdbcType=INTEGER},
      SITE_ID = #{siteId,jdbcType=INTEGER},
      role = #{role,jdbcType=INTEGER},
      HEADER = #{header,jdbcType=VARCHAR},
      role_description = #{roleDescription,jdbcType=INTEGER},
      state = #{state,jdbcType=INTEGER},
      REC_TIME = #{recTime,jdbcType=TIMESTAMP}
    where GUIDER_ID = #{guiderId,jdbcType=VARCHAR}
  </update>
  <update id="updateGuider" parameterType="cn.runsa.crmapp.customer.entity.Guider" >
    UPDATE crm_guider t SET t.role  = #{role,jdbcType=INTEGER}, t.state = #{state,jdbcType=INTEGER} WHERE t.GUIDER_ID = #{guiderId,jdbcType=VARCHAR}
  </update>
  <!-- 获取导购信息 -->
  <select id="getGuiders" resultType="map" parameterType="map" >
    SELECT T1.GUIDER_ID, T1.EMP_ID, T3.siCode SITE_ID, T1.ROLE, T1.HEADER, T1.ROLE_DESCRIPTION, T1.STATE,T2.EMCODE, T2.EMNAME, T2.EMSEX, T2.PTPHONE, T2.PTEMAIL, T3.SICODE, T3.SINAME, T3.PTADDR, T3.SINAVLNG, T3.SINAVLAT FROM CRM_GUIDER T1 LEFT JOIN MTEMPLOYEE T2 ON T1.EMP_ID = T2.EMID LEFT JOIN MTSITE T3 ON T1.SITE_ID = T3.SIID WHERE T1.GUIDER_ID IN ( SELECT T.GUIDER_ID FROM CRM_CUSTOMER_GUIDER T WHERE T.CST_ID = #{cst_id,jdbcType=BIGINT} ) AND T1.SITE_ID IN ( SELECT T1.SIT_ID FROM CRM_ACCOUNT_SET_SITE T1 LEFT JOIN CRM_SITE_GROUP_WXGZH T2 ON T1.GRP_ID = T2.GRP_ID WHERE T2.GZH_ID = #{gzh_id,jdbcType=VARCHAR} )
  </select>
  <!-- 根据网点ID获取导购信息 -->
  <select id="getGuidersBySiteId" resultType="map" parameterType="long" >
    SELECT T1.GUIDER_ID, T1.EMP_ID, T3.siCode SITE_ID, T1.ROLE, T1.HEADER, T1.ROLE_DESCRIPTION, T1.STATE, T2.EMNAME, T2.EMSEX, T2.PTPHONE, T2.PTEMAIL, T3.SINAME, T3.PTADDR, T3.SINAVLNG, T3.SINAVLAT FROM CRM_GUIDER T1 LEFT JOIN MTEMPLOYEE T2 ON T1.EMP_ID = T2.EMID LEFT JOIN MTSITE T3 ON T1.SITE_ID = T3.SIID WHERE T1.SITE_ID = #{site_id,jdbcType=INTEGER}
  </select>
  <!-- 获取导购信息 -->
  <select id="getGuider" resultType="map" parameterType="string" >
    SELECT T1.GUIDER_ID, T1.EMP_ID, T3.siCode SITE_ID, T1.ROLE, T1.HEADER, T1.ROLE_DESCRIPTION, T1.STATE, T2.EMNAME, T2.EMSEX, T2.PTPHONE, T2.PTEMAIL, T3.SINAME, T3.PTADDR, T3.SINAVLNG, T3.SINAVLAT FROM CRM_GUIDER T1 LEFT JOIN MTEMPLOYEE T2 ON T1.EMP_ID = T2.EMID LEFT JOIN MTSITE T3 ON T1.SITE_ID = T3.SIID WHERE T1.GUIDER_ID = #{guider_id,jdbcType=VARCHAR}
  </select>
</mapper>