| | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import vip.xiaonuo.core.annotion.BusinessLog; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.Future; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/outside") |
| | | @Slf4j |
| | | public class BlogArticleOutsideController { |
| | | |
| | | @Resource |
| | |
| | | @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("b49e4cc48616cfb8d5ed3e5b983165c8")) { |
| | | if (!SecureUtil.md5(addDto.getSecret()).equals(ConstantContextHolder.getPushCode())) { |
| | | throw new BlogException("口令错误.."); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | //前端根据条件标注小红点(发布时间和更新时间在7天内) |
| | | //前端根据条件标注小红点(发布时间小于更新时间,且在7天内) |
| | | if (e.getPublishDate().before(e.getUpdateDate()) |
| | | && DateUtil.between(e.getUpdateDate(), now, DateUnit.DAY) <= 7) { |
| | | e.setIsAnyUpdate(MyConstant.Yes); |
| | |
| | | throw new BlogException(BlogExceptionEnum.article_auth_private_error); |
| | | } |
| | | |
| | | //异步查询相邻记录 |
| | | Future<List<BlogArticleVo>> adjoiningRecord = blogArticleService.getAdjoiningRecord(queryDto); |
| | | |
| | | BlogArticleVo vo = new BlogArticleVo(); |
| | | |
| | | BeanUtil.copyProperties(find, vo); |
| | |
| | | |
| | | String tempURL = this.getBlogSourceURL(find.getArticleFileId()); |
| | | |
| | | if (StrUtil.isEmpty(tempURL)) |
| | | throw new BlogException(BlogExceptionEnum.article_file_lose); |
| | | //if (StrUtil.isEmpty(tempURL)) |
| | | //throw new BlogException(BlogExceptionEnum.article_file_lose); |
| | | |
| | | vo.setArticleFileURL(tempURL); |
| | | vo.setCoverFileURL(this.getBlogSourceURL(vo.getCoverFileId())); |
| | | |
| | | while (!adjoiningRecord.isDone()) { |
| | | try { |
| | | Thread.sleep(50); |
| | | } catch (InterruptedException e) { |
| | | } |
| | | } |
| | | |
| | | try { |
| | | vo.setPreviousRecord(adjoiningRecord.get().get(0)); |
| | | vo.setNextRecord(adjoiningRecord.get().get(1)); |
| | | } catch (Exception e) { |
| | | log.error("异步获取上下相邻日志id异常,id:{} ,msg:{}", queryDto.getId(), e.getMessage()); |
| | | } |
| | | |
| | | return new SuccessResponseData(vo); |
| | | } |
| | | |