<?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.sckw.slope.detection.dao.mysql.KwsIntegrationMapper">
  <resultMap id="BaseResultMap" type="com.sckw.slope.detection.model.dos.mysql.KwsIntegration">
    <!--@mbg.generated-->
    <!--@Table kws_integration-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="integration_name" jdbcType="VARCHAR" property="integrationName" />
    <result column="part_names" jdbcType="VARCHAR" property="partNames" />
    <result column="unit" jdbcType="VARCHAR" property="unit" />
    <result column="formula" jdbcType="VARCHAR" property="formula" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="status" jdbcType="TINYINT" property="status" />
    <result column="create_by" jdbcType="BIGINT" property="createBy" />
    <result column="mountain_id" jdbcType="VARCHAR" property="mountainId" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_by" jdbcType="BIGINT" property="updateBy" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="del_flag" jdbcType="TINYINT" property="delFlag" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, integration_name, part_names, unit, formula, remark, `status`, create_by, create_time, 
    update_by, update_time, del_flag,mountain_id
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from kws_integration
    where id = #{id,jdbcType=BIGINT}
  </select>
  <select id="getDataByFindInSet" resultType="com.sckw.slope.detection.model.vo.IntegrationItemVO">
    <!--@mbg.generated-->
    select
    <include refid="Base_Column_List" />
    from kws_integration
    where FIND_IN_SET(#{partNames,jdbcType=VARCHAR},part_names)
  </select>
    <select id="getDataByName" resultType="com.sckw.slope.detection.model.vo.IntegrationVo">
      <!--@mbg.generated-->
      select
      <include refid="Base_Column_List" />
      from kws_integration
      where del_flag=0
      <if test="integrationQuery.integrationName != null and integrationQuery.integrationName != ''">
        and integration_name like concat('%', #{integrationQuery.integrationName}, '%')
      </if>
      <if test="integrationQuery.mountainId != null and integrationQuery.mountainId != ''">
        and mountain_id = #{integrationQuery.mountainId,jdbcType=BIGINT}
      </if>
      order by create_time desc
    </select>

  <select id="getDataByInNames" resultType="com.sckw.slope.detection.model.vo.IntegrationVo">
    <!--@mbg.generated-->
    select
    <include refid="Base_Column_List" />
    from kws_integration
    where del_flag=0
    and mountain_id = #{mountainId}
    <if test="integrationName != null and integrationName != ''">
      and integration_name in
      <foreach collection="integrationName" separator="," open="(" close=")" item="Name">
        #{Name}
      </foreach>
    </if>
    order by create_time desc
  </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from kws_integration
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsIntegration">
    <!--@mbg.generated-->
    insert into kws_integration (id, integration_name, part_names, 
      unit, formula, remark, 
      `status`, create_by, create_time, 
      update_by, update_time, del_flag,mountain_id,ids
      )
    values (#{id,jdbcType=BIGINT}, #{integrationName,jdbcType=VARCHAR}, #{partNames,jdbcType=VARCHAR}, 
      #{unit,jdbcType=VARCHAR}, #{formula,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, 
      #{status,jdbcType=TINYINT}, #{createBy,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, 
      #{updateBy,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=TINYINT}, #{mountainId,jdbcType=BIGINT}, #{ids,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsIntegration">
    <!--@mbg.generated-->
    insert into kws_integration
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="integrationName != null">
        integration_name,
      </if>
      <if test="partNames != null">
        part_names,
      </if>
      <if test="unit != null">
        unit,
      </if>
      <if test="formula != null">
        formula,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="status != null">
        `status`,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updateBy != null">
        update_by,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="delFlag != null">
        del_flag,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="integrationName != null">
        #{integrationName,jdbcType=VARCHAR},
      </if>
      <if test="partNames != null">
        #{partNames,jdbcType=VARCHAR},
      </if>
      <if test="unit != null">
        #{unit,jdbcType=VARCHAR},
      </if>
      <if test="formula != null">
        #{formula,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        #{status,jdbcType=TINYINT},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=BIGINT},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        #{updateBy,jdbcType=BIGINT},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="delFlag != null">
        #{delFlag,jdbcType=TINYINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsIntegration">
    <!--@mbg.generated-->
    update kws_integration
    <set>
      <if test="integrationName != null">
        integration_name = #{integrationName,jdbcType=VARCHAR},
      </if>
      <if test="partNames != null">
        part_names = #{partNames,jdbcType=VARCHAR},
      </if>
      <if test="unit != null">
        unit = #{unit,jdbcType=VARCHAR},
      </if>
      <if test="formula != null">
        formula = #{formula,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        `status` = #{status,jdbcType=TINYINT},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=BIGINT},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        update_by = #{updateBy,jdbcType=BIGINT},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="delFlag != null">
        del_flag = #{delFlag,jdbcType=TINYINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsIntegration">
    <!--@mbg.generated-->
    update kws_integration
    set integration_name = #{integrationName,jdbcType=VARCHAR},
      part_names = #{partNames,jdbcType=VARCHAR},
      unit = #{unit,jdbcType=VARCHAR},
      formula = #{formula,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR},
      `status` = #{status,jdbcType=TINYINT},
      create_by = #{createBy,jdbcType=BIGINT},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_by = #{updateBy,jdbcType=BIGINT},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      del_flag = #{delFlag,jdbcType=TINYINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>