package com.mcwl.web.controller.resource;

import com.mcwl.common.core.domain.R;
import com.mcwl.resource.domain.DownloadRecord;
import com.mcwl.resource.domain.request.RequestDownload;
import com.mcwl.resource.domain.vo.PageVo;
import com.mcwl.resource.service.impl.DownloadRecordServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 文件下载记录
 * @author DaiZibo
 * @date 2025/3/6
 * @apiNote
 */


@Slf4j
@Api(tags = "文件下载记录")
@RestController
@RequestMapping("/downloadRecord")
public class DownloadRecordController {


    @Autowired
    private DownloadRecordServiceImpl downloadRecordService;


    /**
     * 新增下载记录
     * @param downloadRecord
     * @return
     */
    @ApiOperation(value = "新增下载记录")
    @PostMapping("/addDownloadRecord")
    public R addDownloadRecord(@RequestBody DownloadRecord downloadRecord){

        return downloadRecordService.addDownloadRecord(downloadRecord);
    }

    /**
     * 查询下载记录
     * @param pageVo
     * @return
     */
    @ApiOperation(value = "下载记录")
    @PostMapping("/selectDownloadRecord")
    public R selectDownloadRecord(@RequestBody PageVo pageVo){

        return downloadRecordService.selectDownloadRecord(pageVo);
    }


    /**
     * 修改下载状态
     * @return
     */
    @ApiOperation(value = "修改下载状态")
    @PostMapping("/updateDownloadRecord")
    public R updateDownloadRecord(@RequestBody DownloadRecord downloadRecord){

        return downloadRecordService.updateDownloadRecord(downloadRecord);
    }

    /**
     * 批量删除下载记录
     * @param ids
     * @return
     */
    @ApiOperation(value = "批量删除下载记录")
    @GetMapping("/deleteDownloadRecord")
    public R deleteDownloadRecord(@RequestParam String ids){

        return downloadRecordService.deleteDownloadRecord(ids);
    }

    @ApiOperation(value = "根据文件名查询详情")
    @PostMapping("/selectFileByName")
    public R selectByFileName(@RequestBody RequestDownload requestDownload){

        return downloadRecordService.selectByFileName(requestDownload);
    }

}
