package com.backendsys.modules.upload.controller;

import com.backendsys.modules.common.aspect.SysLog;
import com.backendsys.modules.common.config.security.utils.SecurityUtil;
import com.backendsys.modules.common.utils.Result;
import com.backendsys.modules.upload.entity.SysFile;
import com.backendsys.modules.upload.entity.SysFileCategory;
import com.backendsys.modules.upload.service.SysFileCategoryService;
import com.backendsys.modules.upload.service.SysFileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Validated
@RestController
@Tag(name = "文件分类管理")
public class SysFileCategoryController {

    @Autowired
    private SysFileCategoryService sysFileCategoryService;

    @Operation(summary = "获取文件分类列表 (全部)")
    @GetMapping("/api/upload/getUploadFileCategoryAllList")
    public Result getUploadFileCategoryAllList(@Validated SysFileCategory sysFileCategory) {
        return Result.success().put("data", sysFileCategoryService.selectUploadFileCategoryList(sysFileCategory));
    }

    @Operation(summary = "获取文件分类列表 (我的)")
    @GetMapping("/api/upload/getUploadFileCategoryList")
    public Result getUploadFileCategoryList(@Validated SysFileCategory sysFileCategory) {
        sysFileCategory.setUser_id(SecurityUtil.getUserId());
        return Result.success().put("data", sysFileCategoryService.selectUploadFileCategoryList(sysFileCategory));
    }

//
//    @SysLog("上传文件 (普通上传)")
//    @Operation(summary = "上传文件 (普通上传，单文件上传不超过 100MB)")
//    @PreAuthorize("@sr.hasPermission(1.1)")
//    @PostMapping("/api/upload/uploadSmall")
//    public Result uploadSmall(@RequestParam("file") MultipartFile multipartFile, Long category_id) {
//        return Result.success().put("data", sysFileService.uploadSmall(multipartFile, category_id));
//    }
//
//    @SysLog("删除上传文件")
//    @Operation(summary = "删除上传文件")
//    @PreAuthorize("@sr.hasPermission(1.1)")
//    @DeleteMapping("/api/upload/removeUploadFile")
//    public Result removeUploadFile(@Validated(SysFile.Delete.class) @RequestBody SysFile sysFile) {
//        return Result.success().put("data", sysFileService.removeUploadFile(sysFile));
//    }

}
