inleft
2022-02-21 cfde488bdd0163986087c880e0a2762645f8c14c
资源获取修正
5 files modified
48 ■■■■ changed files
snowy-base/snowy-core/src/main/java/vip/xiaonuo/core/context/constant/ConstantContextHolder.java 8 ●●●●● patch | view | raw | blame | history
snowy-base/snowy-core/src/main/java/vip/xiaonuo/core/exception/enums/BlogExceptionEnum.java 1 ●●●● patch | view | raw | blame | history
snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/controller/BlogArticleOutsideController.java 27 ●●●● patch | view | raw | blame | history
snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/mapper/mapping/BlogArticleMapper.xml 2 ●●● patch | view | raw | blame | history
snowy-main/src/main/java/vip/xiaonuo/modular/blogarticletype/controller/BlogArticleTypeOutsideController.java 10 ●●●●● patch | view | raw | blame | history
snowy-base/snowy-core/src/main/java/vip/xiaonuo/core/context/constant/ConstantContextHolder.java
@@ -323,6 +323,14 @@
    }
    /**
     * 获取blog资源地址访问前缀
     * @return
     */
    public static String getBlogSourcePrefix() {
        return getSysConfig("visit", String.class, true);
    }
    /**
     * 获取config表中的配置,如果为空返回默认值
     *
     * @param configCode   变量名称,对应sys_config表中的code
snowy-base/snowy-core/src/main/java/vip/xiaonuo/core/exception/enums/BlogExceptionEnum.java
@@ -47,6 +47,7 @@
    article_auth_pass_error(2, "日志授权码错误"),
    article_auth_private_error(3, "那属于他的自留地,以后再来探索吧.."),
    article_not_found(4, "这是黑洞..什么也没有"),
    article_file_lose(5, "啊噢,该文件已丢失.."),
 ;
    private final Integer code;
snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/controller/BlogArticleOutsideController.java
@@ -34,6 +34,7 @@
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.consts.MyConstant;
import vip.xiaonuo.core.context.constant.ConstantContextHolder;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import vip.xiaonuo.core.exception.BlogException;
import vip.xiaonuo.core.exception.enums.BlogExceptionEnum;
@@ -43,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;
@@ -63,6 +66,10 @@
    @Resource
    private BlogArticleService blogArticleService;
    @Resource
    private SysFileInfoService fileInfoService;
    /**
     * 查询blog文章
     *
@@ -78,12 +85,13 @@
        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.getCoverFileURL())) {
                if (!e.getCoverFileURL().startsWith("http")) {
                    //补上访问参数
                    e.setCoverFileURL(blogSourcePrefix + e.getCoverFileURL());
                }
            }
            return e;
@@ -121,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);
        }
@@ -130,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");
        }
@@ -138,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();
        }
    }
}
snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/mapper/mapping/BlogArticleMapper.xml
@@ -55,7 +55,7 @@
        <include refid="queryListCondition"/>
        order by a.top_value asc , a.create_date desc
        order by a.is_top desc,a.top_value asc , a.create_date desc
        limit #{param.pageNo},#{param.pageSize}
    </select>
snowy-main/src/main/java/vip/xiaonuo/modular/blogarticletype/controller/BlogArticleTypeOutsideController.java
@@ -62,16 +62,6 @@
    public ResponseData queryBlogArticleType() {
        List<BlogArticleTypeVo>  list=  blogArticleTypeService.listCount();
//        List<BlogArticleTypeVo> list = blogArticleTypeService.lambdaQuery()
//                .eq(BlogArticleType::getIsEnable, MyConstant.Yes)
//                .orderByAsc(BlogArticleType::getTopValue)
//                .orderByDesc(BlogArticleType::getCreateDate)
//                .list().stream().map(e -> {
//                    BlogArticleTypeVo vo = new BlogArticleTypeVo();
//                    BeanUtil.copyProperties(e, vo);
//                    return vo;
//                }).collect(Collectors.toList());
        return new SuccessResponseData(list);
    }