package com.ecep.contract.converter;

import com.ecep.contract.model.Contract;
import com.ecep.contract.service.ContractService;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@Lazy
@Component
public class ContractStringConverter extends EntityStringConverter<Contract> {
    @Lazy
    @Autowired
    ContractService service;

    public ContractStringConverter() {
    }

    @PostConstruct
    private void init() {
        setInitialized(project -> service.findById(project.getId()));
        setSuggestion(service::search);
        // TODO 按名称找出，容易出问题
        setFromString(service::findByName);
    }
}