@GetMapping("/queryNewProduct")
public ProductDTO queryNewProduct(@RequestParam("type") String type) {
return opProductService.queryNewProduct(type);
}
@Override
public ProductDTO queryNewProduct(String type) {
//以下出现的第一个入参boolean condition表示该条件是否加入最后生成的sql中,
// 例如:query.like(StringUtils.isNotBlank(name), Entity::getName, name)
// .eq(age!=null && age >= 0, Entity::getAge, age)
OpProduct one = this.getOne(new LambdaQueryWrapper<OpProduct>()
.eq(OpProduct::getType, type)
.orderBy(true, false, OpProduct::getId)
.last("limit 1")
);
ProductDTO productDTO = BeanUtil.copyProperties(one, ProductDTO.class);
return productDTO;
}