Repository navigation
Expand file tree
/
Copy pathBook.xml
More file actions
49 lines (40 loc) · 1.84 KB
/
Copy pathBook.xml
File metadata and controls
49 lines (40 loc) · 1.84 KB
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
<?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.example.springboot.mapper.BookMapper">
<select id="listByCondition" resultType="com.example.springboot.entity.Book">
select * from book
<where>
<if test="name != null and name != ''">
name like concat('%', #{ name }, '%')
</if>
<if test="bookNo != null and bookNo != ''">
and book_no = #{bookNo}
</if>
</where>
order by id desc
</select>
<insert id="save">
insert into book(name, description, publish_date, author, publisher, category, book_no, cover, score, nums)
values(#{name}, #{description}, #{publishDate}, #{author}, #{publisher}, #{category}, #{bookNo}, #{cover}, #{score}, #{nums})
</insert>
<update id="updateById">
update book set name = #{name}, description = #{description}, publish_date = #{publishDate}, author = #{author}, publisher = #{publisher}, category = #{category}, book_no = #{bookNo}, cover = #{cover}, updatetime = #{updatetime}, score = #{score}, nums = #{nums} where id = #{id}
</update>
<update id="updateNumByNo">
update book set nums = nums + 1 where book_no = #{bookNo}
</update>
<delete id="deleteById">
delete from book where id = #{id}
</delete>
<select id="list" resultType="com.example.springboot.entity.Book">
select * from book order by id desc
</select>
<select id="getById" resultType="com.example.springboot.entity.Book">
select * from book where id = #{id}
</select>
<select id="getByNo" resultType="com.example.springboot.entity.Book">
select * from book where book_no = #{bookNo}
</select>
</mapper>