| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | @Resource |
| | | private BlogArticleService blogArticleService; |
| | | |
| | | |
| | | @Resource |
| | | private SysFileInfoService fileInfoService; |
| | | |
| | | /** |
| | | * 查询blog文章 |
| | | * |
| | |
| | | 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; |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | 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"); |
| | | } |
| | |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | } |