package com.yc.ship.module.resource.api.route;

import com.yc.ship.framework.common.util.collection.CollectionUtils;
import com.yc.ship.framework.common.util.object.BeanUtils;
import com.yc.ship.module.resource.api.route.dto.RouteRespDTO;
import com.yc.ship.module.resource.dal.dataobject.route.ResourceRouteDO;
import com.yc.ship.module.resource.service.route.ResourceRouteService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class RouteApiImpl implements RouteApi{

    @Resource
    private ResourceRouteService routeService;
    @Override
    public Map<Long, RouteRespDTO> queryRoute(List<Long> ids) {
        List<ResourceRouteDO> list = routeService.getList(ids);
        List<RouteRespDTO> routeRespDTOS = BeanUtils.toBean(list, RouteRespDTO.class);
        return CollectionUtils.convertMap(routeRespDTOS,RouteRespDTO::getId);
    }

    @Override
    public RouteRespDTO queryRouteById(Long id) {
        ResourceRouteDO resourceRouteDO = routeService.getById(id);
        return BeanUtils.toBean(resourceRouteDO, RouteRespDTO.class);
    }
}
