PolicyMapper.xml 6.79 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.common.mapper.PolicyMapper">
  <resultMap id="BaseResultMap" type="cn.runsa.crmapp.common.entity.Policy">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="PLC_ID" jdbcType="BIGINT" property="plcId" />
    <result column="TPL_ID" jdbcType="VARCHAR" property="tplId" />
    <result column="REC_TIME" jdbcType="TIMESTAMP" property="recTime" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="cn.runsa.crmapp.common.entity.Policy">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <result column="PLC_DESC" jdbcType="LONGVARCHAR" property="plcDesc" />
    <result column="PLC_FRONT_DATA" jdbcType="LONGVARCHAR" property="plcFrontData" />
    <result column="PLC_INNER_DATA" jdbcType="LONGVARCHAR" property="plcInnerData" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    `PLC_ID`, `TPL_ID`, `REC_TIME`
  </sql>
  <sql id="Blob_Column_List">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    `PLC_DESC`, `PLC_FRONT_DATA`, `PLC_INNER_DATA`
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from crm_policy
    where `PLC_ID` = #{plcId,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from crm_policy
    where `PLC_ID` = #{plcId,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="cn.runsa.crmapp.common.entity.Policy">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <selectKey keyProperty="plcId" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into crm_policy (`PLC_ID`, `TPL_ID`, `REC_TIME`, 
      `PLC_DESC`, `PLC_FRONT_DATA`, `PLC_INNER_DATA`
      )
    values (#{plcId,jdbcType=BIGINT}, #{tplId,jdbcType=VARCHAR}, #{recTime,jdbcType=TIMESTAMP}, 
      #{plcDesc,jdbcType=LONGVARCHAR}, #{plcFrontData,jdbcType=LONGVARCHAR}, #{plcInnerData,jdbcType=LONGVARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="cn.runsa.crmapp.common.entity.Policy">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <selectKey keyProperty="plcId" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into crm_policy
    <trim prefix="(" suffix=")" suffixOverrides=",">
      `PLC_ID`,
      <if test="tplId != null">
        `TPL_ID`,
      </if>
      <if test="recTime != null">
        `REC_TIME`,
      </if>
      <if test="plcDesc != null">
        `PLC_DESC`,
      </if>
      <if test="plcFrontData != null">
        `PLC_FRONT_DATA`,
      </if>
      <if test="plcInnerData != null">
        `PLC_INNER_DATA`,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      #{plcId,jdbcType=BIGINT},
      <if test="tplId != null">
        #{tplId,jdbcType=VARCHAR},
      </if>
      <if test="recTime != null">
        #{recTime,jdbcType=TIMESTAMP},
      </if>
      <if test="plcDesc != null">
        #{plcDesc,jdbcType=LONGVARCHAR},
      </if>
      <if test="plcFrontData != null">
        #{plcFrontData,jdbcType=LONGVARCHAR},
      </if>
      <if test="plcInnerData != null">
        #{plcInnerData,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="cn.runsa.crmapp.common.entity.Policy">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update crm_policy
    <set>
      <if test="tplId != null">
        `TPL_ID` = #{tplId,jdbcType=VARCHAR},
      </if>
      <if test="recTime != null">
        `REC_TIME` = #{recTime,jdbcType=TIMESTAMP},
      </if>
      <if test="plcDesc != null">
        `PLC_DESC` = #{plcDesc,jdbcType=LONGVARCHAR},
      </if>
      <if test="plcFrontData != null">
        `PLC_FRONT_DATA` = #{plcFrontData,jdbcType=LONGVARCHAR},
      </if>
      <if test="plcInnerData != null">
        `PLC_INNER_DATA` = #{plcInnerData,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where `PLC_ID` = #{plcId,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="cn.runsa.crmapp.common.entity.Policy">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update crm_policy
    set `TPL_ID` = #{tplId,jdbcType=VARCHAR},
      `REC_TIME` = #{recTime,jdbcType=TIMESTAMP},
      `PLC_DESC` = #{plcDesc,jdbcType=LONGVARCHAR},
      `PLC_FRONT_DATA` = #{plcFrontData,jdbcType=LONGVARCHAR},
      `PLC_INNER_DATA` = #{plcInnerData,jdbcType=LONGVARCHAR}
    where `PLC_ID` = #{plcId,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.runsa.crmapp.common.entity.Policy">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update crm_policy
    set `TPL_ID` = #{tplId,jdbcType=VARCHAR},
      `REC_TIME` = #{recTime,jdbcType=TIMESTAMP}
    where `PLC_ID` = #{plcId,jdbcType=BIGINT}
  </update>
  <select id="selectPolicyExecution" parameterType="java.lang.Long" resultType="cn.runsa.crmapp.common.entity.support.PolicyExecutionData">
  	SELECT p.`PLC_ID` AS plcId,p.`PLC_INNER_DATA` AS plcInnerData,t.`EXE_TYPE` AS exeType,t.`EXE_NAME` AS exeName,t.`EXECUTER` AS executer 
  	FROM crm_policy p 
  	INNER JOIN crm_template t 
  	ON p.`TPL_ID` = t.`TPL_ID` 
  	AND p.`PLC_ID` = #{id};
  </select>
  <select id="selectPolicyByRank" resultType="cn.runsa.crmapp.common.entity.Policy">
  	SELECT 
  	 t3.PLC_ID as plcId,t3.TPL_ID as tplId,t3.PLC_FRONT_DATA as plcFrontData
  	 FROM crm_customer_rank t1 LEFT JOIN crm_rank_policy_change t2
	on t1.ACT_ID = t2.ACT_ID and t1.RAK_ID = t2.RANK_FROM
	LEFT JOIN crm_policy t3
	on t2.PLC_ID = t3.PLC_ID 
	where t1.ACT_ID = #{actId,jdbcType=BIGINT} and RAK_ID = #{rakId,jdbcType=VARCHAR};
  </select>
</mapper>