|
@@ -4,9 +4,11 @@ import cn.hutool.core.util.NumberUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.fjhx.xmhjc.entity.topic.po.TopicReplies;
|
|
import com.fjhx.xmhjc.entity.topic.po.TopicReplies;
|
|
|
|
+import com.fjhx.xmhjc.entity.topic.vo.TopicContentVo;
|
|
import com.fjhx.xmhjc.mapper.topic.TopicRepliesMapper;
|
|
import com.fjhx.xmhjc.mapper.topic.TopicRepliesMapper;
|
|
import com.fjhx.xmhjc.service.topic.TopicRepliesService;
|
|
import com.fjhx.xmhjc.service.topic.TopicRepliesService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.fjhx.xmhjc.service.website.WebsiteUsersService;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.fjhx.xmhjc.entity.topic.vo.TopicRepliesVo;
|
|
import com.fjhx.xmhjc.entity.topic.vo.TopicRepliesVo;
|
|
@@ -14,7 +16,9 @@ import com.fjhx.xmhjc.entity.topic.dto.TopicRepliesSelectDto;
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
import com.fjhx.xmhjc.entity.topic.dto.TopicRepliesDto;
|
|
import com.fjhx.xmhjc.entity.topic.dto.TopicRepliesDto;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -28,6 +32,9 @@ import java.util.List;
|
|
@Service
|
|
@Service
|
|
public class TopicRepliesServiceImpl extends ServiceImpl<TopicRepliesMapper, TopicReplies> implements TopicRepliesService {
|
|
public class TopicRepliesServiceImpl extends ServiceImpl<TopicRepliesMapper, TopicReplies> implements TopicRepliesService {
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private WebsiteUsersService websiteUsersService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<TopicRepliesVo> getList(TopicRepliesSelectDto dto) {
|
|
public List<TopicRepliesVo> getList(TopicRepliesSelectDto dto) {
|
|
IWrapper<TopicReplies> wrapper = getWrapper();
|
|
IWrapper<TopicReplies> wrapper = getWrapper();
|
|
@@ -42,6 +49,10 @@ public class TopicRepliesServiceImpl extends ServiceImpl<TopicRepliesMapper, Top
|
|
wrapper.orderByDesc("tr", TopicReplies::getId);
|
|
wrapper.orderByDesc("tr", TopicReplies::getId);
|
|
wrapper.eq(NumberUtil.isValidNumber(dto.getTopicId()), "topic_id", dto.getTopicId());
|
|
wrapper.eq(NumberUtil.isValidNumber(dto.getTopicId()), "topic_id", dto.getTopicId());
|
|
Page<TopicRepliesVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
Page<TopicRepliesVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
|
+ List<TopicRepliesVo> repliesVos = page.getRecords();
|
|
|
|
+ for (TopicRepliesVo repliesVo : repliesVos) {
|
|
|
|
+ repliesVo.setAuthorName(websiteUsersService.getAuthorName(repliesVo.getAuthor()));
|
|
|
|
+ }
|
|
return page;
|
|
return page;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -88,12 +99,30 @@ public class TopicRepliesServiceImpl extends ServiceImpl<TopicRepliesMapper, Top
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Boolean hasReply(Long id) {
|
|
|
|
|
|
+ public Boolean hasReply(Long topicId) {
|
|
|
|
+ Boolean hasReply = false;
|
|
|
|
+ Long count = lambdaQuery().eq(TopicReplies::getTopicId, topicId).count();
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ hasReply = true;
|
|
|
|
+ }
|
|
|
|
+ return hasReply;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean hasFloorReply(Long floorId) {
|
|
Boolean hasReply = false;
|
|
Boolean hasReply = false;
|
|
- Long count = lambdaQuery().eq(TopicReplies::getTopicId, id).count();
|
|
|
|
|
|
+ Long count = lambdaQuery().eq(TopicReplies::getFloorId, floorId).count();
|
|
if (count > 0) {
|
|
if (count > 0) {
|
|
hasReply = true;
|
|
hasReply = true;
|
|
}
|
|
}
|
|
return hasReply;
|
|
return hasReply;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public void deleteAndChild(Long id) {
|
|
|
|
+ removeById(id);
|
|
|
|
+ lambdaUpdate().eq(TopicReplies::getFloorId, id).remove();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|