package com.vctgo.file.controller;

import com.vctgo.common.security.annotation.Logical;
import com.vctgo.file.domain.FileAshInfo;
import com.vctgo.file.service.IFileAshInfoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vctgo.common.security.annotation.RequiresPermissions;
import com.vctgo.common.core.web.controller.BaseController;
import com.vctgo.common.core.web.domain.AjaxResult;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 * 文件回收站基本信息Controller
 *
 * @author caesar
 * @date 2024-02-26
 */
@RestController
@RequestMapping("/ash")
public class FileAshInfoController extends BaseController {
    @Autowired
    private IFileAshInfoService fileAshInfoService;

    @ApiOperation(value = "文件回收站-分页")
    @Transactional
    @GetMapping("/page")
    @RequiresPermissions(value = {"file:manage:ash"},logical = Logical.OR)
    public AjaxResult getFileManageAshPage(FileAshInfo fileAshInfo) {
        IPage<FileAshInfo> page = fileAshInfoService.getFileAshPage(fileAshInfo);
        return AjaxResult.success(page);
    }


    @ApiOperation(value = "批量彻底删除")
    @Transactional
    @RequestMapping("/remove/{ids}")
    @RequiresPermissions(value = {"file:manage:remove","file:manage:batch:remove"},logical = Logical.OR)
    public AjaxResult doBatchRemoveFile(@PathVariable String ids){
        fileAshInfoService.doBatchRemoveFile(ids);
        return AjaxResult.success();
    }

    @ApiOperation(value = "批量恢复")
    @Transactional
    @RequestMapping("/recover/{ids}")
    @RequiresPermissions(value = {"file:manage:recover","file:manage:batch:recover"},logical = Logical.OR)
    public AjaxResult doBatchRecoverFile(@PathVariable String ids){
        fileAshInfoService.doBatchRecoverFile(ids);
        return AjaxResult.success();
    }
}
