forked from zhanghuanhao/LibrarySystem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f7f969
commit 8e28bff
Showing
3 changed files
with
45 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,27 @@ | ||
<?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.library.dao.LendDao"> | ||
|
||
private final static String RETURN_BOOK_ONE_SQL = "UPDATE lend_list SET back_date = ? WHERE book_id = ? AND | ||
reader_id = ? AND back_date is NULL"; | ||
private final static String RETURN_BOOK_TWO_SQL = "UPDATE book_info SET number = number + 1 WHERE book_id = ? "; | ||
private final static String LEND_BOOK_ONE_SQL = "INSERT INTO lend_list VALUES (NULL , ? , ? , ? , NULL)"; | ||
private final static String LEND_BOOK_TWO_SQL = "UPDATE book_info SET number = number - 1 WHERE book_id = ? "; | ||
private final static String LEND_LIST_SQL = "SELECT * FROM lend_list"; | ||
private final static String MY_LEND_LIST_SQL = "SELECT * FROM lend_list WHERE reader_id = ? "; | ||
private final static String DELETE_LEND_SQL = "DELETE FROM lend_list WHERE ser_num = ?"; | ||
|
||
<update id="returnBookOne" parameterType="com.library.bean.Book"> | ||
update lend_list set back_date = ? where book_id = ? AND reader_id = ? AND back_date is NULL"; | ||
<update id="returnBookOne"> | ||
update lend_list set back_date = sysdate() where book_id = #{book_id} | ||
and reader_id = #{reader_id} and back_date is null | ||
</update> | ||
|
||
|
||
<update id="editBook" parameterType="com.library.bean.Book"> | ||
update book_info set name=#{name}, author=#{author}, | ||
publish=#{publish}, ISBN=#{ISBN}, introduction=#{introduction}, | ||
language=#{language}, price=#{price}, pub_date=#{pub_date}, | ||
class_id=#{class_id}, number=#{number} where book_id=#{book_id} | ||
<update id="returnBookTwo" parameterType="long"> | ||
update book_info set number = number + 1 where book_id = #{book_id} | ||
</update> | ||
<select id="getAllBooks" resultType="com.library.bean.Book"> | ||
select * from book_info | ||
</select> | ||
<select id="queryBook" resultType="com.library.bean.Book" parameterType="String"> | ||
select * from book_info where name like #{search} | ||
or author like #{search} or introduction like #{search} | ||
</select> | ||
<select id="matchBook" resultType="int" parameterType="String"> | ||
select count(*) from book_info where name like #{search} | ||
or author like #{search} or introduction like #{search} | ||
<insert id="lendBookOne"> | ||
insert into lend_list values | ||
(null , #{book_id} , #{reader_id} , sysdate() , null) | ||
</insert> | ||
<update id="lendBookTwo" parameterType="long"> | ||
update book_info set number = number - 1 where book_id = #{book_id} | ||
</update> | ||
<select id="lendList" resultType="com.library.bean.Lend"> | ||
select * from lend_list | ||
</select> | ||
<select id="getBook" resultType="com.library.bean.Book" parameterType="long"> | ||
select * from book_info where book_id = #{book_id} | ||
<select id="myLendList" resultType="com.library.bean.Lend" parameterType="long"> | ||
select * from lend_list where reader_id = #{reader_id} | ||
</select> | ||
<delete id="deleteBook" parameterType="long"> | ||
delete from book_info where book_id = #{book_id} | ||
<delete id="deleteLend" parameterType="long"> | ||
delete from lend_list where ser_num = #{ser_num} | ||
</delete> | ||
</mapper> |