<?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.book.dao.impl.BookRaysClassifyDaoImpl">

    <resultMap type="com.pcloud.book.book.entity.BookRaysClassify" id="BookRaysClassifyMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="bookTemplateId" column="book_template_id" jdbcType="INTEGER"/>
        <result property="raysClassifyId" column="rays_classify_id" jdbcType="INTEGER"/>
    </resultMap>

    <select id="getClassifyIdByBookTemplateId" resultType="long" parameterType="long">
        select rays_classify_id from book.book_rays_classify where  book_template_id = #{bookTemplateId}
    </select>

    <!--新增所有列-->
    <insert id="insert" keyProperty="id" useGeneratedKeys="true">
        insert into book.book_rays_classify(book_template_id, rays_classify_id)
        values (#{bookTemplateId}, #{raysClassifyId})
    </insert>

    <!--通过主键修改数据-->
    <update id="update">
        update book.book_rays_classify
        <set>
            <if test="bookTemplateId != null">
                book_template_id = #{bookTemplateId},
            </if>
            <if test="raysClassifyId != null">
                rays_classify_id = #{raysClassifyId},
            </if>
        </set>
        where id = #{id}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        delete from book.book_rays_classify where id = #{id}
    </delete>

</mapper>