package com.qmth.distributed.print.business.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qmth.distributed.print.business.bean.result.FlowApproveListResult;
import com.qmth.distributed.print.business.entity.TFFlowApprove;
import com.qmth.distributed.print.business.mapper.TFFlowApproveMapper;
import com.qmth.distributed.print.business.service.TFFlowApproveService;
import com.qmth.teachcloud.common.enums.FlowStatusEnum;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;
import java.util.Objects;

/**
 * <p>
 * 流程审核表 服务实现类
 * </p>
 *
 * @author wangliang
 * @since 2021-08-02
 */
@Service
public class TFFlowApproveServiceImpl extends ServiceImpl<TFFlowApproveMapper, TFFlowApprove> implements TFFlowApproveService {

    @Resource
    TFFlowApproveMapper tfFlowApproveMapper;

    /**
     * 根据流程id查询流程状态
     *
     * @param flowId
     * @return
     */
    @Override
    public TFFlowApprove findByFlowId(Long flowId) {
        return tfFlowApproveMapper.findByFlowId(flowId);
    }

    /**
     * 查找流程审批记录列表
     *
     * @param iPage
     * @param status
     * @param teacherUserName
     * @param teachingRoomId
     * @param startTime
     * @param endTime
     * @param pendApproveUserName
     * @param schoolId
     * @param orgId
     * @return
     */
    @Override
    public IPage<FlowApproveListResult> findApproveList(IPage<Map> iPage, FlowStatusEnum status, String teacherUserName, Long teachingRoomId, Long startTime, Long endTime, String pendApproveUserName, Long schoolId, Long orgId) {
        return tfFlowApproveMapper.findApproveList(iPage,
                Objects.nonNull(status) ? status.name() : null,
                teacherUserName,
                teachingRoomId,
                startTime,
                endTime,
                pendApproveUserName,
                schoolId,
                orgId);
    }
}
