PointsSetMapper.xml 7.61 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.points.mapper.PointsSetMapper">
  <resultMap id="BaseResultMap" type="cn.runsa.crmapp.points.entity.PointsSet">
    <!--
      WARNING - @mbggenerated
    -->
    <id column="PNT_ID" jdbcType="BIGINT" property="pntId" />
    <result column="ACT_ID" jdbcType="BIGINT" property="actId" />
    <result column="PNT_TYPE" jdbcType="VARCHAR" property="pntType" />
    <result column="PNT_SET_NAME" jdbcType="VARCHAR" property="pntSetName" />
    <result column="PNT_UNIT" jdbcType="VARCHAR" property="pntUnit" />
    <result column="PNT_U_V" jdbcType="DECIMAL" property="pntUV" />
    <result column="EXCHANGE" jdbcType="BIT" property="exchange" />
    <result column="IS_FANS" jdbcType="BIT" property="isFans" />
    <result column="ENABLE" jdbcType="BIT" property="enable" />
    <result column="REC_TIME" jdbcType="TIMESTAMP" property="recTime" />
    <result column="REC_USER" jdbcType="BIGINT" property="recUser" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbggenerated
    -->
    `PNT_ID`, `ACT_ID`, `PNT_TYPE`, `PNT_SET_NAME`, `PNT_UNIT`, `PNT_U_V`, `EXCHANGE`, 
    `IS_FANS`, `ENABLE`, `REC_TIME`, `REC_USER`
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
    -->
    select 
    <include refid="Base_Column_List" />
    from crm_points_set
    where `PNT_ID` = #{pntId,jdbcType=BIGINT}
  </select>
  <select id="list" parameterType="java.lang.Long" resultMap="BaseResultMap">
	select 
    <include refid="Base_Column_List" />
    from crm_points_set
    where `ACT_ID` = #{actId,jdbcType=BIGINT}
  </select>
  <select id="selectCompositePrimaryKey" parameterType="cn.runsa.crmapp.points.entity.PointsSet" resultMap="BaseResultMap">
	select 
    <include refid="Base_Column_List" />
    from crm_points_set
    where `ACT_ID` = #{actId,jdbcType=BIGINT} and `PNT_TYPE` = #{pntType,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--
      WARNING - @mbggenerated
    -->
    delete from crm_points_set
    where `PNT_ID` = #{pntId,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="cn.runsa.crmapp.points.entity.PointsSet">
    <!--
      WARNING - @mbggenerated
    -->
    insert into crm_points_set (`PNT_ID`, `ACT_ID`, `PNT_TYPE`, 
      `PNT_SET_NAME`, `PNT_UNIT`, `PNT_U_V`, 
      `EXCHANGE`, `IS_FANS`, `ENABLE`, `REC_TIME`, 
      `REC_USER`)
    values (#{pntId,jdbcType=BIGINT}, #{actId,jdbcType=BIGINT}, #{pntType,jdbcType=VARCHAR}, 
      #{pntSetName,jdbcType=VARCHAR}, #{pntUnit,jdbcType=VARCHAR}, #{pntUV,jdbcType=DECIMAL}, 
      #{exchange,jdbcType=BIT}, #{isFans,jdbcType=BIT}, #{enable,jdbcType=BIT}, #{recTime,jdbcType=TIMESTAMP}, 
      #{recUser,jdbcType=BIGINT})
  </insert>
  <insert id="insertSelective" parameterType="cn.runsa.crmapp.points.entity.PointsSet">
    <!--
      WARNING - @mbggenerated
    -->
    <selectKey keyProperty="pntId" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into crm_points_set
    <trim prefix="(" suffix=")" suffixOverrides=",">
      `PNT_ID`,
      <if test="actId != null">
        `ACT_ID`,
      </if>
      <if test="pntType != null">
        `PNT_TYPE`,
      </if>
      <if test="pntSetName != null">
        `PNT_SET_NAME`,
      </if>
      <if test="pntUnit != null">
        `PNT_UNIT`,
      </if>
      <if test="pntUV != null">
        `PNT_U_V`,
      </if>
      <if test="exchange != null">
        `EXCHANGE`,
      </if>
      <if test="isFans != null">
        `IS_FANS`,
      </if>
      <if test="enable != null">
        `ENABLE`,
      </if>
      <if test="recTime != null">
        `REC_TIME`,
      </if>
      <if test="recUser != null">
        `REC_USER`,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      #{pntId,jdbcType=BIGINT},
      <if test="actId != null">
        #{actId,jdbcType=BIGINT},
      </if>
      <if test="pntType != null">
        #{pntType,jdbcType=VARCHAR},
      </if>
      <if test="pntSetName != null">
        #{pntSetName,jdbcType=VARCHAR},
      </if>
      <if test="pntUnit != null">
        #{pntUnit,jdbcType=VARCHAR},
      </if>
      <if test="pntUV != null">
        #{pntUV,jdbcType=DECIMAL},
      </if>
      <if test="exchange != null">
        #{exchange,jdbcType=BIT},
      </if>
      <if test="isFans != null">
        #{isFans,jdbcType=BIT},
      </if>
      <if test="enable != null">
        #{enable,jdbcType=BIT},
      </if>
      <if test="recTime != null">
        #{recTime,jdbcType=TIMESTAMP},
      </if>
      <if test="recUser != null">
        #{recUser,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="cn.runsa.crmapp.points.entity.PointsSet">
    <!--
      WARNING - @mbggenerated
    -->
    update crm_points_set
    <set>
      <if test="actId != null">
        `ACT_ID` = #{actId,jdbcType=BIGINT},
      </if>
      <if test="pntType != null">
        `PNT_TYPE` = #{pntType,jdbcType=VARCHAR},
      </if>
      <if test="pntSetName != null">
        `PNT_SET_NAME` = #{pntSetName,jdbcType=VARCHAR},
      </if>
      <if test="pntUnit != null">
        `PNT_UNIT` = #{pntUnit,jdbcType=VARCHAR},
      </if>
      <if test="pntUV != null">
        `PNT_U_V` = #{pntUV,jdbcType=DECIMAL},
      </if>
      <if test="exchange != null">
        `EXCHANGE` = #{exchange,jdbcType=BIT},
      </if>
      <if test="isFans != null">
        `IS_FANS` = #{isFans,jdbcType=BIT},
      </if>
      <if test="enable != null">
        `ENABLE` = #{enable,jdbcType=BIT},
      </if>
      <if test="recTime != null">
        `REC_TIME` = #{recTime,jdbcType=TIMESTAMP},
      </if>
      <if test="recUser != null">
        `REC_USER` = #{recUser,jdbcType=BIGINT},
      </if>
    </set>
    where `PNT_ID` = #{pntId,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.runsa.crmapp.points.entity.PointsSet">
    <!--
      WARNING - @mbggenerated
    -->
    update crm_points_set
    set `ACT_ID` = #{actId,jdbcType=BIGINT},
      `PNT_TYPE` = #{pntType,jdbcType=VARCHAR},
      `PNT_SET_NAME` = #{pntSetName,jdbcType=VARCHAR},
      `PNT_UNIT` = #{pntUnit,jdbcType=VARCHAR},
      `PNT_U_V` = #{pntUV,jdbcType=DECIMAL},
      `EXCHANGE` = #{exchange,jdbcType=BIT},
      `IS_FANS` = #{isFans,jdbcType=BIT},
      `ENABLE` = #{enable,jdbcType=BIT},
      `REC_TIME` = #{recTime,jdbcType=TIMESTAMP},
      `REC_USER` = #{recUser,jdbcType=BIGINT}
    where `PNT_ID` = #{pntId,jdbcType=BIGINT}
  </update>
  <select id="existsPntId" parameterType="Long" resultType="Integer">
  	SELECT
		COUNT(*)
	FROM
		`crm_points_change`
	WHERE
		PNT_ID = #{pntId,jdbcType=BIGINT}
  </select>
  <select id="findPointsSetAll" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    SELECT T1.* FROM CRM_POINTS_SET T1, CRM_ACCOUNT_SET T2 WHERE T1.ACT_ID = T2.ACT_ID AND T1.ENABLE = 1 AND T2.ACT_TYPE > 0 <if test="plId!=1">AND T2.PTF_ID = #{plId,jdbcType=BIGINT}</if>
  </select>
  <select id="selectByActIdAndPntType" parameterType="cn.runsa.crmapp.points.entity.PointsSet" resultMap="BaseResultMap">
  	select * from crm_points_set where act_id = #{actId,jdbcType=BIGINT} and pnt_type = #{pntType,jdbcType=VARCHAR}
  </select>
  <select id="existsPntAccount" parameterType="cn.runsa.crmapp.points.entity.PointsSet" resultType="Integer">
  	select count(*) from crm_points_account where ACT_ID = #{actId,jdbcType=BIGINT} and PNT_TYPE = #{pntType,jdbcType=VARCHAR};
  </select>
</mapper>