package com.willalp.yiqing.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.willalp.yiqing.domain.HsTaskBelongUser;
import com.willalp.yiqing.domain.HsYiqingTask;
import com.willalp.yiqing.mapper.HsTaskBelongUserMapper;
import com.willalp.yiqing.mapper.HsYiqingTaskMapper;
import com.willalp.yiqing.service.IHsYiqingTaskService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 疫情防控-任务排班Service业务层处理
 *
 * @author willalp
 * @date 2022-04-02
 */
@Service
public class HsYiqingTaskServiceImpl extends ServiceImpl<HsYiqingTaskMapper, HsYiqingTask> implements IHsYiqingTaskService {
    @Resource
    private HsYiqingTaskMapper hsYiqingTaskMapper;

    @Resource
    private HsTaskBelongUserMapper belongUserMapper;

    /**
     * 查询疫情防控-任务排班列表
     *
     * @param hsYiqingTask 疫情防控-任务排班
     * @return 疫情防控-任务排班
     */
    @Override
    public List<HsYiqingTask> selectHsYiqingTaskList(HsYiqingTask hsYiqingTask) {
        List<HsYiqingTask> hsYiqingTasks = hsYiqingTaskMapper.selectHsYiqingTaskList(hsYiqingTask);
        hsYiqingTasks.forEach(t -> {
            List<HsTaskBelongUser> belongUsers = belongUserMapper.selectList(
                    new QueryWrapper<HsTaskBelongUser>().eq("yq_task_id", t.getYqTaskId()));
            HsYiQingServiceImpl.setBelong(t, belongUsers);
        });
        return hsYiqingTasks;
    }
}
