package com.njcn.process.service;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.process.mapper.RSurveyPlanConfigMapper;
import com.njcn.process.pojo.po.RSurveyPlanConfigPO;
import com.njcn.process.service.impl.RSurveyPlanConfigService;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.po.Dept;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

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

/**
 * 
 * Description:
 * 接口文档访问地址：http://serverIP:port/swagger-ui.html
 * Date: 2023/3/9  10:13【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Service
@RequiredArgsConstructor
public class RSurveyPlanConfigServiceImpl extends MppServiceImpl<RSurveyPlanConfigMapper, RSurveyPlanConfigPO> implements RSurveyPlanConfigService{

    private final DeptFeignClient deptFeignClient;
    @Override
    public List<RSurveyPlanConfigPO> getOrgIds() {
        List<Dept> data = deptFeignClient.getAllDept().getData();
        List<String> orgIds = data.stream().map(Dept::getCode).collect(Collectors.toList());
        return  this.list(new LambdaQueryWrapper<RSurveyPlanConfigPO>().in(CollUtil.isNotEmpty(orgIds),RSurveyPlanConfigPO::getOrgId,orgIds ));
    }
}
