oss去除,依赖整理

main
cheney 11 months ago
parent 9c49a1c448
commit 75c1b4038d
  1. 8
      common/pom.xml
  2. 4
      common/src/main/java/com/huoran/common/utils/AliyunOssUtil.java
  3. 10
      nakadai/pom.xml
  4. 25
      nakadai/src/main/java/com/huoran/nakadai/controller/CommentController.java
  5. 67
      nakadai/src/main/java/com/huoran/nakadai/controller/MessageController.java
  6. 35
      nakadai/src/main/java/com/huoran/nakadai/service/impl/OSSFileServiceImpl.java
  7. 32
      occupationlab/src/main/java/com/huoran/occupationlab/service/impl/OSSFileServiceImpl.java
  8. 10
      pom.xml

@ -91,10 +91,10 @@
<artifactId>aliyun-java-sdk-core</artifactId> <artifactId>aliyun-java-sdk-core</artifactId>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>com.aliyun</groupId> <!-- <groupId>com.aliyun</groupId>-->
<artifactId>aliyun-sdk-vod-upload</artifactId> <!-- <artifactId>aliyun-sdk-vod-upload</artifactId>-->
</dependency> <!-- </dependency>-->
<dependency> <dependency>
<groupId>com.aliyun</groupId> <groupId>com.aliyun</groupId>

@ -7,9 +7,7 @@ import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder; import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException; import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.*; import com.aliyun.oss.model.*;
import com.aliyun.vod.upload.impl.UploadVideoImpl;
import com.aliyun.vod.upload.req.UploadStreamRequest;
import com.aliyun.vod.upload.resp.UploadStreamResponse;
import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.vod.model.v20170321.DeleteVideoRequest; import com.aliyuncs.vod.model.v20170321.DeleteVideoRequest;
import com.aliyuncs.vod.model.v20170321.DeleteVideoResponse; import com.aliyuncs.vod.model.v20170321.DeleteVideoResponse;

@ -22,11 +22,11 @@
<dependencies> <dependencies>
<dependency> <!-- <dependency>-->
<groupId>com.huoran.parent</groupId> <!-- <groupId>com.huoran.parent</groupId>-->
<artifactId>websocket</artifactId> <!-- <artifactId>websocket</artifactId>-->
<version>1.0-SNAPSHOT</version> <!-- <version>1.0-SNAPSHOT</version>-->
</dependency> <!-- </dependency>-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

@ -12,8 +12,7 @@ import com.huoran.nakadai.entity.Notify;
import com.huoran.nakadai.entity.res.CommentRes; import com.huoran.nakadai.entity.res.CommentRes;
import com.huoran.nakadai.service.CommentService; import com.huoran.nakadai.service.CommentService;
import com.huoran.nakadai.service.NotifyService; import com.huoran.nakadai.service.NotifyService;
import com.huoran.websocket.model.dto.WebsocketMsgDTO;
import com.huoran.websocket.service.WebsocketService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
@ -42,8 +41,8 @@ public class CommentController {
@Autowired @Autowired
private NotifyService notifyService; private NotifyService notifyService;
@Autowired // @Autowired
private WebsocketService webSocketService; // private WebsocketService webSocketService;
@Autowired @Autowired
private UserClient userClient; private UserClient userClient;
@ -95,15 +94,15 @@ public class CommentController {
} }
// 发送webSocket消息 // 发送webSocket消息
if (comment.getReplyAccountId()!=null){ // if (comment.getReplyAccountId()!=null){
WebsocketMsgDTO websocketMsgDTO = new WebsocketMsgDTO(); // WebsocketMsgDTO websocketMsgDTO = new WebsocketMsgDTO();
websocketMsgDTO.setForm(accountId); // websocketMsgDTO.setForm(accountId);
websocketMsgDTO.setUsername(accountId); // websocketMsgDTO.setUsername(accountId);
websocketMsgDTO.setTo(comment.getReplyAccountId().toString()); // websocketMsgDTO.setTo(comment.getReplyAccountId().toString());
websocketMsgDTO.setContent(comment.getContent()); // websocketMsgDTO.setContent(comment.getContent());
websocketMsgDTO.setExtras(null); // websocketMsgDTO.setExtras(null);
webSocketService.send(websocketMsgDTO); // webSocketService.send(websocketMsgDTO);
} // }
return save ? R.ok() : R.error(); return save ? R.ok() : R.error();
} }

