package com.hz.pm.api.meeting.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.hz.pm.api.meeting.entity.domain.MeetingInnerProject;
import com.hz.pm.api.meeting.mapper.MeetingInnerProjectMapper;
import com.hz.pm.api.meeting.service.IMeetingInnerProjectService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 会议评审内部项目表 服务实现类
 * </p>
 *
 * @author WendyYang
 * @since 2023-02-28
 */
@Service
public class MeetingInnerProjectServiceImpl extends ServiceImpl<MeetingInnerProjectMapper, MeetingInnerProject> implements IMeetingInnerProjectService {

    @Override
    public List<MeetingInnerProject> listByMeetingId(Long meetingId) {
        return list(Wrappers.lambdaQuery(MeetingInnerProject.class)
                .eq(MeetingInnerProject::getMeetingId, meetingId));
    }

    @Override
    public List<Long> listMeetingIdByProjectId(Long projectId) {
        LambdaQueryWrapper<MeetingInnerProject> query = Wrappers
                .lambdaQuery(MeetingInnerProject.class)
                .eq(MeetingInnerProject::getProjectId, projectId);
        return CollUtils.fieldList(list(query), MeetingInnerProject::getMeetingId);
    }

    @Override
    public List<Long> listMeetingIdByProjectCode(String projectCode) {
        LambdaQueryWrapper<MeetingInnerProject> query = Wrappers
                .lambdaQuery(MeetingInnerProject.class)
                .eq(MeetingInnerProject::getProjectCode, projectCode);
        return CollUtils.fieldList(list(query), MeetingInnerProject::getMeetingId);
    }
}
