|
|
@@ -6,8 +6,11 @@ import com.etotem.cfc.mapper.RecipeMapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import com.etotem.cfc.util.SortUtil;
|
|
|
+
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
@@ -17,11 +20,15 @@ public class RecipeService {
|
|
|
private RecipeMapper recipeMapper;
|
|
|
|
|
|
public List<Recipe> listByMealType(String mealType) {
|
|
|
- return recipeMapper.selectList(
|
|
|
- new LambdaQueryWrapper<Recipe>()
|
|
|
- .eq(Recipe::getStatus, "active")
|
|
|
- .eq(mealType != null, Recipe::getMealType, mealType)
|
|
|
- );
|
|
|
+ return listByMealType(mealType, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<Recipe> listByMealType(String mealType, List<Map<String, String>> sortSpecs) {
|
|
|
+ LambdaQueryWrapper<Recipe> wrapper = new LambdaQueryWrapper<Recipe>()
|
|
|
+ .eq(Recipe::getStatus, "active")
|
|
|
+ .eq(mealType != null, Recipe::getMealType, mealType);
|
|
|
+ SortUtil.applySort(wrapper, sortSpecs, null);
|
|
|
+ return recipeMapper.selectList(wrapper);
|
|
|
}
|
|
|
|
|
|
public Recipe getById(Long id) {
|