<?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.yd.dal.mapper.meta.MdTagViewMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.meta.MdTagView">
    <!--@mbg.generated-->
    <!--@Table ag_md_tag_view-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="tag_view_type" jdbcType="VARCHAR" property="tagViewType" />
    <result column="tag_id" jdbcType="BIGINT" property="tagId" />
    <result column="tag_name" jdbcType="VARCHAR" property="tagName" />
    <result column="tag_level" jdbcType="VARCHAR" property="tagLevel" />
    <result column="upper_tag_view_id" jdbcType="BIGINT" property="upperTagViewId" />
    <result column="display_image" jdbcType="VARCHAR" property="displayImage" />
    <result column="display_order" jdbcType="INTEGER" property="displayOrder" />
    <result column="is_active" jdbcType="INTEGER" property="isActive" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
    <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
    <result column="updated_by" jdbcType="BIGINT" property="updatedBy" />
  </resultMap>
  <resultMap id="BaseResultMap2" type="com.yd.dal.entity.meta.MdTagView">
    <!--@mbg.generated-->
    <!--@Table ag_md_tag_view-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="tag_view_type" jdbcType="VARCHAR" property="tagViewType" />
    <result column="tag_id" jdbcType="BIGINT" property="tagId" />
    <result column="tag_name" jdbcType="VARCHAR" property="tagName" />
    <result column="tag_level" jdbcType="VARCHAR" property="tagLevel" />
    <result column="upper_tag_view_id" jdbcType="BIGINT" property="upperTagViewId" />
    <result column="display_image" jdbcType="VARCHAR" property="displayImage" />
    <result column="display_order" jdbcType="INTEGER" property="displayOrder" />
    <result column="is_active" jdbcType="INTEGER" property="isActive" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
    <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
    <result column="updated_by" jdbcType="BIGINT" property="updatedBy" />
    <result column="upperTagViewName" jdbcType="VARCHAR" property="upperTagViewName" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, tag_view_type, tag_id, tag_name, tag_level, upper_tag_view_id, display_image, 
    display_order, is_active, remark, created_at, created_by, updated_at, updated_by
  </sql>
  <sql id="Base_Column_List2">
    <!--@mbg.generated-->
    t.id, t.tag_view_type, t.tag_id, t.tag_name, t.tag_level, t.upper_tag_view_id, t.display_image, 
    t.display_order, t.is_active, t.remark, t.created_at, t.created_by, t.updated_at, t.updated_by,u.tag_name upperTagViewName
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from ag_md_tag_view
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from ag_md_tag_view
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.meta.MdTagView" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ag_md_tag_view (tag_view_type, tag_id, tag_name, 
      tag_level, upper_tag_view_id, display_image, 
      display_order, is_active, remark, 
      created_at, created_by, updated_at, 
      updated_by)
    values (#{tagViewType,jdbcType=VARCHAR}, #{tagId,jdbcType=BIGINT}, #{tagName,jdbcType=VARCHAR}, 
      #{tagLevel,jdbcType=VARCHAR}, #{upperTagViewId,jdbcType=BIGINT}, #{displayImage,jdbcType=VARCHAR}, 
      #{displayOrder,jdbcType=INTEGER}, #{isActive,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, 
      #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}, #{updatedAt,jdbcType=TIMESTAMP}, 
      #{updatedBy,jdbcType=BIGINT})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.meta.MdTagView" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ag_md_tag_view
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="tagViewType != null">
        tag_view_type,
      </if>
      <if test="tagId != null">
        tag_id,
      </if>
      <if test="tagName != null">
        tag_name,
      </if>
      <if test="tagLevel != null">
        tag_level,
      </if>
      <if test="upperTagViewId != null">
        upper_tag_view_id,
      </if>
      <if test="displayImage != null">
        display_image,
      </if>
      <if test="displayOrder != null">
        display_order,
      </if>
      <if test="isActive != null">
        is_active,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="updatedAt != null">
        updated_at,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="tagViewType != null">
        #{tagViewType,jdbcType=VARCHAR},
      </if>
      <if test="tagId != null">
        #{tagId,jdbcType=BIGINT},
      </if>
      <if test="tagName != null">
        #{tagName,jdbcType=VARCHAR},
      </if>
      <if test="tagLevel != null">
        #{tagLevel,jdbcType=VARCHAR},
      </if>
      <if test="upperTagViewId != null">
        #{upperTagViewId,jdbcType=BIGINT},
      </if>
      <if test="displayImage != null">
        #{displayImage,jdbcType=VARCHAR},
      </if>
      <if test="displayOrder != null">
        #{displayOrder,jdbcType=INTEGER},
      </if>
      <if test="isActive != null">
        #{isActive,jdbcType=INTEGER},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="updatedAt != null">
        #{updatedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        #{updatedBy,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.meta.MdTagView">
    <!--@mbg.generated-->
    update ag_md_tag_view
    <set>
      <if test="tagViewType != null">
        tag_view_type = #{tagViewType,jdbcType=VARCHAR},
      </if>
      <if test="tagId != null">
        tag_id = #{tagId,jdbcType=BIGINT},
      </if>
      <if test="tagName != null">
        tag_name = #{tagName,jdbcType=VARCHAR},
      </if>
      <if test="tagLevel != null">
        tag_level = #{tagLevel,jdbcType=VARCHAR},
      </if>
      <if test="upperTagViewId != null">
        upper_tag_view_id = #{upperTagViewId,jdbcType=BIGINT},
      </if>
      <if test="displayImage != null">
        display_image = #{displayImage,jdbcType=VARCHAR},
      </if>
      <if test="displayOrder != null">
        display_order = #{displayOrder,jdbcType=INTEGER},
      </if>
      <if test="isActive != null">
        is_active = #{isActive,jdbcType=INTEGER},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="updatedAt != null">
        updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.meta.MdTagView">
    <!--@mbg.generated-->
    update ag_md_tag_view
    set tag_view_type = #{tagViewType,jdbcType=VARCHAR},
      tag_id = #{tagId,jdbcType=BIGINT},
      tag_name = #{tagName,jdbcType=VARCHAR},
      tag_level = #{tagLevel,jdbcType=VARCHAR},
      upper_tag_view_id = #{upperTagViewId,jdbcType=BIGINT},
      display_image = #{displayImage,jdbcType=VARCHAR},
      display_order = #{displayOrder,jdbcType=INTEGER},
      is_active = #{isActive,jdbcType=INTEGER},
      remark = #{remark,jdbcType=VARCHAR},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      updated_by = #{updatedBy,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateBatch" parameterType="java.util.List">
    <!--@mbg.generated-->
    update ag_md_tag_view
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="tag_view_type = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.tagViewType,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="tag_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.tagId,jdbcType=BIGINT}
        </foreach>
      </trim>
      <trim prefix="tag_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.tagName,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="tag_level = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.tagLevel,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="upper_tag_view_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.upperTagViewId,jdbcType=BIGINT}
        </foreach>
      </trim>
      <trim prefix="display_image = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.displayImage,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="display_order = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.displayOrder,jdbcType=INTEGER}
        </foreach>
      </trim>
      <trim prefix="is_active = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.isActive,jdbcType=INTEGER}
        </foreach>
      </trim>
      <trim prefix="remark = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.remark,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="created_at = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.createdAt,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="created_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.createdBy,jdbcType=BIGINT}
        </foreach>
      </trim>
      <trim prefix="updated_at = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.updatedAt,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="updated_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.updatedBy,jdbcType=BIGINT}
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=BIGINT}
    </foreach>
  </update>
  <update id="updateBatchSelective" parameterType="java.util.List">
    <!--@mbg.generated-->
    update ag_md_tag_view
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="tag_view_type = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.tagViewType != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.tagViewType,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="tag_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.tagId != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.tagId,jdbcType=BIGINT}
          </if>
        </foreach>
      </trim>
      <trim prefix="tag_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.tagName != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.tagName,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="tag_level = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.tagLevel != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.tagLevel,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="upper_tag_view_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.upperTagViewId != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.upperTagViewId,jdbcType=BIGINT}
          </if>
        </foreach>
      </trim>
      <trim prefix="display_image = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.displayImage != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.displayImage,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="display_order = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.displayOrder != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.displayOrder,jdbcType=INTEGER}
          </if>
        </foreach>
      </trim>
      <trim prefix="is_active = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.isActive != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.isActive,jdbcType=INTEGER}
          </if>
        </foreach>
      </trim>
      <trim prefix="remark = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.remark != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.remark,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="created_at = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.createdAt != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.createdAt,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="created_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.createdBy != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.createdBy,jdbcType=BIGINT}
          </if>
        </foreach>
      </trim>
      <trim prefix="updated_at = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.updatedAt != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.updatedAt,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="updated_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.updatedBy != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.updatedBy,jdbcType=BIGINT}
          </if>
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=BIGINT}
    </foreach>
  </update>
  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ag_md_tag_view
    (tag_view_type, tag_id, tag_name, tag_level, upper_tag_view_id, display_image, display_order, 
      is_active, remark, created_at, created_by, updated_at, updated_by)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.tagViewType,jdbcType=VARCHAR}, #{item.tagId,jdbcType=BIGINT}, #{item.tagName,jdbcType=VARCHAR}, 
        #{item.tagLevel,jdbcType=VARCHAR}, #{item.upperTagViewId,jdbcType=BIGINT}, #{item.displayImage,jdbcType=VARCHAR}, 
        #{item.displayOrder,jdbcType=INTEGER}, #{item.isActive,jdbcType=INTEGER}, #{item.remark,jdbcType=VARCHAR}, 
        #{item.createdAt,jdbcType=TIMESTAMP}, #{item.createdBy,jdbcType=BIGINT}, #{item.updatedAt,jdbcType=TIMESTAMP}, 
        #{item.updatedBy,jdbcType=BIGINT})
    </foreach>
  </insert>
  
  
  <select id="selectByIsActive" resultMap="BaseResultMap2">
    select
    <include refid="Base_Column_List2" />
    from ag_md_tag_view t LEFT JOIN ag_md_tag_view u ON t.upper_tag_view_id = u.id
    <where>
     1 = 1
      <if test="isActive != null">
        and t.is_active = #{isActive,jdbcType=BIGINT}
      </if>
      <if test="upperTagViewId != null">
        and t.upper_tag_view_id = #{upperTagViewId,jdbcType=BIGINT}
      </if>
      <if test="taglevel != null">
        and t.tag_level = #{taglevel,jdbcType=VARCHAR}
      </if>
      <if test="tagViewType != null">
        and t.tag_view_type = #{tagViewType,jdbcType=VARCHAR}
      </if>
      <if test="tagName != null">
        and t.tag_name like #{tagName,jdbcType=VARCHAR}
      </if>
    </where>
      ORDER BY t.display_order
    </select>
    
</mapper>