菜品统计
This commit is contained in:
@ -2,6 +2,9 @@ package cn.iocoder.yudao.module.system.api.dish;
|
||||
|
||||
import cn.iocoder.yudao.module.system.api.dish.dto.DishesRespDto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zt
|
||||
* @description <description class purpose>
|
||||
@ -13,4 +16,9 @@ public interface DishesApi {
|
||||
* @Description: 根据菜品id 获取菜品属性
|
||||
*/
|
||||
public DishesRespDto getDish(Long id);
|
||||
|
||||
/**
|
||||
* @Description: 根据菜品id 获取菜品名称
|
||||
*/
|
||||
public Map<Long,String> getDishName(List<Long> ids);
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import cn.iocoder.yudao.module.system.service.dishes.DishesService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 菜品营养 Service 接口
|
||||
@ -25,4 +28,9 @@ public class DishesApiImpl implements DishesApi {
|
||||
DishesDO dishes = dishesService.getDishes(id);
|
||||
return BeanUtils.toBean(dishes,DishesRespDto.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, String> getDishName(List<Long> ids) {
|
||||
return dishesService.getDishName(ids);
|
||||
}
|
||||
}
|
@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesSaveReqVO
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 菜品管理 Service 接口
|
||||
@ -54,4 +56,7 @@ public interface DishesService {
|
||||
*/
|
||||
PageResult<DishesDO> getDishesPage(DishesPageReqVO pageReqVO);
|
||||
|
||||
Map<Long,String> getDishName(List<Long> ids);
|
||||
|
||||
|
||||
}
|
@ -19,6 +19,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.dishes.DishesMapper;
|
||||
import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
|
||||
import cn.iocoder.yudao.module.system.service.dishesnutrition.DishesNutritionService;
|
||||
import cn.iocoder.yudao.module.system.service.dishesraw.DishesRawService;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -26,6 +27,8 @@ import org.springframework.validation.annotation.Validated;
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
@ -137,4 +140,10 @@ public class DishesServiceImpl implements DishesService {
|
||||
return dishesMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, String> getDishName(List<Long> ids) {
|
||||
List<DishesDO> dishesDOS = dishesMapper.selectList(Wrappers.<DishesDO>lambdaQuery().in(DishesDO::getId, ids));
|
||||
Map<Long, String> collect = dishesDOS.stream().collect(Collectors.toMap(DishesDO::getId, DishesDO::getDishesName));
|
||||
return collect;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user