package com.boman.system.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.StatementType;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author wmc
 * @date 2020/8/24 17:08
 */
@Mapper
@Component
public interface StoredProcedureMapper {

    @Options(statementType = StatementType.CALLABLE)
    @Select("{call ${storedName} (#{pId,jdbcType=BIGINT,mode=IN})}")
    void storedProcedure(@Param(value = "pId") Long pid, @Param("storedName") String storedName);

    @Options(statementType = StatementType.CALLABLE)
    @Select("{call ${storedName} (#{pId,jdbcType=BIGINT,mode=IN},#{pIsAdd,jdbcType=BIGINT,mode=IN})}")
    void storedProcedure1(@Param(value = "pId") Long pid,
                          @Param(value = "pIsAdd") Long pIsAdd,
                          @Param(value = "storedName") String storedName);

    @Options(statementType = StatementType.CALLABLE)
    @Select("{call ${storedName} (#{pId,jdbcType=BIGINT,mode=IN},#{pIsAdd,jdbcType=BIGINT,mode=IN},#{p_code,jdbcType=VARCHAR,mode=OUT},#{p_message,jdbcType=VARCHAR,mode=OUT})}")
    void storedProcedure2(Map map);

    //xxl-job 调用的存储过程
    @Options(statementType = StatementType.CALLABLE)
    @Select("{call ${storedName} (#{timeId,jdbcType=BIGINT,mode=IN},#{param,jdbcType=VARCHAR,mode=IN})}")
    void storedProcedureXXLJOB(@Param(value = "timeId") Long timeId,
                               @Param(value = "param") String param,
                               @Param(value = "storedName") String storedName);


    @Options(statementType = StatementType.CALLABLE)
    @Select("{call ${storedName} (#{params,jdbcType=VARCHAR,mode=IN},#{datas,jdbcType=VARCHAR,mode=OUT})}")
    void procedureGetValue(Map map);

    @Options(statementType = StatementType.CALLABLE)
    @Select("{call ${storedName} (#{params,jdbcType=VARCHAR,mode=IN})}")
    void procedureNoValue(Map map);

}
