/*
 * Copyright [2022] [https://www.xiaonuo.vip]
 *
 * Snowy采用APACHE LICENSE 2.0开源协议，您在使用过程中，需要注意以下几点：
 *
 * 1.请不要删除和修改根目录下的LICENSE文件。
 * 2.请不要删除和修改Snowy源码头部的版权声明。
 * 3.本项目代码可免费商业使用，商业使用请保留源码和相关描述文件的项目出处，作者声明等。
 * 4.分发源码时候，请注明软件出处 https://www.xiaonuo.vip
 * 5.不可二次分发开源参与同类竞品，如有想法可联系团队xiaonuobase@qq.com商议合作。
 * 6.若您的项目无法满足以上几点，需要更多功能代码，获取Snowy商业授权许可，请在官网购买授权，地址为 https://www.xiaonuo.vip
 */
package vip.xiaonuo.disk.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.disk.domain.Examine;
import vip.xiaonuo.disk.dto.examine.ExamineReq;
import vip.xiaonuo.disk.service.ExamineService;
import vip.xiaonuo.disk.util.PageQuery;
import vip.xiaonuo.disk.util.TableDataInfo;
import vip.xiaonuo.disk.vo.examine.ExamineVo;

import javax.annotation.Resource;
import java.util.Map;

/**
 * examine控制器
 *
 * @author pans
 * @date  2025/06/19 11:21
 */
@Api(tags = "examine控制器")
@ApiSupport(author = "SNOWY_TEAM", order = 1)
@RestController
@Validated
@RequestMapping("/examine")
public class ExamineController {

    @Resource
    private ExamineService examineService;

    @Operation(summary = "审批列表", description = "审批列表查询接口")
    @RequestMapping(value = "/queryList", method = RequestMethod.GET)
    @ResponseBody
    public TableDataInfo<ExamineVo> queryList(ExamineReq examineReq, PageQuery pageQuery) {
        return examineService.queryList(examineReq,pageQuery);
    }


    @Operation(summary = "审核通过", description = "审核通过")
    @RequestMapping(value = "/pass", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<String> pass(@RequestBody Examine examine) {
        try {
            examineService.pass(examine);
            return CommonResult.ok("审核通过");
        } catch (Exception e) {
            return CommonResult.error("审核失败");
        }
    }


    @Operation(summary = "驳回", description = "审核通过")
    @RequestMapping(value = "/reject", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<String> reject(@RequestBody Examine examine) {
        try {
            examineService.reject(examine);
            return CommonResult.ok("驳回成功");
        } catch (Exception e) {
            return CommonResult.error("驳回失败");
        }
    }


    @Operation(summary = "文件详情接口", description = "文件详情接口")
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<Map<String,Object>> detail(String userFileId) {
        Map<String,Object> map= examineService.detail(userFileId);
        return CommonResult.ok().data(map);
    }




}
