package com.docus.server.service.impl;

import com.docus.server.common.util.YmlUtil;
import com.docus.server.service.ICollectorUpdateService;
import com.docus.server.vo.collector.update.CollectorUpdateVersionVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.LinkedHashMap;

/**
 * 患者信息表 服务实现类
 *
 * @author AutoGenerator
 * @since 2023-08-29
 */
@Service
@Slf4j
public class CollectorUpdateServiceImpl implements ICollectorUpdateService {

    @Override
    public CollectorUpdateVersionVO find() throws Exception {

        String version = loadYaml("docus.collector.version");

        return CollectorUpdateVersionVO.builder().updateNumber(version).build();
    }

    @Override
    public String getFilePath() throws Exception {

        return loadYaml("docus.collector.download-folder");
    }

    public String loadYaml(String key) throws Exception {
        LinkedHashMap params = YmlUtil.loadYaml("bootstrap.yml");

        return (String) YmlUtil.getValByKey(params, key);

    }

}

