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

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.ship.dto.RoomModelFloorNumDTO;
import com.yc.ship.module.resource.api.ship.dto.ShipRespDTO;
import com.yc.ship.module.resource.dal.dataobject.ship.ResourceShipDO;
import com.yc.ship.module.resource.dal.mysql.room.ResourceRoomMapper;
import com.yc.ship.module.resource.service.ship.ResourceShipService;
import org.springframework.stereotype.Service;

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

@Service
public class ShipApiImpl implements ShipApi {

    @Resource
    private ResourceShipService shipService;

    @Resource
    private ResourceRoomMapper roomMapper;
    @Override
    public Map<Long, ShipRespDTO> queryShip(List<Long> ids) {
        List<ResourceShipDO> list = shipService.getList(ids);
        List<ShipRespDTO> shipRespDTOS = BeanUtils.toBean(list, ShipRespDTO.class);
        Map<Long, ShipRespDTO> map = CollectionUtils.convertMap(shipRespDTOS, ShipRespDTO::getId);
        return map;
    }

    @Override
    public ShipRespDTO queryShip(Long id) {
        ResourceShipDO ship = shipService.getShip(id);
        return BeanUtils.toBean(ship, ShipRespDTO.class);
    }

    @Override
    public List<RoomModelFloorNumDTO> queryRoomModelFloorToNum(Long shipId) {
        return roomMapper.selectRoomModelFloorToNum(shipId);
    }
}
