package com.gz.controller.system;

import com.gz.core.exception.BusinessException;
import com.gz.dto.system.FileDTO;
import com.gz.rvo.system.FileUploadRVO;
import com.gz.service.system.FileService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

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

/**
 * @author LiuchangLan
 * @date 2020/9/9 11:23
 */
@RestController
@RequestMapping("system/file")
public class FileController {

    @Resource
    private FileService fileService;

    @PostMapping("upload")
    public FileUploadRVO upload(@RequestBody MultipartFile file, String fileId) throws IOException, BusinessException {
        return fileService.upload(file, fileId);
    }

    @GetMapping("selectByFileId")
    public List<FileDTO> selectByPrimaryKey(String fileId) {
        return fileService.selectByFileId(fileId);
    }

    @DeleteMapping("delete")
    Integer delete(Integer id){
        return fileService.delete(id);
    }
}
