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

import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.infra.api.file.dto.FileDTO;
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileRespVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
import cn.iocoder.yudao.module.infra.service.file.FileService;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

/**
 * 文件 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 FileDTO uploadFile(String name, String path, byte[] content){
        FileRespVO fileRespVO = fileService.uploadFile(name, path, content);
        return BeanUtils.toBean(fileRespVO, FileDTO.class);
    }

    @Override
    public Integer updateFileBiz(List<Long> fileIdList, String serviceId) {
        return fileService.updateFileBiz(fileIdList, serviceId);
    }

    @Override
    public List<FileDTO> getFileDTOListByBiz(String universalId) {
        List<FileDO> fileDOList = fileService.getFileListByBiz(universalId);
        return BeanUtils.toBean(fileDOList, FileDTO.class);
    }

}
