package com.fs.audit.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fs.audit.domain.AuditFlow;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 审核流程记录Mapper
 */
@Mapper
public interface AuditFlowMapper extends BaseMapper<AuditFlow> {

    /**
     * 根据审核实例ID获取流程记录列表
     */
    @Select("SELECT * FROM audit_flow WHERE audit_id = #{auditId} ORDER BY step_number ASC")
    List<AuditFlow> selectByAuditId(@Param("auditId") Long auditId);

    /**
     * 获取当前步骤的流程记录
     */
    @Select("SELECT * FROM audit_flow WHERE audit_id = #{auditId} AND step_number = #{stepNumber} LIMIT 1")
    AuditFlow selectCurrentFlow(@Param("auditId") Long auditId, @Param("stepNumber") Integer stepNumber);
}

