package com.nantian.cloud.jly.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nantian.cloud.jly.entity.DictRegion;
import com.nantian.cloud.jly.mapper.DictRegionMapper;
import com.nantian.cloud.jly.service.DictRegionService;
import com.nantian.cloud.jly.vo.TreeVo;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.nantian.cloud.jly.vo.TreeVoUtil.findTree;


/**
 *
 * @date 2020-08-13
 */
@Service("dictRegionService")
public class DictRegionServiceImpl extends ServiceImpl<DictRegionMapper, DictRegion> implements DictRegionService {

    @Override
    public DictRegion getNameByCode(DictRegion dictRegion) {
        return baseMapper.getNameByCode(dictRegion);
    }

    @Override
    public List<TreeVo> getDictRegionTree(String id) {
        List<TreeVo> dictRegionTree;
        if (id.equals(("530000"))) {
            dictRegionTree = baseMapper.getDictRegionTree(id);

        }
        else{
            dictRegionTree = baseMapper.getDictRegionTrees(id);

        }
        dictRegionTree  = findTree(dictRegionTree,id);

        return dictRegionTree;
    }

}

