<?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.other.LabelsMapper">
  <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.other.Labels">
    <result column="id" jdbcType="VARCHAR" property="id" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="description" jdbcType="VARCHAR" property="description" />
    <result column="parent_id" jdbcType="VARCHAR" property="parentId" />
    <result column="is_valid" jdbcType="VARCHAR" property="isValid" />
    <result column="sort" jdbcType="VARCHAR" property="sort" />
    <result column="scope" jdbcType="VARCHAR" property="scope" />
    <result column="ylzd1" jdbcType="VARCHAR" property="ylzd1" />
    <result column="ylzd2" jdbcType="VARCHAR" property="ylzd2" />
    <result column="ylzd3" jdbcType="VARCHAR" property="ylzd3" />
    <result column="ylzd4" jdbcType="VARCHAR" property="ylzd4" />
    <result column="ylzd5" jdbcType="VARCHAR" property="ylzd5" />
  </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, code, name, description, parent_id, is_valid, sort, ylzd1, ylzd2, ylzd3,
    ylzd4, ylzd5, scope
  </sql>
  <select id="selectByExample" parameterType="com.ruoyi.system.domain.other.BsCommonExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from labels
    <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 labels
    where id = #{id,jdbcType=VARCHAR}
  </select>

  <select id="getWgdxList" parameterType="java.lang.String" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from labels
    where is_valid='1' and  parent_id in (select id from bs_common where code= #{code,jdbcType=VARCHAR}) ORDER BY sort + 0
  </select>

  <delete id="deleteByExample" parameterType="com.ruoyi.system.domain.other.BsCommonExample">
    delete from bs_common
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from labels
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.ruoyi.system.domain.other.BsCommon">
    insert into labels (id, code, name,
      description, parent_id, is_valid,
      sort, ylzd1,
      ylzd2, ylzd3, ylzd4,
      ylzd5)
    values (#{id,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
      #{description,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR}, #{isValid,jdbcType=VARCHAR},
      #{sort,jdbcType=VARCHAR}, #{ylzd1,jdbcType=VARCHAR},
      #{ylzd2,jdbcType=VARCHAR}, #{ylzd3,jdbcType=VARCHAR}, #{ylzd4,jdbcType=VARCHAR},
      #{ylzd5,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.ruoyi.system.domain.other.BsCommon">
    insert into labels
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="code != null">
        code,
      </if>
      <if test="name != null">
        name,
      </if>
      <if test="description != null">
        description,
      </if>
      <if test="parentId != null">
        parent_id,
      </if>
      <if test="isValid != null">
        is_valid,
      </if>
      <if test="sort != null">
        sort,
      </if>
      <if test="ylzd1 != null">
        ylzd1,
      </if>
      <if test="ylzd2 != null">
        ylzd2,
      </if>
      <if test="ylzd3 != null">
        ylzd3,
      </if>
      <if test="ylzd4 != null">
        ylzd4,
      </if>
      <if test="ylzd5 != null">
        ylzd5,
      </if>
      <if test="scope != null">
        scope,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="description != null">
        #{description,jdbcType=VARCHAR},
      </if>
      <if test="parentId != null">
        #{parentId,jdbcType=VARCHAR},
      </if>
      <if test="isValid != null">
        #{isValid,jdbcType=VARCHAR},
      </if>
      <if test="sort != null">
        #{sort,jdbcType=VARCHAR},
      </if>
      <if test="ylzd1 != null">
        #{ylzd1,jdbcType=VARCHAR},
      </if>
      <if test="ylzd2 != null">
        #{ylzd2,jdbcType=VARCHAR},
      </if>
      <if test="ylzd3 != null">
        #{ylzd3,jdbcType=VARCHAR},
      </if>
      <if test="ylzd4 != null">
        #{ylzd4,jdbcType=VARCHAR},
      </if>
      <if test="ylzd5 != null">
        #{ylzd5,jdbcType=VARCHAR},
      </if>
      <if test="scope != null">
        #{scope,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.ruoyi.system.domain.other.BsCommonExample" resultType="java.lang.Long">
    select count(*) from labels
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <select id="getDegreeOne" resultType="java.lang.String">
    select code from labels where id = (select parent_id from labels where id = (select parent_id from labels where code = #{code}))
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update labels
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.code != null">
        code = #{record.code,jdbcType=VARCHAR},
      </if>
      <if test="record.name != null">
        name = #{record.name,jdbcType=VARCHAR},
      </if>
      <if test="record.description != null">
        description = #{record.description,jdbcType=VARCHAR},
      </if>
      <if test="record.parentId != null">
        parent_id = #{record.parentId,jdbcType=VARCHAR},
      </if>
      <if test="record.isValid != null">
        is_valid = #{record.isValid,jdbcType=VARCHAR},
      </if>
      <if test="record.sort != null">
        sort = #{record.sort,jdbcType=VARCHAR},
      </if>
      <if test="record.ylzd1 != null">
        ylzd1 = #{record.ylzd1,jdbcType=VARCHAR},
      </if>
      <if test="record.ylzd2 != null">
        ylzd2 = #{record.ylzd2,jdbcType=VARCHAR},
      </if>
      <if test="record.ylzd3 != null">
        ylzd3 = #{record.ylzd3,jdbcType=VARCHAR},
      </if>
      <if test="record.ylzd4 != null">
        ylzd4 = #{record.ylzd4,jdbcType=VARCHAR},
      </if>
      <if test="record.ylzd5 != null">
        ylzd5 = #{record.ylzd5,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.system.domain.other.BsCommon">
    update labels
    <set>
      <if test="id != null">
        id = #{id,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        code = #{code,jdbcType=VARCHAR},
      </if>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="description != null">
        description = #{description,jdbcType=VARCHAR},
      </if>
      <if test="parentId != null">
        parent_id = #{parentId,jdbcType=VARCHAR},
      </if>
      <if test="isValid != null">
        is_valid = #{isValid,jdbcType=VARCHAR},
      </if>
      <if test="sort != null">
        sort = #{sort,jdbcType=VARCHAR},
      </if>
      <if test="ylzd1 != null">
        ylzd1 = #{ylzd1,jdbcType=VARCHAR},
      </if>
      <if test="ylzd2 != null">
        ylzd2 = #{ylzd2,jdbcType=VARCHAR},
      </if>
      <if test="ylzd3 != null">
        ylzd3 = #{ylzd3,jdbcType=VARCHAR},
      </if>
      <if test="ylzd4 != null">
        ylzd4 = #{ylzd4,jdbcType=VARCHAR},
      </if>
      <if test="ylzd5 != null">
        ylzd5 = #{ylzd5,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByExample" parameterType="map">
    update labels
    set id = #{record.id,jdbcType=VARCHAR},
      code = #{record.code,jdbcType=VARCHAR},
      name = #{record.name,jdbcType=VARCHAR},
      description = #{record.description,jdbcType=VARCHAR},
      parent_id = #{record.parentId,jdbcType=VARCHAR},
      is_valid = #{record.isValid,jdbcType=VARCHAR},
      sort = #{record.sort,jdbcType=VARCHAR},
      ylzd1 = #{record.ylzd1,jdbcType=VARCHAR},
      ylzd2 = #{record.ylzd2,jdbcType=VARCHAR},
      ylzd3 = #{record.ylzd3,jdbcType=VARCHAR},
      ylzd4 = #{record.ylzd4,jdbcType=VARCHAR},
      ylzd5 = #{record.ylzd5,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
</mapper>
