|
|
|
@ -23,7 +23,7 @@ public class BookController {
|
|
|
|
|
if(books.length<=0){
|
|
|
|
|
res.setCode(-1);
|
|
|
|
|
res.setMsg("当前系统没有书籍信息");
|
|
|
|
|
res.data=null;
|
|
|
|
|
res.data.clear();
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
res.setCode(0);
|
|
|
|
@ -40,19 +40,34 @@ public class BookController {
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@GetMapping("/getbooks")
|
|
|
|
|
public Result getAllBooksByKind(@RequestParam("kind")String kind){
|
|
|
|
|
Book []books=bookMapper.getBooksByKind(kind);
|
|
|
|
|
if(books.length<=0){
|
|
|
|
|
res.setCode(-1);
|
|
|
|
|
res.setMsg("当前系统没有此类别书籍信息");
|
|
|
|
|
res.data=null;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
res.setCode(0);
|
|
|
|
|
res.setMsg("获取成功");
|
|
|
|
|
res.data.clear();
|
|
|
|
|
for (Book book : books) {
|
|
|
|
|
res.data.add(book);
|
|
|
|
|
try {
|
|
|
|
|
System.out.println(kind);
|
|
|
|
|
if(kind.equals("推荐")){
|
|
|
|
|
Book []books=bookMapper.getAll();
|
|
|
|
|
res.setCode(0);
|
|
|
|
|
res.data.clear();
|
|
|
|
|
res.setMsg("获取成功");
|
|
|
|
|
for (Book book : books) {
|
|
|
|
|
res.data.add(book);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Book[] books = bookMapper.getBooksByKind(kind);
|
|
|
|
|
if (books.length <= 0) {
|
|
|
|
|
res.setCode(-1);
|
|
|
|
|
res.setMsg("当前系统没有此类别书籍信息");
|
|
|
|
|
res.data.clear();
|
|
|
|
|
} else {
|
|
|
|
|
res.setCode(0);
|
|
|
|
|
res.setMsg("获取成功");
|
|
|
|
|
res.data.clear();
|
|
|
|
|
for (Book book : books) {
|
|
|
|
|
res.data.add(book);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
@ -65,7 +80,7 @@ public class BookController {
|
|
|
|
|
if(books.length<=0){
|
|
|
|
|
res.setCode(-1);
|
|
|
|
|
res.setMsg("当前系统没有相关书籍信息");
|
|
|
|
|
res.data=null;
|
|
|
|
|
res.data.clear();
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
res.setCode(0);
|
|
|
|
@ -91,7 +106,7 @@ public class BookController {
|
|
|
|
|
res.setCode(-1);
|
|
|
|
|
res.setMsg("添加失败");
|
|
|
|
|
}
|
|
|
|
|
res.data=null;
|
|
|
|
|
res.data.clear();
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -108,7 +123,7 @@ public class BookController {
|
|
|
|
|
res.setCode(-1);
|
|
|
|
|
res.setMsg("删除失败");
|
|
|
|
|
}
|
|
|
|
|
res.data=null;
|
|
|
|
|
res.data.clear();
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|