Commit 3734696e authored by 万成波's avatar 万成波

修复Bug

parent 3b33817d
......@@ -92,11 +92,17 @@ spring:
listener:
max-concurrency: 3
# 企业微信配置
wx:
cp:
redirect-url: https://test.tangguo.ren/bbsh5/pages/login/login
pc-redirect-url: https://test.tangguo.ren/bbs/pc/wechatlogin
mobile-redirect-url: https://test.tangguo.ren/bbsh5/pages/login/login
corp-id: ww63ca87d5f8647514
app-config:
agent-id: 1000072
secret: O2KXf2b9oGG2GBrpzDgf4EFdhGwl2KaS9BWtJQT1I64
app-configs:
- name: '移动端应用配置'
agent-id: 1000072
secret: O2KXf2b9oGG2GBrpzDgf4EFdhGwl2KaS9BWtJQT1I64
- name: '管理端应用配置'
agent-id: 1000072
secret: O2KXf2b9oGG2GBrpzDgf4EFdhGwl2KaS9BWtJQT1I64
......@@ -95,7 +95,13 @@ spring:
# 企业微信配置
wx:
cp:
pc-redirect-url: https://test.tangguo.ren/bbs/pc/wechatlogin
mobile-redirect-url: https://test.tangguo.ren/bbsh5/pages/login/login
corp-id: ww63ca87d5f8647514
app-config:
agent-id: 1000072
secret: O2KXf2b9oGG2GBrpzDgf4EFdhGwl2KaS9BWtJQT1I64
app-configs:
- name: '移动端应用配置'
agent-id: 1000072
secret: O2KXf2b9oGG2GBrpzDgf4EFdhGwl2KaS9BWtJQT1I64
- name: '管理端应用配置'
agent-id: 1000072
secret: O2KXf2b9oGG2GBrpzDgf4EFdhGwl2KaS9BWtJQT1I64
......@@ -30,7 +30,7 @@ public class ApplicationTest {
public void test() {
WxCpOAuth2Service oauth2Service = this.mobileWxCpService.getOauth2Service();
System.out.println(oauth2Service.buildAuthorizationUrl("https://test.tangguo.ren/bbs/h5/pages/login/login/", ""));
System.out.println(oauth2Service.buildAuthorizationUrl("https://qywx.tangguo.ren/bbs/h5/pages/login/login/", ""));
}
......
......@@ -14,6 +14,8 @@ import com.tangguo.service.IBbsMomentCommentService;
import com.tangguo.service.IBbsMomentService;
import com.tangguo.service.IBbsMomentVoteOptionService;
import com.tangguo.service.IBbsMomentVoteService;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......@@ -216,4 +218,16 @@ public class MBbsMomentController {
return AjaxResult.success();
}
/**
* 置顶评论
*/
@ApiOperation("置顶评论")
@PostMapping("/comment/top")
public AjaxResult topComment(@RequestBody BbsCommentTopBO bo) {
ValidateOperations.generalValidate(bo);
this.momentService.userTopComment(bo);
return AjaxResult.success();
}
}
......@@ -6,9 +6,11 @@ import com.tangguo.common.core.domain.AjaxResult;
import com.tangguo.common.core.page.TableDataInfo;
import com.tangguo.common.enums.BusinessType;
import com.tangguo.domain.BbsMomentComment;
import com.tangguo.domain.bo.BbsCommentTopBO;
import com.tangguo.service.IBbsMomentCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
......@@ -79,4 +81,16 @@ public class BbsMomentCommentController extends BaseController {
return getDataTable(list);
}
/**
* 置顶评论
*/
@ApiOperation("置顶评论")
@PreAuthorize("@ss.hasPermi('moment:comment:top')")
@PostMapping("/top")
public AjaxResult topComment(@RequestBody BbsCommentTopBO bo) {
this.bbsMomentCommentService.topMomentComment(bo);
return AjaxResult.success();
}
}
......@@ -13,6 +13,7 @@ import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
/**
......@@ -90,6 +91,14 @@ public class BbsMomentComment extends BaseEntity {
@ApiModelProperty("删除评论内容")
private String deleteComment;
/** 评论是否置顶:0 否、1 是 */
@ApiModelProperty("评论是否置顶:0 否、1 是")
private Integer isTop;
/** 评论置顶时间 */
@ApiModelProperty("评论置顶时间")
private Date topTime;
/**
* 动态内容
*/
......
package com.tangguo.domain.bo;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
*
*
* @author 谈笑
* @createTime 2025-11-05 16:12:43 星期三
*/
@Data
public class BbsCommentTopBO {
/**
* 动态Id
*/
@NotNull(message = "动态Id不能为空")
private Long momentId;
/**
* 评论Id
*/
@NotNull(message = "评论Id不能为空")
private Long commentId;
/**
* 置顶状态:0 取消置顶、1 置顶
*/
@NotNull(message = "置顶状态不能为空")
private Integer isTop;
}
......@@ -2,6 +2,7 @@ package com.tangguo.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.tangguo.domain.BbsMomentComment;
import com.tangguo.domain.bo.BbsCommentTopBO;
import com.tangguo.domain.vo.BbsCommentDetailVO;
import java.util.List;
......@@ -68,4 +69,12 @@ public interface IBbsMomentCommentService extends IService<BbsMomentComment> {
*/
void deleteMomentComments(Long momentId);
/**
* 置顶评论
*
* @param bo 请求参数
*/
void topMomentComment(BbsCommentTopBO bo);
}
......@@ -133,4 +133,12 @@ public interface IBbsMomentService extends IService<BbsMoment> {
*/
void userFeaturedComment(FeaturedCommentBO bo);
/**
* 置顶评论
*
* @param bo 评论
*/
void userTopComment(BbsCommentTopBO bo);
}
package com.tangguo.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tangguo.common.exception.ServiceException;
import com.tangguo.domain.BbsMomentComment;
import com.tangguo.domain.bo.BbsCommentTopBO;
import com.tangguo.domain.vo.BbsCommentDetailVO;
import com.tangguo.mapper.BbsMomentCommentMapper;
import com.tangguo.service.IBbsMomentCommentService;
......@@ -11,6 +15,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
......@@ -110,4 +115,29 @@ public class BbsMomentCommentServiceImpl extends ServiceImpl<BbsMomentCommentMap
);
}
/**
* 置顶评论
*
* @param bo 请求参数
*/
@Override
public void topMomentComment(BbsCommentTopBO bo) {
BbsMomentComment dbComment = this.getById(bo.getCommentId());
if (Objects.isNull(dbComment)) {
throw new ServiceException("操作失败,未查询到当前评论数据。");
}
LambdaUpdateWrapper<BbsMomentComment> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(BbsMomentComment::getId, dbComment.getId());
if (bo.getIsTop() == 1) {
wrapper.set(BbsMomentComment::getIsTop, 1);
wrapper.set(BbsMomentComment::getTopTime, new Date());
} else {
wrapper.set(BbsMomentComment::getIsTop, 0);
wrapper.set(BbsMomentComment::getTopTime, null);
}
this.update(wrapper);
}
}
......@@ -467,8 +467,29 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
this.commentService.updateById(updComment);
}
/**
/**
* 置顶评论
*
* @param bo 评论
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void userTopComment(BbsCommentTopBO bo) {
BbsMoment dbMoment = this.getById(bo.getMomentId());
if (Objects.isNull(dbMoment)) {
throw new ServiceException("操作失败,未查询到当前动态数据。");
}
String userName = SecurityUtils.getUsername();
if (!dbMoment.getUserName().equals(userName)) {
throw new ServiceException("操作失败,没有对当前动态评论的操作权限。");
}
this.commentService.topMomentComment(bo);
}
/**
* 构建动态实体
*
* @param bo 动态
......
......@@ -27,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</where>
ORDER BY
c.create_time DESC
c.is_top DESC, c.top_time DESC, c.create_time DESC
</select>
......@@ -41,7 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE
status = 1 AND FIND_IN_SET(#{commentId}, r.ancestor_path) AND r.id != #{commentId}
ORDER BY
r.create_time
r.is_top DESC, r.top_time DESC, r.create_time
</select>
......@@ -53,7 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE
status = 1 AND moment_id = #{momentId}
ORDER BY
create_time
is_top DESC, top_time DESC, create_time
</select>
......@@ -94,6 +94,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
OR m.is_enable_featured_comment = 0
OR (m.is_enable_featured_comment = 1 AND (c.user_name = #{userName} OR c.is_featured = 1))
)
ORDER BY
c.is_top DESC, c.top_time DESC, c.create_time
) AS c
WHERE rn &lt;= #{rows};
</select>
......@@ -126,7 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
OR (m.is_enable_featured_comment = 1 AND (c.user_name = #{userName} OR c.is_featured = 1))
)
ORDER BY
c.create_time
c.is_top DESC, c.top_time DESC, c.create_time
</select>
</mapper>
......@@ -20,6 +20,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="moment.content != null and moment.content != ''">
m.content LIKE CONCAT('%', #{moment.content}, '%')
</if>
<if test="moment.userName != null and moment.userName != ''">
AND uv.user_name LIKE CONCAT('%', #{moment.userName}, '%')
</if>
<if test="moment.nickName != null and moment.nickName != ''">
AND uv.nick_name LIKE CONCAT('%', #{moment.nickName}, '%')
</if>
<if test="moment.topicNames != null and moment.topicNames != ''">
AND m.topic_names LIKE CONCAT('%', #{moment.topicNames}, '%')
</if>
......@@ -133,7 +139,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) v ON v.moment_id = m.id
<where>
<if test="bo.content != null and bo.content != ''">
m.content LIKE CONCAT('%', #{bo.content}, '%')
(m.content LIKE CONCAT('%', #{bo.content}, '%')
OR uv.user_name LIKE CONCAT('%', #{bo.content}, '%')
OR uv.nick_name LIKE CONCAT('%', #{bo.content}, '%'))
</if>
<if test="bo.topicName != null and bo.topicName != ''">
AND m.topic_names LIKE CONCAT('%', #{bo.topicName}, '%')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment