|
|
@@ -1,146 +0,0 @@
|
|
|
-package cn.reghao.bnt.web.console.controller;
|
|
|
-
|
|
|
-import cn.reghao.bnt.web.admin.service.UserContext;
|
|
|
-import cn.reghao.bnt.web.console.model.dto.KeyAuthDto;
|
|
|
-import cn.reghao.bnt.web.console.service.UserKeyService;
|
|
|
-import cn.reghao.jutil.jdk.result.Result;
|
|
|
-import cn.reghao.jutil.jdk.result.WebResult;
|
|
|
-import cn.reghao.oss.sdk.model.dto.ObjectInfo;
|
|
|
-import cn.reghao.oss.sdk.model.dto.ServerInfo;
|
|
|
-import cn.reghao.oss.sdk.model.dto.media.AudioInfo;
|
|
|
-import cn.reghao.oss.sdk.model.dto.media.ConvertedImageInfo;
|
|
|
-import cn.reghao.oss.sdk.model.dto.media.ImageInfo;
|
|
|
-import cn.reghao.oss.sdk.model.dto.media.VideoInfo;
|
|
|
-import cn.reghao.oss.api.iface.ConsoleService;
|
|
|
-import cn.reghao.bnt.web.console.rpc.StoreServiceWrapper;
|
|
|
-import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
-import io.swagger.v3.oas.annotations.Operation;
|
|
|
-import org.springframework.http.MediaType;
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author reghao
|
|
|
- * @date 2024-02-23 09:05:58
|
|
|
- */
|
|
|
-@Tag(name = "oss-sdk 接口")
|
|
|
-@RestController
|
|
|
-@RequestMapping("/bg/api/oss")
|
|
|
-public class OssSdkController {
|
|
|
- private final UserKeyService userKeyService;
|
|
|
- private final ConsoleService consoleService;
|
|
|
- private final StoreServiceWrapper storeServiceWrapper;
|
|
|
-
|
|
|
- public OssSdkController(UserKeyService userKeyService, ConsoleService consoleService,
|
|
|
- StoreServiceWrapper storeServiceWrapper) {
|
|
|
- this.userKeyService = userKeyService;
|
|
|
- this.consoleService = consoleService;
|
|
|
- this.storeServiceWrapper = storeServiceWrapper;
|
|
|
- }
|
|
|
-
|
|
|
- @Operation(summary = "对 oss key 进行认证", description = "N")
|
|
|
- @PostMapping(value = "/key/auth", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String authKey(@Validated KeyAuthDto keyAuthDto) {
|
|
|
- Result result = userKeyService.auth(keyAuthDto);
|
|
|
- if (result.getCode() == 0) {
|
|
|
- return WebResult.success(result.getData());
|
|
|
- }
|
|
|
-
|
|
|
- return WebResult.result(result);
|
|
|
- }
|
|
|
-
|
|
|
- @Operation(summary = "获取上传文件存储的 oss-store 节点", description = "N")
|
|
|
- @GetMapping(value = "/upload/store", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String getUploadStore(@RequestParam("channelCode") int channelCode) {
|
|
|
- ServerInfo serverInfo = consoleService.getUploadStore(channelCode);
|
|
|
- return WebResult.success(serverInfo);
|
|
|
- }
|
|
|
-
|
|
|
- @Operation(summary = "设置对象可见范围", description = "N")
|
|
|
- @PostMapping(value = "/object/scope", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String setObjectScope(int channelCode, String objectId, int scope) throws Exception {
|
|
|
- int loginUser = UserContext.getUserId();
|
|
|
- storeServiceWrapper.setObjectScope(channelCode, objectId, scope, loginUser);
|
|
|
- return WebResult.success();
|
|
|
- }
|
|
|
-
|
|
|
- @Operation(summary = "根据 objectId 删除对象", description = "N")
|
|
|
- @PostMapping(value = "/object/delete/id", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String deleteByObjectId(@RequestParam("channelCode") int channelCode,
|
|
|
- @RequestParam("objectId") String objectId) throws Exception {
|
|
|
- int loginUser = UserContext.getUserId();
|
|
|
- storeServiceWrapper.deleteByObjectId(channelCode, objectId, loginUser);
|
|
|
- return WebResult.success();
|
|
|
- }
|
|
|
-
|
|
|
- @Operation(summary = "根据 objectUrl 删除对象", description = "N")
|
|
|
- @PostMapping(value = "/object/delete/url", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String deleteByObjectUrl(@RequestParam("objectUrl") String objectUrl) {
|
|
|
- int loginUser = UserContext.getUserId();
|
|
|
- storeServiceWrapper.deleteByObjectUrl(objectUrl, loginUser);
|
|
|
- return WebResult.success();
|
|
|
- }
|
|
|
-
|
|
|
- @Operation(summary = "获取对象信息", description = "N")
|
|
|
- @GetMapping(value = "/object/info", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String getObjectInfo(@RequestParam("channelCode") int channelCode,
|
|
|
- @RequestParam("objectId") String objectId) throws Exception {
|
|
|
- int loginUser = UserContext.getUserId();
|
|
|
- ObjectInfo objectInfo = storeServiceWrapper.getObjectInfo(channelCode, objectId, loginUser);
|
|
|
- return WebResult.success(objectInfo);
|
|
|
- }
|
|
|
-
|
|
|
- @Operation(summary = "获取对象签名 url", description = "N")
|
|
|
- @GetMapping(value = "/object/url", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String getSignedUrl(@RequestParam("channelCode") Integer channelCode,
|
|
|
- @RequestParam("objectId") String objectId) throws Exception {
|
|
|
- int loginUser = UserContext.getUserId();
|
|
|
- String signedUrl = storeServiceWrapper.getSignedUrl(channelCode, objectId, loginUser);
|
|
|
- return WebResult.success(signedUrl);
|
|
|
- }
|
|
|
-
|
|
|
- @Operation(summary = "根据对象 url 获取签名 url", description = "N")
|
|
|
- @GetMapping(value = "/object/signed_url", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String getSignedUrlByUrl(@RequestParam("channelCode") Integer channelCode,
|
|
|
- @RequestParam("objectUrl") String objectUrl) throws Exception {
|
|
|
- int loginUser = UserContext.getUserId();
|
|
|
- String signedUrl = storeServiceWrapper.getSignedUrlByUrl(channelCode, objectUrl, loginUser);
|
|
|
- return WebResult.success(signedUrl);
|
|
|
- }
|
|
|
-
|
|
|
- @Operation(summary = "获取视频文件信息", description = "N")
|
|
|
- @GetMapping(value = "/object/video/info", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String getVideoInfo(@RequestParam("channelCode") Integer channelCode,
|
|
|
- @RequestParam("objectId") String objectId) throws Exception {
|
|
|
- int loginUser = UserContext.getUserId();
|
|
|
- VideoInfo videoInfo = storeServiceWrapper.getVideoInfo(channelCode, objectId, loginUser);
|
|
|
- return WebResult.success(videoInfo);
|
|
|
- }
|
|
|
-
|
|
|
- @Operation(summary = "获取图片文件信息", description = "N")
|
|
|
- @GetMapping(value = "/object/image/info", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String getImagesInfo(@RequestParam("channelCode") Integer channelCode,
|
|
|
- @RequestParam("objectId") String objectId) throws Exception {
|
|
|
- int loginUser = UserContext.getUserId();
|
|
|
- ImageInfo imageInfo = storeServiceWrapper.getImageInfo(channelCode, objectId, loginUser);
|
|
|
- return WebResult.success(imageInfo);
|
|
|
- }
|
|
|
-
|
|
|
- @Operation(summary = "获取 webp 图片文件信息", description = "N")
|
|
|
- @PostMapping(value = "/object/image/webp", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String getWebpInfo(@RequestParam("channelCode") Integer channelCode,
|
|
|
- @RequestParam("objectId") String objectId) throws Exception {
|
|
|
- int loginUser = UserContext.getUserId();
|
|
|
- ConvertedImageInfo convertedImageInfo = storeServiceWrapper.getWebpInfo(channelCode, objectId, loginUser);
|
|
|
- return WebResult.success(convertedImageInfo);
|
|
|
- }
|
|
|
-
|
|
|
- @Operation(summary = "获取音频文件信息", description = "N")
|
|
|
- @GetMapping(value = "/media/audio/info", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String getAudioInfo(@RequestParam("channelCode") Integer channelCode,
|
|
|
- @RequestParam("objectId") String objectId) throws Exception {
|
|
|
- int loginUser = UserContext.getUserId();
|
|
|
- AudioInfo audioInfo = storeServiceWrapper.getAudioInfo(channelCode, objectId, loginUser);
|
|
|
- return WebResult.success(audioInfo);
|
|
|
- }
|
|
|
-}
|