|
@@ -4,6 +4,7 @@ import edu.travel.adapter.service.upload.UploadAdapter;
|
|
|
import edu.travel.resp.BaseResponse;
|
|
|
import edu.travel.rpc.RPCBaseResponse;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -26,12 +27,12 @@ public class UploadController {
|
|
|
public BaseResponse exitsFile(String md5) {
|
|
|
RPCBaseResponse rpcBaseResponse = uploadAdapter.exitsFile(md5);
|
|
|
if (rpcBaseResponse != null) {
|
|
|
- if (rpcBaseResponse.getCode() == 200){
|
|
|
- return new BaseResponse(200,"success",rpcBaseResponse.getData());
|
|
|
+ if (rpcBaseResponse.getCode() == HttpStatus.OK.value()){
|
|
|
+ return new BaseResponse(HttpStatus.OK.value(),"success",rpcBaseResponse.getData());
|
|
|
}
|
|
|
- return new BaseResponse(500,"request is error",null);
|
|
|
+ return new BaseResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(),"request is error",null);
|
|
|
}
|
|
|
- return new BaseResponse(500,"request is error",null);
|
|
|
+ return new BaseResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(),"request is error",null);
|
|
|
}
|
|
|
/**
|
|
|
* 上传过哪些分片
|
|
@@ -43,12 +44,12 @@ public class UploadController {
|
|
|
public BaseResponse exitsBlob(String md5) {
|
|
|
RPCBaseResponse rpcBaseResponse = uploadAdapter.exitsBlob(md5);
|
|
|
if (rpcBaseResponse != null) {
|
|
|
- if (rpcBaseResponse.getCode() == 200){
|
|
|
- return new BaseResponse(200,"success",rpcBaseResponse.getData());
|
|
|
+ if (rpcBaseResponse.getCode() == HttpStatus.OK.value()){
|
|
|
+ return new BaseResponse(HttpStatus.OK.value(), "success",rpcBaseResponse.getData());
|
|
|
}
|
|
|
- return new BaseResponse(500,"request is error",null);
|
|
|
+ return new BaseResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(),"request is error",null);
|
|
|
}
|
|
|
- return new BaseResponse(500,"request is error",null);
|
|
|
+ return new BaseResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(),"request is error",null);
|
|
|
}
|
|
|
/**
|
|
|
* 上传大文件分片
|
|
@@ -60,12 +61,12 @@ public class UploadController {
|
|
|
public BaseResponse uploadBigFile(MultipartFile file) {
|
|
|
RPCBaseResponse rpcBaseResponse = uploadAdapter.uploadBigFile(file);
|
|
|
if (rpcBaseResponse != null) {
|
|
|
- if (rpcBaseResponse.getCode() == 200){
|
|
|
- return new BaseResponse(200,"success",rpcBaseResponse.getData());
|
|
|
+ if (rpcBaseResponse.getCode() == HttpStatus.OK.value()){
|
|
|
+ return new BaseResponse(HttpStatus.OK.value(),"success",rpcBaseResponse.getData());
|
|
|
}
|
|
|
- return new BaseResponse(500,"request is error",null);
|
|
|
+ return new BaseResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(),"request is error",null);
|
|
|
}
|
|
|
- return new BaseResponse(500,"request is error",null);
|
|
|
+ return new BaseResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(),"request is error",null);
|
|
|
}
|
|
|
/**
|
|
|
* 合并大文件
|
|
@@ -77,12 +78,12 @@ public class UploadController {
|
|
|
public BaseResponse mergeFile(String json) {
|
|
|
RPCBaseResponse rpcBaseResponse = uploadAdapter.mergeFile(json);
|
|
|
if (rpcBaseResponse != null) {
|
|
|
- if (rpcBaseResponse.getCode() == 200){
|
|
|
- return new BaseResponse(200,"success",rpcBaseResponse.getData());
|
|
|
+ if (rpcBaseResponse.getCode() == HttpStatus.OK.value()){
|
|
|
+ return new BaseResponse(HttpStatus.OK.value(),"success",rpcBaseResponse.getData());
|
|
|
}
|
|
|
- return new BaseResponse(500,"request is error",null);
|
|
|
+ return new BaseResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(),"request is error",null);
|
|
|
}
|
|
|
- return new BaseResponse(500,"request is error",null);
|
|
|
+ return new BaseResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(),"request is error",null);
|
|
|
}
|
|
|
/**
|
|
|
* 上传小文件
|
|
@@ -94,11 +95,11 @@ public class UploadController {
|
|
|
public BaseResponse uploadFile(MultipartFile file) {
|
|
|
RPCBaseResponse rpcBaseResponse = uploadAdapter.uploadFile(file);
|
|
|
if (rpcBaseResponse != null) {
|
|
|
- if (rpcBaseResponse.getCode() == 200){
|
|
|
- return new BaseResponse(200,"success",rpcBaseResponse.getData());
|
|
|
+ if (rpcBaseResponse.getCode() == HttpStatus.OK.value()){
|
|
|
+ return new BaseResponse(HttpStatus.OK.value(),"success",rpcBaseResponse.getData());
|
|
|
}
|
|
|
- return new BaseResponse(500,"request is error",null);
|
|
|
+ return new BaseResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(),"request is error",null);
|
|
|
}
|
|
|
- return new BaseResponse(500,"request is error",null);
|
|
|
+ return new BaseResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(),"request is error",null);
|
|
|
}
|
|
|
}
|