package cn.teammodel.controller.admin.controller;

import cn.teammodel.common.R;
import cn.teammodel.controller.admin.service.BlobService;
import cn.teammodel.model.dto.admin.exam.BlobSasDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;

@RestController
@RequestMapping("admin/blob")
@Api(tags = "管理员-blob相关操作")
public class BlobController {
    @Resource
    private BlobService blobService;
    @PostMapping("getBlobSas")
    @ApiOperation("获取blob 读写权限")
    public R<Map<String, Object>> getBlobSas(@Valid @RequestBody BlobSasDto blobSasDto, HttpServletRequest request) {
        Map<String, Object> res = blobService.getBlobSas(blobSasDto,request);
        return R.success(res);
    }
    @PostMapping("getSasR99")
    @ApiOperation("获取某个容器的只读权限")
    public R<Map<String, Object>> getSasR99(@Valid @RequestBody BlobSasDto blobSasDto, HttpServletRequest request) {
        Map<String, Object> res = blobService.getSasR99(blobSasDto,request);
        return R.success(res);
    }


}
