BookMapper.xml 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.sf.mapper.BookMapper">
  6. <!-- 图书的添加-->
  7. <insert id="addBook" parameterType="book">
  8. insert into book(book_id,book_name,author_name,price) values (#{bookId},#{bookName},#{authorName},#{price})
  9. </insert>
  10. <update id="updateBook" parameterType="book">
  11. update book set
  12. <if test="bookName != null">book_name = #{bookName},</if>
  13. <if test="authorName != null">author_name = #{authorName},</if>
  14. <if test="price != null">price = #{price}</if>
  15. where book_id = #{bookId}
  16. </update>
  17. <delete id="deleteBook" parameterType="int">
  18. delete from book where book_id = #{bookId}
  19. </delete>
  20. <select id="getBookByBookId" parameterType="int" resultType="book">
  21. select * from book where book_id = #{bookId}
  22. </select>
  23. <select id="getList" resultType="book">
  24. select * from book
  25. </select>
  26. <select id="getBookWithLike" resultType="book" parameterType="string">
  27. select * from book where book_name like concat('%',#{bookName},'%');
  28. </select>
  29. </mapper>