第九次作业

BookInfoMapper.xml

<?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.rabbiter.bms.mapper.BookInfoMapper">
  <resultMap id="BaseResultMap" type="com.rabbiter.bms.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="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from book_info
    where bookId = #{bookid,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from book_info
    where bookId = #{bookid,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.rabbiter.bms.model.BookInfo">
    insert into 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.rabbiter.bms.model.BookInfo">
    insert into 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.rabbiter.bms.model.BookInfo">
    update 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.rabbiter.bms.model.BookInfo">
    update 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_type where book_type.bookTypeId = book_info.bookTypeId) as bookTypeName
    from book_info
    limit #{begin}, #{size}
  </select>
  <select id="selectCount" resultType="int">
    select count(*) from book_info
  </select>
  <select id="selectCountBySearch" resultType="int">
    select count(*) from 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_type where book_type.bookTypeId = book_info.bookTypeId) as bookTypeName
    from 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>
  <select id="selectAll" resultMap="BaseResultMap">
    select bookId, bookName, bookAuthor,bookPrice, bookTypeId, bookDesc,isBorrowed, bookImg,
           (select bookTypeName from book_type where book_type.bookTypeId = book_info.bookTypeId) as bookTypeName
    from book_info
  </select>
  <select id="selectCountByType" resultType="int">
    select count(*) from 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_type where book_type.bookTypeId = book_info.bookTypeId) as bookTypeName
    from book_info
    <where>
      <if test="booktypeid != null and booktypeid != '' ">
        and bookTypeId = #{booktypeid}
      </if>
    </where>
    limit #{begin}, #{size}
  </select>
</mapper>

BookTypeMapper.xml

