commit
25a8bf5429
@ -9,5 +9,5 @@ import java.util.List;
|
||||
|
||||
public interface ICommonFileService extends IService<CommonFile> {
|
||||
List<CommonFileUser> selectCommonFileUser(Long userId);
|
||||
List<CommonFileListVo> selectCommonFileByUser(Long userId);
|
||||
List<CommonFileListVo> selectCommonFileByUser(Long userId, Long sessionUserId);
|
||||
}
|
@ -67,8 +67,6 @@ public class AsyncTaskComp {
|
||||
}
|
||||
|
||||
public Future<String> deleteUserFile(String userFileId) {
|
||||
|
||||
long begin = System.currentTimeMillis();
|
||||
UserFile userFile = userFileService.getById(userFileId);
|
||||
if (userFile.getIsDir() == 1) {
|
||||
LambdaQueryWrapper<UserFile> userFileLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
@ -105,11 +103,17 @@ public class AsyncTaskComp {
|
||||
}
|
||||
}
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
System.out.println("任务 deleteUserFile 耗时=" + (end - begin));
|
||||
return new AsyncResult<String>("deleteUserFile");
|
||||
}
|
||||
|
||||
public Future<String> checkESUserFileId(String userFileId) {
|
||||
UserFile userFile = userFileMapper.selectById(userFileId);
|
||||
if (userFile == null) {
|
||||
fileDealComp.deleteESByUserFileId(userFileId);
|
||||
}
|
||||
return new AsyncResult<String>("checkUserFileId");
|
||||
}
|
||||
|
||||
|
||||
public Future<String> saveUnzipFile(UserFile userFile, FileBean fileBean, int unzipMode, String entryName, String filePath) {
|
||||
String unzipUrl = UFOPUtils.getTempFile(fileBean.getFileUrl()).getAbsolutePath().replace("." + userFile.getExtendName(), "");
|
||||
|
@ -287,7 +287,7 @@ public class FileDealComp {
|
||||
fileSearch.setContent(content);
|
||||
|
||||
}*/
|
||||
elasticsearchClient.index(i -> i.index("filesearch").id(String.valueOf(fileSearch.getUserFileId())).document(fileSearch));
|
||||
elasticsearchClient.index(i -> i.index("filesearch").id(fileSearch.getUserFileId()).document(fileSearch));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.debug("ES更新操作失败,请检查配置");
|
||||
@ -300,7 +300,7 @@ public class FileDealComp {
|
||||
try {
|
||||
elasticsearchClient.delete(d -> d
|
||||
.index("filesearch")
|
||||
.id(String.valueOf(userFileId)));
|
||||
.id(userFileId));
|
||||
} catch (Exception e) {
|
||||
log.debug("ES删除操作失败,请检查配置");
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import com.qiwenshare.file.domain.CommonFile;
|
||||
import com.qiwenshare.file.domain.FilePermission;
|
||||
import com.qiwenshare.file.domain.UserFile;
|
||||
import com.qiwenshare.file.dto.commonfile.CommonFileDTO;
|
||||
import com.qiwenshare.file.io.QiwenFile;
|
||||
import com.qiwenshare.file.vo.commonfile.CommonFileListVo;
|
||||
import com.qiwenshare.file.vo.commonfile.CommonFileUser;
|
||||
import com.qiwenshare.file.vo.file.FileListVo;
|
||||
@ -82,13 +83,9 @@ public class CommonFileController {
|
||||
@RequestMapping(value = "/getCommonFileByUser", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public RestResult<CommonFileListVo> getCommonFileByUser(
|
||||
@Parameter(description = "用户id", required = true) Long userId,
|
||||
@Parameter(description = "用户文件路径", required = true) String userFileId,
|
||||
@Parameter(description = "文件路径", required = true) String filePath,
|
||||
@Parameter(description = "当前页", required = true) long currentPage,
|
||||
@Parameter(description = "页面数量", required = true) long pageCount){
|
||||
|
||||
List<CommonFileListVo> commonFileVo = commonFileService.selectCommonFileByUser(userId);
|
||||
@Parameter(description = "用户id", required = true) Long userId){
|
||||
JwtUser sessionUserBean = SessionUtil.getSession();
|
||||
List<CommonFileListVo> commonFileVo = commonFileService.selectCommonFileByUser(userId, sessionUserBean.getUserId());
|
||||
|
||||
return RestResult.success().data(commonFileVo);
|
||||
|
||||
@ -105,8 +102,8 @@ public class CommonFileController {
|
||||
|
||||
CommonFile commonFile = commonFileService.getById(commonFileId);
|
||||
UserFile userFile = userFileService.getById(commonFile.getUserFileId());
|
||||
filePath = userFile.getFilePath() + filePath;
|
||||
IPage<FileListVo> fileList = userFileService.userFileList(userFile.getUserId(), filePath, currentPage, pageCount);
|
||||
QiwenFile qiwenFile = new QiwenFile(userFile.getFilePath(), filePath, true);
|
||||
IPage<FileListVo> fileList = userFileService.userFileList(userFile.getUserId(), qiwenFile.getPath(), currentPage, pageCount);
|
||||
|
||||
return RestResult.success().data(fileList);
|
||||
|
||||
|
@ -16,6 +16,7 @@ import com.qiwenshare.common.util.security.JwtUser;
|
||||
import com.qiwenshare.common.util.security.SessionUtil;
|
||||
import com.qiwenshare.file.api.IFileService;
|
||||
import com.qiwenshare.file.api.IUserFileService;
|
||||
import com.qiwenshare.file.component.AsyncTaskComp;
|
||||
import com.qiwenshare.file.component.FileDealComp;
|
||||
import com.qiwenshare.file.config.es.FileSearch;
|
||||
import com.qiwenshare.file.domain.FileBean;
|
||||
@ -55,6 +56,8 @@ public class FileController {
|
||||
|
||||
@Resource
|
||||
FileDealComp fileDealComp;
|
||||
@Resource
|
||||
AsyncTaskComp asyncTaskComp;
|
||||
@Autowired
|
||||
private ElasticsearchClient elasticsearchClient;
|
||||
|
||||
@ -141,6 +144,7 @@ public class FileController {
|
||||
BeanUtil.copyProperties(hit.source(), searchFileVO);
|
||||
searchFileVO.setHighLight(hit.highlight());
|
||||
searchFileVOList.add(searchFileVO);
|
||||
asyncTaskComp.checkESUserFileId(searchFileVO.getUserFileId());
|
||||
}
|
||||
return RestResult.success().data(searchFileVOList);
|
||||
}
|
||||
|
@ -30,15 +30,8 @@ public class TaskController {
|
||||
private ElasticsearchClient elasticsearchClient;
|
||||
|
||||
|
||||
@Scheduled(initialDelay = 1000 * 60 * 60 * 24, fixedRate = Long.MAX_VALUE)
|
||||
@Scheduled(fixedRate = 1000 * 60 * 60 * 24)
|
||||
public void updateElasticSearch() {
|
||||
|
||||
try {
|
||||
elasticsearchClient.delete(d -> d.index("filesearch"));
|
||||
} catch (Exception e) {
|
||||
log.debug("删除ES失败:" + e);
|
||||
}
|
||||
|
||||
List<UserFile> userfileList = userFileService.list();
|
||||
for (UserFile userFile : userfileList) {
|
||||
fileDealComp.uploadESByUserFileId(userFile.getUserFileId());
|
||||
|
@ -1,7 +1,9 @@
|
||||
package com.qiwenshare.file.io;
|
||||
|
||||
import com.qiwenshare.common.exception.QiwenException;
|
||||
import com.qiwenshare.ufop.util.UFOPUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* @author MAC
|
||||
@ -16,16 +18,16 @@ public class QiwenFile {
|
||||
private boolean isDirectory;
|
||||
|
||||
public QiwenFile(String pathname, boolean isDirectory) {
|
||||
if (pathname == null) {
|
||||
throw new NullPointerException();
|
||||
if (StringUtils.isEmpty(pathname)) {
|
||||
throw new QiwenException("file name format error,pathname:" + pathname);
|
||||
}
|
||||
this.path = formatPath(pathname);
|
||||
this.isDirectory = isDirectory;
|
||||
}
|
||||
|
||||
public QiwenFile(String parent, String child, boolean isDirectory) {
|
||||
if (child == null) {
|
||||
throw new NullPointerException();
|
||||
if (StringUtils.isEmpty(child)) {
|
||||
throw new QiwenException("file name format error,parent:" + parent +", child:" + child);
|
||||
}
|
||||
if (parent != null) {
|
||||
String parentPath = separator.equals(formatPath(parent)) ? "" : formatPath(parent);
|
||||
@ -40,12 +42,6 @@ public class QiwenFile {
|
||||
this.isDirectory = isDirectory;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
QiwenFile qiwen = new QiwenFile("/", "/sdf", true);
|
||||
int index = "/sdf".lastIndexOf(separator);
|
||||
System.out.println(index);
|
||||
}
|
||||
|
||||
public static String formatPath(String path) {
|
||||
path = UFOPUtils.pathSplitFormat(path);
|
||||
if ("/".equals(path)) {
|
||||
|
@ -11,6 +11,6 @@ import java.util.List;
|
||||
|
||||
public interface CommonFileMapper extends BaseMapper<CommonFile> {
|
||||
List<CommonFileUser> selectCommonFileUser(@Param("userId") Long userId);
|
||||
List<CommonFileListVo> selectCommonFileByUser(@Param("userId") Long userId);
|
||||
List<CommonFileListVo> selectCommonFileByUser(@Param("userId") Long userId, @Param("sessionUserId") Long sessionUserId);
|
||||
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ public class CommonFileService extends ServiceImpl<CommonFileMapper, CommonFile>
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommonFileListVo> selectCommonFileByUser(Long userId) {
|
||||
return commonFileMapper.selectCommonFileByUser(userId);
|
||||
public List<CommonFileListVo> selectCommonFileByUser(Long userId, Long sessionUserId) {
|
||||
return commonFileMapper.selectCommonFileByUser(userId, sessionUserId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,6 +36,7 @@ spring.servlet.multipart.enabled=true
|
||||
|
||||
spring.main.allow-bean-definition-overriding=true
|
||||
|
||||
# mybatis-plus 配置
|
||||
mybatis-plus.config-locations=classpath:mybatis-config.xml
|
||||
mybatis-plus.mapper-locations=classpath:mapper/*.xml
|
||||
mybatis-plus.type-aliases-package=com.qiwenshare.file.domain
|
||||
@ -74,9 +75,6 @@ fdfs.pool.max-wait-millis=5000
|
||||
fdfs.tracker-list=127.0.0.1:22122
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Redis数据库索引(默认为0)
|
||||
spring.redis.database=0
|
||||
# Redis服务器地址
|
||||
@ -96,13 +94,6 @@ spring.redis.lettuce.pool.min-idle=10
|
||||
#连接超时时间(毫秒)
|
||||
spring.redis.timeout=5000
|
||||
|
||||
|
||||
spring.data.elasticsearch.client.reactive.endpoints=127.0.0.1:9200
|
||||
spring.elasticsearch.rest.uris=127.0.0.1:9200
|
||||
spring.elasticsearch.rest.username=
|
||||
spring.elasticsearch.rest.password=
|
||||
|
||||
|
||||
#异步线程池
|
||||
#异步线程池组件开关,默认false
|
||||
spring.async-thread-pool.enable=true
|
||||
|
@ -13,10 +13,11 @@
|
||||
WHERE b.userId = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectCommonFileByUser" parameterType="java.lang.Long" resultType="com.qiwenshare.file.vo.commonfile.CommonFileListVo">
|
||||
<select id="selectCommonFileByUser" resultType="com.qiwenshare.file.vo.commonfile.CommonFileListVo">
|
||||
SELECT * FROM commonfile a
|
||||
LEFT JOIN userfile b ON b.userFileId = a.userFileId
|
||||
WHERE userId = #{userId}
|
||||
left join filepermission c on c.commonFileId = a.commonFileId
|
||||
WHERE b.userId = #{userId} and c.userId = #{sessionUserId}
|
||||
</select>
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user