parent
8879b87bd2
commit
7ddcf2aed5
@ -0,0 +1,31 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package cn.teammodel.controller.admin.service;
|
||||||
|
|
||||||
|
import cn.teammodel.model.dto.admin.exam.BlobSasDto;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface BlobService {
|
||||||
|
Map<String,Object> getBlobSas(BlobSasDto blobSasDto, HttpServletRequest request);
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package cn.teammodel.controller.admin.service.impl;
|
||||||
|
|
||||||
|
import cn.teammodel.common.ErrorCode;
|
||||||
|
import cn.teammodel.config.exception.ServiceException;
|
||||||
|
import cn.teammodel.controller.admin.service.BlobService;
|
||||||
|
import cn.teammodel.model.dto.admin.exam.BlobSasDto;
|
||||||
|
import cn.teammodel.utils.GroupUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class BlobServiceImpl implements BlobService {
|
||||||
|
@Autowired
|
||||||
|
private Environment env;
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getBlobSas(BlobSasDto blobSasDto, HttpServletRequest request) {
|
||||||
|
|
||||||
|
Map<String, Object> sas;
|
||||||
|
String url = env.getProperty("ies.server-url-blob-sas-rcwld");
|
||||||
|
|
||||||
|
try {
|
||||||
|
sas = GroupUtil.getGroupId(blobSasDto,new GroupUtil(env), request,url);
|
||||||
|
|
||||||
|
}catch (Exception e) {
|
||||||
|
throw new ServiceException(ErrorCode.SYSTEM_ERROR.getCode(), "数据转换错误");
|
||||||
|
}
|
||||||
|
return sas;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue