package com.ecep.contract.converter;

import javafx.util.StringConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import com.ecep.contract.service.ContractService;
import com.ecep.contract.vo.ContractVo;

import jakarta.annotation.PostConstruct;

public class ContractStringConverter extends StringConverter<ContractVo> {
    ContractService service;

    public ContractStringConverter(ContractService service) {
        this.service = service;
    }

    @Override
    public String toString(ContractVo cc) {
        return cc.getCode() + " " + cc.getName();
    }

    @Override
    public ContractVo fromString(String string) {
        return service.findByCode(string);
    }
}