Description or Example
# Bug修复
## 格式化日期的BUG
```yaml
spring:
jackson:
date-format: "yyyy-MM-dd hh:mm:ss"
```
> 必须自己写一个格式, 不能按照idea给的, 否则会抛异常
## 检索关键字的查询条件必须用括号
> 如果不用括号, `OR`就会暴露出来, 只要`OR`后面的成立了, 前面的都没关系, 不符合我们所需要的逻辑
# 核心代码
```java
@RequestMapping("/list")
// @RequiresPermissions("product:spuinfo:list")
public R list(@RequestParam Map<String, Object> params, SpuSearchVO spuSearchVO){
PageUtils page = spuInfoService.getSpuByVoWithKey(params, spuSearchVO);
return R.ok().put("page", page);
}
```
```java
@Override
public PageUtils getSpuByVoWithKey(Map<String, Object> params, SpuSearchVO spuSearchVO) {
LambdaQueryWrapper<SpuInfoEntity> queryWrapper = new LambdaQueryWrapper<>();
// 获取检索关键字
String key = (String) params.get("key");
// 获取相关的检索条件
Long catalogId = spuSearchVO.getCatelogId();
Long brandId = spuSearchVO.getBrandId();
Integer status = spuSearchVO.getStatus();
if (catalogId != null && catalogId != 0L) // 存在分类ID的查询条件
queryWrapper.eq(SpuInfoEntity::getCatalogId, catalogId);
if (brandId != null && brandId != 0L)
queryWrapper.eq(SpuInfoEntity::getBrandId, brandId);
if (status != null)
queryWrapper.eq(SpuInfoEntity::getPublishStatus, status);
if (StringUtils.isNotBlank(key))
queryWrapper.and(wrapper -> wrapper.eq(SpuInfoEntity::getId, key)
.or().like(SpuInfoEntity::getSpuName, key));
IPage<SpuInfoEntity> page = this.page(new Query<SpuInfoEntity>().getPage(params), queryWrapper);
return new PageUtils(page);
}
```
# 扩展知识
## 快速验证SQL语句是否存在错误的配置
```yaml
logging:
level:
com.junjie.bitmall.product: debug
```
> 可以输出SQL语句日志