<?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.pcloud.book.group.mapper.ResourcePageFolderMapper">
    <resultMap id="BaseResultMap" type="com.pcloud.book.group.entity.ResourcePageFolder">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="resource_page_id" jdbcType="BIGINT" property="resourcePageId"/>
        <result column="resource_page_column_id" jdbcType="BIGINT" property="resourcePageColumnId"/>
        <result column="title" jdbcType="VARCHAR" property="title"/>
        <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
        <result column="icon" jdbcType="VARCHAR" property="icon"/>
        <result column="jump_type" jdbcType="TINYINT" property="jumpType"/>
        <result column="link_url" jdbcType="VARCHAR" property="linkUrl"/>
        <result column="seq_num" jdbcType="INTEGER" property="seqNum"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="create_user" jdbcType="BIGINT" property="createUser"/>
    </resultMap>

    <resultMap id="resourcePageFolderVO" type="com.pcloud.book.group.vo.ResourcePageFolderVO" extends="BaseResultMap">
    </resultMap>

    <sql id="Base_Column_List">
        id,
        resource_page_id,
        resource_page_column_id,
        title,
        sub_title,
        icon,
        jump_type,
        link_url,
        seq_num,
        create_time,
        update_time,
        create_user
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from resource_page_folder
        where id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete
        from resource_page_folder
        where id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.pcloud.book.group.entity.ResourcePageFolder"
            useGeneratedKeys="true">
        insert into resource_page_folder (resource_page_id, resource_page_column_id,
                                          title, sub_title, icon, jump_type,
                                          link_url, seq_num, create_time,
                                          update_time, create_user)
        values (#{resourcePageId,jdbcType=BIGINT}, #{resourcePageColumnId,jdbcType=BIGINT},
                #{title,jdbcType=VARCHAR}, #{subTitle,jdbcType=VARCHAR}, #{icon,jdbcType=VARCHAR}, #{jumpType,jdbcType=TINYINT},
                #{linkUrl,jdbcType=VARCHAR}, #{seqNum,jdbcType=INTEGER}, now(),
                now(), #{createUser,jdbcType=BIGINT})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.pcloud.book.group.entity.ResourcePageFolder"
            useGeneratedKeys="true">
        insert into resource_page_folder
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="resourcePageId != null">
                resource_page_id,
            </if>
            <if test="resourcePageColumnId != null">
                resource_page_column_id,
            </if>
            <if test="title != null and title != ''">
                title,
            </if>
            <if test="subTitle != null and subTitle != ''">
                sub_title,
            </if>
            <if test="icon != null and icon != ''">
                icon,
            </if>
            <if test="jumpType != null">
                jump_type,
            </if>
            <if test="linkUrl != null and linkUrl != ''">
                link_url,
            </if>
            <if test="seqNum != null">
                seq_num,
            </if>
            create_time,
            update_time,
            <if test="createUser != null">
                create_user,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="resourcePageId != null">
                #{resourcePageId,jdbcType=BIGINT},
            </if>
            <if test="resourcePageColumnId != null">
                #{resourcePageColumnId,jdbcType=BIGINT},
            </if>
            <if test="title != null and title != ''">
                #{title,jdbcType=VARCHAR},
            </if>
            <if test="subTitle != null and subTitle != ''">
                #{subTitle,jdbcType=VARCHAR},
            </if>
            <if test="icon != null and icon != ''">
                #{icon,jdbcType=VARCHAR},
            </if>
            <if test="jumpType != null">
                #{jumpType,jdbcType=TINYINT},
            </if>
            <if test="linkUrl != null and linkUrl != ''">
                #{linkUrl,jdbcType=VARCHAR},
            </if>
            <if test="seqNum != null">
                #{seqNum,jdbcType=INTEGER},
            </if>
            now(),
            now(),
            <if test="createUser != null">
                #{createUser,jdbcType=BIGINT},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.group.entity.ResourcePageFolder">
        update resource_page_folder
        <set>
            <if test="resourcePageId != null">
                resource_page_id = #{resourcePageId,jdbcType=BIGINT},
            </if>
            <if test="resourcePageColumnId != null">
                resource_page_column_id = #{resourcePageColumnId,jdbcType=BIGINT},
            </if>
            <if test="title != null and title != ''">
                title = #{title,jdbcType=VARCHAR},
            </if>
            <if test="subTitle != null and subTitle != ''">
                sub_title = #{subTitle,jdbcType=VARCHAR},
            </if>
            <if test="icon != null and icon != ''">
                sub_title = #{icon,jdbcType=VARCHAR},
            </if>
            <if test="jumpType != null">
                jump_type = #{jumpType,jdbcType=TINYINT},
            </if>
            <if test="linkUrl != null and linkUrl != ''">
                link_url = #{linkUrl,jdbcType=VARCHAR},
            </if>
            <if test="seqNum != null">
                seq_num = #{seqNum,jdbcType=INTEGER},
            </if>
            update_time = now(),
            <if test="createUser != null">
                create_user = #{createUser,jdbcType=BIGINT},
            </if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.pcloud.book.group.entity.ResourcePageFolder">
        update resource_page_folder
        set resource_page_id        = #{resourcePageId,jdbcType=BIGINT},
            resource_page_column_id = #{resourcePageColumnId,jdbcType=BIGINT},
            title                   = #{title,jdbcType=VARCHAR},
            sub_title               = #{subTitle,jdbcType=VARCHAR},
            icon                    = #{icon,jdbcType=VARCHAR},
            jump_type               = #{jumpType,jdbcType=TINYINT},
            link_url                = #{linkUrl,jdbcType=VARCHAR},
            seq_num                 = #{seqNum,jdbcType=INTEGER},
            update_time             = now(),
            create_user             = #{createUser,jdbcType=BIGINT}
        where id = #{id,jdbcType=BIGINT}
    </update>

    <delete id="deleteByColumnIds">
        delete
        from resource_page_folder
        where resource_page_column_id in
        <foreach collection="columnIds" open="(" item="it" separator="," close=")">
            #{it,jdbcType=BIGINT}
        </foreach>
    </delete>

    <select id="selectByPrimaryKeys" resultMap="resourcePageFolderVO">
        select
        <include refid="Base_Column_List"/>
        from resource_page_folder
        where id in
        <foreach collection="ids" open="(" item="it" separator="," close=")">
            #{it,jdbcType=BIGINT}
        </foreach>
    </select>
</mapper>