@ -3,9 +3,6 @@ package com.huoran.nakadai.controller;
import com.huoran.common.response.R; import com.huoran.common.response.R;
import com.huoran.common.utils.TokenUtils; import com.huoran.common.utils.TokenUtils;
import com.huoran.nakadai.service.MessageService; import com.huoran.nakadai.service.MessageService;
import com.huoran.websocket.model.dto.WebsocketMsgDTO;
import com.huoran.websocket.model.vo.SendMsgVO;
import com.huoran.websocket.service.WebsocketService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
@ -28,38 +25,38 @@ public class MessageController {
@Autowired @Autowired
private MessageService messageService; private MessageService messageService;
@Autowired // @Autowired
private WebsocketService webSocketService; // private WebsocketService webSocketService;
@ApiOperation(value = "所有在线用户接收消息通知",response = SendMsgVO.class) // @ApiOperation(value = "所有在线用户接收消息通知",response = SendMsgVO.class)
@PostMapping("/refreshPageNotification") // @PostMapping("/refreshPageNotification")
public void refreshPageNotification( // public void refreshPageNotification(
@ApiParam(name = "username", value = "发送者名称", required = false) // @ApiParam(name = "username", value = "发送者名称", required = false)
@RequestParam(required = false) String username, // @RequestParam(required = false) String username,
@ApiParam(name = "to", value = "发给谁(默认发送给所有在线用户)", required = false) // @ApiParam(name = "to", value = "发给谁(默认发送给所有在线用户)", required = false)
@RequestParam(required = false) String to, // @RequestParam(required = false) String to,
@ApiParam(name = "content", value = "消息通知", required = false) // @ApiParam(name = "content", value = "消息通知", required = false)
@RequestParam(required = false) String content) { // @RequestParam(required = false) String content) {
WebsocketMsgDTO websocketMsgDTO = new WebsocketMsgDTO(); // WebsocketMsgDTO websocketMsgDTO = new WebsocketMsgDTO();
websocketMsgDTO.setForm("系统消息"); // websocketMsgDTO.setForm("系统消息");
if (StringUtils.isEmpty(username)){ // if (StringUtils.isEmpty(username)){
websocketMsgDTO.setUsername("系统通知机器人"); // websocketMsgDTO.setUsername("系统通知机器人");
}else { // }else {
websocketMsgDTO.setUsername(username); // websocketMsgDTO.setUsername(username);
} // }
if (StringUtils.isEmpty(to)){ // if (StringUtils.isEmpty(to)){
websocketMsgDTO.setTo("all"); // websocketMsgDTO.setTo("all");
}else { // }else {
websocketMsgDTO.setTo(to); // websocketMsgDTO.setTo(to);
} // }
if (StringUtils.isEmpty(content)){ // if (StringUtils.isEmpty(content)){
websocketMsgDTO.setContent("refresh"); // websocketMsgDTO.setContent("refresh");
}else { // }else {
websocketMsgDTO.setContent(content); // websocketMsgDTO.setContent(content);
} // }
websocketMsgDTO.setExtras(null); // websocketMsgDTO.setExtras(null);
webSocketService.send(websocketMsgDTO); // webSocketService.send(websocketMsgDTO);
} // }
/** /**
* 发送指定的用户队列 * 发送指定的用户队列

@ -1,9 +1,6 @@
package com.huoran.nakadai.service.impl; package com.huoran.nakadai.service.impl;
import com.aliyun.oss.ClientException; import com.aliyun.oss.ClientException;
import com.aliyun.vod.upload.impl.UploadVideoImpl;
import com.aliyun.vod.upload.req.UploadStreamRequest;
import com.aliyun.vod.upload.resp.UploadStreamResponse;
import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.vod.model.v20170321.DeleteVideoRequest; import com.aliyuncs.vod.model.v20170321.DeleteVideoRequest;
import com.aliyuncs.vod.model.v20170321.DeleteVideoResponse; import com.aliyuncs.vod.model.v20170321.DeleteVideoResponse;
@ -70,8 +67,8 @@ public class OSSFileServiceImpl implements OSSFileService {
filesResult.setFileSize(fileSize); filesResult.setFileSize(fileSize);
//上传流请求 //上传流请求
UploadStreamRequest request = new UploadStreamRequest(ConstantPropertiesUtil.ACCESS_KEY_ID, // UploadStreamRequest request = new UploadStreamRequest(ConstantPropertiesUtil.ACCESS_KEY_ID,
ConstantPropertiesUtil.ACCESS_KEY_SECRET, title, originalFilename, inputStream); // ConstantPropertiesUtil.ACCESS_KEY_SECRET, title, originalFilename, inputStream);
/* 是否使用默认水印(可选),指定模板组ID时,根据模板组配置确定是否使用默认水印*/ /* 是否使用默认水印(可选),指定模板组ID时,根据模板组配置确定是否使用默认水印*/
//request.setShowWaterMark(true); //request.setShowWaterMark(true);
@ -104,20 +101,20 @@ public class OSSFileServiceImpl implements OSSFileService {
/* ECS部署区域*/ /* ECS部署区域*/
// request.setEcsRegionId("cn-shanghai"); // request.setEcsRegionId("cn-shanghai");
UploadVideoImpl uploader = new UploadVideoImpl(); // UploadVideoImpl uploader = new UploadVideoImpl();
UploadStreamResponse response = uploader.uploadStream(request); // UploadStreamResponse response = uploader.uploadStream(request);
//
//如果设置回调URL无效,不影响视频上传,可以返回VideoId同时会返回错误码。 // //如果设置回调URL无效,不影响视频上传,可以返回VideoId同时会返回错误码。
// 其他情况上传失败时,VideoId为空,此时需要根据返回错误码分析具体错误原因 // // 其他情况上传失败时,VideoId为空,此时需要根据返回错误码分析具体错误原因
String videoId = response.getVideoId(); // String videoId = response.getVideoId();
if (!response.isSuccess()) { // if (!response.isSuccess()) {
String errorMessage = "阿里云视频上传错误:" + "code:" + response.getCode() + ", message:" + response.getMessage(); // String errorMessage = "阿里云视频上传错误:" + "code:" + response.getCode() + ", message:" + response.getMessage();
log.error(errorMessage); // log.error(errorMessage);
if (StringUtils.isEmpty(videoId)) { // if (StringUtils.isEmpty(videoId)) {
throw new CustomException(ExceptionEnum.UNKNOWN_EXCEPTION); // throw new CustomException(ExceptionEnum.UNKNOWN_EXCEPTION);
} // }
} // }
filesResult.setFileId(videoId); // filesResult.setFileId(videoId);
return filesResult; return filesResult;
} }

