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.entity.TFCustomFlow;
import com.qmth.distributed.print.business.mapper.TFCustomFlowMapper;
import com.qmth.distributed.print.business.service.TFCustomFlowService;
import com.qmth.teachcloud.common.enums.TFCustomTypeEnum;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 自定义流程表 服务实现类
 * </p>
 *
 * @author wangliang
 * @since 2022-01-21
 */
@Service
public class TFCustomFlowServiceImpl extends ServiceImpl<TFCustomFlowMapper, TFCustomFlow> implements TFCustomFlowService {

    @Resource
    TFCustomFlowMapper tfCustomFlowMapper;

    /**
     * 查询版本号
     *
     * @param schoolId
     * @param orgId
     * @param type
     * @return
     */
    @Override
    public TFCustomFlow findMaxVersion(Long schoolId, Long orgId, TFCustomTypeEnum type) {
        return tfCustomFlowMapper.findMaxVersion(schoolId, orgId, Objects.nonNull(type) ? type.name() : null);
    }

    /**
     * 查询自定义流程数据列表
     *
     * @param iPage
     * @param name
     * @param schoolId
     * @param orgId
     * @return
     */
    @Override
    public IPage<TFCustomFlow> list(IPage<Map> iPage, String name, Long schoolId, Long orgId) {
        return tfCustomFlowMapper.list(iPage, name, schoolId, orgId);
    }

    /**
     * 根据key查找id
     *
     * @param flowKey
     * @return
     */
    @Override
    public String findActIdByFlowKey(String flowKey) {
        return tfCustomFlowMapper.findActIdByFlowKey(flowKey);
    }
}
