v0.0.3 点赞
This commit is contained in:
parent
71103eb85e
commit
b829eb35ad
|
|
@ -32,5 +32,15 @@ namespace ZR.LiveForum.Model.Liveforum.Dto
|
|||
|
||||
[ExcelColumn(Name = "点赞类型")]
|
||||
public string? TargetTypeLabel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 点赞用户昵称
|
||||
/// </summary>
|
||||
public string? UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 点赞目标信息(帖子标题或评论内容)
|
||||
/// </summary>
|
||||
public string? TargetInfo { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ namespace ZR.LiveForum.Model.Liveforum
|
|||
public long UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 点赞类型
|
||||
/// 点赞类型 1-帖子,2-评论
|
||||
/// </summary>
|
||||
public int TargetType { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -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<T_Likes, T_LikesDto>(parm);
|
||||
.LeftJoin<T_Users>((l, u) => l.UserId == u.Id)
|
||||
.LeftJoin<T_Posts>((l, u, p) => l.TargetType == 1 && l.TargetId == p.Id)
|
||||
.LeftJoin<T_Comments>((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;
|
||||
}
|
||||
|
||||
/// <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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,15 +33,22 @@
|
|||
highlight-current-row
|
||||
@sort-change="sortChange"
|
||||
>
|
||||
<el-table-column prop="id" label="id" align="center" v-if="columns.showColumn('id')"/>
|
||||
<el-table-column prop="userId" label="点赞用户ID" align="center" v-if="columns.showColumn('userId')"/>
|
||||
<el-table-column prop="targetType" label="点赞类型" align="center" v-if="columns.showColumn('targetType')">
|
||||
<el-table-column prop="id" label="id" align="center" width="80" v-if="columns.showColumn('id')"/>
|
||||
<el-table-column prop="userName" label="点赞用户" align="center" width="120" :show-overflow-tooltip="true" v-if="columns.showColumn('userName')"/>
|
||||
<el-table-column prop="userId" label="点赞用户ID" align="center" width="100" v-if="columns.showColumn('userId')"/>
|
||||
<el-table-column prop="targetType" label="点赞类型" align="center" width="100" v-if="columns.showColumn('targetType')">
|
||||
<template #default="scope">
|
||||
<dict-tag :options=" options.liveforum_like_tag " :value="scope.row.targetType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="targetId" label="点赞目标ID" align="center" v-if="columns.showColumn('targetId')"/>
|
||||
<el-table-column prop="createdAt" label="点赞时间" :show-overflow-tooltip="true" v-if="columns.showColumn('createdAt')"/>
|
||||
<el-table-column prop="targetInfo" label="点赞目标" align="left" width="300" :show-overflow-tooltip="true" v-if="columns.showColumn('targetInfo')">
|
||||
<template #default="scope">
|
||||
<span v-if="scope.row.targetInfo">{{ scope.row.targetInfo }}</span>
|
||||
<span v-else style="color: #999;">-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="targetId" label="点赞目标ID" align="center" width="100" v-if="columns.showColumn('targetId')"/>
|
||||
<el-table-column prop="createdAt" label="点赞时间" :show-overflow-tooltip="true" width="180" v-if="columns.showColumn('createdAt')"/>
|
||||
<el-table-column label="操作" width="160">
|
||||
<template #default="scope">
|
||||
<el-button type="success" size="small" icon="edit" title="编辑" v-hasPermi="['tlikes:edit']" @click="handleUpdate(scope.row)"></el-button>
|
||||
|
|
@ -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' }
|
||||
])
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user