<?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.PublishInfoMapper">
  <resultMap id="BaseResultMap" type="com.lightinit.hsdataplatform.entity.PublishInfo">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="resource_id" jdbcType="BIGINT" property="resourceId" />
    <result column="publish_state" jdbcType="VARCHAR" property="publishState" />
    <result column="data_tag" jdbcType="VARCHAR" property="dataTag" />
    <result column="publish_channel" jdbcType="VARCHAR" property="publishChannel" />
    <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>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.lightinit.hsdataplatform.entity.PublishInfoWithBLOBs">
    <result column="resource_img" jdbcType="LONGVARCHAR" property="resourceImg" />
    <result column="share_condition" jdbcType="LONGVARCHAR" property="shareCondition" />
    <result column="open_condition" jdbcType="LONGVARCHAR" property="openCondition" />
  </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_id, publish_state, data_tag, publish_channel, 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>
  <sql id="Blob_Column_List">
    resource_img, share_condition, open_condition
  </sql>
  <select id="selectByExampleWithBLOBs" parameterType="com.lightinit.hsdataplatform.entity.PublishInfoExample" resultMap="ResultMapWithBLOBs">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from publish_info
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByExample" parameterType="com.lightinit.hsdataplatform.entity.PublishInfoExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from publish_info
    <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.Long" resultMap="ResultMapWithBLOBs">
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from publish_info
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from publish_info
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.lightinit.hsdataplatform.entity.PublishInfoExample">
    delete from publish_info
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.lightinit.hsdataplatform.entity.PublishInfoWithBLOBs">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into publish_info (resource_id, publish_state, data_tag, 
      publish_channel, 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, 
      resource_img, share_condition, open_condition
      )
    values (#{resourceId,jdbcType=BIGINT}, #{publishState,jdbcType=VARCHAR}, #{dataTag,jdbcType=VARCHAR}, 
      #{publishChannel,jdbcType=VARCHAR}, #{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}, 
      #{resourceImg,jdbcType=LONGVARCHAR}, #{shareCondition,jdbcType=LONGVARCHAR}, #{openCondition,jdbcType=LONGVARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.lightinit.hsdataplatform.entity.PublishInfoWithBLOBs">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into publish_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="resourceId != null">
        resource_id,
      </if>
      <if test="publishState != null">
        publish_state,
      </if>
      <if test="dataTag != null">
        data_tag,
      </if>
      <if test="publishChannel != null">
        publish_channel,
      </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>
      <if test="resourceImg != null">
        resource_img,
      </if>
      <if test="shareCondition != null">
        share_condition,
      </if>
      <if test="openCondition != null">
        open_condition,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="resourceId != null">
        #{resourceId,jdbcType=BIGINT},
      </if>
      <if test="publishState != null">
        #{publishState,jdbcType=VARCHAR},
      </if>
      <if test="dataTag != null">
        #{dataTag,jdbcType=VARCHAR},
      </if>
      <if test="publishChannel != null">
        #{publishChannel,jdbcType=VARCHAR},
      </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>
      <if test="resourceImg != null">
        #{resourceImg,jdbcType=LONGVARCHAR},
      </if>
      <if test="shareCondition != null">
        #{shareCondition,jdbcType=LONGVARCHAR},
      </if>
      <if test="openCondition != null">
        #{openCondition,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.lightinit.hsdataplatform.entity.PublishInfoExample" resultType="java.lang.Long">
    select count(*) from publish_info
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update publish_info
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.resourceId != null">
        resource_id = #{record.resourceId,jdbcType=BIGINT},
      </if>
      <if test="record.publishState != null">
        publish_state = #{record.publishState,jdbcType=VARCHAR},
      </if>
      <if test="record.dataTag != null">
        data_tag = #{record.dataTag,jdbcType=VARCHAR},
      </if>
      <if test="record.publishChannel != null">
        publish_channel = #{record.publishChannel,jdbcType=VARCHAR},
      </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>
      <if test="record.resourceImg != null">
        resource_img = #{record.resourceImg,jdbcType=LONGVARCHAR},
      </if>
      <if test="record.shareCondition != null">
        share_condition = #{record.shareCondition,jdbcType=LONGVARCHAR},
      </if>
      <if test="record.openCondition != null">
        open_condition = #{record.openCondition,jdbcType=LONGVARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExampleWithBLOBs" parameterType="map">
    update publish_info
    set id = #{record.id,jdbcType=BIGINT},
      resource_id = #{record.resourceId,jdbcType=BIGINT},
      publish_state = #{record.publishState,jdbcType=VARCHAR},
      data_tag = #{record.dataTag,jdbcType=VARCHAR},
      publish_channel = #{record.publishChannel,jdbcType=VARCHAR},
      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},
      resource_img = #{record.resourceImg,jdbcType=LONGVARCHAR},
      share_condition = #{record.shareCondition,jdbcType=LONGVARCHAR},
      open_condition = #{record.openCondition,jdbcType=LONGVARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update publish_info
    set id = #{record.id,jdbcType=BIGINT},
      resource_id = #{record.resourceId,jdbcType=BIGINT},
      publish_state = #{record.publishState,jdbcType=VARCHAR},
      data_tag = #{record.dataTag,jdbcType=VARCHAR},
      publish_channel = #{record.publishChannel,jdbcType=VARCHAR},
      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.PublishInfoWithBLOBs">
    update publish_info
    <set>
      <if test="resourceId != null">
        resource_id = #{resourceId,jdbcType=BIGINT},
      </if>
      <if test="publishState != null">
        publish_state = #{publishState,jdbcType=VARCHAR},
      </if>
      <if test="dataTag != null">
        data_tag = #{dataTag,jdbcType=VARCHAR},
      </if>
      <if test="publishChannel != null">
        publish_channel = #{publishChannel,jdbcType=VARCHAR},
      </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>
      <if test="resourceImg != null">
        resource_img = #{resourceImg,jdbcType=LONGVARCHAR},
      </if>
      <if test="shareCondition != null">
        share_condition = #{shareCondition,jdbcType=LONGVARCHAR},
      </if>
      <if test="openCondition != null">
        open_condition = #{openCondition,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.lightinit.hsdataplatform.entity.PublishInfoWithBLOBs">
    update publish_info
    set resource_id = #{resourceId,jdbcType=BIGINT},
      publish_state = #{publishState,jdbcType=VARCHAR},
      data_tag = #{dataTag,jdbcType=VARCHAR},
      publish_channel = #{publishChannel,jdbcType=VARCHAR},
      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},
      resource_img = #{resourceImg,jdbcType=LONGVARCHAR},
      share_condition = #{shareCondition,jdbcType=LONGVARCHAR},
      open_condition = #{openCondition,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.lightinit.hsdataplatform.entity.PublishInfo">
    update publish_info
    set resource_id = #{resourceId,jdbcType=BIGINT},
      publish_state = #{publishState,jdbcType=VARCHAR},
      data_tag = #{dataTag,jdbcType=VARCHAR},
      publish_channel = #{publishChannel,jdbcType=VARCHAR},
      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="querypublishList" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceMicroappRegisterSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceMicroappRegisterListModel">
    <if test="resourceName != null and resourceName.length() &gt; 0">
      <bind name="resourceName" value="'%' + _parameter.resourceName + '%'" />
    </if>

    SELECT r.id, r.catelog_type, r.resource_name, r.resource_summary, r.resource_identity, r.resource_state, r.register_date,s.sector_name provider,p.publish_state,
    (SELECT catelog_name FROM resource_catelog rc WHERE rc.id = r.`catelog_theme`) themename
    FROM resource r
    JOIN publish_info p ON r.id = p.resource_id
    JOIN resource_microapp rd ON r.id = rd.id

    LEFT JOIN sector s ON rd.provider = s.id
    LEFT JOIN admin a ON a.id = r.created_by
    <where>
       p.publish_state is not null
      <if test="provider != null and provider.length() &gt; 0">
        s.id = #{provider}
      </if>
      <if test="resourceName != null and resourceName.length() &gt; 0">
        AND r.resource_name like #{resourceName}
      </if>
      <if test="registerDateFrom != null">
        AND r.register_date &gt;= #{registerDateFrom}
      </if>
      <if test="registerDateTo != null">
        AND r.register_date &lt; #{registerDateTo}
      </if>
      <if test="resourceState != null and resourceState.length() &gt; 0 and resourceState != '全部'">
        AND r.resource_state = #{resourceState}
      </if>
      <if test="orgId != null">
        AND a.org_id = #{orgId}
      </if>
    </where>
    ORDER BY r.id DESC
    <if test="page != null">
      LIMIT #{page.beginIndex},#{page.pageSize}
    </if>
  </select>
  <select id="querypublishCount" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceDataRegisterSearchModel" resultType="java.lang.Long">
    <if test="resourceName != null and resourceName.length() &gt; 0">
      <bind name="resourceName" value="'%' + _parameter.resourceName + '%'" />
    </if>

    SELECT COUNT(*),
    (SELECT catelog_name FROM resource_catelog rc WHERE rc.id = r.`catelog_theme`) themename
    FROM resource r
    JOIN publish_info p ON r.id = p.resource_id


    JOIN resource_microapp rd ON r.id = rd.id
    LEFT JOIN sector s ON rd.provider = s.id
    LEFT JOIN admin a ON a.id = r.created_by
    <where>
       p.publish_state is not null
      <if test="provider != null and provider.length() &gt; 0">
        s.id = #{provider}
      </if>
      <if test="resourceName != null and resourceName.length() &gt; 0">
        AND r.resource_name like #{resourceName}
      </if>
      <if test="registerDateFrom != null">
        AND r.register_date &gt;= #{registerDateFrom}
      </if>
      <if test="registerDateTo != null">
        AND r.register_date &lt; #{registerDateTo}
      </if>
      <if test="resourceState != null and resourceState.length() &gt; 0 and resourceState != '全部'">
        AND r.resource_state = #{resourceState}
      </if>
      <if test="orgId != null">
        AND a.org_id = #{orgId}
      </if>
    </where>
  </select>
  <select id="selectModelList" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceMicroappRegisterSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceMicroappRegisterListModel">
    <if test="resourceName != null and resourceName.length() &gt; 0">
      <bind name="resourceName" value="'%' + _parameter.resourceName + '%'" />
    </if>

    SELECT r.id, r.catelog_type, r.resource_name, r.resource_summary, r.resource_identity, r.resource_state, r.register_date,s.sector_name provider
     ,
     (SELECT catelog_name FROM resource_catelog rc WHERE rc.id = r.`catelog_theme`) themename
    FROM resource r
    JOIN resource_microapp rd ON r.id = rd.id
    LEFT JOIN sector s ON rd.provider = s.id
    LEFT JOIN publish_info pi ON pi.resource_id = r.id
    LEFT JOIN admin a ON a.id = r.created_by
    <where>
       r.resource_state = '审核通过' and  pi.publish_state is  null
      <if test="provider != null and provider.length() &gt; 0">
        and s.id = #{provider}
      </if>
      <if test="resourceName != null and resourceName.length() &gt; 0">
        AND r.resource_name like #{resourceName}
      </if>
      <if test="registerDateFrom != null">
        AND r.register_date &gt;= #{registerDateFrom}
      </if>
      <if test="registerDateTo != null">
        AND r.register_date &lt; #{registerDateTo}
      </if>
      <if test="resourceState != null and resourceState.length() &gt; 0 and resourceState != '全部'">
        AND r.resource_state = #{resourceState}
      </if>
      <if test="orgId != null">
        AND a.org_id = #{orgId}
      </if>
    </where>
    ORDER BY r.id DESC
    <if test="page != null">
      LIMIT #{page.beginIndex},#{page.pageSize}
    </if>
  </select>
  <select id="selectModelCount" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceDataRegisterSearchModel" resultType="java.lang.Long">
    <if test="resourceName != null and resourceName.length() &gt; 0">
      <bind name="resourceName" value="'%' + _parameter.resourceName + '%'" />
    </if>

    SELECT COUNT(*)
