package com.artfess.rescue.file.controller;


import com.artfess.base.annotation.ApiGroup;
import com.artfess.base.constants.ApiGroupConsts;
import com.artfess.base.controller.BaseController;
import com.artfess.base.model.CommonResult;
import com.artfess.rescue.file.manager.BizRescueFileCommonManager;
import com.artfess.rescue.file.manager.impl.BizRescueFileCommonManagerImpl;
import com.artfess.rescue.file.model.BizRescueFileCommon;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 文件公共信息表 前端控制器
 *
 * @author 系统管理员
 * @company 阿特菲斯信息技术有限公司
 * @since 2024-07-04
 */
@RestController
@RequestMapping("/bizRescueFileCommon/v1/")
@ApiGroup(group = {ApiGroupConsts.GROUP_BIZ_RESCUE})
@Api(tags = "巡查救援文件公共信息")
public class BizRescueFileCommonController {
    @Resource
    BizRescueFileCommonManager baseService;

    @ApiOperation(value = "minio附件预览", httpMethod = "POST", notes = "minio附件预览")
    @PostMapping("minioPreviewFile")
    public String minioPreviewFile(@RequestParam("fileName") String fileName) {
        return baseService.minioPreviewFile(fileName);
    }

    @ApiOperation(value = "附件上传", httpMethod = "POST", notes = "minio附件预览")
    @PostMapping("qrCodeSaveOrUpdate")
    public CommonResult<String> qrCodeSaveOrUpdate(@RequestBody BizRescueFileCommon fileCommon) {
        baseService.qrCodeSaveOrUpdate(fileCommon);
        return new CommonResult<>("操作成功");
    }
    @ApiOperation(value = "根据当前公司id预览所属公司二维码", httpMethod = "GET", notes = "根据当前用户预览所属公司二维码")
    @GetMapping("viewQrCode/{companyId}")
    public CommonResult<?> viewQrCodeById(@PathVariable("companyId") String companyId) throws Exception {
        List<BizRescueFileCommon> file = baseService.getFileByCommonId(companyId);
        return CommonResult.success(file,"");
    }

    @ApiOperation(value = "根据当前用户预览所属公司二维码", httpMethod = "GET", notes = "根据当前用户预览所属公司二维码")
    @GetMapping("viewQrCode")
    public CommonResult<?> viewQrCode() {
        BizRescueFileCommon code = baseService.viewQrCode();
        return CommonResult.success(code,"");
    }

}
