package com.hzs.system.sys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hzs.common.domain.system.sys.SysApprovalBusiness;
import com.hzs.common.domain.system.sys.ext.SysApprovalBusinessExt;
import com.hzs.system.index.param.CompleteApprovalParam;
import com.hzs.system.sys.param.ApprovalCustomQueryParam;
import com.hzs.system.sys.param.ApprovalQueryParam;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 审批业务表 Mapper 接口
 *
 * @author hzs
 * @since 2022-09-21
 */
public interface SysApprovalBusinessMapper extends BaseMapper<SysApprovalBusiness> {

    /**
     * 业务审批是否进行中
     *
     * @param approvalBusinessList 审批业务类型（EApprovalBusiness）
     * @param businessCodeList     审批业务单号列表
     * @param pkCountry            国家ID
     * @return
     */
    int checkBusinessExist(@Param("approvalBusinessList") List<Integer> approvalBusinessList,
                           @Param("businessCodeList") List<String> businessCodeList,
                           @Param("pkCountry") Integer pkCountry);

    /**
     * 查询业务审批+详情
     *
     * @param approvalBusiness
     * @param businessCodeList
     * @param pkCountry
     * @return
     */
    List<SysApprovalBusinessExt> queryBusinessAndDetail(@Param("approvalBusiness") Integer approvalBusiness,
                                                        @Param("businessCodeList") List<String> businessCodeList,
                                                        @Param("pkCountry") Integer pkCountry);

    /**
     * 根据审批单号获取审批以及明细
     *
     * @param approvalCode 审批单号
     * @return
     */
    SysApprovalBusinessExt queryByApprovalCode(@Param("approvalCode") String approvalCode);

    /**
     * 业务审批列表
     *
     * @param param     审批查询入参
     * @param userId    用户ID
     * @param pkCountry 国家ID
     * @return
     */
    List<SysApprovalBusiness> queryApprovalList(@Param("param") ApprovalQueryParam param, @Param("userId") Long userId, @Param("pkCountry") Integer pkCountry);

    /**
     * 待审批业务数
     *
     * @param userId    用户ID
     * @param pkCountry 国家ID
     * @return
     */
    int waitApprovalNum(@Param("userId") Long userId, @Param("pkCountry") Integer pkCountry);

    /**
     * 待审批业务数据
     *
     * @param param     查询参数
     * @param userId    用户ID
     * @param pkCountry 国家ID
     * @return
     */
    List<SysApprovalBusinessExt> waitApproval(@Param("param") CompleteApprovalParam param,
                                              @Param("userId") Long userId,
                                              @Param("pkCountry") Integer pkCountry);

    /**
     * 已完成审批业务数据
     *
     * @param param     查询参数
     * @param userId    用户ID
     * @param pkCountry 国家ID
     * @return
     */
    List<SysApprovalBusinessExt> completeApproval(@Param("param") CompleteApprovalParam param,
                                                  @Param("userId") Long userId,
                                                  @Param("pkCountry") Integer pkCountry);

    /**
     * 查询最新的编号
     *
     * @return
     */
    String queryLastCode();

    /**
     * 自定义签呈列表
     *
     * @param param     查询参数
     * @param userId    用户ID
     * @param pkCountry 国家ID
     * @return
     */
    List<SysApprovalBusiness> customList(@Param("param") ApprovalCustomQueryParam param,
                                         @Param("userId") Long userId,
                                         @Param("pkCountry") Integer pkCountry);

}
