inleft
2022-02-21 cfde488bdd0163986087c880e0a2762645f8c14c
snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/controller/BlogArticleOutsideController.java
@@ -44,6 +44,8 @@
import vip.xiaonuo.modular.blogarticle.param.BlogArticleQueryDto;
import vip.xiaonuo.modular.blogarticle.param.BlogArticleVo;
import vip.xiaonuo.modular.blogarticle.service.BlogArticleService;
import vip.xiaonuo.sys.modular.file.entity.SysFileInfo;
import vip.xiaonuo.sys.modular.file.service.SysFileInfoService;
import javax.annotation.Resource;
import java.util.HashMap;
@@ -64,6 +66,10 @@
    @Resource
    private BlogArticleService blogArticleService;
    @Resource
    private SysFileInfoService fileInfoService;
    /**
     * 查询blog文章
     *
@@ -79,11 +85,14 @@
        param.put("pageNo", PageUtil.getStart(queryDto.getPageNo() - 1, queryDto.getPageSize()));
        param.put("pageSize", queryDto.getPageSize());
        param.put("typeId", queryDto.getTypeId());
        String fileUploadPathForLinux = ConstantContextHolder.getDefaultFileUploadPathForLinux();
        String blogSourcePrefix = ConstantContextHolder.getBlogSourcePrefix();
        List<BlogArticleVo> resList = blogArticleService.searchList(param).stream().map(e -> {
            if (StrUtil.isNotEmpty(e.getArticleFileURL())) {
                e.setArticleFileURL(fileUploadPathForLinux + e.getArticleFileURL());
            if (StrUtil.isNotEmpty(e.getCoverFileURL())) {
                if (!e.getCoverFileURL().startsWith("http")) {
                    //补上访问参数
                    e.setCoverFileURL(blogSourcePrefix + e.getCoverFileURL());
                }
            }
            return e;
        }).collect(Collectors.toList());
@@ -120,7 +129,7 @@
            if (!SecureUtil.md5(find.getAuthPassword()).equals(queryDto.getAuthWord())) {
                throw new BlogException(BlogExceptionEnum.article_auth_pass_error);
            }
        }else if(find.getAuthStatus().equals(MyConstant.AuthStatus.privateCode)){
        } else if (find.getAuthStatus().equals(MyConstant.AuthStatus.privateCode)) {
            throw new BlogException(BlogExceptionEnum.article_auth_private_error);
        }
@@ -129,7 +138,11 @@
        BeanUtil.copyProperties(find, vo);
        if (queryDto.getId() % 2 == 0) {
            vo.setArticleFileURL("http://t.inleft.com/share/book/blog/es_index.md");
            String tempURL = this.getBlogSourceURL(find.getArticleFileId());
            if (StrUtil.isEmpty(tempURL))
                throw new BlogException(BlogExceptionEnum.article_file_lose);
            vo.setArticleFileURL(tempURL);
        } else {
            vo.setArticleFileURL("http://t.inleft.com/share/book/blog/es-search.md");
        }
@@ -137,5 +150,14 @@
        return new SuccessResponseData(vo);
    }
    private String getBlogSourceURL(Long fileId) {
        SysFileInfo sysFileInfo = fileInfoService.getById(fileId);
        if (sysFileInfo == null) {
            return null;
        } else {
            String blogSourcePrefix = ConstantContextHolder.getBlogSourcePrefix();
            return blogSourcePrefix + sysFileInfo.getFileBucket() + sysFileInfo.getFileObjectName();
        }
    }
}