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.FeedbackDO;
import com.zcloud.safetyDutyList.persistence.mapper.tasklist.FeedbackMapper;
import com.zcloud.safetyDutyList.persistence.repository.tasklist.FeedbackRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

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

@Service
@RequiredArgsConstructor
public class FeedbackRepositoryImpl extends BaseRepositoryImpl<FeedbackMapper, FeedbackDO> implements FeedbackRepository {
    private final FeedbackMapper feedbackMapper;

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

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

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

    @Override
    public List<FeedbackDO> listByTaskExecutionId(String taskExecutionId) {
        return feedbackMapper.listByTaskExecutionId(taskExecutionId);
    }

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

    @Override
    public List<FeedbackDO> listByTaskExecutionIdAndPeriodFlag(String taskExecutionId, String feedbackPeriodFlag) {
        return feedbackMapper.listByTaskExecutionIdAndPeriodFlag(taskExecutionId, feedbackPeriodFlag);
    }

    @Override
    public FeedbackDO getByFeedbackId(String feedbackId) {
        return feedbackMapper.getByFeedbackId(feedbackId);
    }
}
