package com.ecep.contract.service;

import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.ecep.contract.converter.ProjectTypeStringConverter;
import com.ecep.contract.vm.ProjectTypeViewModel;
import com.ecep.contract.vo.ProjectTypeVo;

import javafx.util.StringConverter;

@Service
@CacheConfig(cacheNames = "project-type")
public class ProjectTypeService extends QueryService<ProjectTypeVo, ProjectTypeViewModel> {
    private final StringConverter<ProjectTypeVo> stringConverter;
    
    public ProjectTypeService() {
        this.stringConverter = new ProjectTypeStringConverter(this);
    }

    @Cacheable(key = "#p0")
    @Override
    public ProjectTypeVo findById(Integer id) {
        return super.findById(id);
    }

    public ProjectTypeVo findByName(String name) {
        return findOneByProperty("name", name);
    }

    public ProjectTypeVo findByCode(String code) {
        return findOneByProperty("code", code);
    }

    public StringConverter<ProjectTypeVo> getStringConverter() {
        return stringConverter;
    }

}
