mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-08 15:21:52 +08:00
1. 修改文件名和文件路径字段长度一致,因为如果不存在文件名的情况下,会使用文件路径作为字段名,防止数据库报错字段内容太长。
2. 修改type字段为ext_name,因为此字段本来就存的文件扩展名,并且新增mime_type字段,用来存储文件的类型。方便后期拓展网盘项目。 3. 修改文件路径生成方式:之前是md5,现在是sha256,降低文件碰撞概率。方便拓展网盘项目,实现秒传等功能。
This commit is contained in:
@@ -40,7 +40,7 @@ public class FileServiceTest extends BaseDbUnitTest {
|
||||
// mock 数据
|
||||
FileDO dbFile = randomPojo(FileDO.class, o -> { // 等会查询到
|
||||
o.setPath("yunai");
|
||||
o.setType("jpg");
|
||||
o.setExtName("jpg");
|
||||
o.setCreateTime(buildTime(2021, 1, 15));
|
||||
});
|
||||
fileMapper.insert(dbFile);
|
||||
@@ -48,7 +48,7 @@ public class FileServiceTest extends BaseDbUnitTest {
|
||||
fileMapper.insert(ObjectUtils.cloneIgnoreId(dbFile, o -> o.setPath("tudou")));
|
||||
// 测试 type 不匹配
|
||||
fileMapper.insert(ObjectUtils.cloneIgnoreId(dbFile, o -> {
|
||||
o.setType("png");
|
||||
o.setExtName("png");
|
||||
}));
|
||||
// 测试 createTime 不匹配
|
||||
fileMapper.insert(ObjectUtils.cloneIgnoreId(dbFile, o -> {
|
||||
@@ -82,7 +82,7 @@ public class FileServiceTest extends BaseDbUnitTest {
|
||||
when(client.getId()).thenReturn(10L);
|
||||
String name = "单测文件名";
|
||||
// 调用
|
||||
String result = fileService.createFile(name, path, content);
|
||||
String result = fileService.createFile(name, path, "application/octet-stream", content);
|
||||
// 断言
|
||||
assertEquals(result, url);
|
||||
// 校验数据
|
||||
@@ -90,7 +90,7 @@ public class FileServiceTest extends BaseDbUnitTest {
|
||||
assertEquals(10L, file.getConfigId());
|
||||
assertEquals(path, file.getPath());
|
||||
assertEquals(url, file.getUrl());
|
||||
assertEquals("jpg", file.getType());
|
||||
assertEquals("jpg", file.getExtName());
|
||||
assertEquals(content.length, file.getSize());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user