ZrAdminNetCore/ZR.Service/Liveforum/T_LikesService.cs
2025-11-16 18:50:32 +08:00

81 lines
2.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Infrastructure.Attribute;
using Infrastructure.Extensions;
using ZR.LiveForum.Model.Liveforum.Dto;
using ZR.LiveForum.Model.Liveforum;
using ZR.Repository;
using ZR.Service.Liveforum.ILiveforumService;
namespace ZR.Service.Liveforum
{
/// <summary>
/// 点赞表存储用户对帖子和评论的点赞记录Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IT_LikesService), ServiceLifetime = LifeTime.Transient)]
public class T_LikesService : BaseService<T_Likes>, IT_LikesService
{
/// <summary>
/// 查询点赞表,存储用户对帖子和评论的点赞记录列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<T_LikesDto> GetList(T_LikesQueryDto parm)
{
var predicate = QueryExp(parm);
var response = Queryable()
//.OrderBy("Id desc")
.Where(predicate.ToExpression())
.ToPage<T_Likes, T_LikesDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public T_Likes GetInfo(long Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加点赞表,存储用户对帖子和评论的点赞记录
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public T_Likes AddT_Likes(T_Likes model)
{
return Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改点赞表,存储用户对帖子和评论的点赞记录
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateT_Likes(T_Likes model)
{
return Update(model, true);
}
/// <summary>
/// 查询导出表达式
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
private static Expressionable<T_Likes> QueryExp(T_LikesQueryDto parm)
{
var predicate = Expressionable.Create<T_Likes>();
predicate = predicate.AndIF(parm.UserId != null, it => it.UserId == parm.UserId);
return predicate;
}
}
}