|
@@ -1,21 +1,24 @@
|
|
|
package com.ruoyi.app.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.ruoyi.app.domain.TbAppUser;
|
|
|
-import com.ruoyi.app.domain.TbMyPublish;
|
|
|
-import com.ruoyi.app.domain.TbPublishComment;
|
|
|
-import com.ruoyi.app.domain.TbPublishThumbs;
|
|
|
-import com.ruoyi.app.service.ITbAppUserService;
|
|
|
-import com.ruoyi.app.service.ITbPublishCommentService;
|
|
|
-import com.ruoyi.app.service.ITbPublishThumbsService;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import com.ruoyi.app.domain.*;
|
|
|
+import com.ruoyi.app.service.*;
|
|
|
+import com.ruoyi.common.constant.HttpStatus;
|
|
|
+import com.ruoyi.common.core.page.PageDomain;
|
|
|
+import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
+import com.ruoyi.common.core.page.TableSupport;
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.common.utils.sql.SqlUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ruoyi.app.mapper.TbMyPublishMapper;
|
|
|
-import com.ruoyi.app.service.ITbMyPublishService;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -28,12 +31,89 @@ import java.util.List;
|
|
|
public class TbMyPublishServiceImpl extends ServiceImpl<TbMyPublishMapper, TbMyPublish> implements ITbMyPublishService {
|
|
|
|
|
|
@Autowired
|
|
|
+ private ITbPublishImgService imgService;
|
|
|
+ @Autowired
|
|
|
private ITbPublishThumbsService thumbsService;
|
|
|
@Autowired
|
|
|
private ITbPublishCommentService commentService;
|
|
|
@Autowired
|
|
|
private ITbAppUserService userService;
|
|
|
|
|
|
+ protected void startPage() {
|
|
|
+ PageDomain pageDomain = TableSupport.buildPageRequest();
|
|
|
+ Integer pageNum = pageDomain.getPageNum() == null ? 1 : pageDomain.getPageNum();
|
|
|
+ Integer pageSize = pageDomain.getPageSize() == null ? 10 : pageDomain.getPageSize();
|
|
|
+ if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
|
|
|
+ {
|
|
|
+ String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
|
|
+ PageHelper.startPage(pageNum, pageSize, orderBy);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 响应请求分页数据
|
|
|
+ */
|
|
|
+ @SuppressWarnings({ "rawtypes", "unchecked" })
|
|
|
+ protected TableDataInfo getDataTable(List<?> list) {
|
|
|
+ TableDataInfo rspData = new TableDataInfo();
|
|
|
+ rspData.setCode(HttpStatus.SUCCESS);
|
|
|
+ rspData.setMsg("查询成功");
|
|
|
+ rspData.setRows(list);
|
|
|
+ rspData.setTotal(new PageInfo(list).getTotal());
|
|
|
+ return rspData;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TableDataInfo pageList(TbMyPublish tbMyPublish) {
|
|
|
+ startPage();
|
|
|
+ LambdaQueryWrapper<TbMyPublish> lqw = new LambdaQueryWrapper<TbMyPublish>();
|
|
|
+ if (tbMyPublish.getAppUserId() != null){
|
|
|
+ lqw.eq(TbMyPublish::getAppUserId ,tbMyPublish.getAppUserId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(tbMyPublish.getContents())){
|
|
|
+ lqw.like(TbMyPublish::getContents ,tbMyPublish.getContents());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(tbMyPublish.getMessage())){
|
|
|
+ lqw.eq(TbMyPublish::getMessage ,tbMyPublish.getMessage());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(tbMyPublish.getDeleted())){
|
|
|
+ lqw.eq(TbMyPublish::getDeleted ,tbMyPublish.getDeleted());
|
|
|
+ }
|
|
|
+ List<TbMyPublish> list = baseMapper.pageList(lqw);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TbMyPublish getPublish(Long id) {
|
|
|
+ TbMyPublish publish = this.getById(id);
|
|
|
+ if (publish != null) {
|
|
|
+ List<TbPublishImg> publishImgs = imgService.list(new LambdaQueryWrapper<TbPublishImg>()
|
|
|
+ .in(TbPublishImg::getPublishId, id)
|
|
|
+ );
|
|
|
+ int thumbs = this.getThumbs(id);
|
|
|
+ int comments = this.getComments(id);
|
|
|
+ if (publish.getMessageUserId() != null) {
|
|
|
+ TbAppUser user = userService.getById(publish.getMessageUserId());
|
|
|
+ publish.setMessageUser(user.getNickName());
|
|
|
+ }
|
|
|
+ publish.setImgList(publishImgs);
|
|
|
+ publish.setThumbs(thumbs);
|
|
|
+ publish.setComments(comments);
|
|
|
+ }
|
|
|
+ return publish;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean delPublish(List<Long> ids){
|
|
|
+ List<TbMyPublish> publishList = this.list(new LambdaQueryWrapper<TbMyPublish>()
|
|
|
+ .in(TbMyPublish::getId, Arrays.asList(ids))
|
|
|
+ );
|
|
|
+ if (publishList.size() > 0) {
|
|
|
+ publishList.forEach(item -> {
|
|
|
+ item.setDeleted("Y");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return this.updateBatchById(publishList);
|
|
|
+ }
|
|
|
/**
|
|
|
* 获取点赞数
|
|
|
* @param publishId 近况id
|
|
@@ -82,7 +162,7 @@ public class TbMyPublishServiceImpl extends ServiceImpl<TbMyPublishMapper, TbMyP
|
|
|
if (userList.size() > 0) {
|
|
|
comments.forEach(item -> {
|
|
|
userList.forEach(user -> {
|
|
|
- if (item.getAppUserId() == user.getId()) {
|
|
|
+ if (item.getAppUserId().equals(user.getId())) {
|
|
|
item.setAppUserUrl(user.getAvatar());
|
|
|
item.setAppUser(user.getNickName());
|
|
|
}
|