diff --git a/src/main/java/com/book/demo/mapper/CartMapper.java b/src/main/java/com/book/demo/mapper/CartMapper.java index 3e07d40..8092989 100644 --- a/src/main/java/com/book/demo/mapper/CartMapper.java +++ b/src/main/java/com/book/demo/mapper/CartMapper.java @@ -1,18 +1,19 @@ package com.book.demo.mapper; import com.book.demo.entity.Cart; -import org.apache.ibatis.annotations.Delete; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; @Repository @Mapper public interface CartMapper { - @Select("select * from user_cart where id=#{id} and username=#{username}") - int insertItem(String username,int id); + @Insert("insert into user_cart values (#{username},#{bookname})") + int insertItem(String username,String bookname); @Delete("delete from user_cart where username=#{username}") void clearCart(String username); @Select("select * from user_cart where username=#{username}") Cart queryByName(String username); + @Update({"update user_cart set username=#{username}", "update user_cart set bookname=#{bookname}", "update user_cart set count=#{count}"}) + int updateCount(String username,String bookname,int count); + }