feat[订单支付回调模块,排队模块]:订单查询素材列表,设备执行自动触发等
This commit is contained in:
@@ -113,5 +113,9 @@
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
+2
@@ -22,4 +22,6 @@ public interface ServiceNameConstants {
|
||||
String DEVICE_SERVICE = "device-center";
|
||||
|
||||
String FILE_SERVICE = "file-center";
|
||||
|
||||
String ORDER_SERVICE = "order-center";
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.central.common.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页实体类
|
||||
*
|
||||
@@ -26,7 +26,7 @@ public class PageResult<T> implements Serializable {
|
||||
/**
|
||||
* 是否成功:0 成功、1 失败
|
||||
*/
|
||||
private int code;
|
||||
private int resp_code;
|
||||
/**
|
||||
* 当前页结果集
|
||||
*/
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.io.Serializable;
|
||||
@AllArgsConstructor
|
||||
public class Result<T> implements Serializable {
|
||||
|
||||
private T datas;
|
||||
private T data;
|
||||
private Integer resp_code;
|
||||
private String resp_msg;
|
||||
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.central.common.utils;
|
||||
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class FileToMultipartFileConverterUtil {
|
||||
|
||||
public static MultipartFile convert(File file) throws IOException {
|
||||
String originalFilename = file.getName();
|
||||
String contentType = "application/octet-stream"; // 默认MIME类型,可以根据文件类型设置
|
||||
byte[] content = loadFileContent(file);
|
||||
|
||||
return new MockMultipartFile(
|
||||
"file", // 参数名,即<input type="file" name="...">中的name属性值
|
||||
originalFilename,
|
||||
contentType,
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
private static byte[] loadFileContent(File file) throws IOException {
|
||||
try (FileInputStream inputStream = new FileInputStream(file)) {
|
||||
// 创建一个足够大的字节数组来存储文件内容
|
||||
byte[] content = new byte[(int) file.length()];
|
||||
int bytesRead = inputStream.read(content);
|
||||
if (bytesRead != file.length()) {
|
||||
throw new IOException("Could not read the entire file into the byte array.");
|
||||
}
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
/*public static void main(String[] args) {
|
||||
// 示例用法
|
||||
File file = new File("path/to/your/file.txt");
|
||||
try {
|
||||
MultipartFile multipartFile = convert(file);
|
||||
// 现在你可以使用multipartFile对象,例如在Spring MVC控制器中处理文件上传
|
||||
System.out.println("File converted to MultipartFile successfully.");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
+1
-1
@@ -232,7 +232,7 @@ public class SearchBuilder {
|
||||
SearchHits searchHits = response.getHits();
|
||||
long totalCnt = searchHits.getTotalHits().value;
|
||||
List<JsonNode> list = getList(searchHits);
|
||||
return PageResult.<JsonNode>builder().data(list).code(0).count(totalCnt).build();
|
||||
return PageResult.<JsonNode>builder().data(list).resp_code(0).count(totalCnt).build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+20
-1
@@ -80,7 +80,7 @@ public class CosTemplate implements InitializingBean {
|
||||
* @param bucketName bucket名称
|
||||
* @param objectName 对象名
|
||||
*/
|
||||
private ObjectInfo upload(String bucketName, String objectName, InputStream is, int size, String contentType) {
|
||||
public ObjectInfo upload(String bucketName, String objectName, InputStream is, int size, String contentType) {
|
||||
ObjectMetadata objectMetadata = new ObjectMetadata();
|
||||
objectMetadata.setContentLength(size);
|
||||
objectMetadata.setContentType(contentType);
|
||||
@@ -95,6 +95,25 @@ public class CosTemplate implements InitializingBean {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传对象
|
||||
* @param objectName 对象名
|
||||
*/
|
||||
public ObjectInfo upload(String objectName, InputStream is, int size, String contentType) {
|
||||
ObjectMetadata objectMetadata = new ObjectMetadata();
|
||||
objectMetadata.setContentLength(size);
|
||||
objectMetadata.setContentType(contentType);
|
||||
PutObjectRequest putObjectRequest = new PutObjectRequest(fileProperties.getCos().getBucketName(), objectName, is, objectMetadata);
|
||||
putObjectRequest.getRequestClientOptions().setReadLimit(size + 1);
|
||||
|
||||
cosClient.putObject(putObjectRequest);
|
||||
|
||||
ObjectInfo obj = new ObjectInfo();
|
||||
obj.setObjectPath(fileProperties.getCos().getBucketName() + PATH_SPLIT + objectName);
|
||||
obj.setObjectUrl(fileProperties.getCos().getEndpoint() + PATH_SPLIT + obj.getObjectPath());
|
||||
return obj;
|
||||
}
|
||||
|
||||
public void delete(String objectName) {
|
||||
delete(fileProperties.getCos().getBucketName(), objectName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user