feat: 新增上传采集网络价格数据
This commit is contained in:
38
src/test/java/mjkf/xinke/LoginTest.java
Normal file
38
src/test/java/mjkf/xinke/LoginTest.java
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
package mjkf.xinke;
|
||||
|
||||
import mjkf.xinke.auth.core.enums.SaClientTypeEnum;
|
||||
import mjkf.xinke.auth.modular.login.param.AuthAccountPasswordLoginParam;
|
||||
import mjkf.xinke.auth.modular.login.service.AuthService;
|
||||
import mjkf.xinke.dev.modular.dict.service.DevDictService;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* TestMain方法
|
||||
*
|
||||
*
|
||||
* @date 2022/9/17 17:10
|
||||
*/
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class LoginTest {
|
||||
@Resource
|
||||
DevDictService devDictService;
|
||||
@Resource
|
||||
AuthService authService;
|
||||
|
||||
@org.junit.Test
|
||||
public void test() throws Exception {
|
||||
var param = new AuthAccountPasswordLoginParam();
|
||||
param.setAccount("superAdmin");
|
||||
param.setPassword("3578ea7ec54cf6c870892438b63f30af45096e4c91f3753ae377f369207cc0f7c1fc028bd24464eea8fb9f8e8bc3dd2c9d009351b16f56ee9aee30d6d5c98d1e71e9e9076a3042107eae7edd2666794967d7787b92a1053efc976438db518ee01cd88177a921");
|
||||
var result = authService.doLogin(param, SaClientTypeEnum.B.getValue());
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
49
src/test/java/mjkf/xinke/UploadFileTest.java
Normal file
49
src/test/java/mjkf/xinke/UploadFileTest.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package mjkf.xinke;
|
||||
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import mjkf.xinke.dev.modular.file.enums.DevFileEngineTypeEnum;
|
||||
import mjkf.xinke.dev.modular.file.service.DevFileService;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class UploadFileTest {
|
||||
@Resource
|
||||
DevFileService devFileService;
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
var filePath = "C:\\Users\\Administrator\\Desktop\\材料管理系统模版\\主材\\网络价格.xlsx";
|
||||
var file = new File(filePath);
|
||||
var multipartFile = this.mockMultipartFile(file, "网络价格.xlsx", "application/x-zip-compressed");
|
||||
var fileId = devFileService.uploadReturnId(DevFileEngineTypeEnum.LOCAL.getValue(), multipartFile);
|
||||
System.out.println("UploadFileTest.test | fileId " + fileId);
|
||||
}
|
||||
|
||||
private MultipartFile mockMultipartFile(File file, String fileName, String contentType) {
|
||||
try {
|
||||
// 使用文件内容和文件名创建MockMultipartFile
|
||||
MockMultipartFile mockMultipartFile = new MockMultipartFile(
|
||||
"file", // 参数名,与表单提交时的name属性一致
|
||||
fileName, // 文件名
|
||||
contentType, // 文件内容类型
|
||||
new FileInputStream(file) // 文件内容
|
||||
);
|
||||
return mockMultipartFile;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user