package org.example.Enums;

import org.example.Enums.ParameterDirection;
import org.springframework.jdbc.core.SqlInOutParameter;
import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.core.SqlParameter;

// 1. 抽象基类：定义公共属性和方法
public abstract class CustomSqlParameter {
    protected String name;
    protected int sqlType;


    protected String mode;
    protected ParameterDirection direction;
    protected Object value;

    public CustomSqlParameter(String name, int sqlType, String mode, ParameterDirection direction) {
        this.name = name;
        this.sqlType = sqlType;
        this.mode = mode;
        this.direction = direction;
    }

    public CustomSqlParameter(String name, int sqlType, String mode, ParameterDirection direction, Object value) {
        this.name = name;
        this.sqlType = sqlType;
        this.mode = mode;
        this.direction = direction;
        this.value = value;
    }

    // 抽象方法：返回对应的 Spring 原生参数对象（关键）
    public abstract SqlParameter toSpringSqlParameter();

    // Getter 方法
    public String getName() {
        return name;
    }

    public Object getValue() {
        return value;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setSqlType(int sqlType) {
        this.sqlType = sqlType;
    }

    public void setMode(String mode) {
        this.mode = mode;
    }

    public void setDirection(ParameterDirection direction) {
        this.direction = direction;
    }

    public void setValue(Object value) {
        this.value = value;
    }

    public int getSqlType() {
        return sqlType;
    }

    public String getMode() {
        return mode;
    }

    public ParameterDirection getDirection() {
        return direction;
    }
}

