package com.chuanxia.mcp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chuanxia.mcp.bean.model.CdnCity;
import com.chuanxia.mcp.bean.vo.Result;
import com.chuanxia.mcp.mapper.CdnCityMapper;
import com.chuanxia.mcp.service.CdnService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class CdnServiceImpl extends ServiceImpl<CdnCityMapper, CdnCity> implements CdnService {
    private final CdnCityMapper cityMapper;

    @Override
    public Result<List<CdnCity>> cascade(Integer parentId) {
        LambdaQueryWrapper<CdnCity> query = Wrappers.lambdaQuery();
        query.eq(CdnCity::getParentId, parentId);
        List<CdnCity> cdnCities = cityMapper.selectList(query);
        return Result.success(cdnCities);
    }
}