<!--     ,
     (SELECT catelog_name FROM resource_catelog rc WHERE rc.id = r.`catelog_theme`) themename-->
    FROM resource r
    JOIN resource_microapp rd ON r.id = rd.id
    LEFT JOIN sector s ON rd.provider = s.id
    LEFT JOIN publish_info pi ON pi.resource_id = r.id
    LEFT JOIN admin a ON a.id = r.created_by
    <where>
      r.resource_state = '审核通过' and pi.publish_state is  null
      <if test="provider != null and provider.length() &gt; 0">
        and s.id = #{provider}
      </if>
      <if test="resourceName != null and resourceName.length() &gt; 0">
        AND r.resource_name like #{resourceName}
      </if>
      <if test="registerDateFrom != null">
        AND r.register_date &gt;= #{registerDateFrom}
      </if>
      <if test="registerDateTo != null">
        AND r.register_date &lt; #{registerDateTo}
      </if>
      <if test="resourceState != null and resourceState.length() &gt; 0 and resourceState != '全部'">
        AND r.resource_state = #{resourceState}
      </if>
      <if test="orgId != null">
        AND a.org_id = #{orgId}
      </if>
    </where>
  </select>



  <select id="queryAllPublishApiList" parameterType="com.lightinit.hsdataplatform.model.admin.APIPublishSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.APIPublishListModel">
    <if test="providerName != null and providerName.length() &gt; 0">
      <bind name="providerName" value="'%' + _parameter.providerName + '%'" />
    </if>
    <if test="resourceName != null and resourceName.length() &gt; 0">
      <bind name="resourceName" value="'%' + _parameter.resourceName + '%'" />
    </if>
  SELECT r.id,r.resource_name,r.register_date,r.resource_summary,r.resource_identity,r.catelog_theme,
  pi.publish_state,pi.id publishInfoId,r.out_id_1 outId1,r.out_id_2 outId2,
  s.`sector_name` providerName
  FROM resource r
  JOIN resource_api ra
  ON r.id = ra.id
  LEFT JOIN publish_info pi
  ON pi.resource_id = r.id
  left join sector s
  on s.id = ra.`provider`
  LEFT JOIN  admin a
  ON a.id = r.created_by
  <where>
    pi.publish_state is not null
    <if test="providerName != null and providerName.length() &gt; 0">
     AND s.sector_name like #{providerName}
    </if>
    <if test="resourceName != null and resourceName.length() &gt; 0">
      AND r.resource_name like #{resourceName}
    </if>
    <if test="registerAPIFrom != null">
      AND r.register_date &gt;= #{registerAPIFrom}
    </if>
    <if test="registerAPITo != null">
      AND r.register_date &lt; #{registerAPITo}
    </if>
    <if test="publishState != null and publishState.length() &gt; 0">
      AND pi.publish_state = #{publishState}
    </if>
    <if test="orgId != null">
      AND a.org_id = #{orgId}
    </if>
  </where>
  ORDER BY r.id DESC
  <if test="page != null">
    LIMIT #{page.beginIndex},#{page.pageSize}
  </if>

