package com.ffii.fpsms.modules.pickOrder.enums

import jakarta.persistence.AttributeConverter
import jakarta.persistence.Converter

// Pick Order Status
@Converter(autoApply = true)
class PickOrderStatusConverter : AttributeConverter<PickOrderStatus, String>{
    override fun convertToDatabaseColumn(status: PickOrderStatus?): String? {
        return status?.value
    }

    override fun convertToEntityAttribute(value: String?): PickOrderStatus? {
        return value?.let { v ->
            PickOrderStatus.entries.find { it.value == v }
        }
    }
}

// Pick Order Type
@Converter(autoApply = true)
class PickOrderTypeConverter : AttributeConverter<PickOrderType, String>{
    override fun convertToDatabaseColumn(type: PickOrderType?): String? {
        return type?.value
    }

    override fun convertToEntityAttribute(value: String?): PickOrderType? {
        return value?.let { v ->
            PickOrderType.entries.find { it.value == v }
        }
    }
}