package com.miaxis.lighting.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.miaxis.lighting.domain.LightingCombination;
import com.miaxis.lighting.domain.LightingItem;
import com.miaxis.lighting.mapper.LightingCombinationMapper;
import com.miaxis.lighting.service.ILightingCombinationService;
import com.miaxis.lighting.service.ILightingItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * 灯光组合
Service业务层处理
 *
 * @author miaxis
 * @date 2022-03-21
 */
@Service
public class LightingCombinationServiceImpl extends ServiceImpl<LightingCombinationMapper, LightingCombination> implements ILightingCombinationService {
    @Autowired
    private LightingCombinationMapper lightingCombinationMapper;


    @Autowired
    private ILightingItemService lightingItemService;

    /**
     * 查询灯光组合
列表
     *
     * @param lightingCombination 灯光组合

     * @return 灯光组合

     */
    @Override
    public List<LightingCombination> selectLightingCombinationList(LightingCombination lightingCombination){
        return lightingCombinationMapper.selectLightingCombinationList(lightingCombination);
    }

    @Override
    public List<LightingItem> getLightingItemsById(Long id) {
        LightingCombination lightingCombination = this.getById(id);
        String itemId = lightingCombination.getItemId();
        String[] itemArr = itemId.split(",");
        return lightingItemService.listByIds(Arrays.asList(itemArr));
    }
}
