<?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.shanghaichengdi.ghjgitem.mapper.SysDatashareAuthNewMapper">

  <resultMap id="BaseResultMap" type="com.shanghaichengdi.ghjgitem.domain.SysDatashareAuthNew">
    <result column="USERID" jdbcType="DECIMAL" property="userid"/>
    <result column="SERVICEID" jdbcType="DECIMAL" property="serviceid"/>
    <result column="DEFAULTPARAMS" jdbcType="VARCHAR" property="defaultparams"/>
  </resultMap>

  <select id="selectUserServiceRelevancy"
    resultType="com.shanghaichengdi.ghjgitem.domain.SysDatashareAuthNew">
    select USERID,DEFAULTPARAMS from GHJG_BASICS.SYS_DATASHARE_AUTH_NEW
    where 1=1
    <if test="id != null and id != '' and serviceApi != null and serviceApi != ''">
      and USERID = #{id} and SERVICEID = (select ID from GHJG_BASICS.SYS_DATASHARE_SERVICE_NEW where
      NAME = #{serviceApi} and ISVALID = 1)
    </if>
    and rownum &lt;= 1 order by rownum asc
  </select>

  <sql id="Base_Column_List">
    USERID,SERVICEID,DEFAULTPARAMS
  </sql>

  <select id="selectAllFrequencyInfo" resultType="com.shanghaichengdi.ghjgitem.vo.FrequencyInfoVo">
    SELECT T.CLIENT || ':' || SERVICE.NAME AS userAndUrl,
           SERVICE.FREQUENCY_TIME          AS frequencyTime
    FROM GHJG_BASICS.SYS_DATASHARE_USER T
           LEFT JOIN GHJG_BASICS.SYS_DATASHARE_AUTH_new AU
                     ON T.ID = AU.USERID
           LEFT JOIN GHJG_BASICS.SYS_DATASHARE_SERVICE_new SERVICE
                     ON SERVICE.ID = AU.SERVICEID
  </select>

    <select id="selectFrequencyInfoByClient" resultType="com.shanghaichengdi.ghjgitem.vo.FrequencyInfoVo">
    SELECT T.CLIENT || ':' || SERVICE.NAME AS userAndUrl,
    SERVICE.FREQUENCY_TIME AS frequencyTime
    FROM GHJG_BASICS.SYS_DATASHARE_USER T
    LEFT JOIN GHJG_BASICS.SYS_DATASHARE_AUTH_new AU
    ON T.ID = AU.USERID
    LEFT JOIN GHJG_BASICS.SYS_DATASHARE_SERVICE_new SERVICE
    ON SERVICE.ID = AU.SERVICEID
    where T.CLIENT in
    <foreach item="item" collection="clientList" open="(" separator="," close=")">
      #{item}
    </foreach>
  </select>


</mapper>
