package com.elephant.framework.galaxy.aroad.module.emergency.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.elephant.framework.galaxy.aroad.module.emergency.dto.EquipmentCoordinateDto;
import com.elephant.framework.galaxy.aroad.module.emergency.dto.TeamEquipmentInfoDto;
import com.elephant.framework.galaxy.aroad.module.emergency.entity.EmergencyEquipment;
import com.elephant.framework.galaxy.aroad.module.emergency.mapper.EmergencyEquipmentMapper;
import com.elephant.framework.galaxy.aroad.module.emergency.service.EmergencyEquipmentService;
import org.apache.ibatis.annotations.Param;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 应急处置装备
 *
 * @author songwenjie
 * @date 2019-03-21 14:50:19
 */
@Service
public class EmergencyEquipmentServiceImpl extends ServiceImpl<EmergencyEquipmentMapper, EmergencyEquipment> implements EmergencyEquipmentService {
    public IPage<EmergencyEquipment> getEmergencyEquipmentPage(Page<EmergencyEquipment> page, @Param("text") String text) {
        return baseMapper.getEmergencyEquipmentPage(page, text);
    }

    /**
     * @Description: 通过id获取应急队伍的坐标信息
     * @Param: []
     * @return: java.util.List<com.elephant.framework.galaxy.aroad.module.emergency.dto.EquipmentCoordinateDto>
     * @Author: songwenjie
     * @Date: 2019/4/2
     */
    @Cacheable(value = "equipmentCoordinates")
    public List<EquipmentCoordinateDto> getCoordinates(String teamIds) {
        List<String> teamIdList = Arrays.asList(teamIds.split(","));
        return baseMapper.getCoordinates(teamIdList);
    }

    /**
     * @Description: 获取队伍列表
     * @Param:
     * @return:
     * @Author: XingYuyang
     * @Date: 2019-04-15 10:11:13
     */
    @Cacheable(value = "getTeamsE")
    public List<TeamEquipmentInfoDto> getTeams() {
        return baseMapper.getTeams();
    }
}
