v0.0.2 评论界面处理
This commit is contained in:
parent
0211caf572
commit
71103eb85e
|
|
@ -55,5 +55,25 @@ namespace ZR.LiveForum.Model.Liveforum.Dto
|
||||||
public string? StatusLabel { get; set; }
|
public string? StatusLabel { get; set; }
|
||||||
[ExcelColumn(Name = "是否已删除")]
|
[ExcelColumn(Name = "是否已删除")]
|
||||||
public string? IsDeletedLabel { get; set; }
|
public string? IsDeletedLabel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 评论者昵称
|
||||||
|
/// </summary>
|
||||||
|
public string? UserName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 被回复用户昵称
|
||||||
|
/// </summary>
|
||||||
|
public string? ReplyToUserName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 帖子标题
|
||||||
|
/// </summary>
|
||||||
|
public string? PostTitle { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 父评论内容
|
||||||
|
/// </summary>
|
||||||
|
public string? ParentCommentContent { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -22,12 +22,58 @@ namespace ZR.Service.Liveforum
|
||||||
{
|
{
|
||||||
var predicate = QueryExp(parm);
|
var predicate = QueryExp(parm);
|
||||||
|
|
||||||
var response = Queryable()
|
var query = Queryable()
|
||||||
//.OrderBy("Id desc")
|
|
||||||
.Where(predicate.ToExpression())
|
.Where(predicate.ToExpression())
|
||||||
.ToPage<T_Comments, T_CommentsDto>(parm);
|
.LeftJoin<T_Users>((c, u) => c.UserId == u.Id)
|
||||||
|
.LeftJoin<T_Users>((c, u, ru) => c.ReplyToUserId == ru.Id)
|
||||||
|
.LeftJoin<T_Posts>((c, u, ru, p) => c.PostId == p.Id)
|
||||||
|
.LeftJoin<T_Comments>((c, u, ru, p, pc) => c.ParentCommentId == pc.Id);
|
||||||
|
|
||||||
return response;
|
// 排序:顶级评论在前,回复评论在后,同层级按创建时间倒序
|
||||||
|
// 使用多个OrderBy组合排序
|
||||||
|
query = query.OrderBy((c, u, ru, p, pc) => c.ParentCommentId == null ? 0 : 1, OrderByType.Asc)
|
||||||
|
.OrderBy((c, u, ru, p, pc) => c.CreatedAt, OrderByType.Desc);
|
||||||
|
|
||||||
|
var response = query.Select((c, u, ru, p, pc) => new T_CommentsDto()
|
||||||
|
{
|
||||||
|
Id = c.Id,
|
||||||
|
PostId = c.PostId,
|
||||||
|
UserId = c.UserId,
|
||||||
|
ParentCommentId = c.ParentCommentId,
|
||||||
|
ReplyToUserId = c.ReplyToUserId,
|
||||||
|
Content = c.Content,
|
||||||
|
LikeCount = c.LikeCount,
|
||||||
|
ReplyCount = c.ReplyCount,
|
||||||
|
Status = c.Status,
|
||||||
|
IpAddress = c.IpAddress,
|
||||||
|
CreatedAt = c.CreatedAt,
|
||||||
|
UpdatedAt = c.UpdatedAt,
|
||||||
|
IsDeleted = c.IsDeleted,
|
||||||
|
DeletedAt = c.DeletedAt,
|
||||||
|
UserName = u.NickName,
|
||||||
|
ReplyToUserName = ru.NickName,
|
||||||
|
PostTitle = p.Title,
|
||||||
|
ParentCommentContent = pc.Content,
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
var resp = ToPage(response, parm);
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分页查询(排序已在Select之前完成)
|
||||||
|
/// </summary>
|
||||||
|
private PagedInfo<T> ToPage<T>(ISugarQueryable<T> source, PagerInfo parm)
|
||||||
|
{
|
||||||
|
var page = new PagedInfo<T>();
|
||||||
|
var total = 0;
|
||||||
|
page.PageSize = parm.PageSize;
|
||||||
|
page.PageIndex = parm.PageNum;
|
||||||
|
// 注意:排序已经在 Select 之前完成了,这里不再需要排序
|
||||||
|
page.Result = source
|
||||||
|
.ToPageList(parm.PageNum, parm.PageSize, ref total);
|
||||||
|
page.TotalNum = total;
|
||||||
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,25 @@
|
||||||
@selection-change="handleSelectionChange"
|
@selection-change="handleSelectionChange"
|
||||||
>
|
>
|
||||||
<el-table-column type="selection" width="50" align="center"/>
|
<el-table-column type="selection" width="50" align="center"/>
|
||||||
<el-table-column prop="id" label="评论ID" align="center" v-if="columns.showColumn('id')"/>
|
<el-table-column prop="id" label="评论ID" align="center" width="80" v-if="columns.showColumn('id')"/>
|
||||||
<el-table-column prop="postId" label="帖子ID" align="center" v-if="columns.showColumn('postId')"/>
|
<el-table-column prop="postId" label="帖子ID" align="center" v-if="columns.showColumn('postId')"/>
|
||||||
<el-table-column prop="userId" label="用户Id" align="center" v-if="columns.showColumn('userId')"/>
|
<el-table-column prop="postTitle" label="帖子标题" align="center" width="200" :show-overflow-tooltip="true" v-if="columns.showColumn('postTitle')"/>
|
||||||
<el-table-column prop="parentCommentId" label="父评论Id" align="center" v-if="columns.showColumn('parentCommentId')"/>
|
<el-table-column prop="userId" label="评论者Id" align="center" v-if="columns.showColumn('userId')"/>
|
||||||
<el-table-column prop="replyToUserId" label="回复用户Id" align="center" v-if="columns.showColumn('replyToUserId')"/>
|
<el-table-column prop="userName" label="评论者" align="center" width="120" :show-overflow-tooltip="true" v-if="columns.showColumn('userName')"/>
|
||||||
<el-table-column prop="content" label="评论内容" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('content')"/>
|
<el-table-column prop="replyToUserName" label="被回复用户" align="center" width="120" :show-overflow-tooltip="true" v-if="columns.showColumn('replyToUserName')">
|
||||||
|
<template #default="scope">
|
||||||
|
<span v-if="scope.row.replyToUserName">{{ scope.row.replyToUserName }}</span>
|
||||||
|
<span v-else style="color: #999;">-</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="content" label="评论内容" align="left" width="300" :show-overflow-tooltip="true" v-if="columns.showColumn('content')">
|
||||||
|
<template #default="scope">
|
||||||
|
<div :style="{ paddingLeft: scope.row.parentCommentId ? '30px' : '0', position: 'relative' }">
|
||||||
|
<span v-if="scope.row.parentCommentId" style="color: #409eff; font-weight: bold;">回复:</span>
|
||||||
|
<span>{{ scope.row.content }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column prop="likeCount" label="评论点赞数" align="center" v-if="columns.showColumn('likeCount')"/>
|
<el-table-column prop="likeCount" label="评论点赞数" align="center" v-if="columns.showColumn('likeCount')"/>
|
||||||
<el-table-column prop="replyCount" label="评论回复数量" align="center" v-if="columns.showColumn('replyCount')"/>
|
<el-table-column prop="replyCount" label="评论回复数量" align="center" v-if="columns.showColumn('replyCount')"/>
|
||||||
<el-table-column prop="status" label="评论状态" align="center" v-if="columns.showColumn('status')">
|
<el-table-column prop="status" label="评论状态" align="center" v-if="columns.showColumn('status')">
|
||||||
|
|
@ -158,12 +171,15 @@ const queryParams = reactive({
|
||||||
userId: undefined,
|
userId: undefined,
|
||||||
})
|
})
|
||||||
const columns = ref([
|
const columns = ref([
|
||||||
{ visible: true, align: 'center', type: '', prop: 'id', label: '评论ID,主键自增' },
|
{ visible: true, align: 'center', type: '', prop: 'id', label: '评论ID' },
|
||||||
|
{ visible: true, align: 'center', type: '', prop: 'postTitle', label: '帖子标题' ,showOverflowTooltip: true },
|
||||||
|
{ visible: true, align: 'center', type: '', prop: 'userName', label: '评论者' ,showOverflowTooltip: true },
|
||||||
|
{ visible: true, align: 'center', type: '', prop: 'replyToUserName', label: '被回复用户' ,showOverflowTooltip: true },
|
||||||
{ visible: true, align: 'center', type: '', prop: 'postId', label: '帖子ID' },
|
{ visible: true, align: 'center', type: '', prop: 'postId', label: '帖子ID' },
|
||||||
{ visible: true, align: 'center', type: '', prop: 'userId', label: '用户Id' },
|
{ visible: true, align: 'center', type: '', prop: 'userId', label: '用户Id' },
|
||||||
{ visible: true, align: 'center', type: '', prop: 'parentCommentId', label: '父评论Id' },
|
{ visible: false, align: 'center', type: '', prop: 'parentCommentId', label: '父评论Id' },
|
||||||
{ visible: true, align: 'center', type: '', prop: 'replyToUserId', label: '回复用户Id' },
|
{ visible: false, align: 'center', type: '', prop: 'replyToUserId', label: '回复用户Id' },
|
||||||
{ visible: true, align: 'center', type: '', prop: 'content', label: '评论内容' ,showOverflowTooltip: true },
|
{ visible: true, align: 'left', type: '', prop: 'content', label: '评论内容' ,showOverflowTooltip: true },
|
||||||
{ visible: true, align: 'center', type: '', prop: 'likeCount', label: '评论点赞数' },
|
{ visible: true, align: 'center', type: '', prop: 'likeCount', label: '评论点赞数' },
|
||||||
{ visible: true, align: 'center', type: '', prop: 'replyCount', label: '评论回复数量' },
|
{ visible: true, align: 'center', type: '', prop: 'replyCount', label: '评论回复数量' },
|
||||||
{ visible: false, align: 'center', type: 'dict', prop: 'status', label: '评论状态' ,dictType: 'liveforum_posts_comments' },
|
{ visible: false, align: 'center', type: 'dict', prop: 'status', label: '评论状态' ,dictType: 'liveforum_posts_comments' },
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user