<?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.hsdataportal.mapper.ResourceAuthMapper">
  <resultMap id="BaseResultMap" type="com.lightinit.hsdataportal.entity.ResourceAuth">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="platform_type" jdbcType="VARCHAR" property="platformType" />
    <result column="publish_info_id" jdbcType="BIGINT" property="publishInfoId" />
    <result column="publish_setting_id" jdbcType="BIGINT" property="publishSettingId" />
    <result column="auth_state" jdbcType="VARCHAR" property="authState" />
    <result column="applier" jdbcType="BIGINT" property="applier" />
    <result column="apply_time" jdbcType="TIMESTAMP" property="applyTime" />
    <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" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.lightinit.hsdataportal.entity.ResourceAuth">
    <result column="apply_reason" jdbcType="LONGVARCHAR" property="applyReason" />
  </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, platform_type, publish_info_id, publish_setting_id, auth_state, applier, apply_time, 
    audited_by, audited_at, audit_result, audit_opinion, created_at, created_by, deleted_at, 
    deleted_by
  </sql>
  <sql id="Blob_Column_List">
    apply_reason
  </sql>
  <select id="selectByExampleWithBLOBs" parameterType="com.lightinit.hsdataportal.entity.ResourceAuthExample" resultMap="ResultMapWithBLOBs">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from resource_auth
    <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.hsdataportal.entity.ResourceAuthExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from resource_auth
    <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 resource_auth
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from resource_auth
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.lightinit.hsdataportal.entity.ResourceAuthExample">
    delete from resource_auth
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.lightinit.hsdataportal.entity.ResourceAuth">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into resource_auth (platform_type, publish_info_id, publish_setting_id, 
      auth_state, applier, apply_time, 
      audited_by, audited_at, audit_result, 
      audit_opinion, created_at, created_by, 
      deleted_at, deleted_by, apply_reason
      )
    values (#{platformType,jdbcType=VARCHAR}, #{publishInfoId,jdbcType=BIGINT}, #{publishSettingId,jdbcType=BIGINT}, 
      #{authState,jdbcType=VARCHAR}, #{applier,jdbcType=BIGINT}, #{applyTime,jdbcType=TIMESTAMP}, 
      #{auditedBy,jdbcType=BIGINT}, #{auditedAt,jdbcType=TIMESTAMP}, #{auditResult,jdbcType=VARCHAR}, 
      #{auditOpinion,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}, 
      #{deletedAt,jdbcType=TIMESTAMP}, #{deletedBy,jdbcType=BIGINT}, #{applyReason,jdbcType=LONGVARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.lightinit.hsdataportal.entity.ResourceAuth">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into resource_auth
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="platformType != null">
        platform_type,
      </if>
      <if test="publishInfoId != null">
        publish_info_id,
      </if>
      <if test="publishSettingId != null">
        publish_setting_id,
      </if>
      <if test="authState != null">
        auth_state,
      </if>
      <if test="applier != null">
        applier,
      </if>
      <if test="applyTime != null">
        apply_time,
      </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="applyReason != null">
        apply_reason,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="platformType != null">
        #{platformType,jdbcType=VARCHAR},
      </if>
      <if test="publishInfoId != null">
        #{publishInfoId,jdbcType=BIGINT},
      </if>
      <if test="publishSettingId != null">
        #{publishSettingId,jdbcType=BIGINT},
      </if>
      <if test="authState != null">
        #{authState,jdbcType=VARCHAR},
      </if>
      <if test="applier != null">
        #{applier,jdbcType=BIGINT},
      </if>
      <if test="applyTime != null">
        #{applyTime,jdbcType=TIMESTAMP},
      </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="applyReason != null">
        #{applyReason,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.lightinit.hsdataportal.entity.ResourceAuthExample" resultType="java.lang.Long">
    select count(*) from resource_auth
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update resource_auth
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.platformType != null">
        platform_type = #{record.platformType,jdbcType=VARCHAR},
      </if>
      <if test="record.publishInfoId != null">
        publish_info_id = #{record.publishInfoId,jdbcType=BIGINT},
      </if>
      <if test="record.publishSettingId != null">
        publish_setting_id = #{record.publishSettingId,jdbcType=BIGINT},
      </if>
      <if test="record.authState != null">
        auth_state = #{record.authState,jdbcType=VARCHAR},
      </if>
      <if test="record.applier != null">
        applier = #{record.applier,jdbcType=BIGINT},
      </if>
      <if test="record.applyTime != null">
        apply_time = #{record.applyTime,jdbcType=TIMESTAMP},
      </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.applyReason != null">
        apply_reason = #{record.applyReason,jdbcType=LONGVARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExampleWithBLOBs" parameterType="map">
    update resource_auth
    set id = #{record.id,jdbcType=BIGINT},
      platform_type = #{record.platformType,jdbcType=VARCHAR},
      publish_info_id = #{record.publishInfoId,jdbcType=BIGINT},
      publish_setting_id = #{record.publishSettingId,jdbcType=BIGINT},
      auth_state = #{record.authState,jdbcType=VARCHAR},
      applier = #{record.applier,jdbcType=BIGINT},
      apply_time = #{record.applyTime,jdbcType=TIMESTAMP},
      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},
      apply_reason = #{record.applyReason,jdbcType=LONGVARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update resource_auth
    set id = #{record.id,jdbcType=BIGINT},
      platform_type = #{record.platformType,jdbcType=VARCHAR},
      publish_info_id = #{record.publishInfoId,jdbcType=BIGINT},
      publish_setting_id = #{record.publishSettingId,jdbcType=BIGINT},
      auth_state = #{record.authState,jdbcType=VARCHAR},
      applier = #{record.applier,jdbcType=BIGINT},
      apply_time = #{record.applyTime,jdbcType=TIMESTAMP},
      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}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.lightinit.hsdataportal.entity.ResourceAuth">
    update resource_auth
    <set>
      <if test="platformType != null">
        platform_type = #{platformType,jdbcType=VARCHAR},
      </if>
      <if test="publishInfoId != null">
        publish_info_id = #{publishInfoId,jdbcType=BIGINT},
      </if>
      <if test="publishSettingId != null">
        publish_setting_id = #{publishSettingId,jdbcType=BIGINT},
      </if>
      <if test="authState != null">
        auth_state = #{authState,jdbcType=VARCHAR},
      </if>
      <if test="applier != null">
        applier = #{applier,jdbcType=BIGINT},
      </if>
      <if test="applyTime != null">
        apply_time = #{applyTime,jdbcType=TIMESTAMP},
      </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="applyReason != null">
        apply_reason = #{applyReason,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.lightinit.hsdataportal.entity.ResourceAuth">
    update resource_auth
    set platform_type = #{platformType,jdbcType=VARCHAR},
      publish_info_id = #{publishInfoId,jdbcType=BIGINT},
      publish_setting_id = #{publishSettingId,jdbcType=BIGINT},
      auth_state = #{authState,jdbcType=VARCHAR},
      applier = #{applier,jdbcType=BIGINT},
      apply_time = #{applyTime,jdbcType=TIMESTAMP},
      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},
      apply_reason = #{applyReason,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.lightinit.hsdataportal.entity.ResourceAuth">
    update resource_auth
    set platform_type = #{platformType,jdbcType=VARCHAR},
      publish_info_id = #{publishInfoId,jdbcType=BIGINT},
      publish_setting_id = #{publishSettingId,jdbcType=BIGINT},
      auth_state = #{authState,jdbcType=VARCHAR},
      applier = #{applier,jdbcType=BIGINT},
      apply_time = #{applyTime,jdbcType=TIMESTAMP},
      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}
    where id = #{id,jdbcType=BIGINT}
  </update>

  <select id="applyList" parameterType="com.lightinit.hsdataportal.model.MyAPIApplySearchModel" resultType="com.lightinit.hsdataportal.model.MyAPIApplyListModel">
    select ra.id,r.resource_name,r.resource_summary,ra.apply_time,ra.auth_state,r.open_type,r.share_type,r.id resourceId,
    ra.publish_setting_id,ra.publish_info_id,ps.expiried_date
    from resource_auth ra
    join publish_info pi
    on pi.id = ra.`publish_info_id`
    join resource r
    on r.id = pi.`resource_id`
    LEFT JOIN publish_setting ps
    ON ps.id = ra.publish_setting_id
    <if test="dicPlatformType == '开放平台'.toString()">
      LEFT JOIN `user` u
      ON u.id = ra.applier
      WHERE u.id = #{followId} AND r.resource_type = #{resourceType}
    </if>
    <if test="dicPlatformType == '共享平台'.toString()">
      LEFT JOIN `admin` a
      ON a.id = ra.applier
      WHERE a.id = #{followId} AND r.resource_type = #{resourceType}
    </if>
    ORDER BY ra.id DESC
    <if test="page != null">
      LIMIT #{page.beginIndex},#{page.pageSize}
    </if>
  </select>

  <select id="applyCount" parameterType="com.lightinit.hsdataportal.model.MyAPIApplySearchModel" resultType="java.lang.Long">
    select count(*)
    from resource_auth ra
    join publish_info pi
    on pi.id = ra.`publish_info_id`
    join resource r
    on r.id = pi.`resource_id`
    <if test="dicPlatformType = '开放平台'">
      LEFT JOIN `user` u
      ON u.id = ra.applier
      WHERE u.id = #{followId} AND r.resource_type = #{resourceType}
    </if>
    <if test="dicPlatformType = '共享平台'">
      LEFT JOIN `admin` a
      ON a.id = ra.applier
      WHERE a.id = #{followId} AND r.resource_type = #{resourceType}
    </if>
  </select>
  <select id="selectMicroappApplyList" parameterType="com.lightinit.hsdataportal.model.MyMicroappApplySearchModel" resultType="com.lightinit.hsdataportal.model.MyMicroappApplyListModel">
    SELECT ra.id, r.`resource_name`,rm.`url`,ra.`apply_time`,ra.`audit_result`,r.`open_type`,o.`rest_times`,ra.publish_setting_id publishSettingId,rm.url,ra.auth_state,r.share_type,o.rest_times
    FROM `resource_auth` ra
    JOIN `publish_info` p ON ra.`publish_info_id` = p.`id`
    JOIN `resource`r ON r.id = p.`resource_id`
    JOIN `resource_microapp` rm ON r.`id`= rm.id
    LEFT JOIN order_goods o ON o.resource_auth_id= ra.id
    <if test="platformType == '开放平台'.toString()">
      LEFT JOIN `user` u
      ON u.id = ra.applier
    </if>
    <if test="platformType == '共享平台'.toString()">
      LEFT JOIN `admin` a
      ON a.id = ra.applier
    </if>
    <where>
      r.resource_type = #{resourceType}
      <if test="applyBy != null">
        AND ra.applier = #{applyBy}
      </if>
    </where>
    ORDER BY ra.id DESC
    <if test="page != null">
      LIMIT #{page.beginIndex},#{page.pageSize}
    </if>
  </select>

  <select id="selectMicroappApplyCount" parameterType="com.lightinit.hsdataportal.model.MyMicroappApplySearchModel" resultType="java.lang.Long">
    select count(*)
    FROM `resource_auth` ra
    JOIN `publish_info` p ON ra.`publish_info_id` = p.`id`
    JOIN `resource`r ON r.id = p.`resource_id`
    JOIN `resource_microapp` rm ON r.`id`= rm.id
    LEFT JOIN order_goods o ON o.resource_auth_id= ra.id
    <if test="platformType == '开放平台'.toString()">
      LEFT JOIN `user` u
      ON u.id = ra.applier
      WHERE r.resource_type = #{resourceType}
    </if>
    <if test="platformType == '共享平台'.toString()">
      LEFT JOIN `admin` a
      ON a.id = ra.applier
      WHERE r.resource_type = #{resourceType}
    </if>
  </select>
    <select id="selectMyDataOpenListModel" parameterType="com.lightinit.hsdataportal.model.ResourceAuthMapperDemo" resultType="com.lightinit.hsdataportal.model.MyDataShareListModel">
      SELECT
      DISTINCT(ra.id) AS resource_authId,
      r.id as resourceId,
      r.resource_name,
      r.resource_summary,
      s.sector_name,
      ra.apply_time,
      r.open_type,
      r.share_type,
      ra.auth_state,
      ra.applier,
      ra.platform_type,
      u.id               AS user_orAdminId,
      o.id               AS order_id,
      pu.id AS publish_infoId,
      ps.id AS publish_settingId,
      op.payment_result,
      og.charge_method,
      og.package_name,
      og.package_price,
      og.description,
      r.resource_summary,
      o.order_number,
      o.order_state,
      ra.audit_opinion,
      rd.demo_file,
      rd.data_file
      FROM resource_auth ra
      INNER JOIN publish_setting ps ON ps.id=ra.publish_setting_id
      INNER JOIN publish_info pu ON ps.publish_info_id = pu.id
      INNER JOIN resource r ON r.id = pu.resource_id
      INNER JOIN resource_data rd ON rd.id = r.id

      LEFT JOIN order_goods og ON og.resource_auth_id = ra.id
      LEFT JOIN orders o ON o.id = og.order_id
      LEFT JOIN order_payment op ON op.order_number = o.id
      INNER JOIN sector s ON rd.belong_to = s.id
      <if test="openType !=null and openType!=''">
      INNER JOIN USER u ON u.id = ra.applier and u.id=#{applierId}
      </if>
      <if test="shareType !=null and shareType!=''">
      INNER JOIN admin u ON u.id = ra.applier and u.id=#{applierId}
      </if>
      <if test="resourceAuthId != null">
            and ra.id=#{resourceAuthId}
        </if>
    </select>

    <!--sun:-->
    <!--<select id="selectMyDataShareListModel" parameterType="com.lightinit.hsdataportal.model.ResourceAuthMapperDemo" resultType="com.lightinit.hsdataportal.model.MyDataShareListModel">
        SELECT
        ra.id AS resource_authId,
        r.resource_name,
        r.resource_summary,
        s.sector_name,
        ra.apply_time,
        r.open_type,
        r.share_type,
        ra.auth_state,
        ra.applier,
        ra.platform_type,
        a.id               AS user_orAdminId,
        o.id               AS order_id,
        pu.id AS publish_infoId,
        ps.id AS publish_settingId,
        op.payment_result,
        og.charge_method,
        og.package_name,
        og.package_price,
        og.description,
        r.resource_summary
        FROM resource_auth ra
        INNER JOIN publish_info pu ON ra.publish_info_id = pu.id
        INNER JOIN resource r ON r.id = pu.resource_id
        INNER JOIN resource_data rd ON rd.id = r.id
        INNER JOIN sector s ON rd.belong_to = s.id
        INNER JOIN admin a ON a.id = ra.applier
        LEFT JOIN order_goods og ON og.resource_auth_id = pu.id/*四个left待修改为inner join*/
        LEFT JOIN orders o ON o.id = og.order_id
        LEFT JOIN order_payment op ON op.order_number = o.id
        LEFT JOIN publish_setting ps ON ps.publish_info_id=pu.id
        WHERE r.share_type !=#{shareOrOpenType} AND r.share_type IS NOT NULL AND r.resource_type=#{resourceType} AND ra.platform_type=#{platformType} AND ra.applier=#{applierId}
        <if test="resourceAuthId != null">
            and ra.id=#{resourceAuthId}
        </if>
    </select>-->

  <select id="selectResourceAuth" parameterType="com.lightinit.hsdataportal.entity.ResourceAuth" resultType="com.lightinit.hsdataportal.entity.ResourceAuth">
     SELECT ra.publish_setting_id FROM `resource_auth` ra
     <where>
       ra.publish_setting_id = #{publishSettingId}
       and ra.applier = ${applier}
     </where>
  </select>
</mapper>