package com.ningdatech.pmapi.expert.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.ningdatech.basic.util.CollUtils;
import com.ningdatech.pmapi.expert.entity.ExpertIntentionWorkRegion;
import com.ningdatech.pmapi.expert.mapper.ExpertIntentionWorkRegionMapper;
import com.ningdatech.pmapi.expert.service.IExpertIntentionWorkRegionService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Liuxinxin
 * @since 2023-02-22
 */
@Service
public class ExpertIntentionWorkRegionServiceImpl extends ServiceImpl<ExpertIntentionWorkRegionMapper, ExpertIntentionWorkRegion> implements IExpertIntentionWorkRegionService {

    @Override
    public List<Long> userIdsMatchIntentionRegion(String regionCode, Integer regionLevel) {
        LambdaQueryWrapper<ExpertIntentionWorkRegion> intentionQuery = Wrappers.lambdaQuery(ExpertIntentionWorkRegion.class)
                .eq(ExpertIntentionWorkRegion::getRegionCode, regionCode)
                .eq(ExpertIntentionWorkRegion::getRegionLevel, regionLevel)
                .select(ExpertIntentionWorkRegion::getUserId);
        List<ExpertIntentionWorkRegion> userIdMatchIntentionRegion = list(intentionQuery);
        return CollUtils.fieldList(userIdMatchIntentionRegion, ExpertIntentionWorkRegion::getUserId);
    }

}
