package com.mcwl.web.controller.communityCenter;


import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.communityCenter.domain.dto.*;
import com.mcwl.communityCenter.service.CommunityFileLogService;
import com.mcwl.communityCenter.service.CommunityFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * 社区文件
 */
@Api(tags = "社区文件")
@RestController
@RequestMapping("communityFile")
@RequiredArgsConstructor
public class CommunityFileController {

    private final CommunityFileService communityFileService;

    private final CommunityFileLogService communityFileLogService;

    /**
     * 社区文件列表
     */
    @ApiOperation(value = "社区文件列表")
    @PostMapping("/list")
    public TableDataInfo getCommunityFileList(@RequestBody @Valid CommunityFilePageListRes communityFilePageListRes) {
        return communityFileService.getCommunityFileList(communityFilePageListRes);
    }


    /**
     * 社区文件上传
     */
    @ApiOperation(value = "社区文件上传")
    @PostMapping("/upload")
    public R<String> upload(@RequestBody @Valid CommunityUploadFileRes communityUploadFileRes) {
        return communityFileService.upload(communityUploadFileRes);
    }

    /**
     * 社区文件下载
     */
    @ApiOperation(value = "社区文件下载")
    @PostMapping("/download")
    public R<String> download(@RequestBody @Valid CommunityDownloadFileRes communityDownloadFileRes) {
        return communityFileService.download(communityDownloadFileRes);
    }


}