@ -1,8 +1,6 @@
package com.huoran.occupationlab.service.impl; package com.huoran.occupationlab.service.impl;
import com.aliyun.vod.upload.impl.UploadVideoImpl;
import com.aliyun.vod.upload.req.UploadStreamRequest;
import com.aliyun.vod.upload.resp.UploadStreamResponse;
import com.aliyuncs.DefaultAcsClient; import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.vod.model.v20170321.DeleteVideoRequest; import com.aliyuncs.vod.model.v20170321.DeleteVideoRequest;
@ -91,23 +89,23 @@ public class OSSFileServiceImpl implements OSSFileService {
filesResult.setFileType(fileType); filesResult.setFileType(fileType);
//上传流请求 //上传流请求
UploadStreamRequest request = new UploadStreamRequest(ConstantPropertiesUtil.ACCESS_KEY_ID, ConstantPropertiesUtil.ACCESS_KEY_SECRET, title, originalFilename, inputStream); // UploadStreamRequest request = new UploadStreamRequest(ConstantPropertiesUtil.ACCESS_KEY_ID, ConstantPropertiesUtil.ACCESS_KEY_SECRET, title, originalFilename, inputStream);
//
//
UploadVideoImpl uploader = new UploadVideoImpl(); // UploadVideoImpl uploader = new UploadVideoImpl();
UploadStreamResponse response = uploader.uploadStream(request); // UploadStreamResponse response = uploader.uploadStream(request);
//如果设置回调URL无效,不影响视频上传,可以返回VideoId同时会返回错误码。 //如果设置回调URL无效,不影响视频上传,可以返回VideoId同时会返回错误码。
// 其他情况上传失败时,VideoId为空,此时需要根据返回错误码分析具体错误原因 // 其他情况上传失败时,VideoId为空,此时需要根据返回错误码分析具体错误原因
String videoId = response.getVideoId(); // String videoId = response.getVideoId();
if (!response.isSuccess()) { // if (!response.isSuccess()) {
String errorMessage = "阿里云视频上传错误:" + "code:" + response.getCode() + ", message:" + response.getMessage(); // String errorMessage = "阿里云视频上传错误:" + "code:" + response.getCode() + ", message:" + response.getMessage();
log.error(errorMessage); // log.error(errorMessage);
if (StringUtils.isEmpty(videoId)) { // if (StringUtils.isEmpty(videoId)) {
throw new CustomException(201, errorMessage); // throw new CustomException(201, errorMessage);
} // }
} // }
filesResult.setFileId(videoId); // filesResult.setFileId(videoId);
return filesResult; return filesResult;
} }

@ -200,11 +200,11 @@
<version>${aliyun-java-sdk-vod.version}</version> <version>${aliyun-java-sdk-vod.version}</version>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>com.aliyun</groupId> <!-- <groupId>com.aliyun</groupId>-->
<artifactId>aliyun-sdk-vod-upload</artifactId> <!-- <artifactId>aliyun-sdk-vod-upload</artifactId>-->
<version>${aliyun-sdk-vod-upload.version}</version> <!-- <version>${aliyun-sdk-vod-upload.version}</version>-->
</dependency> <!-- </dependency>-->
<!-- Easy poi--> <!-- Easy poi-->
<!-- excle导入导出依赖包 start --> <!-- excle导入导出依赖包 start -->

Loading…
Cancel
Save