package com.ruoyi.cms.controller.app;

import com.ruoyi.common.core.domain.entity.File;
import com.ruoyi.cms.service.IFileService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/app/file")
public class AppFileController extends BaseController {
    @Autowired
    private IFileService fileService;
    @ApiOperation("上传文件")
    @PostMapping("/upload")
    public AjaxResult uploadFile(@RequestParam("file") MultipartFile file, @RequestParam(value = "bussinessid",required = false) Long bussinessId) {
       return fileService.uploadFile(file,bussinessId);
    }

    @ApiOperation("获取附件列表")
    @GetMapping("/list")
    public TableDataInfo list(File file)
    {
        List<File> results = fileService.selectFileList(file);
        return getDataTable(results);
    }
}
