zmd50 4 years ago
parent 96aa0680c7
commit 5dcf891496

@ -15,7 +15,7 @@ public class BookController {
@Autowired
Result res;
//初始化获取图书信息
@ResponseBody
@GetMapping("/getallbooks")
public Result getAllBooks(){
@ -28,6 +28,7 @@ public class BookController {
else{
res.setCode(0);
res.setMsg("获取成功");
res.data.clear();
for (Book book : books) {
res.data.add(book);
}
@ -35,6 +36,7 @@ public class BookController {
return res;
}
//通过类别实现图书查找
@ResponseBody
@GetMapping("/getbooks")
public Result getAllBooksByKind(@RequestParam("kind")String kind){
@ -47,6 +49,7 @@ public class BookController {
else{
res.setCode(0);
res.setMsg("获取成功");
res.data.clear();
for (Book book : books) {
res.data.add(book);
}
@ -54,6 +57,7 @@ public class BookController {
return res;
}
//通过书名查找
@ResponseBody
@GetMapping("/searchbooks")
public Result getAllBooksBySearch(@RequestParam("bookname")String bookname){
@ -66,13 +70,14 @@ public class BookController {
else{
res.setCode(0);
res.setMsg("获取成功");
res.data.clear();
for (Book book : books) {
res.data.add(book);
}
}
return res;
}
/*
//添加型图书 图书表结构更改
@ResponseBody
@PostMapping("/addbook")
@ -106,5 +111,5 @@ public class BookController {
res.data=null;
return res;
}
*/
}

@ -15,13 +15,13 @@ public class CartController {
@Autowired
Result res;
/*
//添加商品进购物车 id为isbn
//添加商品进购物车 (用户名,书名为联合主键)>>连接插入价格为书的单价数量设为1
@ResponseBody
@GetMapping("/addintocart")
public Result AddBookIn(@RequestParam("username")String username,@RequestParam("id") int id){
public Result AddBookIn(@RequestParam("username")String username,@RequestParam("bookname") String bookname){
//把数量默认都设为1
int state=cartMapper.insertItem(username,id);
int state=cartMapper.insertItem(username,bookname);
if(state>0){
res.setCode(0);
res.setMsg("添加成功");
@ -51,5 +51,21 @@ public class CartController {
res.data=null;
return res;
}
*/
//更新购物车图书数量
@ResponseBody
@GetMapping("/updateItem")
public Result updateItem(@RequestParam("username")String username,@RequestParam("bookname")String bookname,@RequestParam("count")int count){
int state=cartMapper.updateCount(username,bookname,count);
if(state>0){
res.setCode(0);
res.setMsg("数量更新成功");
}
else{
res.setCode(-1);
res.setMsg("数量更新失败");
}
res.data=null;
return res;
}
}

@ -84,7 +84,7 @@ public class UserController {
}
return res;
}
/*
//用户管理>删除用户 注销账号
@ResponseBody
@GetMapping("/delete")
@ -107,6 +107,8 @@ public class UserController {
return res;
}
//用户管理》请求所有用户数据 》》》要求只查询用户类别为0的即用户
@ResponseBody
@GetMapping("/getalluser")
public Result getAllUser() {
@ -125,5 +127,5 @@ public class UserController {
return res;
}
*/
}

@ -15,15 +15,15 @@ import java.util.List;
public interface BookMapper {
@Select("select * from book_list where kind=#{kind}")
@Select("select * from book where kind=#{kind}")
Book[] getBooksByKind(String kind);
@Select("select * from book_list")
@Select("select * from book")
Book[] getAll();
@Select("select * from book_list where bookname=#{bookname}")
@Select("select * from book where bookname=#{bookname}")
Book[] searchBooks(String bookname);
@Delete("delete from book_list where bookname=#{bookname}")
@Delete("delete from book where bookname=#{bookname}")
int deleteByBookName(String bookname);
@Insert("insert into book_list values (#{bookname},#{price},#{kind})")
@Insert("insert into book values (#{bookname},#{price},#{kind})")
int Insert(Book book);
}

@ -17,8 +17,8 @@ public interface UserMapper {
@Insert("insert into user values(#{username},#{password},#{kind})")
int InsertUser(User user);
@Delete("delete from user_list where username=#{username}")
@Delete("delete from user where username=#{username}")
int deleteUserByName(String username);
@Select("select * from user_list")
@Select("select * from user")
User[] queryAllUser();
}

Loading…
Cancel
Save