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

103 lines
3.0 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_FollowsService), ServiceLifetime = LifeTime.Transient)]
public class T_FollowsService : BaseService<T_Follows>, IT_FollowsService
{
/// <summary>
/// 查询关注记录列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<T_FollowsDto> GetList(T_FollowsQueryDto parm)
{
var predicate = QueryExp(parm);
var response = Queryable()
//.OrderBy("Id desc")
.Where(predicate.ToExpression())
.ToPage<T_Follows, T_FollowsDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public T_Follows GetInfo(long Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加关注记录
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public T_Follows AddT_Follows(T_Follows model)
{
return Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改关注记录
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateT_Follows(T_Follows model)
{
return Update(model, true);
}
/// <summary>
/// 导出关注记录
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<T_FollowsDto> ExportList(T_FollowsQueryDto parm)
{
parm.PageNum = 1;
parm.PageSize = 100000;
var predicate = QueryExp(parm);
var response = Queryable()
.Where(predicate.ToExpression())
.Select((it) => new T_FollowsDto()
{
}, true)
.ToPage(parm);
return response;
}
/// <summary>
/// 查询导出表达式
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
private static Expressionable<T_Follows> QueryExp(T_FollowsQueryDto parm)
{
var predicate = Expressionable.Create<T_Follows>();
predicate = predicate.AndIF(parm.FollowerId != null, it => it.FollowerId == parm.FollowerId);
predicate = predicate.AndIF(parm.FollowedUserId != null, it => it.FollowedUserId == parm.FollowedUserId);
return predicate;
}
}
}