Merge branches 'preview' and 'preview' of https://gitea.qinmian.online/CY/mcwl-ai into preview
commit
aabccf6d99
|
@ -0,0 +1,81 @@
|
|||
package com.mcwl.web.controller.communityCenter;
|
||||
|
||||
import com.mcwl.common.core.controller.BaseController;
|
||||
import com.mcwl.common.core.domain.AjaxResult;
|
||||
import com.mcwl.communityCenter.domain.dto.CommentRes;
|
||||
import com.mcwl.communityCenter.domain.vo.PublicModelCommentVo;
|
||||
import com.mcwl.communityCenter.domain.PublishComment;
|
||||
import com.mcwl.communityCenter.service.PublishCommentService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 社群评论
|
||||
*/
|
||||
@Api(tags = "社群评论")
|
||||
@RequestMapping("publishComment")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
|
||||
public class PublishCommentController extends BaseController {
|
||||
|
||||
private final PublishCommentService publishCommentService;
|
||||
|
||||
|
||||
/**
|
||||
* 添加评论
|
||||
*
|
||||
* @param commentRes 评论请求参数
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "添加评论")
|
||||
@PostMapping("/save")
|
||||
public AjaxResult save(@RequestBody @Valid CommentRes commentRes) {
|
||||
|
||||
return publishCommentService.addComment(commentRes);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取评论
|
||||
*
|
||||
* @param publishComment
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取评论")
|
||||
@GetMapping("/comment/{Id}")
|
||||
public List<PublicModelCommentVo> getComment(@RequestBody PublishComment publishComment) {
|
||||
|
||||
return publishCommentService.getComment(publishComment);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 点赞或取消点赞评论
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param commentId 评论ID
|
||||
* @return 更新后的点赞数
|
||||
*/
|
||||
@ApiOperation(value = "点赞或取消点赞评论")
|
||||
@PostMapping("/{commentId}/like")
|
||||
public ResponseEntity<Integer> toggleLike(@PathVariable Long commentId, @RequestParam Long userId) {
|
||||
int updatedLikes = publishCommentService.toggleLike(userId, commentId);
|
||||
return ResponseEntity.ok(updatedLikes);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "删除评论")
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<String> delete(@PathVariable Long id) {
|
||||
publishCommentService.removeById(id);
|
||||
return ResponseEntity.ok("删除成功");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.mcwl.web.controller.communityCenter;
|
||||
|
||||
import com.mcwl.common.core.controller.BaseController;
|
||||
import com.mcwl.communityCenter.service.PublishCommissionLikeService;
|
||||
import com.mcwl.communityCenter.service.PublishCommentLikeService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -18,10 +18,10 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
@Api(tags = "社群评论区点赞")
|
||||
@RestController
|
||||
@RequestMapping("PublishCommissionLike")
|
||||
public class PublishCommissionLikeController extends BaseController {
|
||||
public class PublishCommentLikeController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private PublishCommissionLikeService publishCommissionLikeService;
|
||||
private PublishCommentLikeService publishCommentLikeService;
|
||||
|
||||
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
package com.mcwl.web.controller.communityCenter;
|
||||
|
||||
import com.mcwl.common.core.controller.BaseController;
|
||||
import com.mcwl.communityCenter.domain.PublicModelCommentVo;
|
||||
import com.mcwl.communityCenter.domain.PublishCommission;
|
||||
import com.mcwl.communityCenter.service.PublishCommissionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**社群评论
|
||||
* @Author:ChenYan
|
||||
* @Project:mcwl-ai
|
||||
* @Package:com.mcwl.web.controller.communityCenter
|
||||
* @Filename:PublishCommissionController
|
||||
* @Description TODO
|
||||
* @Date:2025/1/17 14:21
|
||||
*/
|
||||
@Api(tags = "社群评论")
|
||||
@RequestMapping("PublishCommission")
|
||||
@RestController
|
||||
public class PublishCommissionController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private PublishCommissionService publishCommissionService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取评论
|
||||
* @param publishCommission
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "获取评论")
|
||||
@GetMapping("/comment/{Id}")
|
||||
public List<PublicModelCommentVo> getComment(@RequestBody PublishCommission publishCommission) {
|
||||
|
||||
return publishCommissionService.getComment(publishCommission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加评论
|
||||
* @param publishCommission
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "添加评论")
|
||||
@PostMapping("/save")
|
||||
public ResponseEntity<String> save(@RequestBody PublishCommission publishCommission) {
|
||||
publishCommissionService.save(publishCommission);
|
||||
return ResponseEntity.ok("评论成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 点赞或取消点赞评论
|
||||
* @param userId 用户ID
|
||||
* @param commentId 评论ID
|
||||
* @return 更新后的点赞数
|
||||
*/
|
||||
@ApiOperation(value = "点赞或取消点赞评论")
|
||||
@PostMapping("/{commentId}/like")
|
||||
public ResponseEntity<Integer> toggleLike(@PathVariable Long commentId, @RequestParam Long userId) {
|
||||
int updatedLikes = publishCommissionService.toggleLike(userId, commentId);
|
||||
return ResponseEntity.ok(updatedLikes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "删除评论")
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<String> delete(@PathVariable Long id) {
|
||||
publishCommissionService.removeById(id);
|
||||
return ResponseEntity.ok("删除成功");
|
||||
}
|
||||
|
||||
}
|
|
@ -9,18 +9,12 @@ import lombok.Data;
|
|||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**社群评论区
|
||||
* @Author:ChenYan
|
||||
* @Project:mcwl-ai
|
||||
* @Package:com.mcwl.web.controller.communityCenter
|
||||
* @Filename:PublishCommission
|
||||
* @Description TODO
|
||||
* @Date:2025/1/17 14:11
|
||||
*/
|
||||
@ApiModel(description = "评论区评论")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("cc_publish_commission")
|
||||
public class PublishCommission extends BaseEntity {
|
||||
@TableName("cc_publish_comment")
|
||||
public class PublishComment extends BaseEntity {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
|
@ -32,6 +26,16 @@ public class PublishCommission extends BaseEntity {
|
|||
*/
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Long tenantId;
|
||||
/**
|
||||
* 社区id
|
||||
*/
|
||||
@ApiModelProperty(value = "社区id")
|
||||
private Long communityId;
|
||||
/**
|
||||
* 运营id
|
||||
*/
|
||||
@ApiModelProperty(value = "运营id")
|
||||
private Long operatorId;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
|
@ -52,11 +56,12 @@ public class PublishCommission extends BaseEntity {
|
|||
*/
|
||||
@ApiModelProperty(value = "点赞数")
|
||||
private Integer likeNum;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
* 评论类型 0发布 1提问
|
||||
*/
|
||||
@ApiModelProperty(value = "删除标志(0代表存在 2代表删除)")
|
||||
private String delFlag;
|
||||
@ApiModelProperty(value = "评论类型 0发布 1提问")
|
||||
private Integer type;
|
||||
|
||||
|
||||
}
|
|
@ -19,8 +19,8 @@ import lombok.EqualsAndHashCode;
|
|||
@ApiModel(description = "评论点赞")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("cc_publish_commission_like")
|
||||
public class PublishCommissionLike extends BaseEntity {
|
||||
@TableName("cc_publish_comment_like")
|
||||
public class PublishCommentLike extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 评论点赞id
|
||||
|
@ -42,5 +42,5 @@ public class PublishCommissionLike extends BaseEntity {
|
|||
* 评论id
|
||||
*/
|
||||
@ApiModelProperty(value = "评论id")
|
||||
private Long publishCommissionId;
|
||||
private Long publishCommentId;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.mcwl.communityCenter.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 评论请求参数
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "评论请求参数")
|
||||
public class CommentRes {
|
||||
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
@ApiModelProperty(value = "租户id", required = true)
|
||||
@NotNull(message = "租户id不能为空")
|
||||
private Long tenantId;
|
||||
/**
|
||||
* 社区id
|
||||
*/
|
||||
@ApiModelProperty(value = "社区id", required = true)
|
||||
@NotNull(message = "社区id不能为空")
|
||||
private Long communityId;
|
||||
/**
|
||||
* 运营id
|
||||
*/
|
||||
@ApiModelProperty(value = "运营id", required = true)
|
||||
@NotNull(message = "运营id不能为空")
|
||||
private Long operatorId;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@ApiModelProperty(value = "内容", required = true)
|
||||
@NotBlank(message = "内容不能为空")
|
||||
private String content;
|
||||
|
||||
|
||||
}
|
|
@ -12,7 +12,6 @@ import javax.validation.constraints.NotNull;
|
|||
* 社区请求参数
|
||||
*/
|
||||
@Data
|
||||
@TableName("cc_community")
|
||||
@ApiModel(value = "社区请求参数")
|
||||
public class CommunityRes {
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.mcwl.communityCenter.domain;
|
||||
package com.mcwl.communityCenter.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
|
@ -29,6 +29,8 @@ public class CustomTenantHandler implements TenantLineHandler {
|
|||
tables.add("cc_publish");
|
||||
// 提问表
|
||||
tables.add("cc_question");
|
||||
// 发布评论表
|
||||
tables.add("cc_publish_comment");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.mcwl.communityCenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mcwl.communityCenter.domain.PublishCommissionLike;
|
||||
import com.mcwl.communityCenter.domain.PublishCommentLike;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
|
@ -13,5 +13,5 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
* @Date:2025/1/17 14:26
|
||||
*/
|
||||
@Mapper
|
||||
public interface PublishCommissionLikeMapper extends BaseMapper<PublishCommissionLike> {
|
||||
public interface PublishCommentLikeMapper extends BaseMapper<PublishCommentLike> {
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
package com.mcwl.communityCenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mcwl.communityCenter.domain.PublishCommission;
|
||||
import com.mcwl.communityCenter.domain.PublishComment;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @Author:ChenYan
|
||||
|
@ -13,5 +15,6 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
* @Date:2025/1/17 14:29
|
||||
*/
|
||||
@Mapper
|
||||
public interface PublishCommissionMapper extends BaseMapper<PublishCommission> {
|
||||
public interface PublishCommentMapper extends BaseMapper<PublishComment> {
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.mcwl.communityCenter.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mcwl.communityCenter.domain.PublishCommissionLike;
|
||||
import com.mcwl.communityCenter.domain.PublishCommentLike;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
|
@ -13,6 +13,6 @@ import org.springframework.stereotype.Service;
|
|||
* @Date:2025/1/17 14:23
|
||||
*/
|
||||
@Service
|
||||
public interface PublishCommissionLikeService extends IService<PublishCommissionLike> {
|
||||
public interface PublishCommentLikeService extends IService<PublishCommentLike> {
|
||||
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
package com.mcwl.communityCenter.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mcwl.communityCenter.domain.PublicModelCommentVo;
|
||||
import com.mcwl.communityCenter.domain.PublishCommission;
|
||||
import com.mcwl.common.core.domain.AjaxResult;
|
||||
import com.mcwl.communityCenter.domain.dto.CommentRes;
|
||||
import com.mcwl.communityCenter.domain.vo.PublicModelCommentVo;
|
||||
import com.mcwl.communityCenter.domain.PublishComment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -15,7 +17,7 @@ import java.util.List;
|
|||
* @Date:2025/1/17 14:27
|
||||
*/
|
||||
|
||||
public interface PublishCommissionService extends IService<PublishCommission> {
|
||||
public interface PublishCommentService extends IService<PublishComment> {
|
||||
/**
|
||||
* 点赞或取消点赞评论
|
||||
* @param userId 用户ID
|
||||
|
@ -24,6 +26,7 @@ public interface PublishCommissionService extends IService<PublishCommission> {
|
|||
*/
|
||||
int toggleLike(Long userId, Long commentId);
|
||||
|
||||
List<PublicModelCommentVo> getComment(PublishCommission publishCommission);
|
||||
List<PublicModelCommentVo> getComment(PublishComment publishComment);
|
||||
|
||||
AjaxResult addComment(CommentRes commentRes);
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package com.mcwl.communityCenter.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.communityCenter.domain.PublishCommissionLike;
|
||||
import com.mcwl.communityCenter.mapper.PublishCommissionLikeMapper;
|
||||
import com.mcwl.communityCenter.service.PublishCommissionLikeService;
|
||||
import com.mcwl.communityCenter.domain.PublishCommentLike;
|
||||
import com.mcwl.communityCenter.mapper.PublishCommentLikeMapper;
|
||||
import com.mcwl.communityCenter.service.PublishCommentLikeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**评论区点赞业务层
|
||||
|
@ -15,5 +15,5 @@ import org.springframework.stereotype.Service;
|
|||
* @Date:2025/1/17 14:25
|
||||
*/
|
||||
@Service
|
||||
public class PublishCommissionLikeServiceImpl extends ServiceImpl<PublishCommissionLikeMapper, PublishCommissionLike>implements PublishCommissionLikeService {
|
||||
public class PublishCommentLikeServiceImpl extends ServiceImpl<PublishCommentLikeMapper, PublishCommentLike>implements PublishCommentLikeService {
|
||||
}
|
|
@ -1,15 +1,22 @@
|
|||
package com.mcwl.communityCenter.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mcwl.common.core.domain.AjaxResult;
|
||||
import com.mcwl.common.core.domain.entity.SysUser;
|
||||
import com.mcwl.communityCenter.domain.PublicModelCommentVo;
|
||||
import com.mcwl.communityCenter.domain.PublishCommission;
|
||||
import com.mcwl.communityCenter.domain.PublishCommissionLike;
|
||||
import com.mcwl.communityCenter.mapper.PublishCommissionLikeMapper;
|
||||
import com.mcwl.communityCenter.mapper.PublishCommissionMapper;
|
||||
import com.mcwl.communityCenter.service.PublishCommissionService;
|
||||
import com.mcwl.common.utils.SecurityUtils;
|
||||
import com.mcwl.communityCenter.domain.Publish;
|
||||
import com.mcwl.communityCenter.domain.dto.CommentRes;
|
||||
import com.mcwl.communityCenter.domain.vo.PublicModelCommentVo;
|
||||
import com.mcwl.communityCenter.domain.PublishComment;
|
||||
import com.mcwl.communityCenter.domain.PublishCommentLike;
|
||||
import com.mcwl.communityCenter.mapper.PublishCommentLikeMapper;
|
||||
import com.mcwl.communityCenter.mapper.PublishCommentMapper;
|
||||
import com.mcwl.communityCenter.mapper.PublishMapper;
|
||||
import com.mcwl.communityCenter.service.PublishCommentService;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -19,7 +26,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**评论区业务层
|
||||
/**
|
||||
* 评论区业务层
|
||||
*
|
||||
* @Author:ChenYan
|
||||
* @Project:mcwl-ai
|
||||
* @Package:com.mcwl.communityCenter.service.impl
|
||||
|
@ -28,17 +37,20 @@ import java.util.Objects;
|
|||
* @Date:2025/1/17 14:28
|
||||
*/
|
||||
@Service
|
||||
public class PublishCommissionServiceImpl extends ServiceImpl<PublishCommissionMapper, PublishCommission> implements PublishCommissionService {
|
||||
@Autowired
|
||||
private PublishCommissionMapper publishCommentMapper;
|
||||
@Autowired
|
||||
private PublishCommissionLikeMapper likeMapper;
|
||||
@RequiredArgsConstructor
|
||||
public class PublishCommentServiceImpl extends ServiceImpl<PublishCommentMapper, PublishComment> implements PublishCommentService {
|
||||
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
private final PublishCommentMapper publishCommentMapper;
|
||||
|
||||
private final PublishCommentLikeMapper likeMapper;
|
||||
|
||||
private final ISysUserService sysUserService;
|
||||
|
||||
private final PublishMapper publishMapper;
|
||||
|
||||
/**
|
||||
* 点赞或取消点赞评论
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param commentId 评论ID
|
||||
* @return 更新后的点赞数
|
||||
|
@ -47,22 +59,22 @@ public class PublishCommissionServiceImpl extends ServiceImpl<PublishCommissionM
|
|||
@Transactional
|
||||
public int toggleLike(Long userId, Long commentId) {
|
||||
// 检查评论是否存在
|
||||
PublishCommission comment = this.getById(commentId);
|
||||
PublishComment comment = this.getById(commentId);
|
||||
if (comment == null) {
|
||||
throw new RuntimeException("Comment not found");
|
||||
}
|
||||
|
||||
// 检查用户是否已经点赞
|
||||
PublishCommissionLike like = likeMapper.selectOne(
|
||||
new LambdaQueryWrapper<PublishCommissionLike>()
|
||||
.eq(PublishCommissionLike::getUserId, userId)
|
||||
.eq(PublishCommissionLike::getPublishCommissionId, commentId));
|
||||
PublishCommentLike like = likeMapper.selectOne(
|
||||
new LambdaQueryWrapper<PublishCommentLike>()
|
||||
.eq(PublishCommentLike::getUserId, userId)
|
||||
.eq(PublishCommentLike::getPublishCommentId, commentId));
|
||||
|
||||
if (like == null) { // 如果没有找到点赞记录,则进行点赞
|
||||
like = new PublishCommissionLike();
|
||||
like = new PublishCommentLike();
|
||||
like.setUserId(userId);
|
||||
like.setCommunityId(1L); // 假设有一个默认的社区ID
|
||||
like.setPublishCommissionId(commentId);
|
||||
like.setPublishCommentId(commentId);
|
||||
likeMapper.insert(like);
|
||||
|
||||
// 更新评论的点赞数
|
||||
|
@ -81,17 +93,17 @@ public class PublishCommissionServiceImpl extends ServiceImpl<PublishCommissionM
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<PublicModelCommentVo> getComment(PublishCommission publishCommission) {
|
||||
public List<PublicModelCommentVo> getComment(PublishComment publishComment) {
|
||||
List<PublicModelCommentVo> CommentVoList = new ArrayList<>();
|
||||
|
||||
// 查询所有父评论
|
||||
LambdaQueryWrapper<PublishCommission> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(PublishCommission::getTenantId, publishCommission.getTenantId())
|
||||
.isNull(PublishCommission::getParentId)
|
||||
.orderByDesc(PublishCommission::getCreateTime);
|
||||
LambdaQueryWrapper<PublishComment> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(PublishComment::getTenantId, publishComment.getTenantId())
|
||||
.isNull(PublishComment::getParentId)
|
||||
.orderByDesc(PublishComment::getCreateTime);
|
||||
// 添加父评论
|
||||
List<PublishCommission> modelCommentList = publishCommentMapper.selectList(lqw);
|
||||
for (PublishCommission Comment : modelCommentList) {
|
||||
List<PublishComment> modelCommentList = publishCommentMapper.selectList(lqw);
|
||||
for (PublishComment Comment : modelCommentList) {
|
||||
PublicModelCommentVo CommentVo = getModelCommentVo(Comment);
|
||||
CommentVoList.add(CommentVo);
|
||||
}
|
||||
|
@ -99,6 +111,28 @@ public class PublishCommissionServiceImpl extends ServiceImpl<PublishCommissionM
|
|||
return CommentVoList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult addComment(CommentRes commentRes) {
|
||||
Long tenantId = commentRes.getTenantId();
|
||||
Long communityId = commentRes.getCommunityId();
|
||||
Long operatorId = commentRes.getOperatorId();
|
||||
|
||||
Publish publish = publishMapper.selectByIdAndTenantIdAndCommunityId(operatorId, tenantId, communityId);
|
||||
if (Objects.isNull(publish)) {
|
||||
return AjaxResult.error("评论失败,该内容不存在");
|
||||
}
|
||||
|
||||
PublishComment publishComment = new PublishComment();
|
||||
BeanUtil.copyProperties(commentRes, publishComment);
|
||||
publishComment.setOperatorId(operatorId);
|
||||
publishComment.setUserId(SecurityUtils.getUserId());
|
||||
publishComment.setType(0);
|
||||
|
||||
publishCommentMapper.insert(publishComment);
|
||||
|
||||
return AjaxResult.success("评论成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构建CommentVo对象
|
||||
|
@ -107,7 +141,7 @@ public class PublishCommissionServiceImpl extends ServiceImpl<PublishCommissionM
|
|||
* @return CommentVo对象
|
||||
*/
|
||||
@NotNull
|
||||
private PublicModelCommentVo getModelCommentVo(PublishCommission Comment) {
|
||||
private PublicModelCommentVo getModelCommentVo(PublishComment Comment) {
|
||||
Long userId = Comment.getUserId();
|
||||
SysUser sysUser = sysUserService.selectUserById(userId);
|
||||
|
||||
|
@ -139,13 +173,13 @@ public class PublishCommissionServiceImpl extends ServiceImpl<PublishCommissionM
|
|||
}
|
||||
|
||||
// 查询子评论
|
||||
LambdaQueryWrapper<PublishCommission> lqw = new LambdaQueryWrapper<PublishCommission>()
|
||||
.eq(PublishCommission::getParentId, CommentId)
|
||||
.orderByDesc(PublishCommission::getCreateTime);
|
||||
LambdaQueryWrapper<PublishComment> lqw = new LambdaQueryWrapper<PublishComment>()
|
||||
.eq(PublishComment::getParentId, CommentId)
|
||||
.orderByDesc(PublishComment::getCreateTime);
|
||||
|
||||
List<PublishCommission> CommentList = publishCommentMapper.selectList(lqw);
|
||||
List<PublishComment> CommentList = publishCommentMapper.selectList(lqw);
|
||||
|
||||
for (PublishCommission Comment : CommentList) {
|
||||
for (PublishComment Comment : CommentList) {
|
||||
Long userId = Comment.getUserId();
|
||||
SysUser sysUser = sysUserService.selectUserById(userId);
|
||||
PublicModelCommentVo CommentVo = new PublicModelCommentVo();
|
Loading…
Reference in New Issue