@PostMapping("/showAll") public Result showAll(Integer page, Integer limit, BookPO book) { if ("".equals(book.getAuthor())) { book.setAuthor(null); } if ("".equals(book.getbTitle())) { book.setbTitle(null); } if ("".equals(book.getCate())) { book.setCate(null); } // integer类型,前台传值时为空,转化为null if (book.getAuthor() == null && book.getbTitle() == null && book.getCate() == null && book.getGoodNum() == null && book.getReadNum() == null) { Integer pages = (page - 1) * limit; List<BookPO> list = afBookService.showAll(pages, limit); for (int i = 0; i < list.size(); i++) { list.get(i).setbPicture(ToolsUtils.getImgPath(list.get(i).getbPicture())); } Integer count = afBookService.showAllItem().size(); return Result.success(Result.SUCCESS, count, list); } List<BookPO> list = afBookService.showScreen(book); for (int i = 0; i < list.size(); i++) { list.get(i).setbPicture(ToolsUtils.getImgPath(list.get(i).getbPicture())); } LoggerFactory.getLogger(AfBookController.class).info(list.toString()); return Result.success(list); }
时间: 2024-04-18 11:33:34 浏览: 12
这段代码是一个Spring Boot的控制器方法,用于处理POST请求并返回结果。
该方法接受三个参数:page、limit和book。其中,page和limit是用于分页查询的参数,book是一个BookPO对象,用于进行筛选条件。
在方法内部,先进行了一些条件判断和处理。如果book对象的作者、书名或分类属性为空字符串,则将其设置为null。这样做是为了方便后续的查询操作。
接下来,判断book对象的各个属性是否都为null。如果是,则表示没有任何筛选条件,直接调用afBookService的showAll方法进行分页查询,并将结果进行一些处理后返回。
如果book对象的某个属性不为null,则表示有筛选条件,调用afBookService的showScreen方法进行筛选查询,并将结果进行处理后返回。
最后,通过日志记录器将查询结果打印出来,并返回结果对象Result.success(list)。
相关问题
Constant.twoInteger.equals
The method `Constant.twoInteger.equals` is not valid Java syntax. In order to check whether two integers are equal, you can simply use the `==` operator. For example:
```
int a = 5;
int b = 5;
if (a == b) {
System.out.println("a and b are equal");
}
```
Alternatively, you can use the `equals` method if you convert the integers to `Integer` objects using autoboxing. For example:
```
Integer a = 5;
Integer b = 5;
if (a.equals(b)) {
System.out.println("a and b are equal");
}
```
However, it is generally recommended to use `==` when comparing primitive types like `int`.
integer.equals
Integer.equals 是 Java 中 Integer 类的一个方法,用于比较两个整型数是否相等。如果两个 Integer 对象的值相等,则返回 true,否则返回 false。需要注意的是,如果使用“==”运算符比较 Integer 对象,比较的是对象的引用地址,而不是对象的值。因此,应该使用 equals 方法来比较 Integer 对象的值是否相等。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)