<?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.ruoyi.system.mapper.visit.dr.VisitDrCompanyDataPoolOldMapper">
  <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.visit.dr.VisitDrCompanyDataPool">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="rule_id" jdbcType="VARCHAR" property="ruleId" />
    <result column="company_id" jdbcType="VARCHAR" property="companyId" />
    <result column="company_name" jdbcType="VARCHAR" property="companyName" />
    <result column="random_field" jdbcType="INTEGER" property="randomField" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, rule_id, company_id, company_name, random_field
  </sql>
  <select id="selectByExample" parameterType="com.ruoyi.system.domain.visit.dr.VisitDrCompanyDataPoolExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from visit_dr_company_data_pool
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from visit_dr_company_data_pool
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from visit_dr_company_data_pool
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.ruoyi.system.domain.visit.dr.VisitDrCompanyDataPoolExample">
    delete from visit_dr_company_data_pool
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.ruoyi.system.domain.visit.dr.VisitDrCompanyDataPool">
    insert into visit_dr_company_data_pool (id, rule_id, company_id,
      company_name, random_field)
    values (#{id,jdbcType=VARCHAR}, #{ruleId,jdbcType=VARCHAR}, #{companyId,jdbcType=VARCHAR}, 
      #{companyName,jdbcType=VARCHAR}, #{randomField,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.ruoyi.system.domain.visit.dr.VisitDrCompanyDataPool">
    insert into visit_dr_company_data_pool
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="ruleId != null">
        rule_id,
      </if>
      <if test="companyId != null">
        company_id,
      </if>
      <if test="companyName != null">
        company_name,
      </if>
      <if test="randomField != null">
        random_field,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="ruleId != null">
        #{ruleId,jdbcType=VARCHAR},
      </if>
      <if test="companyId != null">
        #{companyId,jdbcType=VARCHAR},
      </if>
      <if test="companyName != null">
        #{companyName,jdbcType=VARCHAR},
      </if>
      <if test="randomField != null">
        #{randomField,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.ruoyi.system.domain.visit.dr.VisitDrCompanyDataPoolExample" resultType="java.lang.Long">
    select count(*) from visit_dr_company_data_pool
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update visit_dr_company_data_pool
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.ruleId != null">
        rule_id = #{record.ruleId,jdbcType=VARCHAR},
      </if>
      <if test="record.companyId != null">
        company_id = #{record.companyId,jdbcType=VARCHAR},
      </if>
      <if test="record.companyName != null">
        company_name = #{record.companyName,jdbcType=VARCHAR},
      </if>
      <if test="record.randomField != null">
        random_field = #{record.randomField,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update visit_dr_company_data_pool
    set id = #{record.id,jdbcType=VARCHAR},
      rule_id = #{record.ruleId,jdbcType=VARCHAR},
      company_id = #{record.companyId,jdbcType=VARCHAR},
      company_name = #{record.companyName,jdbcType=VARCHAR},
      random_field = #{record.randomField,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.system.domain.visit.dr.VisitDrCompanyDataPool">
    update visit_dr_company_data_pool
    <set>
      <if test="ruleId != null">
        rule_id = #{ruleId,jdbcType=VARCHAR},
      </if>
      <if test="companyId != null">
        company_id = #{companyId,jdbcType=VARCHAR},
      </if>
      <if test="companyName != null">
        company_name = #{companyName,jdbcType=VARCHAR},
      </if>
      <if test="randomField != null">
        random_field = #{randomField,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.ruoyi.system.domain.visit.dr.VisitDrCompanyDataPool">
    update visit_dr_company_data_pool
    set rule_id = #{ruleId,jdbcType=VARCHAR},
      company_id = #{companyId,jdbcType=VARCHAR},
      company_name = #{companyName,jdbcType=VARCHAR},
      random_field = #{randomField,jdbcType=INTEGER}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <delete id="deleteAllDataByRuleId" parameterType="java.lang.String">
    delete from visit_dr_company_data_pool
    where rule_id = #{ruleId,jdbcType=VARCHAR}
  </delete>
  <select id="selectDataByRuleId" parameterType="java.lang.String" resultMap="BaseResultMap">
    select *  from visit_dr_company_data_pool
    where rule_id=#{ruleId,jdbcType=VARCHAR}
  </select>
</mapper>