电商系统 常用代码 MyBatis-Plus

查询object

Optional<Brand> brand = new LambdaQueryChainWrapper<>(baseMapper)
	.eq(Brand::getName, brandName)
	.oneOpt();

查询list

List<ProductAttributeValue> entities = new LambdaQueryChainWrapper<>(baseMapper)
	.eq(ProductAttributeValue::getProductId, 1)
	.list();

获取最大排序

private int getMaxSort(){
	List<Store> stores = new LambdaQueryChainWrapper<>(baseMapper)
		.orderByDesc(Store::getSort)
		.list();
	if (stores.size() <= 0) {
		return 1;
	}
	return stores.get(0).getSort() + 1;
}			
原文地址:https://www.cnblogs.com/guxingy/p/14209738.html