RuleChannelConfigDao.xml 6.2 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="com.sy.mapper.RuleChannelConfigDao">
  <resultMap id="BaseResultMap" type="com.sy.model.RuleChannelConfig">
    <id column="config_id" jdbcType="INTEGER" property="configId" />
    <result column="channel_num" jdbcType="VARCHAR" property="channelNum" />
    <result column="business_type" jdbcType="VARCHAR" property="businessType" />
    <result column="goods_type" jdbcType="VARCHAR" property="goodsType" />
    <result column="rule_id" jdbcType="INTEGER" property="ruleId" />
    <result column="config_order" jdbcType="TINYINT" property="configOrder" />
    <result column="creat_time" jdbcType="TIMESTAMP" property="creatTime" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  </resultMap>
  <resultMap id="WithRuleConf" extends="BaseResultMap" type="com.sy.model.RuleChannelConfig">
        <association property="ruleConfig" javaType="com.sy.model.RuleConfig">
          <result column="script_key" jdbcType="VARCHAR" property="scriptKey" />
          <result column="script_method_name" jdbcType="VARCHAR" property="scriptMethodName" />
          <result column="script_method_return" jdbcType="VARCHAR" property="scriptMethodReturn" />
          <result column="rule_name" jdbcType="VARCHAR" property="ruleName" />
          <result column="rule_type" jdbcType="VARCHAR" property="ruleType" />
        </association>
  </resultMap>
  <sql id="Base_Column_List">
    config_id, channel_num, business_type, goods_type, rule_id, config_order, creat_time,
    update_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from rule_channel_config
    where config_id = #{configId,jdbcType=INTEGER}
  </select>
  <select id="selectByChannelAndBusiTypeAndGoodsType" parameterType="com.sy.model.RuleChannelConfig" resultMap="WithRuleConf">
    SELECT
      conf.channel_num,
      conf.business_type,
      conf.goods_type,
      conf.config_order,
      conf.rule_id,
      rule.script_key,
      rule.script_method_name,
      rule.script_method_return,
      rule.rule_name,
      rule.rule_type
    FROM
	(
      SELECT
          channel_num,
          business_type,
          goods_type,
          config_order,
          rule_id
      FROM
          rule_channel_config
      WHERE
          channel_num = #{channelNum,jdbcType=VARCHAR}
          AND business_type = #{businessType,jdbcType=VARCHAR}
          AND goods_type = #{goodsType,jdbcType=VARCHAR}
	) conf
	LEFT JOIN
		rule_config rule
	ON
		conf.rule_id = rule.rule_id
	ORDER BY config_order
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from rule_channel_config
    where config_id = #{configId,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="config_id" keyProperty="configId" parameterType="com.sy.model.RuleChannelConfig" useGeneratedKeys="true">
    insert into rule_channel_config (channel_num, business_type, goods_type,
      rule_id, config_order, creat_time,
      update_time)
    values (#{channelNum,jdbcType=VARCHAR}, #{businessType,jdbcType=VARCHAR}, #{goodsType,jdbcType=VARCHAR},
      #{ruleId,jdbcType=INTEGER}, #{configOrder,jdbcType=TINYINT}, #{creatTime,jdbcType=TIMESTAMP},
      #{updateTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" keyColumn="config_id" keyProperty="configId" parameterType="com.sy.model.RuleChannelConfig" useGeneratedKeys="true">
    insert into rule_channel_config
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="channelNum != null">
        channel_num,
      </if>
      <if test="businessType != null">
        business_type,
      </if>
      <if test="goodsType != null">
        goods_type,
      </if>
      <if test="ruleId != null">
        rule_id,
      </if>
      <if test="configOrder != null">
        config_order,
      </if>
      <if test="creatTime != null">
        creat_time,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="channelNum != null">
        #{channelNum,jdbcType=VARCHAR},
      </if>
      <if test="businessType != null">
        #{businessType,jdbcType=VARCHAR},
      </if>
      <if test="goodsType != null">
        #{goodsType,jdbcType=VARCHAR},
      </if>
      <if test="ruleId != null">
        #{ruleId,jdbcType=INTEGER},
      </if>
      <if test="configOrder != null">
        #{configOrder,jdbcType=TINYINT},
      </if>
      <if test="creatTime != null">
        #{creatTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.sy.model.RuleChannelConfig">
    update rule_channel_config
    <set>
      <if test="channelNum != null">
        channel_num = #{channelNum,jdbcType=VARCHAR},
      </if>
      <if test="businessType != null">
        business_type = #{businessType,jdbcType=VARCHAR},
      </if>
      <if test="goodsType != null">
        goods_type = #{goodsType,jdbcType=VARCHAR},
      </if>
      <if test="ruleId != null">
        rule_id = #{ruleId,jdbcType=INTEGER},
      </if>
      <if test="configOrder != null">
        config_order = #{configOrder,jdbcType=TINYINT},
      </if>
      <if test="creatTime != null">
        creat_time = #{creatTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where config_id = #{configId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.sy.model.RuleChannelConfig">
    update rule_channel_config
    set channel_num = #{channelNum,jdbcType=VARCHAR},
      business_type = #{businessType,jdbcType=VARCHAR},
      goods_type = #{goodsType,jdbcType=VARCHAR},
      rule_id = #{ruleId,jdbcType=INTEGER},
      config_order = #{configOrder,jdbcType=TINYINT},
      creat_time = #{creatTime,jdbcType=TIMESTAMP},
      update_time = #{updateTime,jdbcType=TIMESTAMP}
    where config_id = #{configId,jdbcType=INTEGER}
  </update>
</mapper>