<?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.rabbiter.bms.mapper.BookTypeMapper">
  <resultMap id="BaseResultMap" type="com.rabbiter.bms.model.BookType">
    <id column="bookTypeId" jdbcType="INTEGER" property="booktypeid" />
    <result column="bookTypeName" jdbcType="VARCHAR" property="booktypename" />
    <result column="bookTypeDesc" jdbcType="VARCHAR" property="booktypedesc" />
  </resultMap>
  <sql id="Base_Column_List">
    bookTypeId, bookTypeName, bookTypeDesc
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from book_type
    where bookTypeId = #{booktypeid,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from book_type
    where bookTypeId = #{booktypeid,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.rabbiter.bms.model.BookType">
    insert into book_type (bookTypeId, bookTypeName, bookTypeDesc
      )
    values (#{booktypeid,jdbcType=INTEGER}, #{booktypename,jdbcType=VARCHAR}, #{booktypedesc,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.rabbiter.bms.model.BookType">
    insert into book_type
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="booktypeid != null">
        bookTypeId,
      </if>
      <if test="booktypename != null">
        bookTypeName,
      </if>
      <if test="booktypedesc != null">
        bookTypeDesc,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="booktypeid != null">
        #{booktypeid,jdbcType=INTEGER},
      </if>
      <if test="booktypename != null">
        #{booktypename,jdbcType=VARCHAR},
      </if>
      <if test="booktypedesc != null">
        #{booktypedesc,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.rabbiter.bms.model.BookType">
    update book_type
    <set>
      <if test="booktypename != null">
        bookTypeName = #{booktypename,jdbcType=VARCHAR},
      </if>
      <if test="booktypedesc != null">
        bookTypeDesc = #{booktypedesc,jdbcType=VARCHAR},
      </if>
    </set>
    where bookTypeId = #{booktypeid,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.rabbiter.bms.model.BookType">
    update book_type
    set bookTypeName = #{booktypename,jdbcType=VARCHAR},
      bookTypeDesc = #{booktypedesc,jdbcType=VARCHAR}
    where bookTypeId = #{booktypeid,jdbcType=INTEGER}
  </update>
  <select id="selectAllByLimit" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" />
    from book_type
    limit #{begin}, #{size}
  </select>
  <select id="selectCount" resultType="int">
    select count(*) from book_type
  </select>
  <select id="selectAll" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" />
    from book_type
  </select>
  <select id="selectCountBySearch" resultType="int">
    select count(*) from book_type
    <where>
      <if test="booktypename != null and booktypename != '' ">
        and bookTypeName like concat('%',#{booktypename},'%')
      </if>
    </where>
  </select>
  <select id="selectBySearch" resultMap="BaseResultMap">
    select bookTypeId, bookTypeName, bookTypeDesc
    from book_type
    <where>
      <if test="booktypename != null and booktypename != '' ">
        and bookTypeName like concat('%',#{booktypename},'%')
      </if>
    </where>
    limit #{begin}, #{size}
  </select>
</mapper>

BorrowMapper.xml

<?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.rabbiter.bms.mapper.BorrowMapper">
  <resultMap id="BaseResultMap" type="com.rabbiter.bms.model.Borrow">
    <id column="borrowId" jdbcType="INTEGER" property="borrowid" />
    <result column="userId" jdbcType="INTEGER" property="userid" />
    <result column="userName" jdbcType="INTEGER" property="username" />
    <result column="bookId" jdbcType="INTEGER" property="bookid" />
    <result column="bookName" jdbcType="INTEGER" property="bookname" />
    <result column="borrowTime" jdbcType="TIMESTAMP" property="borrowtime" />
    <result column="returnTime" jdbcType="TIMESTAMP" property="returntime" />
  </resultMap>
  <sql id="Base_Column_List">
    borrowId, userId, bookId, borrowTime, returnTime
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from borrow
    where borrowId = #{borrowid,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from borrow
    where borrowId = #{borrowid,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.rabbiter.bms.model.Borrow">
    insert into borrow (borrowId, userId, bookId, 
      borrowTime, returnTime)
    values (#{borrowid,jdbcType=INTEGER}, #{userid,jdbcType=INTEGER}, #{bookid,jdbcType=INTEGER}, 
      #{borrowtime,jdbcType=TIMESTAMP}, #{returntime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.rabbiter.bms.model.Borrow">
    insert into borrow
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="borrowid != null">
        borrowId,
      </if>
      <if test="userid != null">
        userId,
      </if>
      <if test="bookid != null">
        bookId,
      </if>
      <if test="borrowtime != null">
        borrowTime,
      </if>
      <if test="returntime != null">
        returnTime,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="borrowid != null">
        #{borrowid,jdbcType=INTEGER},
      </if>
      <if test="userid != null">
        #{userid,jdbcType=INTEGER},
      </if>
      <if test="bookid != null">
        #{bookid,jdbcType=INTEGER},
      </if>
      <if test="borrowtime != null">
        #{borrowtime,jdbcType=TIMESTAMP},
      </if>
      <if test="returntime != null">
        #{returntime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.rabbiter.bms.model.Borrow">
    update borrow
    <set>
      <if test="userid != null">
        userId = #{userid,jdbcType=INTEGER},
      </if>
      <if test="bookid != null">
        bookId = #{bookid,jdbcType=INTEGER},
      </if>
      <if test="borrowtime != null">
        borrowTime = #{borrowtime,jdbcType=TIMESTAMP},
      </if>
      <if test="returntime != null">
        returnTime = #{returntime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where borrowId = #{borrowid,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.rabbiter.bms.model.Borrow">
    update borrow
    set userId = #{userid,jdbcType=INTEGER},
      bookId = #{bookid,jdbcType=INTEGER},
      borrowTime = #{borrowtime,jdbcType=TIMESTAMP},
      returnTime = #{returntime,jdbcType=TIMESTAMP}
    where borrowId = #{borrowid,jdbcType=INTEGER}
  </update>
  <select id="selectAllByLimit" resultMap="BaseResultMap">
    select borrowId, userId, bookId, borrowTime, returnTime,
           (select userName from user where borrow.userId = user.userId) userName,
           (select bookName from book_info where borrow.bookId = book_info.bookId) bookName
    from borrow
    limit #{begin}, #{size}
  </select>
  <select id="selectCount" resultType="int">
    select count(*) from borrow
  </select>
  <select id="selectCountBySearch" resultType="int">
    select count(*)
    from borrow, user, book_info
    where borrow.userId = user.userId and borrow.bookId = book_info.bookId
    <if test="bookId != null and bookId != '' ">
      and borrow.bookId like concat('%',#{bookId},'%')
    </if>
    <if test="username != null and username != '' ">
      and userName like concat('%',#{username},'%')
    </if>
    <if test="bookname != null and bookname != '' ">
      and bookName like concat('%',#{bookname},'%')
    </if>
    <if test="userid != null and userid != '' ">
      and borrow.userId = #{userid}
    </if>
  </select>
  <select id="selectBySearch" resultMap="BaseResultMap">
    select borrowId, borrow.userId, borrow.bookId, borrowTime, returnTime, userName, bookName
    from borrow, user, book_info
    where borrow.userId = user.userId and borrow.bookId = book_info.bookId
    <if test="username != null and username != '' ">
      and userName like concat('%',#{username},'%')
    </if>
    <if test="bookname != null and bookname != '' ">
      and bookName like concat('%',#{bookname},'%')
    </if>
    <if test="userid != null and userid != '' ">
      and borrow.userId = #{userid}
    </if>
    limit #{begin}, #{size}
  </select>
  <select id="selectCountByReader" resultType="int">
    select count(*) from borrow
    where userId = #{userid}
  </select>
  <select id="selectAllByLimitByReader" resultMap="BaseResultMap">
    select borrowId, userId, bookId, borrowTime, returnTime,
           (select userName from user where borrow.userId = user.userId) userName,
           (select bookName from book_info where borrow.bookId = book_info.bookId) bookName
    from borrow
    where userId = #{userid}
    limit #{begin}, #{size}
  </select>
</mapper>

UserMapper.xml

<?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.rabbiter.bms.mapper.UserMapper">
  <resultMap id="BaseResultMap" type="com.rabbiter.bms.model.User">
    <id column="userId" jdbcType="INTEGER" property="userid" />
    <result column="userName" jdbcType="VARCHAR" property="username" />
    <result column="userPassword" jdbcType="VARCHAR" property="userpassword" />
    <result column="isAdmin" jdbcType="TINYINT" property="isadmin" />
  </resultMap>
  <sql id="Base_Column_List">
    userId, userName, userPassword, isAdmin
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from user
    where userId = #{userid,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from user
    where userId = #{userid,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.rabbiter.bms.model.User">
    insert into user (userId, userName, userPassword, 
      isAdmin)
    values (#{userid,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{userpassword,jdbcType=VARCHAR}, 
      #{isadmin,jdbcType=TINYINT})
  </insert>
  <insert id="insertSelective" parameterType="com.rabbiter.bms.model.User">
    insert into user
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="userid != null">
        userId,
      </if>
      <if test="username != null">
        userName,
      </if>
      <if test="userpassword != null">
        userPassword,
      </if>
      <if test="isadmin != null">
        isAdmin,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="userid != null">
        #{userid,jdbcType=INTEGER},
      </if>
      <if test="username != null">
        #{username,jdbcType=VARCHAR},
      </if>
      <if test="userpassword != null">
        #{userpassword,jdbcType=VARCHAR},
      </if>
      <if test="isadmin != null">
        #{isadmin,jdbcType=TINYINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.rabbiter.bms.model.User">
    update user
    <set>
      <if test="username != null">
        userName = #{username,jdbcType=VARCHAR},
      </if>
      <if test="userpassword != null">
        userPassword = #{userpassword,jdbcType=VARCHAR},
      </if>
      <if test="isadmin != null">
        isAdmin = #{isadmin,jdbcType=TINYINT},
      </if>
    </set>
    where userId = #{userid,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.rabbiter.bms.model.User">
    update user
    set userName = #{username,jdbcType=VARCHAR},
      userPassword = #{userpassword,jdbcType=VARCHAR},
      isAdmin = #{isadmin,jdbcType=TINYINT}
    where userId = #{userid,jdbcType=INTEGER}
  </update>
  <select id="selectByUsernameAndPasswordAndIsAdmin" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from user
    where userName = #{username}
      and userPassword = #{password}
      and isAdmin = #{isAdmin}
    limit 1
  </select>
  <select id="selectByUsername" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from user
    where userName = #{username}
    limit 1
  </select>
  <select id="selectAllByLimit" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" />
    from user
    limit #{begin}, #{size}
  </select>
  <select id="selectCount" resultType="int">
    select count(*) from user
  </select>
  <select id="selectAll" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" />
    from user
  </select>
  <select id="selectCountBySearch" resultType="int">
    select count(*) from user
    <where>
      <if test="username != null and username != '' ">
        and userName like concat('%',#{username},'%')
      </if>
    </where>
  </select>
  <select id="selectBySearch" resultMap="BaseResultMap">
    select userId, userName, userPassword, isAdmin
    from user
    <where>
      <if test="username != null and username != '' ">
        and userName like concat('%',#{username},'%')
      </if>
    </where>
    limit #{begin}, #{size}
  </select>
</mapper>

创建Git仓库

相关推荐
九鼎科技-Leo30 分钟前
什么是 WPF 中的依赖属性?有什么作用?
windows·c#·.net·wpf
qq_174482857531 分钟前
springboot基于微信小程序的旧衣回收系统的设计与实现
spring boot·后端·微信小程序
代码小鑫3 小时前
A043-基于Spring Boot的秒杀系统设计与实现
java·开发语言·数据库·spring boot·后端·spring·毕业设计
真心喜欢你吖3 小时前
SpringBoot与MongoDB深度整合及应用案例
java·spring boot·后端·mongodb·spring
Yang.993 小时前
基于Windows系统用C++做一个点名工具
c++·windows·sql·visual studio code·sqlite3
周全全3 小时前
Spring Boot + Vue 基于 RSA 的用户身份认证加密机制实现
java·vue.js·spring boot·安全·php
我不瘦但很逗3 小时前
Windows下使用DBeaver连接云数据库(MySQL)
数据库·windows
飞升不如收破烂~4 小时前
Spring boot常用注解和作用
java·spring boot·后端
计算机毕设源码qq-38365310414 小时前
(附项目源码)Java开发语言,215 springboot 大学生爱心互助代购网站,计算机毕设程序开发+文案(LW+PPT)
java·开发语言·spring boot·mysql·课程设计
ashane13144 小时前
Java list
java·windows·list