package com.hzu.labbooking.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzu.labbooking.domain.RecordWeek;
import com.hzu.labbooking.mapper.RecordWeekMapper;
import com.hzu.labbooking.service.IRecordWeekService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 预约信息周次映射Service业务层处理
 *
 * @author yezihao
 * @date 2021-06-13
 */
@Service
public class RecordWeekServiceImpl extends ServiceImpl<RecordWeekMapper, RecordWeek> implements IRecordWeekService {

    @Override
    public List<Long> selectWeekList(Long recordId) {
        QueryWrapper<RecordWeek> wrapper = new QueryWrapper<>();
        wrapper.select("week_id").eq("record_id", recordId);
        List<RecordWeek> weekIdList = this.list(wrapper);
        List<Long> res = new ArrayList<>();
        for (RecordWeek week : weekIdList) {
            res.add(week.getWeekId());
        }
        return res;
    }

    @Override
    public List<Long> selectAllWeekList(List<Long> recordIdList) {
        QueryWrapper<RecordWeek> wrapper = new QueryWrapper<>();
        wrapper.select("week_id").in("record_id", recordIdList);
        List<RecordWeek> weekIdList = this.list(wrapper);
        List<Long> res = new ArrayList<>();
        for (RecordWeek week : weekIdList) {
            res.add(week.getWeekId());
        }
        return res;
    }

}
