<?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.dxhy.auth.dao.ClientDao">
    <resultMap id="BaseResultMap" type="com.dxhy.auth.entity.ClientEntity">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="code" property="code" jdbcType="VARCHAR"/>
        <result column="secret" property="secret" jdbcType="VARCHAR"/>
        <result column="name" property="name" jdbcType="VARCHAR"/>
        <result column="locked" property="locked" jdbcType="CHAR"/>
        <result column="description" property="description" jdbcType="VARCHAR"/>
        <result column="crt_time" property="crtTime" jdbcType="TIMESTAMP"/>
        <result column="crt_user" property="crtUser" jdbcType="VARCHAR"/>
        <result column="crt_name" property="crtName" jdbcType="VARCHAR"/>
        <result column="crt_host" property="crtHost" jdbcType="VARCHAR"/>
        <result column="upd_time" property="updTime" jdbcType="TIMESTAMP"/>
        <result column="upd_user" property="updUser" jdbcType="VARCHAR"/>
        <result column="upd_name" property="updName" jdbcType="VARCHAR"/>
        <result column="upd_host" property="updHost" jdbcType="VARCHAR"/>
        <result column="attr1" property="attr1" jdbcType="VARCHAR"/>
        <result column="attr2" property="attr2" jdbcType="VARCHAR"/>
        <result column="attr3" property="attr3" jdbcType="VARCHAR"/>
        <result column="attr4" property="attr4" jdbcType="VARCHAR"/>
        <result column="attr5" property="attr5" jdbcType="VARCHAR"/>
        <result column="attr6" property="attr6" jdbcType="VARCHAR"/>
        <result column="attr7" property="attr7" jdbcType="VARCHAR"/>
        <result column="attr8" property="attr8" jdbcType="VARCHAR"/>
    </resultMap>

    <select id="selectAllowedClient" resultType="java.lang.String">
        SELECT client.CODE
        FROM auth_client client
                 INNER JOIN auth_client_service gcs ON gcs.client_id = client.id
        WHERE gcs.service_id = #{serviceId}
    </select>

    <select id="selectAuthorityServiceInfo" resultMap="BaseResultMap">
        SELECT client.*
        FROM auth_client client
                 INNER JOIN auth_client_service gcs ON gcs.service_id = client.id
        WHERE gcs.client_id = #{clientId}
    </select>
</mapper>
