From d80267c86dae99a64327cda6c7b48a7ce0f64f25 Mon Sep 17 00:00:00 2001 From: inleft <inleft@qq.com> Date: Wed, 10 Aug 2022 18:32:31 +0800 Subject: [PATCH] 优化视频文件出现时其他api受到的影响 --- snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/controller/BlogArticleOutsideController.java | 46 +++++++++++++++++++++++++++++++--------------- 1 files changed, 31 insertions(+), 15 deletions(-) diff --git a/snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/controller/BlogArticleOutsideController.java b/snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/controller/BlogArticleOutsideController.java index 843e2d0..fba976d 100644 --- a/snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/controller/BlogArticleOutsideController.java +++ b/snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/controller/BlogArticleOutsideController.java @@ -25,6 +25,8 @@ package vip.xiaonuo.modular.blogarticle.controller; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.PageUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.SecureUtil; @@ -40,9 +42,9 @@ import vip.xiaonuo.core.pojo.response.ResponseData; import vip.xiaonuo.core.pojo.response.SuccessResponseData; import vip.xiaonuo.modular.blogarticle.entity.BlogArticle; +import vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo; import vip.xiaonuo.modular.blogarticle.param.BlogArticleAddDto; import vip.xiaonuo.modular.blogarticle.param.BlogArticleQueryDto; -import vip.xiaonuo.modular.blogarticle.param.BlogArticleVo; import vip.xiaonuo.modular.blogarticle.service.BlogArticleService; import vip.xiaonuo.modular.blogarticletype.entity.BlogArticleType; import vip.xiaonuo.modular.blogarticletype.service.BlogArticleTypeService; @@ -79,7 +81,7 @@ @PostMapping("/blogArticle/add") @BusinessLog(title = "外部blog系统_blog文章_增加", opType = LogAnnotionOpTypeEnum.ADD) public ResponseData add(@RequestBody @Validated(BlogArticleAddDto.add.class) BlogArticleAddDto addDto) { - if (!SecureUtil.md5(addDto.getSecret()).equals("8616CFB8D5ED3E5B")) { + if (!SecureUtil.md5(addDto.getSecret()).equals("b49e4cc48616cfb8d5ed3e5b983165c8")) { throw new BlogException("口令错误.."); } @@ -122,9 +124,12 @@ BlogArticle article = new BlogArticle(); BeanUtil.copyProperties(addDto, article); - System.out.println(article.toString()); + article.setSeparateYear(DateUtil.year(article.getPublishDate())); + article.setSeparateMonth(DateUtil.month(article.getPublishDate()) + 1); + article.setSeparateDay(DateUtil.dayOfMonth(article.getPublishDate())); -// blogArticleService.add(blogArticleParam); + article.setIsEnable(MyConstant.Yes); + blogArticleService.save(article); return new SuccessResponseData(); } @@ -143,8 +148,13 @@ param.put("pageNo", PageUtil.getStart(queryDto.getPageNo() - 1, queryDto.getPageSize())); param.put("pageSize", queryDto.getPageSize()); param.put("typeId", queryDto.getTypeId()); + param.put("fileType", queryDto.getFileType()); String blogSourcePrefix = ConstantContextHolder.getBlogSourcePrefix(); + + Date now = DateUtil.date(); + //空类型查询条件,排除笔记系列,按更新时间倒序 + //含有类型查询,按发布时间倒序 List<BlogArticleVo> resList = blogArticleService.searchList(param).stream().map(e -> { if (StrUtil.isNotEmpty(e.getCoverFileURL())) { if (!e.getCoverFileURL().startsWith("http")) { @@ -152,6 +162,15 @@ e.setCoverFileURL(blogSourcePrefix + e.getCoverFileURL()); } } + + //前端根据条件标注小红点(发布时间和更新时间在7天内) + if (e.getPublishDate().before(e.getUpdateDate()) + && DateUtil.between(e.getUpdateDate(), now, DateUnit.DAY) <= 7) { + e.setIsAnyUpdate(MyConstant.Yes); + } else { + e.setIsAnyUpdate(MyConstant.No); + } + return e; }).collect(Collectors.toList()); @@ -184,7 +203,7 @@ throw new BlogException(BlogExceptionEnum.article_auth_error); } //授权码比对 - if (!SecureUtil.md5(find.getAuthPassword()).equals(queryDto.getAuthWord())) { + if (!find.getAuthPassword().equals(queryDto.getAuthWord())) { throw new BlogException(BlogExceptionEnum.article_auth_pass_error); } } else if (find.getAuthStatus().equals(MyConstant.AuthStatus.privateCode)) { @@ -195,16 +214,13 @@ BeanUtil.copyProperties(find, vo); - if (queryDto.getId() % 2 == 0) { - String tempURL = this.getBlogSourceURL(find.getArticleFileId()); -// if (StrUtil.isEmpty(tempURL)) -// throw new BlogException(BlogExceptionEnum.article_file_lose); - vo.setArticleFileURL(tempURL); - vo.setArticleFileURL("http://t.inleft.com/share/book/blog/a岛神灯.md"); - } else { - vo.setArticleFileURL("http://t.inleft.com/share/book/blog/es-search.md"); - } + String tempURL = this.getBlogSourceURL(find.getArticleFileId()); + + if (StrUtil.isEmpty(tempURL)) + throw new BlogException(BlogExceptionEnum.article_file_lose); + + vo.setArticleFileURL(tempURL); return new SuccessResponseData(vo); } @@ -215,7 +231,7 @@ return null; } else { String blogSourcePrefix = ConstantContextHolder.getBlogSourcePrefix(); - return blogSourcePrefix + sysFileInfo.getFileBucket() + sysFileInfo.getFileObjectName(); + return blogSourcePrefix + sysFileInfo.getFileBucket() + "/" + sysFileInfo.getFileObjectName(); } } -- Gitblit v1.9.1