package jnpf.cultivate.v2.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.cultivate.mapper.FtbCultivatePositionSettingMapper;
import jnpf.cultivate.v2.service.FtbCultivatePositionSettingService;
import jnpf.model.cultivate.po.position.FtbCultivatePositionSetting;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class FtbCultivatePositionSettingServiceImpl extends ServiceImpl<FtbCultivatePositionSettingMapper, FtbCultivatePositionSetting> implements FtbCultivatePositionSettingService {

    /**
     * 根据岗位学习id获取岗位设置
     *
     * @param positionLearnId 岗位学习id
     * @return 岗位设置
     */
    @Override
    public FtbCultivatePositionSetting listByPostLearnId(String positionLearnId) {
        LambdaQueryWrapper<FtbCultivatePositionSetting> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(FtbCultivatePositionSetting::getPostLearnId, positionLearnId);
        List<FtbCultivatePositionSetting> list = list(wrapper);
        if (CollUtil.isNotEmpty(list)) {
            return list.get(0);
        }
        return null;
    }

    /**
     * 根据岗位学习id和职级id获取岗位设置
     *
     * @param positionLearnId 岗位学习id
     * @param gradeId         职级id
     * @return 岗位设置
     */
    @Override
    public FtbCultivatePositionSetting listByPostLearnIdAndGradeId(String positionLearnId, String gradeId) {
        LambdaQueryWrapper<FtbCultivatePositionSetting> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(FtbCultivatePositionSetting::getPostLearnId, positionLearnId);
        wrapper.eq(FtbCultivatePositionSetting::getGradeId, gradeId);
        List<FtbCultivatePositionSetting> list = list(wrapper);
        if (CollUtil.isNotEmpty(list)) {
            return list.get(0);
        }
        return null;
    }
}