| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.article.domain.pojo.Article; |
| | | import com.ruoyi.article.domain.pojo.ArticleComments; |
| | | import com.ruoyi.article.dto.ArticleDTO; |
| | | import com.ruoyi.article.mapper.ArticleMapper; |
| | | import com.ruoyi.article.service.IArticleCommentsService; |
| | | import com.ruoyi.article.service.IArticleService; |
| | | import com.ruoyi.article.vo.ArticleCommentsVO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.enums.ArticleTypeEnum; |
| | | import com.ruoyi.common.core.enums.AuditStatusEnum; |
| | | import com.ruoyi.common.core.utils.page.PageDTO; |
| | | import com.ruoyi.system.api.domain.Member; |
| | | import com.ruoyi.system.api.domain.MemberAddress; |
| | | import com.ruoyi.system.api.feignClient.MemberClient; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import util.HuaWeiOBSUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Resource |
| | | private IArticleService articleService; |
| | | |
| | | @Resource |
| | | private IArticleCommentsService articleCommentsService; |
| | | |
| | | @Resource |
| | | private MemberClient emberClient; |
| | | |
| | | @Override |
| | | public PageDTO<Article> getArticleList(ArticleDTO articleDTO) { |
| | |
| | | wrapper.eq(Article::getMemberId,articleDTO.getMemberId()); |
| | | wrapper.eq( Article::getDelFlag,0); |
| | | wrapper.orderByDesc(Article::getCreateTime); |
| | | Page< Article> page1 = articleService.page(page, wrapper); |
| | | Page<Article> page1 = articleService.page(page, wrapper); |
| | | return PageDTO.of(page1); |
| | | } |
| | | |
| | | @Override |
| | | public void saveMemberArticle(ArticleDTO articleDTO) { |
| | | Article article=new Article(); |
| | | if (articleDTO.getId()!=null){ |
| | | article=articleService.getById(articleDTO.getId()); |
| | | } |
| | | article.setMemberId(articleDTO.getMemberId()); |
| | | article.setArticleType(ArticleTypeEnum.USER_POSTING); |
| | | article.setStatus(AuditStatusEnum.TO_BE_REVIEWED); |
| | | article.setContent(articleDTO.getContent()); |
| | | article.setTitle(articleDTO.getTitle()); |
| | | List<String> urlList=new ArrayList<>(); |
| | | if (articleDTO.getRticleImageUrl().length>0){ |
| | | for (MultipartFile file:articleDTO.getRticleImageUrl()){ |
| | | try { |
| | | String url= HuaWeiOBSUtil.obsUpload(file); |
| | | urlList.add(url); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | article.setImages(urlList.toString()); |
| | | } |
| | | articleService.saveOrUpdate(article); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void delMemberArticle(ArticleDTO articleDTO) { |
| | | articleService.removeById(articleDTO.getId()); |
| | | } |
| | | |
| | | @Override |
| | | public Article getMemberArticleInfo(ArticleDTO articleDTO) { |
| | | Article article=articleService.getById(articleDTO.getId()); |
| | | return article; |
| | | } |
| | | |
| | | @Override |
| | | public PageDTO<ArticleCommentsVO> getArticleCommentsList(ArticleDTO articleDTO) { |
| | | Page<ArticleComments> page = new Page<>(articleDTO.getPageCurr(), articleDTO.getPageSize()); |
| | | LambdaQueryWrapper< ArticleComments> wrapper= Wrappers.lambdaQuery(); |
| | | wrapper.eq(ArticleComments::getArticleId,articleDTO.getId()); |
| | | wrapper.eq( ArticleComments::getDelFlag,0); |
| | | wrapper.eq( ArticleComments::getType,1); |
| | | wrapper.orderByDesc(ArticleComments::getCreateTime); |
| | | Page<ArticleComments> page1 = articleCommentsService.page(page, wrapper); |
| | | |
| | | List<ArticleComments> articleCommentsList=page1.getRecords(); |
| | | List<ArticleCommentsVO> articleCommentsVOList=new ArrayList<>(); |
| | | for(ArticleComments articleComments:articleCommentsList){ |
| | | ArticleCommentsVO articleCommentsVO=new ArticleCommentsVO(); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public void getReport(ArticleDTO articleDTO) { |
| | | Article article= articleService.getById(articleDTO.getId()); |
| | | R<Member> membeOne = emberClient.getMembeOne(articleDTO.getMemberId()); |
| | | Member data = membeOne.getData(); |
| | | article.setReportBy(data.getNickname()); |
| | | article.setReportedTime(LocalDateTime.now()); |
| | | articleService.saveOrUpdate(article); |
| | | } |
| | | } |