1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
| <?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.zh.mapper.BookInfoMapper"> <resultMap id="BaseResultMap" type="com.zh.model.BookInfo"> <id column="bookId" jdbcType="INTEGER" property="bookid" /> <result column="bookName" jdbcType="VARCHAR" property="bookname" /> <result column="bookAuthor" jdbcType="VARCHAR" property="bookauthor" /> <result column="bookPrice" jdbcType="DECIMAL" property="bookprice" /> <result column="bookTypeId" jdbcType="INTEGER" property="booktypeid" /> <result column="bookTypeName" jdbcType="INTEGER" property="booktypename" /> <result column="bookDesc" jdbcType="VARCHAR" property="bookdesc" /> <result column="isBorrowed" jdbcType="TINYINT" property="isborrowed" /> <result column="bookImg" jdbcType="TINYINT" property="bookimg" /> </resultMap> <sql id="Base_Column_List"> bookId, bookName, bookAuthor, bookPrice, bookTypeId, bookDesc, isBorrowed, bookImg </sql>
<select id="selectCount" resultType="int"> select count(*) from book_manager.book_info </select>
<select id="selectAll" resultMap="BaseResultMap"> select bookId, bookName, bookAuthor,bookPrice, bookTypeId, bookDesc,isBorrowed, bookImg, (select bookTypeName from book_manager.book_type where book_manager.book_type.bookTypeId = book_manager.book_info.bookTypeId) as bookTypeName from book_manager.book_info </select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from book_manager.book_info where bookId = #{bookid,jdbcType=INTEGER} </select>
<select id="selectCountBySearch" resultType="int"> select count(*) from book_manager.book_info <where> <if test="bookname != null and bookname != '' ">and bookName like concat('%',#{bookname},'%')</if> <if test="bookauthor != null and bookauthor != '' ">and bookAuthor like concat('%',#{bookauthor},'%')</if> <if test="booktypeid != null and booktypeid != '' ">and bookTypeId = #{booktypeid}</if> </where> </select>
<select id="selectBySearch" resultMap="BaseResultMap"> select bookId, bookName, bookAuthor,bookPrice, bookTypeId, bookDesc,isBorrowed, bookImg, (select bookTypeName from book_manager.book_type where book_manager.book_type.bookTypeId = book_manager.book_info.bookTypeId) as bookTypeName from book_manager.book_info <where> <if test="bookname != null and bookname != '' ">and bookName like concat('%',#{bookname},'%')</if> <if test="bookauthor != null and bookauthor != '' ">and bookAuthor like concat('%',#{bookauthor},'%')</if> <if test="booktypeid != null and booktypeid != '' ">and bookTypeId = #{booktypeid}</if> </where> limit #{begin}, #{size} </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> delete from book_manager.book_info where bookId = #{bookid,jdbcType=INTEGER} </delete>
<insert id="insert" parameterType="com.zh.model.BookInfo"> insert into book_manager.book_info (bookId, bookName, bookAuthor, bookPrice, bookTypeId, bookDesc, isBorrowed, bookImg) values (#{bookid,jdbcType=INTEGER}, #{bookname,jdbcType=VARCHAR}, #{bookauthor,jdbcType=VARCHAR}, #{bookprice,jdbcType=DECIMAL}, #{booktypeid,jdbcType=INTEGER}, #{bookdesc,jdbcType=VARCHAR}, #{isborrowed,jdbcType=TINYINT}, #{bookimg,jdbcType=TINYINT}) </insert>
<insert id="insertSelective" parameterType="com.zh.model.BookInfo"> insert into book_manager.book_info <trim prefix="(" suffix=")" suffixOverrides=","> <if test="bookid != null">bookId,</if> <if test="bookname != null">bookName,</if> <if test="bookauthor != null">bookAuthor,</if> <if test="bookprice != null">bookPrice,</if> <if test="booktypeid != null">bookTypeId,</if> <if test="bookdesc != null">bookDesc,</if> <if test="isborrowed != null">isBorrowed,</if> <if test="bookimg != null">bookImg,</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="bookid != null">#{bookid,jdbcType=INTEGER},</if> <if test="bookname != null">#{bookname,jdbcType=VARCHAR},</if> <if test="bookauthor != null">#{bookauthor,jdbcType=VARCHAR},</if> <if test="bookprice != null">#{bookprice,jdbcType=DECIMAL},</if> <if test="booktypeid != null">#{booktypeid,jdbcType=INTEGER},</if> <if test="bookdesc != null">#{bookdesc,jdbcType=VARCHAR},</if> <if test="isborrowed != null">#{isborrowed,jdbcType=TINYINT},</if> <if test="bookimg != null">#{bookimg,jdbcType=TINYINT},</if> </trim> </insert>
<update id="updateByPrimaryKeySelective" parameterType="com.zh.model.BookInfo"> update book_manager.book_info <set> <if test="bookname != null">bookName = #{bookname,jdbcType=VARCHAR},</if> <if test="bookauthor != null">bookAuthor = #{bookauthor,jdbcType=VARCHAR},</if> <if test="bookprice != null">bookPrice = #{bookprice,jdbcType=DECIMAL},</if> <if test="booktypeid != null">bookTypeId = #{booktypeid,jdbcType=INTEGER},</if> <if test="bookdesc != null">bookDesc = #{bookdesc,jdbcType=VARCHAR},</if> <if test="isborrowed != null">isBorrowed = #{isborrowed,jdbcType=TINYINT},</if> <if test="bookimg != null">bookImg = #{bookimg,jdbcType=TINYINT},</if> </set> where bookId = #{bookid,jdbcType=INTEGER} </update>
<update id="updateByPrimaryKey" parameterType="com.zh.model.BookInfo"> update book_manager.book_info set bookName = #{bookname,jdbcType=VARCHAR}, bookAuthor = #{bookauthor,jdbcType=VARCHAR}, bookPrice = #{bookprice,jdbcType=DECIMAL}, bookTypeId = #{booktypeid,jdbcType=INTEGER}, bookDesc = #{bookdesc,jdbcType=VARCHAR}, isBorrowed = #{isborrowed,jdbcType=TINYINT}, bookImg = #{bookimg,jdbcType=TINYINT} where bookId = #{bookid,jdbcType=INTEGER} </update>
<select id="selectAllByLimit" resultMap="BaseResultMap"> select bookId, bookName, bookAuthor,bookPrice, bookTypeId, bookDesc,isBorrowed, bookImg, (select bookTypeName from book_manager.book_type where book_manager.book_type.bookTypeId = book_manager.book_info.bookTypeId) as bookTypeName from book_manager.book_info limit #{begin}, #{size} </select>
<select id="selectCountByType" resultType="int"> select count(*) from book_manager.book_info <where> <if test="booktypeid != null and booktypeid != '' ">and bookTypeId = #{booktypeid}</if> </where> </select>
<select id="selectByType" resultMap="BaseResultMap"> select bookId, bookName, bookAuthor,bookPrice, bookTypeId, bookDesc,isBorrowed, bookImg, (select bookTypeName from book_manager.book_type where book_manager.book_type.bookTypeId = book_manager.book_info.bookTypeId) as bookTypeName from book_manager.book_info <where> <if test="booktypeid != null and booktypeid != '' ">and bookTypeId = #{booktypeid}</if> </where> limit #{begin}, #{size} </select>
</mapper>
|