package cn.iocoder.yudao.module.infra.api.file;

import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileCreateRespVo;
import cn.iocoder.yudao.module.infra.service.file.FileService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 文件 API 实现类
 *
 * @author 芋道源码
 */
@Service
@Validated
public class FileApiImpl implements FileApi {

    @Resource
    private FileService fileService;

    @Override
    public String createFile(String name, String path, byte[] content) {
        return fileService.createFile(name, path, content);
    }

    @Override
    public Map<String,Object> llmCreateFile(String originalFilename, byte[] bytes) {
        FileCreateRespVo fileCreateRespVo = fileService.llmcreateFile(originalFilename, null, bytes);
        Map<String,Object> map = new HashMap<>();
        map.put("url",fileCreateRespVo.getUrl());
        map.put("id",fileCreateRespVo.getId());
        return map;
    }

}
