package com.yuchen.saas.park.service.service.impl;

import com.yuchen.saas.park.api.entity.park.PmgBatParkFileRelevance;
import com.yuchen.saas.park.api.vo.park.PmgBatParkDictVo;
import com.yuchen.saas.park.service.mapper.PmgBatParkFileRelevanceMapper;
import com.yuchen.saas.park.service.service.PmgBatParkFileRelevanceService;
import org.apache.commons.lang.StringUtils;
import org.nest.springwrap.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 刘碧清
 * @date 2021/04/26 11:31
 */
@Service
public class PmgBatParkFileRelevanceServiceImpl extends BaseServiceImpl<PmgBatParkFileRelevanceMapper, PmgBatParkFileRelevance> implements PmgBatParkFileRelevanceService {
    @Override
    public List<PmgBatParkDictVo> getPmgBatParkDict(String dictValue) {
        List<PmgBatParkDictVo> parkDictList=new ArrayList<>();
        List<PmgBatParkDictVo> parkDicts=baseMapper.getPmgBatParkDict();
        if(StringUtils.isBlank(dictValue)){
            for(PmgBatParkDictVo parkDict : parkDicts.stream().filter(p->p.getDictValue().equals(dictValue)).collect(Collectors.toList())){
                parkDictList.addAll(parkDicts.stream().filter(p->p.getParentId().equals(parkDict.getId())).collect(Collectors.toList()));
            }
        }else {
            parkDictList=parkDicts;
        }
        return parkDictList;
    }
}