</select>
  <select id="queryAllPublishApiCount" parameterType="com.lightinit.hsdataplatform.model.admin.APIPublishSearchModel" resultType="java.lang.Long">
    <if test="providerName != null and providerName.length() &gt; 0">
      <bind name="providerName" value="'%' + _parameter.providerName + '%'" />
    </if>
    <if test="resourceName != null and resourceName.length() &gt; 0">
      <bind name="resourceName" value="'%' + _parameter.resourceName + '%'" />
    </if>
    SELECT count(*)
    FROM resource r
    JOIN resource_api ra
    ON r.id = ra.id
    LEFT JOIN publish_info pi
    ON pi.resource_id = r.id
    left join sector s
    on s.id = ra.`provider`
    LEFT JOIN  admin a
    ON a.id = r.created_by
    <where>
      pi.publish_state is not null
      <if test="providerName != null and providerName.length() &gt; 0">
        AND s.sector_name like #{providerName}
      </if>
      <if test="resourceName != null and resourceName.length() &gt; 0">
        AND r.resource_name like #{resourceName}
      </if>
      <if test="registerAPIFrom != null">
        AND r.register_date &gt;= #{registerAPIFrom}
      </if>
      <if test="registerAPITo != null">
        AND r.register_date &lt; #{registerAPITo}
      </if>
      <if test="publishState != null and publishState.length() &gt; 0">
        AND pi.publish_state = #{publishState}
      </if>
      <if test="orgId != null">
        AND a.org_id = #{orgId}
      </if>
    </where>
  </select>
  <select id="queryPublishList" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceAPIRegisterSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceAPIRegisterListModel">
    <if test="resourceName != null and resourceName.length() &gt; 0">
      <bind name="resourceName" value="'%' + _parameter.resourceName + '%'" />
    </if>
    <if test="providerName != null and providerName.length() &gt; 0">
      <bind name="providerName" value="'%' + _parameter.providerName + '%'" />
    </if>
    SELECT r.id,r.`catelog_type`,r.`resource_name`,r.`resource_identity`,
    r.`resource_summary`,s.`sector_name` providerName,r.`register_date`,r.`resource_state`
    FROM resource r
    JOIN resource_api ra ON r.id = ra.id
    LEFT JOIN sector s ON ra.provider = s.id
    LEFT JOIN publish_info pi ON pi.resource_id = r.id
    <where>
      pi.publish_state is null
      <if test="providerName != null and providerName.length() &gt; 0">
       AND s.sector_name like #{providerName}
      </if>
      <if test="resourceName != null and resourceName.length() &gt; 0">
        AND r.resource_name like #{resourceName}
      </if>
      <if test="registerAPIFrom != null">
        AND r.register_date &gt;= #{registerAPIFrom}
      </if>
      <if test="registerAPITo != null">
        AND r.register_date &lt; #{registerAPITo}
      </if>
      <if test="resourceState != null and resourceState.length() &gt; 0">
        AND r.resource_state = #{resourceState}
      </if>
      <if test="orgId != null ">
        AND a.org_id = #{orgId}
      </if>
    </where>
    ORDER BY r.id DESC
    <if test="page != null">
      LIMIT #{page.beginIndex},#{page.pageSize}
    </if>
  </select>
  <select id="queryPublishCount" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceAPIRegisterSearchModel" resultType="java.lang.Long">
    <if test="resourceName != null and resourceName.length() &gt; 0">
      <bind name="resourceName" value="'%' + _parameter.resourceName + '%'" />
    </if>
    <if test="providerName != null and providerName.length() &gt; 0">
      <bind name="providerName" value="'%' + _parameter.providerName + '%'" />
    </if>
    SELECT count(*)
    FROM resource r
    JOIN resource_api ra ON r.id = ra.id
    LEFT JOIN sector s ON ra.provider = s.id
    LEFT JOIN publish_info pi ON pi.resource_id = r.id
    <where>
      pi.publish_state is null
      <if test="providerName != null and providerName.length() &gt; 0">
       AND s.sector_name LIKE #{providerName}
      </if>
      <if test="resourceName != null and resourceName.length() &gt; 0">
        AND r.resource_name like #{resourceName}
      </if>
      <if test="registerAPIFrom != null">
        AND r.register_date &gt;= #{registerAPIFrom}
      </if>
      <if test="registerAPITo != null">
        AND r.register_date &lt; #{registerAPITo}
      </if>
      <if test="resourceState != null and resourceState.length() &gt; 0">
        AND r.resource_state = #{resourceState}
      </if>
      <if test="orgId != null ">
        AND a.org_id = #{orgId}
      </if>
    </where>
  </select>
  <select id="querypublishAduitList" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceMicroappRegisterSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.ResourceMicroappRegisterListModel">
    <if test="resourceName != null and resourceName.length() &gt; 0">
      <bind name="resourceName" value="'%' + _parameter.resourceName + '%'" />
    </if>

    SELECT r.id, r.catelog_type, r.resource_name, r.resource_summary, r.resource_identity, p.publish_state, r.register_date,s.sector_name provider,
    (SELECT catelog_name FROM resource_catelog rc WHERE rc.id = r.`catelog_theme`) themename
    FROM resource r
    JOIN resource_microapp rd ON r.id = rd.id
    LEFT JOIN sector s ON rd.provider = s.id
   join publish_info p on r.id = p.resource_id
      LEFT JOIN  admin a
      ON a.id = r.created_by
    <where>
      p.publish_state="审核中"
      <if test="provider != null and provider.length() &gt; 0">
        and s.id = #{provider}
      </if>
      <if test="resourceName != null and resourceName.length() &gt; 0">
        AND r.resource_name like #{resourceName}
      </if>
      <if test="registerDateFrom != null">
        AND r.register_date &gt;= #{registerDateFrom}
      </if>
      <if test="registerDateTo != null">
        AND r.register_date &lt; #{registerDateTo}
      </if>
      <if test="resourceState != null and resourceState.length() &gt; 0 and resourceState != '全部'">
        AND r.resource_state = #{resourceState}
      </if>
      <if test="orgId != null ">
      AND a.org_id = #{orgId}
    </if>
    </where>
    ORDER BY r.id DESC
    <if test="page != null">
      LIMIT #{page.beginIndex},#{page.pageSize}
    </if>
  </select>
  <select id="querypublishAduitCount" parameterType="com.lightinit.hsdataplatform.model.admin.ResourceMicroappRegisterSearchModel" resultType="java.lang.Long">
    <if test="resourceName != null and resourceName.length() &gt; 0">
      <bind name="resourceName" value="'%' + _parameter.resourceName + '%'" />
    </if>

    SELECT COUNT(*)
    <!--,
    (SELECT catelog_name FROM resource_catelog rc WHERE rc.id = r.`catelog_theme`) themename-->
    FROM resource r
    JOIN resource_microapp rd ON r.id = rd.id
    LEFT JOIN sector s ON rd.provider = s.id
   join publish_info p on r.id = p.resource_id
      LEFT JOIN  admin a
      ON a.id = r.created_by
    <where>
      p.publish_state="审核中"
      <if test="provider != null and provider.length() &gt; 0">
        and s.id = #{provider}
      </if>
      <if test="resourceName != null and resourceName.length() &gt; 0">
        AND r.resource_name like #{resourceName}
      </if>
      <if test="registerDateFrom != null">
        AND r.register_date &gt;= #{registerDateFrom}
      </if>
      <if test="registerDateTo != null">
        AND r.register_date &lt; #{registerDateTo}
      </if>
      <if test="resourceState != null and resourceState.length() &gt; 0 and resourceState != '全部'">
        AND r.resource_state = #{resourceState}
      </if>
      <if test="orgId != null ">
        AND a.org_id = #{orgId}
      </if>
    </where>
  </select>
  <select id="selectByResourceId" parameterType="java.lang.Long" resultType="com.lightinit.hsdataplatform.entity.PublishInfoWithBLOBs">
    select
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from publish_info
    where resource_id = #{id,jdbcType=BIGINT}
  </select>

  <select id="queryList" 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 pu.id,r.resource_name,r.resource_summary,s.sector_name,pu.publish_state,pu.created_at FROM publish_info pu
    INNER JOIN  resource r ON pu.resource_id=r.id
    INNER JOIN resource_data rd ON r.id=rd.id
    LEFT JOIN sector s ON rd.belong_to=s.id
    <if test="userId !=null">
      left join admin a on a.org_id=s.id
    </if>
    <where>
      <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>
      <if test="createdAt !=null">
        and Date(pu.created_at) = #{createdAt}
      </if>
      <if test="dicDataPublishState !=null and dicDataPublishState !=''">
        and pu.publish_state=#{dicDataPublishState}
      </if>
    </where>
    ORDER BY pu.created_at DESC
    <if test="page !=null">
      LIMIT ${page.beginIndex},${page.pageSize}
    </if>
  </select>

  <select id="queryListCount" 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 publish_info pu
    INNER JOIN  resource r ON pu.resource_id=r.id
    INNER JOIN resource_data rd ON r.id=rd.id
    LEFT JOIN sector s ON rd.belong_to=s.id
    <if test="userId !=null">
      left join admin a on a.org_id=s.id
    </if>
    <where>
      <if test="userId !=null">
        and a.id=#{userId}
      </if>
      <if test="resourceName !=null and resourceName !=''">
        r.resource_name like #{resourceNameLike}
      </if>
      <if test="sectorName !=null and sectorName !=''">
        and s.sector_name like #{sectorNameLike}
      </if>
      <if test="createdAt !=null">
        and Date(pu.created_at) = #{createdAt}
      </if>
      <if test="dicDataPublishState !=null and dicDataPublishState !=''">
        and pu.publish_state=#{dicDataPublishState}
      </if>
    </where>
  </select>
  <select id="queryDataPublishNotAuditList" 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 pu.id,r.resource_name,r.resource_summary,s.sector_name,pu.publish_state,pu.created_at FROM publish_info pu
    INNER JOIN  resource r ON pu.resource_id=r.id
    INNER JOIN resource_data rd ON r.id=rd.id
    LEFT JOIN sector s ON rd.belong_to=s.id
    <where>
      pu.audit_result is NULL and pu.publish_state = '审核中'
      <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>
      <if test="createdAt !=null">
        and pu.created_at &gt;= #{createdAt}
      </if>
    </where>
    order by pu.created_at DESC
    <if test="page !=null">
      LIMIT ${page.beginIndex},${page.pageSize}
    </if>
  </select>

  <select id="queryDataPublishNotAuditCount" 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 publish_info pu
    INNER JOIN  resource r ON pu.resource_id=r.id
    INNER JOIN resource_data rd ON r.id=rd.id
    LEFT JOIN sector s ON rd.belong_to=s.id
    <where>
      pu.audit_result is NULL and pu.publish_state = '审核中'
      <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>
      <if test="createdAt !=null">
        and pu.created_at &gt;= #{createdAt}
      </if>
    </where>
  </select>

  <!--sun:-->
  <update id="updateByPrimaryKeySelectiveExcludResourceId" parameterType="com.lightinit.hsdataplatform.entity.PublishInfoWithBLOBs">
    update publish_info
    <set>
      <if test="publishState != null">
        publish_state = #{publishState,jdbcType=VARCHAR},
      </if>
      <if test="dataTag != null">
        data_tag = #{dataTag,jdbcType=VARCHAR},
      </if>
      <if test="publishChannel != null">
        publish_channel = #{publishChannel,jdbcType=VARCHAR},
      </if>
        audited_by = #{auditedBy,jdbcType=BIGINT},
        audited_at = #{auditedAt,jdbcType=TIMESTAMP},
        audit_result = #{auditResult,jdbcType=VARCHAR},
        audit_opinion = #{auditOpinion,jdbcType=VARCHAR},
      <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="resourceImg != null">
        resource_img = #{resourceImg,jdbcType=LONGVARCHAR},
      </if>
      <if test="shareCondition != null">
        share_condition = #{shareCondition,jdbcType=LONGVARCHAR},
      </if>
      <if test="openCondition != null">
        open_condition = #{openCondition,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>

  <select id="resourceList" parameterType="com.lightinit.hsdataplatform.model.admin.ContractResourceSearchModel" resultType="com.lightinit.hsdataplatform.model.admin.ContractResourceListModel">
        select pi.id publishInfoId,r.resource_name,r.resource_type,rc.catelog_name
        from resource r
        join publish_info pi
        on r.id = pi.resource_id
        LEFT JOIN resource_catelog rc
        ON rc.id = r.catelog_theme
        LEFT JOIN admin a
        ON a.id = r.created_by
        where pi.publish_state = #{publishState}
        and r.open_type is not NULL and r.`open_type` !=''
        and r.open_type != #{openType}
        <if test="orgId != null">
          AND a.org_id = #{orgId}
        </if>
        <if test="catelogTheme != null">
          AND r.catelog_theme = #{catelogTheme}
        </if>
        <if test="resourceType != null and resourceType != '' ">
          AND r.resource_type = #{resourceType}
        </if>
        <if test="page !=null">
          LIMIT ${page.beginIndex},${page.pageSize}
        </if>
  </select>

    <select id="resourceCount" parameterType="com.lightinit.hsdataplatform.model.admin.ContractResourceSearchModel" resultType="java.lang.Long">
        select count(*)
        from resource r
        join publish_info pi
        on r.id = pi.resource_id
        LEFT JOIN resource_catelog rc
        ON rc.id = r.catelog_theme
        LEFT JOIN admin a
        ON a.id = r.created_by
        where pi.publish_state = #{publishState}
        and r.open_type is not NULL and r.`open_type` !=''
        and r.open_type != #{openType}
      <if test="orgId != null">
        AND a.org_id = #{orgId}
      </if>
      <if test="catelogTheme != null">
        AND r.catelog_theme = #{catelogTheme}
      </if>
      <if test="resourceType != null and resourceType != '' ">
        AND r.resource_type = #{resourceType}
      </if>
    </select>



  <select id="getRolecodeByUserId" parameterType="long" resultType="string">
     select distinct(sr.rolecode)
      from admin a
      inner join admin_role ar on a.id=ar.userid
      inner join sentry_role sr on sr.id=ar.roleid
      where
      <if test="userId !=null">
        a.id=#{userId}
      </if>
      <if test="userId ==null">
        1=2
      </if>
  </select>

  <select id="getResourceByPublishInfoId" parameterType="java.lang.Long" resultType="com.lightinit.hsdataplatform.model.admin.ContractResourceResultModel">
      SELECT r.resource_type,r.resource_name,rc.catelog_name catelogName
      FROM publish_info pi
      LEFT JOIN  resource r
      ON pi.resource_id = r.id
      LEFT JOIN resource_catelog rc
      ON rc.id = r.catelog_theme
      WHERE pi.id = #{publishInfoId}
  </select>

    <delete id="deleteByResourceId" parameterType="java.lang.Long">
        delete from publish_info
        where resource_id = #{id,jdbcType=BIGINT}
    </delete>

    <update id="insertOutIdTwo">
       UPDATE publish_info set
       out_id_3  = #{outId},
        out_id_1= #{authId}
        WHERE id = #{id}
    </update>

  <update id="insertOutId">
    UPDATE publish_info set
    out_id_3  = #{outId}
    WHERE id = #{id}
  </update>
</mapper>