feat[订单支付回调模块,排队模块]:订单查询素材列表,设备执行自动触发等
This commit is contained in:
+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();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
Reference in New Issue
Block a user