<?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.lightinit.hsdataplatform.mapper.ResourceMapper">
  <resultMap id="BaseResultMap" type="com.lightinit.hsdataplatform.entity.Resource">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="resource_type" jdbcType="VARCHAR" property="resourceType" />
    <result column="resource_state" jdbcType="VARCHAR" property="resourceState" />
    <result column="resource_name" jdbcType="VARCHAR" property="resourceName" />
    <result column="resource_identity" jdbcType="VARCHAR" property="resourceIdentity" />
    <result column="resource_summary" jdbcType="VARCHAR" property="resourceSummary" />
    <result column="register_date" jdbcType="TIMESTAMP" property="registerDate" />
    <result column="catelog_type" jdbcType="VARCHAR" property="catelogType" />
    <result column="catelog_basic" jdbcType="BIGINT" property="catelogBasic" />
    <result column="catelog_sector" jdbcType="BIGINT" property="catelogSector" />
    <result column="catelog_theme" jdbcType="BIGINT" property="catelogTheme" />
    <result column="catelog_custom" jdbcType="BIGINT" property="catelogCustom" />
    <result column="share_type" jdbcType="VARCHAR" property="shareType" />
    <result column="open_type" jdbcType="VARCHAR" property="openType" />
    <result column="allow_deal" jdbcType="TINYINT" property="allowDeal" />
    <result column="audited_by" jdbcType="BIGINT" property="auditedBy" />
    <result column="audited_at" jdbcType="TIMESTAMP" property="auditedAt" />
    <result column="audit_result" jdbcType="VARCHAR" property="auditResult" />
    <result column="audit_opinion" jdbcType="VARCHAR" property="auditOpinion" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
    <result column="deleted_at" jdbcType="TIMESTAMP" property="deletedAt" />
    <result column="deleted_by" jdbcType="BIGINT" property="deletedBy" />
    <result column="out_id_1" jdbcType="VARCHAR" property="outId1" />
    <result column="out_id_2" jdbcType="VARCHAR" property="outId2" />
    <result column="out_id_3" jdbcType="VARCHAR" property="outId3" />
  </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, resource_type, resource_state, resource_name, resource_identity, resource_summary, 
    register_date, catelog_type, catelog_basic, catelog_sector, catelog_theme, catelog_custom, 
    share_type, open_type, allow_deal, audited_by, audited_at, audit_result, audit_opinion, 
    created_at, created_by, deleted_at, deleted_by, out_id_1, out_id_2, out_id_3
  </sql>
  <select id="selectByExample" parameterType="com.lightinit.hsdataplatform.entity.ResourceExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from resource
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="page != null" >
      limit ${page.beginIndex},${page.pageSize}
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from resource
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from resource
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.lightinit.hsdataplatform.entity.ResourceExample">
    delete from resource
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.lightinit.hsdataplatform.entity.Resource">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into resource (resource_type, resource_state, resource_name, 
      resource_identity, resource_summary, register_date, 
      catelog_type, catelog_basic, catelog_sector, 
      catelog_theme, catelog_custom, share_type, 
      open_type, allow_deal, audited_by, 
      audited_at, audit_result, audit_opinion, 
      created_at, created_by, deleted_at, 
      deleted_by, out_id_1, out_id_2, 
      out_id_3)
    values (#{resourceType,jdbcType=VARCHAR}, #{resourceState,jdbcType=VARCHAR}, #{resourceName,jdbcType=VARCHAR}, 
      #{resourceIdentity,jdbcType=VARCHAR}, #{resourceSummary,jdbcType=VARCHAR}, #{registerDate,jdbcType=TIMESTAMP}, 
      #{catelogType,jdbcType=VARCHAR}, #{catelogBasic,jdbcType=BIGINT}, #{catelogSector,jdbcType=BIGINT}, 
      #{catelogTheme,jdbcType=BIGINT}, #{catelogCustom,jdbcType=BIGINT}, #{shareType,jdbcType=VARCHAR}, 
      #{openType,jdbcType=VARCHAR}, #{allowDeal,jdbcType=TINYINT}, #{auditedBy,jdbcType=BIGINT}, 
      #{auditedAt,jdbcType=TIMESTAMP}, #{auditResult,jdbcType=VARCHAR}, #{auditOpinion,jdbcType=VARCHAR}, 
      #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}, #{deletedAt,jdbcType=TIMESTAMP}, 
      #{deletedBy,jdbcType=BIGINT}, #{outId1,jdbcType=VARCHAR}, #{outId2,jdbcType=VARCHAR}, 
      #{outId3,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.lightinit.hsdataplatform.entity.Resource">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into resource
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="resourceType != null">
        resource_type,
      </if>
      <if test="resourceState != null">
        resource_state,
      </if>
      <if test="resourceName != null">
        resource_name,
      </if>
      <if test="resourceIdentity != null">
        resource_identity,
      </if>
      <if test="resourceSummary != null">
        resource_summary,
      </if>
      <if test="registerDate != null">
        register_date,
      </if>
      <if test="catelogType != null">
        catelog_type,
      </if>
      <if test="catelogBasic != null">
        catelog_basic,
      </if>
      <if test="catelogSector != null">
        catelog_sector,
      </if>
      <if test="catelogTheme != null">
        catelog_theme,
      </if>
      <if test="catelogCustom != null">
        catelog_custom,
      </if>
      <if test="shareType != null">
        share_type,
      </if>
      <if test="openType != null">
        open_type,
      </if>
      <if test="allowDeal != null">
        allow_deal,
      </if>
      <if test="auditedBy != null">
        audited_by,
      </if>
      <if test="auditedAt != null">
        audited_at,
      </if>
      <if test="auditResult != null">
        audit_result,
      </if>
      <if test="auditOpinion != null">
        audit_opinion,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="deletedAt != null">
        deleted_at,
      </if>
      <if test="deletedBy != null">
        deleted_by,
      </if>
      <if test="outId1 != null">
        out_id_1,
      </if>
      <if test="outId2 != null">
        out_id_2,
      </if>
      <if test="outId3 != null">
        out_id_3,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="resourceType != null">
        #{resourceType,jdbcType=VARCHAR},
      </if>
      <if test="resourceState != null">
        #{resourceState,jdbcType=VARCHAR},
      </if>
      <if test="resourceName != null">
        #{resourceName,jdbcType=VARCHAR},
      </if>
      <if test="resourceIdentity != null">
        #{resourceIdentity,jdbcType=VARCHAR},
      </if>
      <if test="resourceSummary != null">
        #{resourceSummary,jdbcType=VARCHAR},
      </if>
      <if test="registerDate != null">
        #{registerDate,jdbcType=TIMESTAMP},
      </if>
      <if test="catelogType != null">
        #{catelogType,jdbcType=VARCHAR},
      </if>
      <if test="catelogBasic != null">
        #{catelogBasic,jdbcType=BIGINT},
      </if>
      <if test="catelogSector != null">
        #{catelogSector,jdbcType=BIGINT},
      </if>
      <if test="catelogTheme != null">
        #{catelogTheme,jdbcType=BIGINT},
      </if>
      <if test="catelogCustom != null">
        #{catelogCustom,jdbcType=BIGINT},
      </if>
      <if test="shareType != null">
        #{shareType,jdbcType=VARCHAR},
      </if>
      <if test="openType != null">
        #{openType,jdbcType=VARCHAR},
      </if>
      <if test="allowDeal != null">
        #{allowDeal,jdbcType=TINYINT},
      </if>
      <if test="auditedBy != null">
        #{auditedBy,jdbcType=BIGINT},
      </if>
      <if test="auditedAt != null">
        #{auditedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="auditResult != null">
        #{auditResult,jdbcType=VARCHAR},
      </if>
      <if test="auditOpinion != null">
        #{auditOpinion,jdbcType=VARCHAR},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="deletedAt != null">
        #{deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="deletedBy != null">
        #{deletedBy,jdbcType=BIGINT},
      </if>
      <if test="outId1 != null">
        #{outId1,jdbcType=VARCHAR},
      </if>
      <if test="outId2 != null">
        #{outId2,jdbcType=VARCHAR},
      </if>
      <if test="outId3 != null">
        #{outId3,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.lightinit.hsdataplatform.entity.ResourceExample" resultType="java.lang.Long">
    select count(*) from resource
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update resource
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.resourceType != null">
        resource_type = #{record.resourceType,jdbcType=VARCHAR},
      </if>
      <if test="record.resourceState != null">
        resource_state = #{record.resourceState,jdbcType=VARCHAR},
      </if>
      <if test="record.resourceName != null">
        resource_name = #{record.resourceName,jdbcType=VARCHAR},
      </if>
      <if test="record.resourceIdentity != null">
        resource_identity = #{record.resourceIdentity,jdbcType=VARCHAR},
      </if>
      <if test="record.resourceSummary != null">
        resource_summary = #{record.resourceSummary,jdbcType=VARCHAR},
      </if>
      <if test="record.registerDate != null">
        register_date = #{record.registerDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.catelogType != null">
        catelog_type = #{record.catelogType,jdbcType=VARCHAR},
      </if>
      <if test="record.catelogBasic != null">
        catelog_basic = #{record.catelogBasic,jdbcType=BIGINT},
      </if>
      <if test="record.catelogSector != null">
        catelog_sector = #{record.catelogSector,jdbcType=BIGINT},
      </if>
      <if test="record.catelogTheme != null">
        catelog_theme = #{record.catelogTheme,jdbcType=BIGINT},
      </if>
      <if test="record.catelogCustom != null">
        catelog_custom = #{record.catelogCustom,jdbcType=BIGINT},
      </if>
      <if test="record.shareType != null">
        share_type = #{record.shareType,jdbcType=VARCHAR},
      </if>
      <if test="record.openType != null">
        open_type = #{record.openType,jdbcType=VARCHAR},
      </if>
      <if test="record.allowDeal != null">
        allow_deal = #{record.allowDeal,jdbcType=TINYINT},
      </if>
      <if test="record.auditedBy != null">
        audited_by = #{record.auditedBy,jdbcType=BIGINT},
      </if>
      <if test="record.auditedAt != null">
        audited_at = #{record.auditedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.auditResult != null">
        audit_result = #{record.auditResult,jdbcType=VARCHAR},
      </if>
      <if test="record.auditOpinion != null">
        audit_opinion = #{record.auditOpinion,jdbcType=VARCHAR},
      </if>
      <if test="record.createdAt != null">
        created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createdBy != null">
        created_by = #{record.createdBy,jdbcType=BIGINT},
      </if>
      <if test="record.deletedAt != null">
        deleted_at = #{record.deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="record.deletedBy != null">
        deleted_by = #{record.deletedBy,jdbcType=BIGINT},
      </if>
      <if test="record.outId1 != null">
        out_id_1 = #{record.outId1,jdbcType=VARCHAR},
      </if>
      <if test="record.outId2 != null">
        out_id_2 = #{record.outId2,jdbcType=VARCHAR},
      </if>
      <if test="record.outId3 != null">
        out_id_3 = #{record.outId3,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update resource
    set id = #{record.id,jdbcType=BIGINT},
      resource_type = #{record.resourceType,jdbcType=VARCHAR},
      resource_state = #{record.resourceState,jdbcType=VARCHAR},
      resource_name = #{record.resourceName,jdbcType=VARCHAR},
      resource_identity = #{record.resourceIdentity,jdbcType=VARCHAR},
      resource_summary = #{record.resourceSummary,jdbcType=VARCHAR},
      register_date = #{record.registerDate,jdbcType=TIMESTAMP},
      catelog_type = #{record.catelogType,jdbcType=VARCHAR},
      catelog_basic = #{record.catelogBasic,jdbcType=BIGINT},
      catelog_sector = #{record.catelogSector,jdbcType=BIGINT},
      catelog_theme = #{record.catelogTheme,jdbcType=BIGINT},
      catelog_custom = #{record.catelogCustom,jdbcType=BIGINT},
      share_type = #{record.shareType,jdbcType=VARCHAR},
      open_type = #{record.openType,jdbcType=VARCHAR},
      allow_deal = #{record.allowDeal,jdbcType=TINYINT},
      audited_by = #{record.auditedBy,jdbcType=BIGINT},
      audited_at = #{record.auditedAt,jdbcType=TIMESTAMP},
      audit_result = #{record.auditResult,jdbcType=VARCHAR},
      audit_opinion = #{record.auditOpinion,jdbcType=VARCHAR},
      created_at = #{record.createdAt,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=BIGINT},
      deleted_at = #{record.deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{record.deletedBy,jdbcType=BIGINT},
      out_id_1 = #{record.outId1,jdbcType=VARCHAR},
      out_id_2 = #{record.outId2,jdbcType=VARCHAR},
      out_id_3 = #{record.outId3,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.lightinit.hsdataplatform.entity.Resource">
    update resource
    <set>
      <if test="resourceType != null">
        resource_type = #{resourceType,jdbcType=VARCHAR},
      </if>
      <if test="resourceState != null">
        resource_state = #{resourceState,jdbcType=VARCHAR},
      </if>
      <if test="resourceName != null">
        resource_name = #{resourceName,jdbcType=VARCHAR},
      </if>
      <if test="resourceIdentity != null">
        resource_identity = #{resourceIdentity,jdbcType=VARCHAR},
      </if>
      <if test="resourceSummary != null">
        resource_summary = #{resourceSummary,jdbcType=VARCHAR},
      </if>
      <if test="registerDate != null">
        register_date = #{registerDate,jdbcType=TIMESTAMP},
      </if>
      <if test="catelogType != null">
        catelog_type = #{catelogType,jdbcType=VARCHAR},
      </if>
      <if test="catelogBasic != null">
        catelog_basic = #{catelogBasic,jdbcType=BIGINT},
      </if>
      <if test="catelogSector != null">
        catelog_sector = #{catelogSector,jdbcType=BIGINT},
      </if>
      <if test="catelogTheme != null">
        catelog_theme = #{catelogTheme,jdbcType=BIGINT},
      </if>
      <if test="catelogCustom != null">
        catelog_custom = #{catelogCustom,jdbcType=BIGINT},
      </if>
      <if test="shareType != null">
        share_type = #{shareType,jdbcType=VARCHAR},
      </if>
      <if test="openType != null">
        open_type = #{openType,jdbcType=VARCHAR},
      </if>
      <if test="allowDeal != null">
        allow_deal = #{allowDeal,jdbcType=TINYINT},
      </if>
      <if test="auditedBy != null">
        audited_by = #{auditedBy,jdbcType=BIGINT},
      </if>
      <if test="auditedAt != null">
        audited_at = #{auditedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="auditResult != null">
        audit_result = #{auditResult,jdbcType=VARCHAR},
      </if>
      <if test="auditOpinion != null">
        audit_opinion = #{auditOpinion,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="deletedAt != null">
        deleted_at = #{deletedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="deletedBy != null">
        deleted_by = #{deletedBy,jdbcType=BIGINT},
      </if>
      <if test="outId1 != null">
        out_id_1 = #{outId1,jdbcType=VARCHAR},
      </if>
      <if test="outId2 != null">
        out_id_2 = #{outId2,jdbcType=VARCHAR},
      </if>
      <if test="outId3 != null">
        out_id_3 = #{outId3,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.lightinit.hsdataplatform.entity.Resource">
    update resource
    set resource_type = #{resourceType,jdbcType=VARCHAR},
      resource_state = #{resourceState,jdbcType=VARCHAR},
      resource_name = #{resourceName,jdbcType=VARCHAR},
      resource_identity = #{resourceIdentity,jdbcType=VARCHAR},
      resource_summary = #{resourceSummary,jdbcType=VARCHAR},
      register_date = #{registerDate,jdbcType=TIMESTAMP},
      catelog_type = #{catelogType,jdbcType=VARCHAR},
      catelog_basic = #{catelogBasic,jdbcType=BIGINT},
      catelog_sector = #{catelogSector,jdbcType=BIGINT},
      catelog_theme = #{catelogTheme,jdbcType=BIGINT},
      catelog_custom = #{catelogCustom,jdbcType=BIGINT},
      share_type = #{shareType,jdbcType=VARCHAR},
      open_type = #{openType,jdbcType=VARCHAR},
      allow_deal = #{allowDeal,jdbcType=TINYINT},
      audited_by = #{auditedBy,jdbcType=BIGINT},
      audited_at = #{auditedAt,jdbcType=TIMESTAMP},
      audit_result = #{auditResult,jdbcType=VARCHAR},
      audit_opinion = #{auditOpinion,jdbcType=VARCHAR},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      deleted_at = #{deletedAt,jdbcType=TIMESTAMP},
      deleted_by = #{deletedBy,jdbcType=BIGINT},
      out_id_1 = #{outId1,jdbcType=VARCHAR},
      out_id_2 = #{outId2,jdbcType=VARCHAR},
      out_id_3 = #{outId3,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <select id="queryOneViewResource" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAPIRegisterViewResourceModel">
        SELECT r.id,r.resource_state,r.resource_name,r.resource_identity,r.resource_summary,r.register_date,r.catelog_type,
        (SELECT catelog_name FROM resource_catelog  WHERE id = r.catelog_basic) catelogBasicName,
        (SELECT catelog_name FROM resource_catelog  WHERE id = r.catelog_sector) catelogSectorName,
        (SELECT catelog_name FROM resource_catelog  WHERE id = r.catelog_theme) catelogThemeName,
        (SELECT catelog_name FROM resource_catelog  WHERE id = r.catelog_custom) catelogCustomName,
        r.share_type,r.open_type,r.allow_deal,r.audit_opinion,r.out_id_1 outId1,
        (SELECT sector_name FROM  sector WHERE id = ra.provider) providerName,
        ra.service_type,ra.service_tag,ra.component
        FROM resource r
        LEFT JOIN resource_api ra
        ON r.id = ra.id
      WHERE r.id = #{id}
  </select>

  <select id="queryPublishResourceDataList" parameterType="com.lightinit.hsdataplatform.model.admin.DataPublishSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.DataPublishListModel">
    <if test="resourceName != null and resourceName !=''">
      <bind name="resourceNameLike" value="'%' + resourceName + '%'" />
    </if>
    <if test="sectorName !=null and sectorName !=''">
      <bind name="sectorNameLike" value="'%' + sectorName + '%'" />
    </if>
    SELECT r.id,r.resource_name,r.resource_summary,s.sector_name FROM resource r
    JOIN resource_data rd ON r.id=rd.id
    LEFT JOIN sector s ON rd.belong_to=s.id
    LEFT JOIN publish_info pu ON pu.resource_id=r.id
    <if test="userId !=null">
      left join admin a on a.org_id=s.id
    </if>
    <where>
       pu.publish_state IS null
      <if test="userId !=null">
        and a.id=#{userId}
      </if>
      <if test="resourceName !=null and resourceName !=''">
         and r.resource_name like #{resourceNameLike}
      </if>
      <if test="sectorName !=null and sectorName !=''">
        and s.sector_name like #{sectorNameLike}
      </if>
    </where>
    order by r.register_date DESC
    <if test="page !=null">
    LIMIT ${page.beginIndex},${page.pageSize}
    </if>
  </select>
  <select id="queryCount" parameterType="com.lightinit.hsdataplatform.model.admin.DataPublishSearchModel" resultType="java.lang.Long">
    <if test="resourceName != null and resourceName !=''">
      <bind name="resourceNameLike" value="'%' + resourceName + '%'" />
    </if>
    <if test="sectorName !=null and sectorName !=''">
      <bind name="sectorNameLike" value="'%' + sectorName + '%'" />
    </if>
    SELECT  count(*) FROM  resource r
    JOIN resource_data rd ON r.id=rd.id
    LEFT JOIN sector s ON rd.belong_to=s.id
    LEFT JOIN publish_info pu ON pu.resource_id=r.id
    <if test="userId !=null">
      left join admin a on a.org_id=s.id
    </if>
    <where>
        pu.publish_state IS null
      <if test="userId !=null">
        and a.id=#{userId}
      </if>
      <if test="resourceName !=null and resourceName !=''">
        and r.resource_name like #{resourceNameLike}
      </if>
      <if test="sectorName !=null and sectorName !=''">
        and s.sector_name like #{sectorNameLike}
      </if>
    </where>
  </select>
  <select id="queryClassificationAndAggregationList" parameterType="com.lightinit.hsdataplatform.model.admin.ClassificationAndAggregationSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.ClassificationAndAggregationListModel">
    <if test="resourceName != null and resourceName.length() &gt; 0">
      <bind name="resourceName" value="'%' + _parameter.resourceName + '%'" />
    </if>
    SELECT r.`resource_name`,r.`resource_type`,f.id publishInfoId,r.id resourceId,rm.id resourceMicroappId,
    CASE
    WHEN s1.sector_name IS NOT  NULL  THEN s1.sector_name
    WHEN s2.sector_name IS NOT  NULL  THEN s2.sector_name
    WHEN s3.sector_name IS NOT  NULL  THEN s3.sector_name
    ELSE NULL END provider,

      CASE
      WHEN ra.service_tag IS NOT  NULL  THEN ra.service_tag
      WHEN rd.`data_tag` IS NOT  NULL  THEN rd.`data_tag`
      WHEN rm.service_tag IS NOT  NULL  THEN rm.service_tag
      ELSE NULL END service_tag

      FROM `resource` r
      LEFT JOIN `resource_api` ra ON r.`id` = ra.`id`
      LEFT JOIN `resource_data` rd ON r.`id` = rd.`id`
      LEFT JOIN `resource_microapp` rm ON r.`id` = rm.`id`
      LEFT JOIN sector s1 ON rm.provider = s1.id
      LEFT JOIN sector s2 ON ra.provider = s2.id
      LEFT JOIN sector s3 ON rd.`belong_to`  = s3.id
    LEFT JOIN `publish_info` f ON r.id = f.resource_id
    <where>
      <if test="provider != null and provider.length() &gt; 0">
        s1.id = #{provider}
      </if>
      <if test="resourceName != null and resourceName.length() &gt; 0">
        AND r.resource_name like #{resourceName}
      </if>
      <if test="resourceType != null and resourceType.length() &gt; 0 ">
        AND r.resource_type = #{resourceType}
      </if>
    </where>
    ORDER BY r.id DESC
    <if test="page != null">
      limit ${page.beginIndex},${page.pageSize}
    </if>
  </select>
  <select id="queryClassificationAndAggregationCount" parameterType="com.lightinit.hsdataplatform.model.admin.ClassificationAndAggregationSearchModel" resultType="java.lang.Long">
    <if test="resourceName != null and resourceName.length() &gt; 0">
      <bind name="resourceName" value="'%' + _parameter.resourceName + '%'" />
    </if>
    SELECT count(*)
    FROM `resource` r
    LEFT JOIN `resource_api` ra ON r.`id` = ra.`id`
    LEFT JOIN `resource_data` rd ON r.`id` = rd.`id`
    LEFT JOIN `resource_microapp` rm ON r.`id` = rm.`id`
    LEFT JOIN sector s1 ON rm.provider = s1.id
    LEFT JOIN sector s2 ON ra.provider = s2.id
    LEFT JOIN sector s3 ON rd.`belong_to`  = s3.id
    LEFT JOIN `publish_info` f ON r.id = f.resource_id
      <where>
      <if test="provider != null and provider.length() &gt; 0">
        s1.id = #{provider}
      </if>
      <if test="resourceName != null and resourceName.length() &gt; 0">
        AND r.resource_name like #{resourceName}
      </if>
      <if test="resourceType != null and resourceType.length() &gt; 0 ">
        AND r.resource_type = #{resourceType}
      </if>
    </where>
  </select>
  <select id="queryRelationshipManageList" parameterType="com.lightinit.hsdataplatform.model.admin.RelationshipManageSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.RelationshipManageListModel">
    <if test="resourceName != null and resourceName.length() &gt; 0">
      <bind name="resourceName" value="'%' + _parameter.resourceName + '%'" />
    </if>
    SELECT r.`resource_name`,r.`resource_type`,p.`created_at`,r.id resourceId,p.id publishInfoId
    FROM `resource` r
    JOIN `publish_info` p ON r.id = p.`resource_id`
    <where>
      <if test="resourceName != null and resourceName.length() &gt; 0">
        AND r.resource_name like #{resourceName}
      </if>
      <if test="resourceType != null and resourceType.length() &gt; 0 ">
        AND r.resource_type = #{resourceType}
      </if>
    </where>
    ORDER BY r.id DESC
    <if test="page != null">
    limit ${page.beginIndex},${page.pageSize}
  </if>
  </select>
  <select id="queryRelationshipManageCount" parameterType="com.lightinit.hsdataplatform.model.admin.RelationshipManageSearchModel" resultType="java.lang.Long">
    <if test="resourceName != null and resourceName.length() &gt; 0">
      <bind name="resourceName" value="'%' + _parameter.resourceName + '%'" />
    </if>
    SELECT count(*)
    FROM `resource` r
    JOIN `publish_info` p ON r.id = p.`resource_id`
    <where>
      <if test="resourceName != null and resourceName.length() &gt; 0">
        AND r.resource_name like #{resourceName}
      </if>
      <if test="resourceType != null and resourceType.length() &gt; 0 ">
        AND r.resource_type = #{resourceType}
      </if>
    </where>
  </select>
  <select id="detal" resultType="com.lightinit.hsdataplatform.model.admin.RelationshipManageViewModel">
SELECT r.`resource_type`,p.`created_at`,ps.`charge_method`,rc4.`catelog_name`,rc1.`catelog_name` basicName,
rc2.`catelog_name` customName,rc3.`catelog_name` sectorName,rd.`data_tag` themeName,ai.id interfaceId


 FROM `resource` r

 LEFT JOIN `resource_data` rd ON r.`id` = rd.id

 LEFT JOIN `resource_api` ra ON r.`id` = ra.id

 LEFT JOIN `resource_api_interface` ai ON ra.id = ai.`api_id`

 LEFT JOIN `resource_microapp` rm ON r.`id` = rm.`id`

 JOIN `publish_info` p ON r.`id` = p.`resource_id`
 JOIN `publish_setting` ps ON p.`id` = ps.`publish_info_id`
 LEFT JOIN `resource_catelog` rc1 ON r.`catelog_basic` = rc1.`id`
  LEFT JOIN `resource_catelog` rc2 ON r.`catelog_custom` = rc2.`id`
   LEFT JOIN `resource_catelog` rc3 ON r.`catelog_sector` = rc3.`id`
    LEFT JOIN `resource_catelog` rc4 ON r.`catelog_theme` = rc4.`id`
    WHERE r.id=#{resourceId}
  </select>

  <select id="queryInterfaceIn" parameterType="java.lang.Long" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAPIRegisterAddAPIInterfaceInputModel">
   SELECT* FROM `resource_api_interface` ai
    LEFT JOIN `resource_api_interface_input` aii ON  ai.id =  aii.`interface_id`

 WHERE ai.`id`=#{id}

  </select>
  <select id="queryInterfaceOut" parameterType="java.lang.Long" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAPIRegisterAddAPIInterfaceOutputModel">
      SELECT* FROM `resource_api_interface` ai
      LEFT JOIN `resource_api_interface_output` aio ON ai.`id` = aio.`interface_id`
      WHERE ai.`id`=#{id}
  </select>
  <select id="selectResourceByCatelogCode" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceTreeNodeModel">
    <if test="catelogCode != null and catelogCode !=''">
      <bind name="catelogCode" value="catelogCode + '%'" />
    </if>
    <if test="resourceName != null and resourceName !=''">
      <bind name="resourceName" value="'%' + resourceName + '%'" />
    </if>
      select r.resource_name name,concat('资源',r.id) value
      from resource r
      left join resource_catelog rc
      on r.catelog_theme = rc.id
      where
      rc.catelog_code LIKE #{catelogCode}
      <if test="resourceName != null and resourceName.length&gt;0">
        AND r.resource_name LIKE #{resourceName}
      </if>
  </select>
  <select id="findAllList" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesListModel">
        <if test="resourceName != null and resourceName !=''">
          <bind name="resourceName" value="'%' + resourceName + '%'" />
        </if>
        select A.*,s.sector_name providerName from (SELECT r.id,r.resource_name,r.resource_type,r.share_type,r.open_type,rc1.catelog_name catelogThemeName,rc1.catelog_code,
              IFNULL(ra.service_tag,IFNULL(rd.data_tag,rm.service_tag)) serviceTag,
              IFNULL(ra.provider,IFNULL(rd.belong_to,rm.provider)) provider
              FROM resource r
              join resource_catelog rc on r.`catelog_theme` = rc.id
              join resource_catelog rc1 on rc.`catelog_code` like CONCAT(rc1.`catelog_code`, '%') and rc1.`parent_id` is null
              LEFT JOIN resource_api ra ON  ra.id = r.id
              LEFT JOIN resource_data rd ON  rd.id = r.id
              LEFT JOIN resource_microapp rm ON  rm.id = r.id)A
              left join sector s on s.id = A.provider
        <where>
          <if test="resourceName != null and resourceName !=''">
            AND A.resource_name LIKE #{resourceName}
          </if>
        </where>
        <if test="page != null">
          limit ${page.beginIndex},${page.pageSize}
        </if>
  </select>
  <select id="findAllListCount" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesSearchModel" resultType="java.lang.Long">
    <if test="resourceName != null and resourceName !=''">
      <bind name="resourceName" value="'%' + resourceName + '%'" />
    </if>
    SELECT count(*)
    FROM resource r
    join resource_catelog rc on r.`catelog_theme` = rc.id
    join resource_catelog rc1 on rc.`catelog_code` like CONCAT(rc1.`catelog_code`, '%') and rc1.`parent_id` is null
    <where>
      <if test="resourceName != null and resourceName !=''">
        AND r.resource_name LIKE #{resourceName}
      </if>
    </where>
  </select>
  <select id="findAllThemeList" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceNoImgThemeListModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesListModel">
    <if test="catelogCode != null and catelogCode !=''">
      <bind name="catelogCode" value="catelogCode + '%'" />
    </if>
    select A.*,s.sector_name providerName from (SELECT r.id,r.resource_name,r.resource_type,r.share_type,r.open_type,rc1.catelog_name catelogThemeName,
    IFNULL(ra.service_tag,IFNULL(rd.data_tag,rm.service_tag)) serviceTag,
    IFNULL(ra.provider,IFNULL(rd.belong_to,rm.provider)) provider
    FROM resource r
    join resource_catelog rc on r.`catelog_theme` = rc.id
    join resource_catelog rc1 on rc.`catelog_code` like CONCAT(rc1.`catelog_code`, '%') and rc1.`parent_id` is null
    LEFT JOIN resource_api ra ON  ra.id = r.id
    LEFT JOIN resource_data rd ON  rd.id = r.id
    LEFT JOIN resource_microapp rm ON  rm.id = r.id
    <where>
    <if test="catelogCode!=null and catelogCode.length()&gt;0">
      rc.catelog_code LIKE #{catelogCode}
    </if>
    </where>
    )A
    left join sector s on s.id = A.provider
      <if test="page != null">
          limit ${page.beginIndex},${page.pageSize}
      </if>
  </select>

  <select id="findAllThemeListCount" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceNoImgThemeListModel" resultType="java.lang.Long">
    <if test="catelogCode != null and catelogCode !=''">
      <bind name="catelogCode" value="catelogCode + '%'" />
    </if>
    SELECT count(*)
    FROM resource r
    join resource_catelog rc on r.`catelog_theme` = rc.id
    join resource_catelog rc1 on rc.`catelog_code` like CONCAT(rc1.`catelog_code`, '%') and rc1.`parent_id` is null
    <where>
      <if test="catelogCode!=null and catelogCode.length()&gt;0">
        rc.catelog_code LIKE #{catelogCode}
      </if>
    </where>
  </select>

    <select id="selectThisThemeDirectDate" parameterType="java.lang.String" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImgFreeModel">
        select r.resource_name name,concat('资源',r.id) value
        from resource r
        left join resource_catelog rc
        on r.catelog_theme = rc.id
        where
        rc.catelog_code = #{themeCode}
    </select>

  <select id="findResourceById" parameterType="java.lang.String" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesListModel">
    select A.*,s.sector_name providerName from (SELECT r.id,r.resource_name,r.resource_type,r.share_type,r.open_type,rc1.catelog_name catelogThemeName,
    IFNULL(ra.service_tag,IFNULL(rd.data_tag,rm.service_tag)) serviceTag,
    IFNULL(ra.provider,IFNULL(rd.belong_to,rm.provider)) provider
    FROM resource r
    join resource_catelog rc on r.`catelog_theme` = rc.id
    join resource_catelog rc1 on rc.`catelog_code` like CONCAT(rc1.`catelog_code`, '%') and rc1.`parent_id` is null
    LEFT JOIN resource_api ra ON  ra.id = r.id
    LEFT JOIN resource_data rd ON  rd.id = r.id
    LEFT JOIN resource_microapp rm ON  rm.id = r.id
    WHERE r.id = #{resourceId}
    )A
    left join sector s on s.id = A.provider
  </select>
  <select id="queryResourceList" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceCountSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceCountListModel">
    <if test="resourceName != null and resourceName.length() &gt; 0">
      <bind name="resourceName" value="'%' + _parameter.resourceName + '%'" />
    </if>
    SELECT r.`resource_name`,r.`resource_type` , rvt1.`view_times` viewTimes
    , apply1.`apply_times` applyCount
    , apply1.`follow_times` follow FROM `resource` r
    LEFT JOIN resource_view_times rvt1 ON r.`id` = rvt1.`id`
     JOIN (
      SELECT p.`resource_id` resource_id, COUNT(ps.`id`) apply_times, COUNT(rf.`id`) follow_times
      FROM publish_info p
      LEFT JOIN publish_setting ps ON p.`id` = ps.`publish_info_id`
      LEFT JOIN resource_auth ra ON ps.`id` = ra.`publish_setting_id`
      LEFT JOIN resource_follow rf ON ps.`id` = rf.`publish_setting_id`
      GROUP BY p.`resource_id`
    ) apply1 ON r.`id` = apply1.`resource_id`
    <where>
      <if test="resourceName != null and resourceName.length() &gt; 0">
        AND r.resource_name like #{resourceName}
      </if>
      <if test="fromDate != null">
        AND r.register_date &gt;= #{fromDate}
      </if>
      <if test="toDate != null">
        AND r.register_date &lt; #{toDate}
      </if>
    </where>
    <if test="page != null">
      LIMIT #{page.beginIndex},#{page.pageSize}
    </if>
  </select>
  <select id="queryResourceCount" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceCountSearchModel" resultType="java.lang.Long">
    <if test="resourceName != null and resourceName.length() &gt; 0">
      <bind name="resourceName" value="'%' + _parameter.resourceName + '%'" />
    </if>
    SELECT count(*)
     FROM `resource` r
    LEFT JOIN resource_view_times rvt1 ON r.`id` = rvt1.`id`
     JOIN (
      SELECT p.`resource_id` resource_id, COUNT(ps.`id`) apply_times, COUNT(rf.`id`) follow_times
      FROM publish_info p
      LEFT JOIN publish_setting ps ON p.`id` = ps.`publish_info_id`
      LEFT JOIN resource_auth ra ON ps.`id` = ra.`publish_setting_id`
      LEFT JOIN resource_follow rf ON ps.`id` = rf.`publish_setting_id`
      GROUP BY p.`resource_id`
    ) apply1 ON r.`id` = apply1.`resource_id`
    <where>
      <if test="resourceName != null and resourceName.length() &gt; 0">
        AND r.resource_name like #{resourceName}
      </if>
      <if test="fromDate != null">
        AND r.register_date &gt;= #{fromDate}
      </if>
      <if test="toDate != null">
        AND r.register_date &lt; #{toDate}
      </if>
    </where>
  </select>
  <select id="insertOutId">
    UPDATE resource set out_id_1 = #{outId} WHERE id = #{id}
  </select>
  <select id="selectTwoLogList" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceTreeNodeModel">
    <!--<if test="catelogCode != null and catelogCode !=''">-->
      <!--<bind name="catelogCode" value="catelogCode + '%'" />-->
    <!--</if>-->
    <if test="resourceName != null and resourceName !=''">
      <bind name="resourceName" value="'%' + resourceName + '%'" />
    </if>
      SELECT catelog_name name ,concat('主题',catelog_code) value
      FROM resource_catelog
      WHERE catelog_code LIKE concat(#{catelogCode},'%')
      AND catelog_code!=#{catelogCode}
  </select>

  <!--基础图谱-->
  <select id="findBasicsAllList" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesListModel">
    <if test="resourceName != null and resourceName !=''">
      <bind name="resourceName" value="'%' + resourceName + '%'" />
    </if>
    select A.*,s.sector_name providerName from (SELECT r.id,r.resource_name,r.resource_type,r.share_type,r.open_type,rc1.catelog_name catelogThemeName,rc1.catelog_code,
    IFNULL(ra.service_tag,IFNULL(rd.data_tag,rm.service_tag)) serviceTag,
    IFNULL(ra.provider,IFNULL(rd.belong_to,rm.provider)) provider
    FROM resource r
    join resource_catelog rc on r.`catelog_basic` = rc.id
    join resource_catelog rc1 on rc.`catelog_code` like CONCAT(rc1.`catelog_code`, '%') and rc1.`parent_id` is null
    LEFT JOIN resource_api ra ON  ra.id = r.id
    LEFT JOIN resource_data rd ON  rd.id = r.id
    LEFT JOIN resource_microapp rm ON  rm.id = r.id)A
    left join sector s on s.id = A.provider
    <where>
      <if test="resourceName != null and resourceName !=''">
        AND A.resource_name LIKE #{resourceName}
      </if>
    </where>
    <if test="page != null">
      limit ${page.beginIndex},${page.pageSize}
    </if>
  </select>
  <select id="findBasicsAllListCount" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesSearchModel" resultType="java.lang.Long">
    <if test="resourceName != null and resourceName !=''">
      <bind name="resourceName" value="'%' + resourceName + '%'" />
    </if>
    SELECT count(*)
    FROM resource r
    join resource_catelog rc on r.`catelog_basic` = rc.id
    join resource_catelog rc1 on rc.`catelog_code` like CONCAT(rc1.`catelog_code`, '%') and rc1.`parent_id` is null
    <where>
      <if test="resourceName != null and resourceName !=''">
        AND r.resource_name LIKE #{resourceName}
      </if>
    </where>
  </select>
  <select id="selectThisBasicsDirectDate" parameterType="java.lang.String" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImgFreeModel">
    select r.resource_name name,concat('资源',r.id) value
    from resource r
    left join resource_catelog rc
    on r.catelog_basic = rc.id
    where
    rc.catelog_code = #{themeCode}
  </select>
  <select id="selectBasicsByCatelogCode" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceTreeNodeModel">
    <if test="catelogCode != null and catelogCode !=''">
      <bind name="catelogCode" value="catelogCode + '%'" />
    </if>
    <if test="resourceName != null and resourceName !=''">
      <bind name="resourceName" value="'%' + resourceName + '%'" />
    </if>
    select r.resource_name name,concat('资源',r.id) value
    from resource r
    left join resource_catelog rc
    on r.catelog_basic = rc.id
    where
    rc.catelog_code LIKE #{catelogCode}
    <if test="resourceName != null and resourceName.length&gt;0">
      AND r.resource_name LIKE #{resourceName}
    </if>
  </select>
  <select id="findBasicsById" parameterType="java.lang.String" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesListModel">
    select A.*,s.sector_name providerName from (SELECT r.id,r.resource_name,r.resource_type,r.share_type,r.open_type,rc1.catelog_name catelogThemeName,
    IFNULL(ra.service_tag,IFNULL(rd.data_tag,rm.service_tag)) serviceTag,
    IFNULL(ra.provider,IFNULL(rd.belong_to,rm.provider)) provider
    FROM resource r
    join resource_catelog rc on r.`catelog_basic` = rc.id
    join resource_catelog rc1 on rc.`catelog_code` like CONCAT(rc1.`catelog_code`, '%') and rc1.`parent_id` is null
    LEFT JOIN resource_api ra ON  ra.id = r.id
    LEFT JOIN resource_data rd ON  rd.id = r.id
    LEFT JOIN resource_microapp rm ON  rm.id = r.id
    WHERE r.id = #{resourceId}
    )A
    left join sector s on s.id = A.provider
  </select>
  <select id="findAllBasicsList" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceNoImgThemeListModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesListModel">
    <if test="catelogCode != null and catelogCode !=''">
      <bind name="catelogCode" value="catelogCode + '%'" />
    </if>
    select A.*,s.sector_name providerName from (SELECT r.id,r.resource_name,r.resource_type,r.share_type,r.open_type,rc1.catelog_name catelogThemeName,
    IFNULL(ra.service_tag,IFNULL(rd.data_tag,rm.service_tag)) serviceTag,
    IFNULL(ra.provider,IFNULL(rd.belong_to,rm.provider)) provider
    FROM resource r
    join resource_catelog rc on r.`catelog_basic` = rc.id
    join resource_catelog rc1 on rc.`catelog_code` like CONCAT(rc1.`catelog_code`, '%') and rc1.`parent_id` is null
    LEFT JOIN resource_api ra ON  ra.id = r.id
    LEFT JOIN resource_data rd ON  rd.id = r.id
    LEFT JOIN resource_microapp rm ON  rm.id = r.id
    <where>
      <if test="catelogCode!=null and catelogCode.length()&gt;0">
        rc.catelog_code LIKE #{catelogCode}
      </if>
    </where>
    )A
    left join sector s on s.id = A.provider
    <if test="page != null">
      limit ${page.beginIndex},${page.pageSize}
    </if>
  </select>
  <select id="findAllBasicsListCount" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceNoImgThemeListModel" resultType="java.lang.Long">
    <if test="catelogCode != null and catelogCode !=''">
      <bind name="catelogCode" value="catelogCode + '%'" />
    </if>
    SELECT count(*)
    FROM resource r
    join resource_catelog rc on r.`catelog_basic` = rc.id
    join resource_catelog rc1 on rc.`catelog_code` like CONCAT(rc1.`catelog_code`, '%') and rc1.`parent_id` is null
    <where>
      <if test="catelogCode!=null and catelogCode.length()&gt;0">
        rc.catelog_code LIKE #{catelogCode}
      </if>
    </where>
  </select>

  <!--部门图谱-->
  <select id="findDeptAllList" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesListModel">
    <if test="resourceName != null and resourceName !=''">
      <bind name="resourceName" value="'%' + resourceName + '%'" />
    </if>
    select A.*,s.sector_name providerName from (SELECT r.id,r.resource_name,r.resource_type,r.share_type,r.open_type,rc1.catelog_name catelogThemeName,rc1.catelog_code,
    IFNULL(ra.service_tag,IFNULL(rd.data_tag,rm.service_tag)) serviceTag,
    IFNULL(ra.provider,IFNULL(rd.belong_to,rm.provider)) provider
    FROM resource r
    join resource_catelog rc on r.`catelog_sector` = rc.id
    join resource_catelog rc1 on rc.`catelog_code` like CONCAT(rc1.`catelog_code`, '%') and rc1.`parent_id` is null
    LEFT JOIN resource_api ra ON  ra.id = r.id
    LEFT JOIN resource_data rd ON  rd.id = r.id
    LEFT JOIN resource_microapp rm ON  rm.id = r.id)A
    left join sector s on s.id = A.provider
    <where>
      <if test="resourceName != null and resourceName !=''">
        AND A.resource_name LIKE #{resourceName}
      </if>
    </where>
    <if test="page != null">
      limit ${page.beginIndex},${page.pageSize}
    </if>
  </select>
  <select id="findDeptAllListCount" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesSearchModel" resultType="java.lang.Long">
    <if test="resourceName != null and resourceName !=''">
      <bind name="resourceName" value="'%' + resourceName + '%'" />
    </if>
    SELECT count(*)
    FROM resource r
    join resource_catelog rc on r.`catelog_sector` = rc.id
    join resource_catelog rc1 on rc.`catelog_code` like CONCAT(rc1.`catelog_code`, '%') and rc1.`parent_id` is null
    <where>
      <if test="resourceName != null and resourceName !=''">
        AND r.resource_name LIKE #{resourceName}
      </if>
    </where>
  </select>
  <select id="selectThisDeptDirectDate" parameterType="java.lang.String" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImgFreeModel">
    select r.resource_name name,concat('资源',r.id) value
    from resource r
    left join resource_catelog rc
    on r.catelog_sector = rc.id
    where
    rc.catelog_code = #{themeCode}
  </select>
  <select id="selectDeptByCatelogCode" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceTreeNodeModel">
    <if test="catelogCode != null and catelogCode !=''">
      <bind name="catelogCode" value="catelogCode + '%'" />
    </if>
    <if test="resourceName != null and resourceName !=''">
      <bind name="resourceName" value="'%' + resourceName + '%'" />
    </if>
    select r.resource_name name,concat('资源',r.id) value
    from resource r
    left join resource_catelog rc
    on r.catelog_sector = rc.id
    where
    rc.catelog_code LIKE #{catelogCode}
    <if test="resourceName != null and resourceName.length&gt;0">
      AND r.resource_name LIKE #{resourceName}
    </if>
  </select>
  <select id="findDeptById" parameterType="java.lang.String" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesListModel">
    select A.*,s.sector_name providerName from (SELECT r.id,r.resource_name,r.resource_type,r.share_type,r.open_type,rc1.catelog_name catelogThemeName,
    IFNULL(ra.service_tag,IFNULL(rd.data_tag,rm.service_tag)) serviceTag,
    IFNULL(ra.provider,IFNULL(rd.belong_to,rm.provider)) provider
    FROM resource r
    join resource_catelog rc on r.`catelog_sector` = rc.id
    join resource_catelog rc1 on rc.`catelog_code` like CONCAT(rc1.`catelog_code`, '%') and rc1.`parent_id` is null
    LEFT JOIN resource_api ra ON  ra.id = r.id
    LEFT JOIN resource_data rd ON  rd.id = r.id
    LEFT JOIN resource_microapp rm ON  rm.id = r.id
    WHERE r.id = #{resourceId}
    )A
    left join sector s on s.id = A.provider
  </select>
  <select id="findAllDeptList" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceNoImgThemeListModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesListModel">
    <if test="catelogCode != null and catelogCode !=''">
      <bind name="catelogCode" value="catelogCode + '%'" />
    </if>
    select A.*,s.sector_name providerName from (SELECT r.id,r.resource_name,r.resource_type,r.share_type,r.open_type,rc1.catelog_name catelogThemeName,
    IFNULL(ra.service_tag,IFNULL(rd.data_tag,rm.service_tag)) serviceTag,
    IFNULL(ra.provider,IFNULL(rd.belong_to,rm.provider)) provider
    FROM resource r
    join resource_catelog rc on r.`catelog_sector` = rc.id
    join resource_catelog rc1 on rc.`catelog_code` like CONCAT(rc1.`catelog_code`, '%') and rc1.`parent_id` is null
    LEFT JOIN resource_api ra ON  ra.id = r.id
    LEFT JOIN resource_data rd ON  rd.id = r.id
    LEFT JOIN resource_microapp rm ON  rm.id = r.id
    <where>
      <if test="catelogCode!=null and catelogCode.length()&gt;0">
        rc.catelog_code LIKE #{catelogCode}
      </if>
    </where>
    )A
    left join sector s on s.id = A.provider
    <if test="page != null">
      limit ${page.beginIndex},${page.pageSize}
    </if>
  </select>
  <select id="findAllDeptListCount" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceNoImgThemeListModel" resultType="java.lang.Long">
    <if test="catelogCode != null and catelogCode !=''">
      <bind name="catelogCode" value="catelogCode + '%'" />
    </if>
    SELECT count(*)
    FROM resource r
    join resource_catelog rc on r.`catelog_sector` = rc.id
    join resource_catelog rc1 on rc.`catelog_code` like CONCAT(rc1.`catelog_code`, '%') and rc1.`parent_id` is null
    <where>
      <if test="catelogCode!=null and catelogCode.length()&gt;0">
        rc.catelog_code LIKE #{catelogCode}
      </if>
    </where>
  </select>

  <!--共享图谱-->
  <select id="getShareType" resultType="java.lang.String">
    select distinct share_type  from resource where `share_type` !=''
  </select>
  <select id="findShareAllList" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesListModel">
    <if test="resourceName != null and resourceName !=''">
      <bind name="resourceName" value="'%' + resourceName + '%'" />
    </if>
    select A.*,s.sector_name providerName from (SELECT r.id,r.resource_name,r.resource_type,r.share_type,r.open_type,
    IFNULL(ra.service_tag,IFNULL(rd.data_tag,rm.service_tag)) serviceTag,
    IFNULL(ra.provider,IFNULL(rd.belong_to,rm.provider)) provider
    FROM resource r
    LEFT JOIN resource_api ra ON  ra.id = r.id
    LEFT JOIN resource_data rd ON  rd.id = r.id
    LEFT JOIN resource_microapp rm ON  rm.id = r.id)A
    left join sector s on s.id = A.provider
    <where>
      A.share_type != ''
      <if test="resourceName != null and resourceName !=''">
        AND A.resource_name LIKE #{resourceName}
      </if>
    </where>
    <if test="page != null">
      limit ${page.beginIndex},${page.pageSize}
    </if>
  </select>
  <select id="findShareAllListCount" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesSearchModel" resultType="java.lang.Long">
    <if test="resourceName != null and resourceName !=''">
      <bind name="resourceName" value="'%' + resourceName + '%'" />
    </if>
    SELECT count(*)
    FROM resource r
    LEFT JOIN resource_api ra ON  ra.id = r.id
    LEFT JOIN resource_data rd ON  rd.id = r.id
    <where>
      r.share_type != ''
      <if test="resourceName != null and resourceName !=''">
        AND r.resource_name LIKE #{resourceName}
      </if>
    </where>
  </select>
  <select id="findAllShareList" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceNoImgThemeListModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesListModel">
    select A.*,s.sector_name providerName from (SELECT r.id,r.resource_name,r.resource_type,r.share_type,r.open_type,
    IFNULL(ra.service_tag,IFNULL(rd.data_tag,rm.service_tag)) serviceTag,
    IFNULL(ra.provider,IFNULL(rd.belong_to,rm.provider)) provider
    FROM resource r
    LEFT JOIN resource_api ra ON  ra.id = r.id
    LEFT JOIN resource_data rd ON  rd.id = r.id
    LEFT JOIN resource_microapp rm ON  rm.id = r.id)A
    left join sector s on s.id = A.provider
    <where>
      <if test="catelogCode!=null and catelogCode.length()&gt;0">
        A.share_type = #{catelogCode}
      </if>
    </where>
    <if test="page != null">
      limit ${page.beginIndex},${page.pageSize}
    </if>
  </select>
  <select id="findAllShareListCount" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceNoImgThemeListModel" resultType="java.lang.Long">
    SELECT count(*)
    FROM resource r
    LEFT JOIN resource_api ra ON  ra.id = r.id
    LEFT JOIN resource_data rd ON  rd.id = r.id
    <where>
      <if test="catelogCode != null and catelogCode !=''">
        r.share_type = #{catelogCode}
      </if>
    </where>
  </select>
  <select id="findShareById" parameterType="java.lang.String" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesListModel">
    select A.*,s.sector_name providerName from (SELECT r.id,r.resource_name,r.resource_type,r.share_type,r.open_type,
    IFNULL(ra.service_tag,IFNULL(rd.data_tag,rm.service_tag)) serviceTag,
    IFNULL(ra.provider,IFNULL(rd.belong_to,rm.provider)) provider
    FROM resource r
    LEFT JOIN resource_api ra ON  ra.id = r.id
    LEFT JOIN resource_data rd ON  rd.id = r.id
    LEFT JOIN resource_microapp rm ON  rm.id = r.id
    WHERE r.id = #{resourceId}
    )A
    left join sector s on s.id = A.provider
  </select>
  <select id="findShareResourceById" parameterType="java.lang.String" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesListModel">
    select A.*,s.sector_name providerName from (SELECT r.id,r.resource_name,r.resource_type,r.share_type,r.open_type,
    IFNULL(ra.service_tag,IFNULL(rd.data_tag,rm.service_tag)) serviceTag,
    IFNULL(ra.provider,IFNULL(rd.belong_to,rm.provider)) provider
    FROM resource r
    LEFT JOIN resource_api ra ON  ra.id = r.id
    LEFT JOIN resource_data rd ON  rd.id = r.id
    LEFT JOIN resource_microapp rm ON  rm.id = r.id
    WHERE r.id = #{resourceId}
    )A
    left join sector s on s.id = A.provider
  </select>

  <!--开放图谱-->
  <select id="getOpenType" resultType="java.lang.String">
    select distinct open_type  from resource where `open_type` !=''
  </select>
    <select id="findOpenAllList" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesListModel">
        <if test="resourceName != null and resourceName !=''">
            <bind name="resourceName" value="'%' + resourceName + '%'" />
        </if>
        select A.*,s.sector_name providerName from (SELECT r.id,r.resource_name,r.resource_type,r.share_type,r.open_type,
        IFNULL(ra.service_tag,IFNULL(rd.data_tag,rm.service_tag)) serviceTag,
        IFNULL(ra.provider,IFNULL(rd.belong_to,rm.provider)) provider
        FROM resource r
        LEFT JOIN resource_api ra ON  ra.id = r.id
        LEFT JOIN resource_data rd ON  rd.id = r.id
        LEFT JOIN resource_microapp rm ON  rm.id = r.id)A
        left join sector s on s.id = A.provider
        <where>
            A.open_type != ''
            <if test="resourceName != null and resourceName !=''">
                AND A.resource_name LIKE #{resourceName}
            </if>
        </where>
        <if test="page != null">
            limit ${page.beginIndex},${page.pageSize}
        </if>
    </select>
    <select id="findOpenAllListCount" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesSearchModel" resultType="java.lang.Long">
        <if test="resourceName != null and resourceName !=''">
            <bind name="resourceName" value="'%' + resourceName + '%'" />
        </if>
        SELECT count(*)
        FROM resource r
        LEFT JOIN resource_api ra ON  ra.id = r.id
        LEFT JOIN resource_data rd ON  rd.id = r.id
        <where>
            r.open_type != ''
            <if test="resourceName != null and resourceName !=''">
                AND r.resource_name LIKE #{resourceName}
            </if>
        </where>
    </select>
    <select id="findAllOpenList" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceNoImgThemeListModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAllImagesListModel">
        select A.*,s.sector_name providerName from (SELECT r.id,r.resource_name,r.resource_type,r.share_type,r.open_type,
        IFNULL(ra.service_tag,IFNULL(rd.data_tag,rm.service_tag)) serviceTag,
        IFNULL(ra.provider,IFNULL(rd.belong_to,rm.provider)) provider
        FROM resource r
        LEFT JOIN resource_api ra ON  ra.id = r.id
        LEFT JOIN resource_data rd ON  rd.id = r.id
        LEFT JOIN resource_microapp rm ON  rm.id = r.id)A
        left join sector s on s.id = A.provider
        <where>
            <if test="catelogCode!=null and catelogCode.length()&gt;0">
                A.open_type = #{catelogCode}
            </if>
        </where>
        <if test="page != null">
            limit ${page.beginIndex},${page.pageSize}
        </if>
    </select>
    <select id="findAllOpenListCount" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceNoImgThemeListModel" resultType="java.lang.Long">
        SELECT count(*)
        FROM resource r
        LEFT JOIN resource_api ra ON  ra.id = r.id
        LEFT JOIN resource_data rd ON  rd.id = r.id
        <where>
            <if test="catelogCode != null and catelogCode !=''">
                r.open_type = #{catelogCode}
            </if>
        </where>
    </select>

  <select id="getResourceCount" resultType="com.lightinit.hsdataplatform.model.admin.NameAndValueModel">
     SELECT r.`resource_type` NAME ,COUNT(*) VALUE FROM resource r
 WHERE r.`resource_type`  IS NOT NULL AND  r.`resource_type`  != ''
GROUP BY r.`resource_type`
  </select>


  <select id="getUserCount" resultType="com.lightinit.hsdataplatform.model.admin.NameAndValueModel">
      SELECT COUNT(*) VALUE,"用户总数" NAME FROM user r

  </select>

  <select id="getResourceViewCount" resultType="com.lightinit.hsdataplatform.model.admin.NameAndValueModel">
     SELECT r.`resource_type` NAME ,SUM(rve.`view_times`) VALUE FROM resource r
     JOIN `resource_view_times` rve ON rve.`id` = r.`id`
     WHERE r.`resource_type`  IS NOT NULL AND  r.`resource_type`  != ''
    GROUP BY r.`resource_type`
  </select>

  <select id="getResourceFollowCount" resultType="com.lightinit.hsdataplatform.model.admin.NameAndValueModel">
      SELECT r.`resource_type` NAME ,COUNT(*) VALUE FROM resource r
      JOIN `publish_info` p ON r.`id` = p.`resource_id`
      JOIN `publish_setting` ps ON p.`id` = ps.`publish_info_id`
      JOIN `resource_follow` rf ON ps.`id` = rf.`publish_setting_id`
      GROUP BY r.`resource_type`
  </select>
</mapper>