Commit aade6923 authored by 万成波's avatar 万成波

优化代码

parent d1ef00e3
...@@ -11,18 +11,21 @@ ...@@ -11,18 +11,21 @@
<el-form-item label="账号"> <el-form-item label="账号">
<el-input v-model="queryParams.userName" placeholder="请输入"></el-input> <el-input v-model="queryParams.userName" placeholder="请输入"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="动态编号">
<el-input v-model="queryParams.momentId" placeholder="请输入"></el-input>
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="handleQuery">查询</el-button> <el-button type="primary" @click="handleQuery">查询</el-button>
<el-button @click="handleReset">重置</el-button> <el-button @click="handleReset">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-row class="mb10"> <el-row class="mb10">
<el-button type="primary" @click="handleExport">导出</el-button>
</el-row> </el-row>
<el-table :data="tableList"> <el-table :data="tableList">
<el-table-column label="序号" width="55" type="index" align="center"></el-table-column>
<el-table-column label="评论内容" prop="content" align="center"></el-table-column> <el-table-column label="评论内容" prop="content" align="center"></el-table-column>
<el-table-column label="所属动态" prop="momentContent" align="center"></el-table-column> <el-table-column label="动态编号" align="center" prop="momentId" width="100"></el-table-column>
<el-table-column label="动态内容" prop="momentContent" align="center"></el-table-column>
<el-table-column label="账号" prop="userName" align="center"></el-table-column> <el-table-column label="账号" prop="userName" align="center"></el-table-column>
<el-table-column label="姓名" prop="nickName" align="center"></el-table-column> <el-table-column label="姓名" prop="nickName" align="center"></el-table-column>
<el-table-column label="创建时间" prop="createTime" align="center"></el-table-column> <el-table-column label="创建时间" prop="createTime" align="center"></el-table-column>
...@@ -94,6 +97,11 @@ export default { ...@@ -94,6 +97,11 @@ export default {
} }
this.getList() this.getList()
}, },
handleExport() {
this.download('bbs/moment/comment/list/export', {
...this.queryParams
}, `动态评论_${new Date().getTime()}.xlsx`)
},
// 置顶/取消置顶 // 置顶/取消置顶
handleTop(row, isTop) { handleTop(row, isTop) {
let text = isTop == '0' ? '取消置顶' : '置顶' let text = isTop == '0' ? '取消置顶' : '置顶'
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<el-button type="primary" @click="handleExport">导出</el-button> <el-button type="primary" @click="handleExport">导出</el-button>
</el-row> </el-row>
<el-table :data="tableList"> <el-table :data="tableList">
<el-table-column label="序号" width="55" type="index" align="center"></el-table-column> <el-table-column label="动态编号" align="center" prop="id" width="100"></el-table-column>
<el-table-column label="动态内容" prop="content" align="center"> <el-table-column label="动态内容" prop="content" align="center">
<template #default="{ row }"> <template #default="{ row }">
<div v-html="formatContent(row.content)" class="content-container"></div> <div v-html="formatContent(row.content)" class="content-container"></div>
......
...@@ -5,6 +5,8 @@ import com.tangguo.common.core.controller.BaseController; ...@@ -5,6 +5,8 @@ import com.tangguo.common.core.controller.BaseController;
import com.tangguo.common.core.domain.AjaxResult; import com.tangguo.common.core.domain.AjaxResult;
import com.tangguo.common.core.page.TableDataInfo; import com.tangguo.common.core.page.TableDataInfo;
import com.tangguo.common.enums.BusinessType; import com.tangguo.common.enums.BusinessType;
import com.tangguo.common.utils.poi.ExcelUtil;
import com.tangguo.domain.BbsMoment;
import com.tangguo.domain.BbsMomentComment; import com.tangguo.domain.BbsMomentComment;
import com.tangguo.domain.bo.BbsCommentTopBO; import com.tangguo.domain.bo.BbsCommentTopBO;
import com.tangguo.service.IBbsMomentCommentService; import com.tangguo.service.IBbsMomentCommentService;
...@@ -15,6 +17,7 @@ import org.springframework.security.access.prepost.PreAuthorize; ...@@ -15,6 +17,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
...@@ -45,6 +48,20 @@ public class BbsMomentCommentController extends BaseController { ...@@ -45,6 +48,20 @@ public class BbsMomentCommentController extends BaseController {
} }
/**
* 导出动态列表
*/
@ApiOperation("导出动态评论列表")
@PreAuthorize("@ss.hasPermi('bbs:moment:export')")
@Log(title = "导出动态评论列表", businessType = BusinessType.EXPORT)
@PostMapping("/list/export")
public void export(HttpServletResponse response, BbsMomentComment comment) {
List<BbsMomentComment> list = bbsMomentCommentService.selectBbsMomentCommentList(comment);
ExcelUtil<BbsMomentComment> util = new ExcelUtil<>(BbsMomentComment.class);
util.exportExcel(response, list, "动态评论数据");
}
/** /**
* 获取动态评论记录详细信息 * 获取动态评论记录详细信息
*/ */
......
...@@ -37,17 +37,17 @@ public class BbsMomentComment extends BaseEntity { ...@@ -37,17 +37,17 @@ public class BbsMomentComment extends BaseEntity {
private Long id; private Long id;
/** 轻享内容ID */ /** 轻享内容ID */
@Excel(name = "轻享内容ID") @Excel(name = "动态编号")
@ApiModelProperty("轻享内容ID") @ApiModelProperty("轻享内容ID")
private Long momentId; private Long momentId;
/** 评论用户姓名 */ /** 评论用户姓名 */
@Excel(name = "评论用户姓名") @Excel(name = "用户姓名")
@ApiModelProperty("评论用户姓名") @ApiModelProperty("评论用户姓名")
private String nickName; private String nickName;
/** 评论用户名 */ /** 评论用户名 */
@Excel(name = "评论用户名") @Excel(name = "用户名")
@ApiModelProperty("评论用户名") @ApiModelProperty("评论用户名")
private String userName; private String userName;
...@@ -57,37 +57,30 @@ public class BbsMomentComment extends BaseEntity { ...@@ -57,37 +57,30 @@ public class BbsMomentComment extends BaseEntity {
private String content; private String content;
/** 评论图片地址(1-3张) */ /** 评论图片地址(1-3张) */
@Excel(name = "评论图片地址", readConverterExp = "1=-3张")
@ApiModelProperty("评论图片地址(1-3张)") @ApiModelProperty("评论图片地址(1-3张)")
private String imgsUrl; private String imgsUrl;
/** 评论状态:0 删除、1 正常 */ /** 评论状态:0 删除、1 正常 */
@Excel(name = "评论状态:0 删除、1 正常")
@ApiModelProperty("评论状态:0 删除、1 正常、2 隐藏") @ApiModelProperty("评论状态:0 删除、1 正常、2 隐藏")
private Integer status; private Integer status;
/** 评论是否精选:0 否、1 是 */ /** 评论是否精选:0 否、1 是 */
@Excel(name = "评论是否精选:0 否、1 是")
@ApiModelProperty("评论是否精选:0 否、1 是") @ApiModelProperty("评论是否精选:0 否、1 是")
private Integer isFeatured; private Integer isFeatured;
/** 父级评论ID(为空为评论,否则为回复。) */ /** 父级评论ID(为空为评论,否则为回复。) */
@Excel(name = "父级评论ID", readConverterExp = "为=空为评论,否则为回复。")
@ApiModelProperty("父级评论ID(为空为评论,否则为回复。)") @ApiModelProperty("父级评论ID(为空为评论,否则为回复。)")
private Long parentId; private Long parentId;
/** 回复的用户姓名 */ /** 回复的用户姓名 */
@Excel(name = "回复的用户姓名")
@ApiModelProperty("回复的用户姓名") @ApiModelProperty("回复的用户姓名")
private String replyNickName; private String replyNickName;
/** 评论祖级路径(逗号分隔) */ /** 评论祖级路径(逗号分隔) */
@Excel(name = "评论祖级路径", readConverterExp = "逗=号分隔")
@ApiModelProperty("评论祖级路径(逗号分隔)") @ApiModelProperty("评论祖级路径(逗号分隔)")
private String ancestorPath; private String ancestorPath;
/** 删除评论内容 */ /** 删除评论内容 */
@Excel(name = "删除评论内容")
@ApiModelProperty("删除评论内容") @ApiModelProperty("删除评论内容")
private String deleteComment; private String deleteComment;
...@@ -102,6 +95,7 @@ public class BbsMomentComment extends BaseEntity { ...@@ -102,6 +95,7 @@ public class BbsMomentComment extends BaseEntity {
/** /**
* 动态内容 * 动态内容
*/ */
@Excel(name = "动态内容")
@TableField(exist = false) @TableField(exist = false)
private String momentContent; private String momentContent;
......
...@@ -45,4 +45,7 @@ public class BbsCommentDetailVO { ...@@ -45,4 +45,7 @@ public class BbsCommentDetailVO {
/** 评论是否置顶:0 否、1 是 */ /** 评论是否置顶:0 否、1 是 */
private Integer isTop; private Integer isTop;
/** 动态选项编码 */
private String voteOptionCode;
} }
...@@ -352,6 +352,13 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment ...@@ -352,6 +352,13 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
throw new ServiceException("评论失败,当前动态未开启评论。"); throw new ServiceException("评论失败,当前动态未开启评论。");
} }
if (EnableStatus.QY.getStatus() == dbMoment.getIsEnableVote()) {
long voteCount = this.voteService.getUserMomentVoteCount(dbMoment.getId(), SecurityUtils.getUsername());
if (voteCount < 1) {
throw new ServiceException("评论失败,请先对当前动态进行投票。");
}
}
// 检查评论内容 // 检查评论内容
String content = bo.getContent(); String content = bo.getContent();
FoundWord fw = SensitiveWordUtils.getFoundFirstSensitive(content); FoundWord fw = SensitiveWordUtils.getFoundFirstSensitive(content);
......
...@@ -25,6 +25,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -25,6 +25,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="comment.userName != null and comment.userName != ''"> <if test="comment.userName != null and comment.userName != ''">
AND c.user_name LIKE CONCAT('%', #{comment.userName}, '%') AND c.user_name LIKE CONCAT('%', #{comment.userName}, '%')
</if> </if>
<if test="comment.momentId != null">
AND c.moment_id = #{comment.momentId}
</if>
</where> </where>
ORDER BY ORDER BY
c.is_top DESC, c.top_time DESC, c.create_time DESC c.is_top DESC, c.top_time DESC, c.create_time DESC
...@@ -114,11 +117,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -114,11 +117,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
c.reply_nick_name, c.reply_nick_name,
c.is_featured, c.is_featured,
c.is_top, c.is_top,
v.option_code AS vote_option_code,
IF(c.user_name = #{userName}, 1, 0) AS is_self IF(c.user_name = #{userName}, 1, 0) AS is_self
FROM FROM
bbs_moment_comment c bbs_moment_comment c
INNER JOIN INNER JOIN
bbs_moment m ON m.id = c.moment_id bbs_moment m ON m.id = c.moment_id
LEFT JOIN
(SELECT * FROM bbs_moment_vote WHERE user_name = #{userName}) v ON v.moment_id = m.id
WHERE WHERE
m.id = #{momentId} m.id = #{momentId}
AND AND
......
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