package cn.sagacloud.server.algorithm.converter

import cn.sagacloud.server.algorithm.models.modelFile.ModelFile
import com.alibaba.fastjson.JSONObject
import org.springframework.core.convert.converter.Converter
import org.springframework.stereotype.Component
import org.springframework.util.StringUtils

/**
 * Controller转换器
 */
@Component
class ModelFileConverter : Converter<String, ModelFile> {
    override fun convert(source: String): ModelFile? {
        if (StringUtils.isEmpty(source)) {
            return null
        }
        val obj = JSONObject.parseObject(source)
        return obj.toJavaObject(ModelFile::class.java)
    }
}
