package com.zcloud.safetyDutyList.persistence.repository.impl.tasklist;

import com.alibaba.cola.dto.PageResponse;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jjb.saas.framework.repository.common.PageHelper;
import com.jjb.saas.framework.repository.repo.impl.BaseRepositoryImpl;
import com.zcloud.gbscommon.utils.Query;
import com.zcloud.safetyDutyList.persistence.dataobject.tasklist.TaskExecutionDO;
import com.zcloud.safetyDutyList.persistence.mapper.tasklist.TaskExecutionMapper;
import com.zcloud.safetyDutyList.persistence.repository.tasklist.TaskExecutionRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
@RequiredArgsConstructor
public class TaskExecutionRepositoryImpl extends BaseRepositoryImpl<TaskExecutionMapper, TaskExecutionDO> implements TaskExecutionRepository {

    private final TaskExecutionMapper taskExecutionMapper;

    @Override
    public PageResponse<TaskExecutionDO> listPage(Map<String, Object> params) {
        IPage<TaskExecutionDO> iPage = new Query<TaskExecutionDO>().getPage(params);
        IPage<TaskExecutionDO> result = taskExecutionMapper.listPage(iPage, params);
        return PageHelper.pageToResponse(result, result.getRecords());
    }

    @Override
    public TaskExecutionDO getByTaskExecutionId(String taskExecutionId) {
        return taskExecutionMapper.getByTaskExecutionId(taskExecutionId);
    }

    @Override
    public List<TaskExecutionDO> listByTaskIssueId(String taskIssueId) {
        return taskExecutionMapper.listByTaskIssueId(taskIssueId);
    }

    @Override
    public List<TaskExecutionDO> listByTaskListId(String taskListId) {
        return taskExecutionMapper.listByTaskListId(taskListId);
    }

    @Override
    public List<TaskExecutionDO> listByTaskDetailId(String taskDetailId) {
        return taskExecutionMapper.listByTaskDetailId(taskDetailId);
    }
}
