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

82 lines
2.4 KiB
C#

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_CommentsService), ServiceLifetime = LifeTime.Transient)]
public class T_CommentsService : BaseService<T_Comments>, IT_CommentsService
{
/// <summary>
/// 查询帖子评论记录列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<T_CommentsDto> GetList(T_CommentsQueryDto parm)
{
var predicate = QueryExp(parm);
var response = Queryable()
//.OrderBy("Id desc")
.Where(predicate.ToExpression())
.ToPage<T_Comments, T_CommentsDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public T_Comments GetInfo(long Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加帖子评论记录
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public T_Comments AddT_Comments(T_Comments model)
{
return Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改帖子评论记录
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateT_Comments(T_Comments model)
{
return Update(model, true);
}
/// <summary>
/// 查询导出表达式
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
private static Expressionable<T_Comments> QueryExp(T_CommentsQueryDto parm)
{
var predicate = Expressionable.Create<T_Comments>();
predicate = predicate.AndIF(parm.PostId != null, it => it.PostId == parm.PostId);
predicate = predicate.AndIF(parm.UserId != null, it => it.UserId == parm.UserId);
return predicate;
}
}
}