use of com.qiwenshare.common.anno.MyLog in project qiwen-file by qiwenshare.
the class WebLogAcpect method doBefore.
/**
* 前置通知:在连接点之前执行的通知
*
* @param joinPoint 切入点
*/
@Before("webLog()")
public void doBefore(JoinPoint joinPoint) {
// 从切面织入点处通过反射机制获取织入点处的方法
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
// 获取切入点所在的方法
Method method = signature.getMethod();
// 获取操作
MyLog myLog = method.getAnnotation(MyLog.class);
if (myLog != null) {
operation = myLog.operation();
module = myLog.module();
}
// 接收到请求,记录请求内容
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
request = attributes.getRequest();
}
use of com.qiwenshare.common.anno.MyLog in project qiwen-file by qiwenshare.
the class CommonFileController method commonFile.
@Operation(summary = "共享文件", description = "共享文件统一接口", tags = { "common" })
@PostMapping(value = "/commonfile")
@MyLog(operation = "共享文件", module = CURRENT_MODULE)
@ResponseBody
public RestResult<String> commonFile(@RequestBody CommonFileDTO commonFileDTO) {
CommonFile commonFile = new CommonFile();
commonFile.setUserFileId(commonFileDTO.getUserFileId());
commonFileService.save(commonFile);
List<Long> list = JSON.parseArray(commonFileDTO.getCommonUserIds(), Long.class);
List<FilePermission> filePermissionList = new ArrayList<>();
for (Long userId : list) {
FilePermission filePermission = new FilePermission();
filePermission.setUserId(Long.parseLong(commonFileDTO.getCommonUserIds()));
filePermission.setCommonFileId(commonFile.commonFileId);
filePermission.setFilePermissionCode(commonFileDTO.getPermissionCode());
filePermissionList.add(filePermission);
}
filePermissionService.saveBatch(filePermissionList);
return RestResult.success();
}
use of com.qiwenshare.common.anno.MyLog in project qiwen-file by qiwenshare.
the class CommonFileController method commonFileUser.
@Operation(summary = "共享文件用户", description = "共享文件用户接口", tags = { "common" })
@GetMapping(value = "/commonfileuser")
@MyLog(operation = "共享文件用户", module = CURRENT_MODULE)
@ResponseBody
public RestResult<List<CommonFileUser>> commonFileUser() {
JwtUser sessionUserBean = SessionUtil.getSession();
List<CommonFileUser> list = commonFileService.selectCommonFileUser(sessionUserBean.getUserId());
return RestResult.success().data(list);
}
use of com.qiwenshare.common.anno.MyLog in project qiwen-file by qiwenshare.
the class FileController method searchFile.
@Operation(summary = "文件搜索", description = "文件搜索", tags = { "file" })
@GetMapping(value = "/search")
@MyLog(operation = "文件搜索", module = CURRENT_MODULE)
@ResponseBody
public RestResult<SearchHits<FileSearch>> searchFile(SearchFileDTO searchFileDTO) {
JwtUser sessionUserBean = SessionUtil.getSession();
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder();
HighlightBuilder.Field allHighLight = new HighlightBuilder.Field("*").preTags("<span class='keyword'>").postTags("</span>");
queryBuilder.withHighlightFields(allHighLight);
// 设置分页
int currentPage = (int) searchFileDTO.getCurrentPage() - 1;
int pageCount = (int) (searchFileDTO.getPageCount() == 0 ? 10 : searchFileDTO.getPageCount());
String order = searchFileDTO.getOrder();
Sort.Direction direction = null;
if (searchFileDTO.getDirection() == null) {
direction = Sort.Direction.DESC;
} else if ("asc".equals(searchFileDTO.getDirection())) {
direction = Sort.Direction.ASC;
} else if ("desc".equals(searchFileDTO.getDirection())) {
direction = Sort.Direction.DESC;
} else {
direction = Sort.Direction.DESC;
}
if (order == null) {
queryBuilder.withPageable(PageRequest.of(currentPage, pageCount));
} else {
queryBuilder.withPageable(PageRequest.of(currentPage, pageCount, Sort.by(direction, order)));
}
DisMaxQueryBuilder disMaxQueryBuilder = QueryBuilders.disMaxQuery();
QueryBuilder q1 = QueryBuilders.boolQuery().must(QueryBuilders.multiMatchQuery(searchFileDTO.getFileName(), "fileName", "content")).must(QueryBuilders.termQuery("userId", sessionUserBean.getUserId())).boost(// 分词
1f);
QueryBuilder q2 = QueryBuilders.boolQuery().must(QueryBuilders.wildcardQuery("fileName", "*" + searchFileDTO.getFileName() + "*")).must(QueryBuilders.wildcardQuery("content", "*" + searchFileDTO.getFileName() + "*")).must(QueryBuilders.termQuery("userId", sessionUserBean.getUserId())).boost(// 模糊匹配
2f);
disMaxQueryBuilder.add(q1);
disMaxQueryBuilder.add(q2);
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(disMaxQueryBuilder).withHighlightFields(allHighLight).build();
//
// queryBuilder.withQuery(QueryBuilders.boolQuery()
// // .must(QueryBuilders.matchQuery("fileName", searchFileDTO.getFileName()))
// .must(QueryBuilders.multiMatchQuery(searchFileDTO.getFileName(),"fileName", "content"))
// .must(QueryBuilders.termQuery("userId", sessionUserBean.getUserId()))
// ).withQuery(QueryBuilders.wildcardQuery("fileName", "*" + searchFileDTO.getFileName() + "*"));
SearchHits<FileSearch> search = elasticsearchRestTemplate.search(searchQuery, FileSearch.class);
return RestResult.success().data(search);
}
use of com.qiwenshare.common.anno.MyLog in project qiwen-file by qiwenshare.
the class FileController method createFile.
@Operation(summary = "创建文件", description = "目录(文件夹)的创建", tags = { "file" })
@RequestMapping(value = "/createfile", method = RequestMethod.POST)
@MyLog(operation = "创建文件", module = CURRENT_MODULE)
@ResponseBody
public RestResult<String> createFile(@Valid @RequestBody CreateFileDTO createFileDto) {
JwtUser sessionUserBean = SessionUtil.getSession();
boolean isDirExist = userFileService.isDirExist(createFileDto.getFileName(), createFileDto.getFilePath(), sessionUserBean.getUserId());
if (isDirExist) {
return RestResult.fail().message("同名文件已存在");
}
UserFile userFile = new UserFile();
userFile.setUserId(sessionUserBean.getUserId());
userFile.setFileName(createFileDto.getFileName());
userFile.setFilePath(createFileDto.getFilePath());
userFile.setDeleteFlag(0);
userFile.setIsDir(1);
userFile.setUploadTime(DateUtil.getCurrentTime());
userFileService.save(userFile);
fileDealComp.uploadESByUserFileId(userFile.getUserFileId());
return RestResult.success();
}
Aggregations