<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.skill.dao.impl.PcloudSkillGuideDaoImpl">
    <resultMap id="BaseResultMap" type="com.pcloud.book.skill.entity.PcloudSkillGuide">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="pcloud_skill_id" property="pcloudSkillId" jdbcType="BIGINT"/>
        <result column="guide_id" property="guideId" jdbcType="BIGINT"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id, pcloud_skill_id, guide_id, create_time
    </sql>

    <select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List"/>
        from pcloud_skill_guide
        where id = #{id,jdbcType=BIGINT}
    </select>

    <insert id="insert" parameterType="com.pcloud.book.skill.entity.PcloudSkillGuide" useGeneratedKeys="true" keyProperty="id">
        insert into pcloud_skill_guide
        <trim prefix="(" suffix=")" suffixOverrides=",">
            pcloud_skill_id,
            guide_id,
            create_time
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{pcloudSkillId,jdbcType=BIGINT},
            #{guideId,jdbcType=BIGINT},
            NOW()
        </trim>
    </insert>
    <insert id="batchInsert"  parameterType="com.pcloud.book.skill.entity.PcloudSkillGuide" useGeneratedKeys="true" keyProperty="id">
        insert into pcloud_skill_guide (
        pcloud_skill_id,
        guide_id,
        create_time
        ) values
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.pcloudSkillId,jdbcType=BIGINT},
            #{item.guideId,jdbcType=BIGINT},
            NOW()
            )
        </foreach>
    </insert>

    <delete id="deleteByPcloudSkillId" parameterType="long">
        delete from pcloud_skill_guide
        where pcloud_skill_id=#{pcloudSkillId}
    </delete>

    <select id="getListByPcloudSkillId" parameterType="long" resultMap="BaseResultMap">
        select <include refid="Base_Column_List"/>
        from pcloud_skill_guide
        where pcloud_skill_id=#{pcloudSkillId}
    </select>

    <select id="getListByPcloudSkillIds" parameterType="map" resultMap="BaseResultMap">
        select <include refid="Base_Column_List"/>
        from pcloud_skill_guide
        where pcloud_skill_id in
        <foreach collection="pcloudSkillIds" item="item" open="(" separator="," close=")">
            ${item}
        </foreach>
    </select>

</mapper>