package cn.reghao.tnb.file.app.service;

import cn.reghao.tnb.file.app.db.mapper.OssConfigMapper;
import cn.reghao.tnb.file.app.model.dto.OssConfigDto;
import cn.reghao.tnb.file.app.model.po.OssConfig;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @author reghao
 * @date 2026-04-27 17:08:01
 */
@Service
public class AdminFileService {
    private final OssConfigMapper ossConfigMapper;

    public AdminFileService(OssConfigMapper ossConfigMapper) {
        this.ossConfigMapper = ossConfigMapper;
    }

    public void addOssConfig(OssConfigDto ossConfigDto) {
        OssConfig ossConfig = new OssConfig(ossConfigDto);
        ossConfigMapper.save(ossConfig);
    }

    public List<OssConfig> getOssConfigList() {
        int ossType = 1;
        OssConfig ossConfig = ossConfigMapper.findByOssType(ossType);
        if (ossConfig != null) {
            return List.of(ossConfig);
        }

        return Collections.emptyList();
    }
}
