You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.9 KiB

<?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}, score = #{score},
nums = #{nums}, updatetime = #{updatetime} 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>