<?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.yonge.cooleshow.auth.dal.dao.SysOauthClientDetailsDao">

    <resultMap type="com.yonge.cooleshow.auth.api.entity.SysOauthClientDetails" id="SysOauthClientDetails">
        <result column="id_" property="id"/>
        <result column="resource_ids_" property="resourceIds"/>
        <result column="client_secret_" property="clientSecret"/>
        <result column="scope_" property="scope"/>
        <result column="authorized_grant_types_" property="authorizedGrantTypes"/>
        <result column="web_server_redirect_uri_" property="webServerRedirectUri"/>
        <result column="authorities_" property="authorities"/>
        <result column="access_token_validity_" property="accessTokenValidity"/>
        <result column="refresh_token_validity_" property="refreshTokenValidity"/>
        <result column="additional_information_" property="additionalInformation"/>
        <result column="autoapprove_" property="autoapprove"/>
    </resultMap>

    <!-- 根据主键查询一条记录 -->
    <select id="get" resultMap="SysOauthClientDetails">
		SELECT * FROM sys_oauth_client_details WHERE id_ = #{id}
	</select>

    <!-- 全查询 -->
    <select id="findAll" resultMap="SysOauthClientDetails">
		SELECT * FROM sys_oauth_client_details ORDER BY id_
	</select>

    <!-- 向数据库增加一条记录 -->
    <insert id="insert" parameterType="com.yonge.cooleshow.auth.api.entity.SysOauthClientDetails" useGeneratedKeys="true"
            keyColumn="id" keyProperty="id">
        <!--
        <selectKey resultClass="int" keyProperty="id" >
        SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
        </selectKey>
        -->
        INSERT INTO sys_oauth_client_details
        (id_,resource_ids_,client_secret_,scope_,authorized_grant_types_,web_server_redirect_uri_,authorities_,access_token_validity_,refresh_token_validity_,additional_information_,autoapprove_)
        VALUES(#{id},#{resourceIds},#{clientSecret},#{scope},#{authorizedGrantTypes},#{webServerRedirectUri},#{authorities},#{accessTokenValidity},#{refreshTokenValidity},#{additionalInformation},#{autoapprove})
    </insert>

    <!-- 根据主键查询一条记录 -->
    <update id="update" parameterType="com.yonge.cooleshow.auth.api.entity.SysOauthClientDetails">
        UPDATE sys_oauth_client_details
        <set>
            <if test="accessTokenValidity != null">
                access_token_validity_ = #{accessTokenValidity},
            </if>
            <if test="resourceIds != null">
                resource_ids_ = #{resourceIds},
            </if>
            <if test="refreshTokenValidity != null">
                refresh_token_validity_ = #{refreshTokenValidity},
            </if>
            <if test="additionalInformation != null">
                additional_information_ = #{additionalInformation},
            </if>
            <if test="clientSecret != null">
                client_secret_ = #{clientSecret},
            </if>
            <if test="webServerRedirectUri != null">
                web_server_redirect_uri_ = #{webServerRedirectUri},
            </if>
            <if test="authorizedGrantTypes != null">
                authorized_grant_types_ = #{authorizedGrantTypes},
            </if>
            <if test="authorities != null">
                authorities_ = #{authorities},
            </if>
            <if test="scope != null">
                scope_ = #{scope},
            </if>
            <if test="autoapprove != null">
                autoapprove_ = #{autoapprove},
            </if>
        </set>
        WHERE id_ = #{id}
    </update>

    <!-- 根据主键删除一条记录 -->
    <delete id="delete">
		DELETE FROM sys_oauth_client_details WHERE id_ = #{id}
	</delete>

    <!-- 分页查询 -->
    <select id="queryPage" resultMap="SysOauthClientDetails" parameterType="map">
        SELECT * FROM sys_oauth_client_details ORDER BY id_
        <include refid="global.limit"/>
    </select>

    <!-- 查询当前表的总记录数 -->
    <select id="queryCount" resultType="int">
		SELECT COUNT(*) FROM sys_oauth_client_details
	</select>
</mapper>
