diff --git a/ZR.LiveForum.Model/Liveforum/Dto/T_LikesDto.cs b/ZR.LiveForum.Model/Liveforum/Dto/T_LikesDto.cs
index dcc5a44..3c53eae 100644
--- a/ZR.LiveForum.Model/Liveforum/Dto/T_LikesDto.cs
+++ b/ZR.LiveForum.Model/Liveforum/Dto/T_LikesDto.cs
@@ -32,5 +32,15 @@ namespace ZR.LiveForum.Model.Liveforum.Dto
[ExcelColumn(Name = "点赞类型")]
public string? TargetTypeLabel { get; set; }
+
+ ///
+ /// 点赞用户昵称
+ ///
+ public string? UserName { get; set; }
+
+ ///
+ /// 点赞目标信息(帖子标题或评论内容)
+ ///
+ public string? TargetInfo { get; set; }
}
}
\ No newline at end of file
diff --git a/ZR.LiveForum.Model/Liveforum/T_Likes.cs b/ZR.LiveForum.Model/Liveforum/T_Likes.cs
index 19ff942..68dd251 100644
--- a/ZR.LiveForum.Model/Liveforum/T_Likes.cs
+++ b/ZR.LiveForum.Model/Liveforum/T_Likes.cs
@@ -20,7 +20,7 @@ namespace ZR.LiveForum.Model.Liveforum
public long UserId { get; set; }
///
- /// 点赞类型
+ /// 点赞类型 1-帖子,2-评论
///
public int TargetType { get; set; }
diff --git a/ZR.Service/Liveforum/T_LikesService.cs b/ZR.Service/Liveforum/T_LikesService.cs
index 24d5eb7..3089bc5 100644
--- a/ZR.Service/Liveforum/T_LikesService.cs
+++ b/ZR.Service/Liveforum/T_LikesService.cs
@@ -22,12 +22,45 @@ namespace ZR.Service.Liveforum
{
var predicate = QueryExp(parm);
- var response = Queryable()
- //.OrderBy("Id desc")
+ var query = Queryable()
.Where(predicate.ToExpression())
- .ToPage(parm);
+ .LeftJoin((l, u) => l.UserId == u.Id)
+ .LeftJoin((l, u, p) => l.TargetType == 1 && l.TargetId == p.Id)
+ .LeftJoin((l, u, p, c) => l.TargetType == 2 && l.TargetId == c.Id);
- return response;
+ // 默认按创建时间倒序
+ query = query.OrderBy((l, u, p, c) => l.CreatedAt, OrderByType.Desc);
+
+ var response = query.Select((l, u, p, c) => new T_LikesDto()
+ {
+ Id = l.Id,
+ UserId = l.UserId,
+ TargetType = l.TargetType,
+ TargetId = l.TargetId,
+ CreatedAt = l.CreatedAt,
+ UserName = u.NickName,
+ // 根据TargetType选择对应的信息:1-帖子标题,2-评论内容
+ TargetInfo = l.TargetType == 1 ? p.Title : (l.TargetType == 2 ? c.Content : null),
+ }, true);
+
+ var resp = ToPage(response, parm);
+ return resp;
+ }
+
+ ///
+ /// 分页查询(排序已在Select之前完成)
+ ///
+ private PagedInfo ToPage(ISugarQueryable source, PagerInfo parm)
+ {
+ var page = new PagedInfo();
+ 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;
}
diff --git a/ZR.Vue/src/views/liveforum/tlikes.vue b/ZR.Vue/src/views/liveforum/tlikes.vue
index 0ae9c59..9c461a0 100644
--- a/ZR.Vue/src/views/liveforum/tlikes.vue
+++ b/ZR.Vue/src/views/liveforum/tlikes.vue
@@ -33,15 +33,22 @@
highlight-current-row
@sort-change="sortChange"
>
-
-
-
+
+
+
+
-
-
+
+
+ {{ scope.row.targetInfo }}
+ -
+
+
+
+
@@ -110,9 +117,11 @@ const queryParams = reactive({
})
const columns = ref([
{ visible: true, align: 'center', type: '', prop: 'id', label: 'id' },
- { visible: true, align: 'center', type: '', prop: 'userId', label: '点赞用户ID' },
+ { visible: true, align: 'center', type: '', prop: 'userName', label: '点赞用户' ,showOverflowTooltip: true },
+ { visible: false, align: 'center', type: '', prop: 'userId', label: '点赞用户ID' },
{ visible: true, align: 'center', type: 'dict', prop: 'targetType', label: '点赞类型' ,dictType: 'liveforum_like_tag' },
- { visible: true, align: 'center', type: '', prop: 'targetId', label: '点赞目标ID' },
+ { visible: true, align: 'left', type: '', prop: 'targetInfo', label: '点赞目标' ,showOverflowTooltip: true },
+ { visible: false, align: 'center', type: '', prop: 'targetId', label: '点赞目标ID' },
{ visible: true, align: 'center', type: '', prop: 'createdAt', label: '点赞时间' ,showOverflowTooltip: true },
//{ visible: false, prop: 'actions', label: '操作', type: 'slot', width: '160' }
])