package com.willalp.flow.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.willalp.flow.domain.HsFlowBase;
import com.willalp.flow.mapper.HsFlowBaseMapper;
import com.willalp.flow.service.IHsFlowBaseService;
import org.springframework.stereotype.Service;

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

/**
 * 流程基础模型Service业务层处理
 *
 * @author willalp
 * @date 2022-10-09
 */
@Service
public class HsFlowBaseServiceImpl extends ServiceImpl<HsFlowBaseMapper, HsFlowBase>  implements IHsFlowBaseService
{
    @Resource
    private HsFlowBaseMapper hsFlowBaseMapper;

    /**
     * 查询流程基础模型列表
     *
     * @param hsFlowBase 流程基础模型
     * @return 流程基础模型
     */
    @Override
    public List<HsFlowBase> selectHsFlowBaseList(HsFlowBase hsFlowBase)
    {
        return hsFlowBaseMapper.selectHsFlowBaseList(hsFlowBase);
    }

    @Override
    public HsFlowBase getFlowTaskBaseByGroupIdAndBaseId(String groupId, String baseId) {
        return hsFlowBaseMapper.selectOne(
                new QueryWrapper<HsFlowBase>()
                        .eq("group_id", groupId)
                        .eq("id", baseId));
    }

    @Override
    public HsFlowBase getNextFlowTaskBase(String groupId, String baseId) {
        return hsFlowBaseMapper.selectOne(
                new QueryWrapper<HsFlowBase>()
                        .eq("group_id", groupId)
                        .eq("up_step_id", baseId));
    }
}
