Search in sources :

Example 1 with MyLog

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();
}
Also used : MethodSignature(org.aspectj.lang.reflect.MethodSignature) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) Method(java.lang.reflect.Method) MyLog(com.qiwenshare.common.anno.MyLog) Before(org.aspectj.lang.annotation.Before)

Example 2 with MyLog

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();
}
Also used : CommonFile(com.qiwenshare.file.domain.CommonFile) ArrayList(java.util.ArrayList) FilePermission(com.qiwenshare.file.domain.FilePermission) Operation(io.swagger.v3.oas.annotations.Operation) MyLog(com.qiwenshare.common.anno.MyLog)

Example 3 with MyLog

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);
}
Also used : CommonFileUser(com.qiwenshare.file.vo.commonfile.CommonFileUser) JwtUser(com.qiwenshare.common.util.security.JwtUser) Operation(io.swagger.v3.oas.annotations.Operation) MyLog(com.qiwenshare.common.anno.MyLog)

Example 4 with MyLog

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);
}
Also used : QueryBuilder(org.elasticsearch.index.query.QueryBuilder) DisMaxQueryBuilder(org.elasticsearch.index.query.DisMaxQueryBuilder) NativeSearchQueryBuilder(org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder) NativeSearchQuery(org.springframework.data.elasticsearch.core.query.NativeSearchQuery) DisMaxQueryBuilder(org.elasticsearch.index.query.DisMaxQueryBuilder) Sort(org.springframework.data.domain.Sort) JwtUser(com.qiwenshare.common.util.security.JwtUser) NativeSearchQueryBuilder(org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder) HighlightBuilder(org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder) FileSearch(com.qiwenshare.file.config.es.FileSearch) Operation(io.swagger.v3.oas.annotations.Operation) MyLog(com.qiwenshare.common.anno.MyLog)

Example 5 with MyLog

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();
}
Also used : UserFile(com.qiwenshare.file.domain.UserFile) JwtUser(com.qiwenshare.common.util.security.JwtUser) Operation(io.swagger.v3.oas.annotations.Operation) MyLog(com.qiwenshare.common.anno.MyLog)

Aggregations

MyLog (com.qiwenshare.common.anno.MyLog)21 Operation (io.swagger.v3.oas.annotations.Operation)20 JwtUser (com.qiwenshare.common.util.security.JwtUser)16 UserFile (com.qiwenshare.file.domain.UserFile)8 RecoveryFile (com.qiwenshare.file.domain.RecoveryFile)2 ShareFile (com.qiwenshare.file.domain.ShareFile)2 UserBean (com.qiwenshare.file.domain.user.UserBean)2 UploadFileVo (com.qiwenshare.file.vo.file.UploadFileVo)2 LambdaUpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper)1 RestResult (com.qiwenshare.common.result.RestResult)1 FileSearch (com.qiwenshare.file.config.es.FileSearch)1 CommonFile (com.qiwenshare.file.domain.CommonFile)1 FilePermission (com.qiwenshare.file.domain.FilePermission)1 Share (com.qiwenshare.file.domain.Share)1 CommonFileUser (com.qiwenshare.file.vo.commonfile.CommonFileUser)1 ShareFileVO (com.qiwenshare.file.vo.share.ShareFileVO)1 UserLoginVo (com.qiwenshare.file.vo.user.UserLoginVo)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1